Use OpenMP.
This commit is contained in:
parent
d3c1cfafa7
commit
6ab76a1e9b
4
Makefile
4
Makefile
@ -18,9 +18,9 @@ CC=gcc
|
||||
DEBUG=0
|
||||
PREFIX=/usr/local
|
||||
INCFLAGS=
|
||||
LDFLAGS=-lm
|
||||
LDFLAGS=-lm -fopenmp
|
||||
DEFS=-DVERSION=\"1.0\"
|
||||
CFLAGS=$(INCFLAGS) -std=c99 -Wall -Wextra -Wfatal-errors -Werror
|
||||
CFLAGS=$(INCFLAGS) -std=c99 -Wall -Wextra -Wfatal-errors -Werror -fopenmp
|
||||
HDRS=
|
||||
OBJS=src/main.o
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <omp.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if(argc < 2)
|
||||
@ -48,11 +49,14 @@ int main(int argc, char *argv[]) {
|
||||
return 1;
|
||||
unsigned long long int test_root = sqrt(test_num);
|
||||
|
||||
int not_prime = 0;
|
||||
|
||||
#pragma omp parallel for
|
||||
for(unsigned long long int i = 3; i < test_root; i += 2)
|
||||
{
|
||||
if(test_num % i == 0)
|
||||
return 1;
|
||||
not_prime = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return not_prime;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user