summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2020-04-05 02:57:40 +0200
committerjonsykkel <jonrevold@gmail.com>2020-04-05 02:57:40 +0200
commitb34264e1a66b3017cfe704fead04c145caea6cb5 (patch)
tree954988133f06503d9518d39e39420da169317d4e
parentf4ba91887cd954276bd1b7a0dfaf253cb03db926 (diff)
downloadct_sequence-b34264e1a66b3017cfe704fead04c145caea6cb5.tar.gz
vork
-rw-r--r--makefile2
-rw-r--r--src/main.c19
-rw-r--r--src/n1.c5
-rw-r--r--src/n3.c3
4 files changed, 13 insertions, 16 deletions
diff --git a/makefile b/makefile
index 1b69bd8..049cc71 100644
--- a/makefile
+++ b/makefile
@@ -56,7 +56,7 @@ ifneq ($(run),)
run_cmd := @echo "run $(bin)"
run_cmd += && cd bin
run_cmd += && echo "----------------------------------------------------------------"
- run_cmd += && time ./$(out_file) 100000000
+ run_cmd += && time ./$(out_file) 10000000
run_cmd += ; echo "----------------------------------------------------------------"
run_cmd += && cd ..
endif
diff --git a/src/main.c b/src/main.c
index dc0ffa9..f0c20fb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -59,20 +59,21 @@ static void numper_p(void){
}
int main(int argc,char **argv){
- int err;
+#ifdef _WIN32
+ SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS);
+#endif
+ init = n1_init;
+ loop = n1_loop;
+ nump = numper;
+
if(argc < 2){
printf("usake: numper [-p] <n>\n");
printf(" -p display progress percentage\n");
fflush(stdout);
- return 1;
+ exit(0);
}
- init = n1_init;
- loop = n1_loop;
- nump = numper;
- err = 0;
-
for(int x = 1;x < argc-1;x++){
if(strcmp(argv[x],"-p") == 0){
nump = numper_p;
@@ -80,12 +81,10 @@ int main(int argc,char **argv){
}
printf("unrecognized option: %s\n",argv[x]);
- err++;
}
- if(err) exit(1);
+ n = strtoull(argv[argc-1],0,10);
- n = strtoull(argv[argc-1],0,10);
printf("n = %llu\n",n); fflush(stdout);
init(n);
ftimer_init(&ft);
diff --git a/src/n1.c b/src/n1.c
index 00c8d36..8b24562 100644
--- a/src/n1.c
+++ b/src/n1.c
@@ -11,9 +11,8 @@ void n1_init(uint64_t n){
size_t size;
size = sizeof(uint32_t)*n;
- h = malloc(size);
+ h = calloc(size,1);
if(!h) fuk("memory");
- memset(h,0x00,size);
}
void n1_loop(uint64_t x0,uint64_t x1){
@@ -21,7 +20,7 @@ void n1_loop(uint64_t x0,uint64_t x1){
uint64_t z;
z = h[t];
h[t] = x;
- t = z == 0 ? 0 : x-z;
+ t = z == 0 ? 0 : x-z;
}
}
diff --git a/src/n3.c b/src/n3.c
index 518bed2..c636bcb 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -15,9 +15,8 @@ void n3_init(uint64_t n){
size_t size;
size = sizeof(uint8_t)*n*BITS>>3;
- h = malloc(size);
+ h = calloc(size,1);
if(!h) fuk("memory");
- memset(h,0x00,size);
}
void n3_loop(uint64_t x0,uint64_t x1){