From ebd22aa302dd595617b48d93ef62712d3348c09e Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 24 Mar 2008 09:20:38 +0000 Subject: [PATCH] changes --- Robust/src/Runtime/DSTM/interface/trans.c | 63 +++++++++++++---------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index eb25ff50..49f7da64 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -127,33 +127,42 @@ inline int findmax(int *array, int arraylength) { /* This function is a prefetch call generated by the compiler that * populates the shared primary prefetch queue*/ void prefetch(int ntuples, unsigned int *oids, unsigned short *endoffsets, short *arrayfields) { - int qnodesize; - int len = 0; - int i, rc; - - /* Allocate for the queue node*/ - char *node; - if(ntuples > 0) { - qnodesize = sizeof(prefetchqelem_t) + sizeof(int) + ntuples * (sizeof(unsigned short) + sizeof(unsigned int)) + endoffsets[ntuples - 1] * sizeof(short); - if((node = calloc(1, qnodesize)) == NULL) { - printf("Calloc Error %s, %d\n", __FILE__, __LINE__); - return; - } - /* Set queue node values */ - len = sizeof(prefetchqelem_t); - memcpy(node + len, &ntuples, sizeof(int)); - len += sizeof(int); - memcpy(node + len, oids, ntuples*sizeof(unsigned int)); - len += ntuples * sizeof(unsigned int); - memcpy(node + len, endoffsets, ntuples*sizeof(unsigned short)); - len += ntuples * sizeof(unsigned short); - memcpy(node + len, arrayfields, endoffsets[ntuples-1]*sizeof(short)); - /* Lock and insert into primary prefetch queue */ - pthread_mutex_lock(&pqueue.qlock); - pre_enqueue((prefetchqelem_t *)node); - pthread_cond_signal(&pqueue.qcond); - pthread_mutex_unlock(&pqueue.qlock); - } + /* Allocate for the queue node*/ + if(ntuples > 0) { + int qnodesize = sizeof(prefetchqelem_t) + sizeof(int) + ntuples * (sizeof(unsigned short) + sizeof(unsigned int)) + endoffsets[ntuples - 1] * sizeof(short); + char * node; + + if((node = calloc(1, qnodesize)) == NULL) { + printf("Calloc Error %s, %d\n", __FILE__, __LINE__); + return; + } else { + /* Set queue node values */ + int len = sizeof(prefetchqelem_t); + int i; + unsigned int *narray; + unsigned short *narray2; + short * narray3; + int top=endoffsets[ntuples-1]; + *((int *)(node+len))=ntuples; + len += sizeof(int); + narray=(unsigned int *)(node+len); + narray2=(unsigned short *)(narray+ntuples); + narray3=(short *)(narray2+ntuples); + + for(i=0;i