/* Returns the size of CPU's cacheline */ BOOT_CODE uint32_t CONST getCacheLineSizeBits(void) { uint32_t line_size; uint32_t n; line_size = getCacheLineSize(); if (line_size == 0) { printf("Cacheline size must be >0\n"); return 0; } /* determine size_bits */ n = 0; while (!(line_size & 1)) { line_size >>= 1; n++; } if (line_size != 1) { printf("Cacheline size must be a power of two\n"); return 0; } return n; }
* POSSIBILITY OF SUCH DAMAGE. */ #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "wrap.h" #include "memtool.h" #include "tracer.h" //4096 #define BlockSize 1024 int IntsPerLine = getCacheLineSize() / sizeof(int); int IntsPerBlock = BlockSize / sizeof(int); int arraySize; int *shadowPaging = NULL; void init(int *p, int size, int hotCache) { WRAPTOKEN w = wrapOpen(); int i; for (i=0; i < size; i++) wrapWrite((p + i), &i, sizeof(int), w); wrapClose(w); // TODO for hot cache will need to have started stats before here! int *f = p;