summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2020-04-05 01:42:19 +0200
committerjonsykkel <jonrevold@gmail.com>2020-04-05 01:42:19 +0200
commitd7aab7fb313d25b8a870ce3ca9c10d26859fd806 (patch)
tree602a9e5f0687ee30cac4612a3fcd4a3503501527
parent438212632bebdb7be8a501fd68dd6fa0f195004d (diff)
downloadct_sequence-d7aab7fb313d25b8a870ce3ca9c10d26859fd806.tar.gz
vork
-rw-r--r--makefile4
-rw-r--r--src/main.c56
2 files changed, 36 insertions, 24 deletions
diff --git a/makefile b/makefile
index ead176d..b2f6bcd 100644
--- a/makefile
+++ b/makefile
@@ -37,7 +37,7 @@ out := $(bin)
ifeq ($(build),debug)
CFLAGS += -g
else ifeq ($(build),release)
- CFLAGS += -O3
+ CFLAGS += -Ofast -march=native -mtune=native -fomit-frame-pointer
#CFLAGS += -Wunused-variable -Wunused-function -Wunused-parameter -Wunused-label
LDFLAGS += $(RELFLAGS)
else ifeq ($(build),analyze)
@@ -56,7 +56,7 @@ ifneq ($(run),)
run_cmd := @echo "run $(bin)"
run_cmd += && cd bin
run_cmd += && echo "----------------------------------------------------------------"
- run_cmd += && time ./$(out_file) 5000000000
+ run_cmd += && time ./$(out_file) 100000000
run_cmd += ; echo "----------------------------------------------------------------"
run_cmd += && cd ..
endif
diff --git a/src/main.c b/src/main.c
index 9fef679..53a65be 100644
--- a/src/main.c
+++ b/src/main.c
@@ -11,6 +11,11 @@
static ftimer_t ft;
static uint8_t *h;
+static uint64_t t;
+static uint64_t n;
+static uint64_t agurk;
+static uint64_t outer;
+static uint64_t last;
static void fuk(char const *str){
printf("error!( %s\n",str);
@@ -61,13 +66,35 @@ static uint64_t load_store(uint64_t t,uint64_t i){
return r;
}
-int main(int argc,char **argv){
- uint64_t t;
- uint64_t n;
- uint64_t agurk;
- uint64_t outer;
- uint64_t last;
+static void numper(void){
+ for(uint64_t x = 1;x < n;x++){
+ uint64_t z;
+
+ z = load_store(t,x);
+ t = z == 0 ? 0 : x-z;
+ }
+ perse(100);
+}
+
+static void numper_perse(void){
+ perse(0);
+ for(uint64_t y = 0;y < outer;y++){
+ uint64_t beg = y*agurk;
+ uint64_t end = beg+(y == outer-1 ? last : agurk);
+ if(y == 0) beg++;
+
+ for(uint64_t x = beg;x < end;x++){
+ uint64_t z;
+
+ z = load_store(t,x);
+ t = z == 0 ? 0 : x-z;
+ }
+
+ perse((y+1)*100/outer);
+ }
+}
+int main(int argc,char **argv){
if(argc < 2){
printf("usake: numper <n>\n"); fflush(stdout);
return 1;
@@ -87,22 +114,7 @@ int main(int argc,char **argv){
}
ftimer_init(&ft);
- perse(0);
-
- for(uint64_t y = 0;y < outer;y++){
- uint64_t beg = y*agurk;
- uint64_t end = beg+(y == outer-1 ? last : agurk);
- if(y == 0) beg++;
-
- for(uint64_t x = beg;x < end;x++){
- uint64_t z;
-
- z = load_store(t,x);
- t = z == 0 ? 0 : x-z;
- }
-
- perse((y+1)*100/outer);
- }
+ numper_perse();
printf("result = %llu\n",t); fflush(stdout);