2 #include "addPrefetchEnhance.h"
4 extern int numprefetchsites;
5 //pfcstats_t evalPrefetch[numprefetchsites]; //Global array for all prefetch sites in the executable
6 extern pfcstats_t *evalPrefetch;
8 pfcstats_t *initPrefetchStats() {
10 if((ptr = calloc(numprefetchsites, sizeof(pfcstats_t))) == NULL) {
11 printf("%s() Calloc error in %s at line %d\n", __func__, __FILE__, __LINE__);
15 /* Enable prefetching at the beginning */
16 for(i=0; i<numprefetchsites; i++) {
19 ptr[i].retrycount = RETRYINTERVAL; //N
20 ptr[i].uselesscount = SHUTDOWNINTERVAL; //M
25 int getRetryCount(int siteid) {
26 return evalPrefetch[siteid].retrycount;
29 int getUselessCount(int siteid) {
30 return evalPrefetch[siteid].uselesscount;
33 char getOperationMode(int siteid) {
34 return evalPrefetch[siteid].operMode;
37 void handleDynPrefetching(int numLocal, int ntuples, int siteid) {
38 if(numLocal < ntuples) {
39 /* prefetch not found locally(miss in cache) */
40 evalPrefetch[siteid].operMode = 1;
41 evalPrefetch[siteid].uselesscount = SHUTDOWNINTERVAL;
43 if(getOperationMode(siteid) != 0) {
44 evalPrefetch[siteid].uselesscount--;
45 if(evalPrefetch[siteid].uselesscount <= 0)
46 evalPrefetch[siteid].operMode = 0;