diff options
author | yves <steve.harrison@gmx.net> | 2011-05-24 14:20:13 +0200 |
---|---|---|
committer | yves <steve.harrison@gmx.net> | 2011-05-24 14:20:13 +0200 |
commit | ef176e8f2d80fbdebb3b6e00005dd873fc2c4233 (patch) | |
tree | 43c169ec48efb0ca3ebc0818c67e0e8080bb2d79 | |
parent | c630a1b07403339ab3ce74cc10798cd0353230ad (diff) | |
download | manycore-ef176e8f2d80fbdebb3b6e00005dd873fc2c4233.tar.gz manycore-ef176e8f2d80fbdebb3b6e00005dd873fc2c4233.tar.bz2 manycore-ef176e8f2d80fbdebb3b6e00005dd873fc2c4233.zip |
put yves asm in
-rw-r--r-- | cacheRows.c | 20 | ||||
-rw-r--r-- | inlineasm.h | 9 |
2 files changed, 16 insertions, 13 deletions
diff --git a/cacheRows.c b/cacheRows.c index c75be89..0111018 100644 --- a/cacheRows.c +++ b/cacheRows.c @@ -2,21 +2,24 @@ #include "inlineasm.h" #include <stdlib.h> -#define MEASURE_METHOD optmemmeasure -#define RUNS 10000 +#define MEASURE_METHOD memmeasure #define MIN_OFFSET 1 -#define MAX_OFFSET 512 +#define MAX_OFFSET 4096 #define OFFSETS (MAX_OFFSET - MIN_OFFSET) #define FIELD_TYPE uint8_t void measure(int offset,FIELD_TYPE *field){ + uint64_t *res = malloc(sizeof(uint64_t)*MAX_OFFSET); void *lowerAddress = field + offset; int i; + int a = field[0]; + + for(i=MAX_OFFSET;i >= MIN_OFFSET;i--){ + res[i] = MEASURE_METHOD(lowerAddress,res[i]*sizeof(FIELD_TYPE)); + } for(i=MIN_OFFSET;i <= MAX_OFFSET;i++){ - uint64_t time = MEASURE_METHOD(lowerAddress,i*sizeof(FIELD_TYPE)); - //if (time > 128 && time < 10000) - fprintf(stdout,"%d %lld \r\n",i,time); + fprintf(stdout,"%d %lld \r\n",i,res[i]); } } @@ -26,10 +29,7 @@ int main(int argc, char* argv[]) { FIELD_TYPE *field = malloc(sizeof(FIELD_TYPE)*(MAX_OFFSET+1)); int i=0; - //for(i=0;i < RUNS;i++){ - //fprintf(stdout,"RUN: %d \r\n",i); - measure(0,field); - //} + measure(0,field); return 0; diff --git a/inlineasm.h b/inlineasm.h index fc048ca..218c532 100644 --- a/inlineasm.h +++ b/inlineasm.h @@ -38,14 +38,17 @@ static uint64_t rdtsc() static uint64_t memmeasure(char* memory, uint64_t offset) { asm( + + // here be magic dragons and memory access (read segfaults) ahead + // TODO: evaluate if more cmp types (like w and l) do make sense + "cmpb $0x23, (%%rbx) ;" + + // get starting time "rdtsc ;" "shl $32, %%rdx ;" "add %%rax, %%rdx ;" "mov %%rdx, %%rdi ;" - // here be magic dragons and memory access (read segfaults) ahead - // TODO: evaluate if more cmp types (like w and l) do make sense - "cmpb $0x23, (%%rbx) ;" "cmpb $0x42, (%%rbx,%%rcx) ;" "rdtsc ;" |