diff options
author | jonsykkel <jonrevold@gmail.com> | 2020-04-07 13:12:17 +0200 |
---|---|---|
committer | jonsykkel <jonrevold@gmail.com> | 2020-04-07 13:12:17 +0200 |
commit | 7791bcc0fbc32f12cc127c14519d4781c596d76d (patch) | |
tree | ab7ff005be4e9143d9d51b3db19e68483409b6cd | |
parent | 60577b2b48358d81f141e54821308191ea701a0b (diff) | |
download | ct_sequence-7791bcc0fbc32f12cc127c14519d4781c596d76d.tar.gz |
vok
-rw-r--r-- | src/a3.c | 66 |
1 files changed, 52 insertions, 14 deletions
@@ -2,37 +2,75 @@ #include <stdint.h> #include <stdlib.h> #include <string.h> +#include <stdio.h> void a3_init(uint64_t n); void a3_loop(uint64_t x0,uint64_t x1); algo_t a3 = { - .name = "a3", + .name = "a3 aka SDI0", .nmax = 1ULL<<32, .init = a3_init, .loop = a3_loop, }; -static uint16_t *m_fast; //mammory -static uint32_t *m_slow; //mammory +#define CROSSOVER 24576 +#define M24_SIZE 3 +#define M24_RANGE (1<<24) -void a3_init(uint64_t n){ - size_t size; //size +static uint8_t *m24; +static uint32_t *m32; +static size_t m24_n; +static size_t m32_n; + +static void inner(uint32_t x); - t = 0; - size = sizeof(uint32_t)*n; - m_slow = calloc(size,1); - if(!m_slow) fuk("memory\n"); +void a3_init(uint64_t n){ + t = 0; + m24_n = n > CROSSOVER ? CROSSOVER : n; + m32_n = n-m24_n; + m24 = calloc(sizeof(uint8_t)*M24_SIZE*m24_n,1); + m32 = calloc(sizeof(uint32_t)*m32_n,1); + if(!m24 || !m32) fuk("memory\n"); } void a3_loop(uint64_t x0,uint64_t x1){ uint32_t x1_32 = x1; - for(uint32_t x = x0;x < x1_32;x++){ - uint32_t r; //index readed + printf("MAIN %10u -> %10u\n",(uint32_t)x0,x1_32); + for(uint32_t x = x0;x < x1_32;){ + if(x+M24_RANGE >= x1_32){ + printf(" %10u -> %10u\n",x,x+x1_32); + for(;x < x1_32;x++){ + inner(x); + } + break; + }else{ + printf(" %10u -> %10u\n",x,x+M24_RANGE); + for(;x < x+M24_RANGE;x++){ + inner(x); + } + //scale back + } + } +} + +static void inner(uint32_t x){ + return; + uint32_t r; - r = m_slow[t]; - m_slow[t] = x; - t = r == 0 ? 0 : x-r; + if(t < CROSSOVER){ + uint8_t *p; + + r = 0; + p = m24+(t*M24_SIZE); + memcpy(&r,p,M24_SIZE); + memcpy(p,&x,M24_SIZE); + }else{ + uint64_t i = t-m24_n; + r = m32[i]; + m32[i] = x; } + + t = r == 0 ? 0 : x-r; } |