summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2020-04-04 23:32:16 +0200
committerjonsykkel <jonrevold@gmail.com>2020-04-04 23:32:16 +0200
commit6e6979791071ab9022512dadac143387c8711680 (patch)
tree93deaeb6d62b4fdf646887007cf5d3b3a5bc5e80
parentc97ac652eb4e270d15370cd53fdd2fab269cea20 (diff)
downloadct_sequence-6e6979791071ab9022512dadac143387c8711680.tar.gz
oge
-rw-r--r--makefile4
-rw-r--r--src/main.c45
2 files changed, 26 insertions, 23 deletions
diff --git a/makefile b/makefile
index 6616a61..e95eed8 100644
--- a/makefile
+++ b/makefile
@@ -1,6 +1,6 @@
#version 5
-out_name := numper
+out_name := numper3
build := release
tmp_dir := tmp
bin_dir := bin
@@ -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 802e1ab..3d013ca 100644
--- a/src/main.c
+++ b/src/main.c
@@ -7,9 +7,11 @@
#define U32_MAX ((1ULL<<32)-1)
#define I32_MAX ((1ULL<<31)-1)
+#define BITS 34
+
static ftimer_t ft;
-static uint32_t *h_lo;
-static uint8_t *h_hi;
+static bstream_t bs;
+static uint8_t *h;
static void fuk(char const *str){
printf("error!( %s\n",str);
@@ -18,35 +20,36 @@ static void fuk(char const *str){
}
static void perse(int p){
- char buf[FMTFTIME_BUFSIZE];
- ftime_t t = ftimer_time(&ft);
+ char buf[FMTFTIME_BUFSIZE];
+ ftime_t t;
+
+ t = ftimer_time(&ft);
fmtftime(buf,t);
printf("%12s %3u%%\n",buf,p);
fflush(stdout);
}
static void init(uint64_t n){
- h_lo = malloc(sizeof(uint32_t)*n);
- h_hi = malloc(sizeof(uint8_t)*n);
- if(!h_lo || !h_hi) fuk("memory");
- memset(h_lo,0x00,sizeof(uint32_t)*n);
- memset(h_hi,0x00,sizeof(uint8_t)*n);
+ size_t size;
+
+ size = sizeof(uint8_t)*n*BITS/8;
+ h = malloc(size);
+ if(!h) fuk("memory");
+ memset(h,0x00,size);
+
+ bstream_open(&bs,h,0,size*8);
}
static uint64_t load_store(uint64_t t,uint64_t in){
uint64_t r;
-
- r = h_lo[t];
- if(r & 0x0000000080000000){
- r &= 0x000000007FFFFFFF;
- r |= (uint64_t)h_hi[t]<<31;
- }
-
- h_lo[t] = in;
- if(in > I32_MAX){
- h_lo[t] |= 0x80000000;
- h_hi[t] = in>>31;
- }
+
+ bstream_seek(&bs,t*BITS);
+ bstream_read64(&bs,&r,BITS);
+ bstream_seek(&bs,t*BITS);
+ bstream_write64(&bs,in,BITS);
+
+ //r = h[t];
+ //h[t] = in;
return r;
}