int kernelHeight = 5;
int kernelWidth = 5;
double[][] kernel = new double[kernelHeight][kernelWidth];
+ initKernel(kernel);
atomic {
- initKernel(kernel);
double tempinput[][] = img.inputImage;
double tempout[][] = img.outputImage;
double tout[] = tempout[i];
tinput0 = tinput1; tinput1=tinput2; tinput2=tinput3; tinput3=tinput4; tinput4=tempinput[l];
for(int j=y0;j<y1;++j){
- tout[j] = 0;
+ double s=0;
for(int b=0;b<kernelHeight;++b){
- tout[j] = tout[j] + (tinput0[j+b] * kernel[0][b] + tinput1[j+b] * kernel[1][b] + tinput2[j+b]*kernel[2][b] +
+ s+=(tinput0[j+b] * kernel[0][b] + tinput1[j+b] * kernel[1][b] + tinput2[j+b]*kernel[2][b] +
tinput3[j+b]*kernel[3][b] + tinput4[j+b]*kernel[4][b]);
}
+ tout[j]=s;
}
}
}
}
//define 5X5 Gaussian kernel
- public void initKernel(double[][] kernel) {
+ public static void initKernel(double[][] kernel) {
kernel[0][0] = 1/256.0;
kernel[0][1] = 4/256.0;
kernel[0][2] = 6/256.0;
double tout[] = tempout[i];
tinput0 = tinput1; tinput1=tinput2; tinput2=tinput3; tinput3=tinput4; tinput4=tempinput[l];
for(int j=y0;j<y1;++j){
- tout[j] = 0;
+ double s=0;
for(int b=0;b<kernelHeight;++b){
- tout[j] = tout[j] + (tinput0[j+b] * kernel[0][b] + tinput1[j+b] * kernel[1][b] + tinput2[j+b]*kernel[2][b] +
- tinput3[j+b]*kernel[3][b] + tinput4[j+b]*kernel[4][b]);
+ s += tinput0[j+b] * kernel[0][b] + tinput1[j+b] * kernel[1][b] + tinput2[j+b]*kernel[2][b] +
+ tinput3[j+b]*kernel[3][b] + tinput4[j+b]*kernel[4][b];
}
+ tout[j] = s;
+
}
}
}
}
//define 5X5 Gaussian kernel
- public void initKernel(double[][] kernel) {
+ public static void initKernel(double[][] kernel) {
kernel[0][0] = 1/256.0;
kernel[0][1] = 4/256.0;
kernel[0][2] = 6/256.0;
* @param nodeTable the list of nodes to choose from.
**/
public void makeUniqueNeighbors(EVector[] reversetable,Node[] nodeTable, Random rand, int begin, int end) {
- int len=toNodes.length;
+ Node [] toN=toNodes;
+ int len=toN.length;
for (int filled = 0; filled < len; filled++) {
int k;
Node otherNode;
otherNode = nodeTable[index];
for (k = 0; (k < filled) && (isBreak==false); k++) {
- if (otherNode == toNodes[k])
+ if (otherNode == toN[k])
isBreak = true;
}
} while (k < filled);
// other node is definitely unique among "filled" toNodes
- toNodes[filled] = otherNode;
+ toN[filled] = otherNode;
// update fromCount for the other node
if (reversetable[index]==null)
* @param nodeTable the list of nodes to choose from.
**/
public void makeUniqueNeighbors(EVector[] reversetable,Node[] nodeTable, Random rand, int begin, int end) {
- int len=toNodes.length;
+ Node[] toN=toNodes;
+ int len=toN.length;
for (int filled = 0; filled < len; filled++) {
int k;
Node otherNode;
otherNode = nodeTable[index];
for (k = 0; (k < filled) && (isBreak==false); k++) {
- if (otherNode == toNodes[k])
+ if (otherNode == toN[k])
isBreak = true;
}
} while (k < filled);
// other node is definitely unique among "filled" toNodes
- toNodes[filled] = otherNode;
+ toN[filled] = otherNode;
// update fromCount for the other node
if (reversetable[index]==null)
#set -x
MACHINELIST='dc-1.calit2.uci.edu dc-2.calit2.uci.edu dc-3.calit2.uci.edu dc-4.calit2.uci.edu dc-5.calit2.uci.edu dc-6.calit2.uci.edu dc-7.calit2.uci.edu dc-8.calit2.uci.edu'
-benchmarks='1152fft2d 40962dconv 20482dconv 600mmver moldynverA em3dver40001306'
+benchmarks='1152fft2d 40962dconv 20482dconv 800mmver moldynverA em3dver40001306'
LOGDIR=~/research/Robust/src/Benchmarks/Prefetch/runlog
TOPDIR=`pwd`
for count in 2 4 6 8
do
echo "------- Running $count threads $BMDIR non-prefetch + non-cache on $count machines -----"
-run 1 $count $NONPREFETCH_NONCACHE
+#run 1 $count $NONPREFETCH_NONCACHE
echo "------- Running $count threads $BMDIR prefetch on $count machines -----"
-run 1 $count $PREFETCH
+#run 1 $count $PREFETCH
done
cd $TOPDIR
if ((state.THREAD||state.DSM)&&GENERATEPRECISEGC) {
if (state.DSM&&lb.isAtomic())
- output.println("checkcollect2(&"+localsprefix+",trans);");
+ output.println("if (needtocollect) checkcollect2(&"+localsprefix+",trans);");
else
- output.println("checkcollect(&"+localsprefix+");");
+ output.println("if (needtocollect) checkcollect(&"+localsprefix+");");
}
/* Do the actual code generation */
}
}
+#if 1
/* This function clears from prefetch cache those
* entries that caused a transaction abort */
void cleanPCache(transrecord_t *record) {
}
}
}
+#else
+/* This function clears from prefetch cache those
+ * entries that caused a transaction abort */
+void cleanPCache(transrecord_t *record) {
+ transrecord_t *rec = record;
+ unsigned int size = rec->lookupTable->size;
+ struct chashentry *ptr = rec->lookupTable->table;
+ int i;
+ for(i = 0; i < size; i++) {
+ struct chashentry *curr = &ptr[i]; //for each entry in the cache lookupTable
+ if(curr->key == 0)
+ continue;
+ objheader_t *header1, *header2;
+ /* Not found in local machine's object store and found in prefetch cache */
+ if((header1 = mhashSearch(curr->key)) == NULL && ((header2 = prehashSearch(curr->key)) != NULL)) {
+ /* Remove from prefetch cache */
+ prehashRemove(curr->key);
+ }
+ }
+}
+#endif
/* This function updates the prefetch cache with
* entries from the transaction cache when a
//REMOVE HASH FUNCTION CALL TO MAKE SURE IT IS INLINED HERE
chashlistnode_t *node = &table->table[(key & table->mask)>>1];
- while(node != NULL) {
+ do {
if(node->key == key) {
return node->val;
}
node = node->next;
- }
+ } while(node != NULL);
+
return NULL;
}
-#include "clookup2.h"
+#include "clookup.h"
#define INLINE inline __attribute__((always_inline))
chashtable_t *chashCreate(unsigned int size, float loadfactor) {
}
//Finds the right bin in the hash table
-static INLINE unsigned int chashFunction(chashtable_t *table, unsigned int key) {
- return ( key & (table->mask))>>1; //throw away low order bit
+static INLINE unsigned int chashFunction(chashtable_t *table, unsigned int key, unsigned int i) {
+ return ((key+i*331) & table->mask)>>1; //throw away low order bit
}
//Store objects and their pointers into hash
void chashInsert(chashtable_t *table, unsigned int key, void *val) {
- unsigned int newsize;
- unsigned int index;
- struct chashentry *node;
+ struct chashentry *node = &table->table[(key & table->mask)>>1];
+ unsigned int ne=table->numelements++;
+ unsigned int i;
- if(table->numelements > table->capacity) {
+ if (node->key==0) {
+ node->ptr=val;
+ node->key=key;
+ return;
+ }
+
+ if(ne > table->capacity) {
//Resize
- newsize = table->size << 1;
+ unsigned int newsize = table->size << 1;
chashResize(table,newsize);
+ node = &table->table[(key & table->mask)>>1];
+ if (node->key==0) {
+ node->ptr=val;
+ node->key=key;
+ return;
+ }
}
- index=(key &table->mask)>>1;
- while(1) {
- node = &table->table[index];
- if (node->ptr==NULL) {
+
+
+ for(i=1;1;i++) {
+ node = &table->table[((key+i*331) & table->mask)>>1];
+ if (node->key==0) {
node->ptr=val;
node->key=key;
return;
}
- index++;
- if (index==table->size)
- index=0;
}
}
// Search for an address for a given oid
INLINE void * chashSearch(chashtable_t *table, unsigned int key) {
//REMOVE HASH FUNCTION CALL TO MAKE SURE IT IS INLINED HERE
- unsigned int tmp=(key &table->mask)>>1;
- struct chashentry *node;
- unsigned int ckey;
- while(1) {
- node = &table->table[tmp];
+ struct chashentry *node=&table->table[(key & table->mask)>>1];
+ unsigned int i,ckey;
+
+ if (node->key==key)
+ return node->ptr;
+ if (node->key==0)
+ return NULL;
+
+ for(i=1;1;i++) {
+ node = &table->table[((key+i*331) & table->mask)>>1];
ckey=node->key;
if (ckey==key)
return node->ptr;
if (ckey==0)
return NULL;
- tmp++;
- if (tmp==table->size)
- tmp=0;
}
}
printf("Calloc error %s %d\n", __FILE__, __LINE__);
return;
}
-
table->table = node; //Update the global hashtable upon resize()
table->size = newsize;
- mask=table->mask = (newsize << 1)-1;
- table->numelements = 0;
+ table->capacity=table->loadfactor*table->size;
+ mask=(table->mask = (newsize << 1)-1);
for(i = 0; i < oldsize; i++) { //Outer loop for each bin in hash table
curr=&ptr[i];
key=curr->key;
if (key != 0) {
- bin=(key&mask)>>1;
- while(1) {
- newnode= &table->table[bin];
+ newnode= &table->table[(key&mask)>>1];
+ if (newnode->key==0) {
+ newnode->key=key;
+ newnode->ptr=curr->ptr;
+ continue;
+ }
+
+ for(bin=1;1;bin++) {
+ newnode = &table->table[((key+bin*331) & mask)>>1];
if (newnode->key==0) {
newnode->key=key;
newnode->ptr=curr->ptr;
break;
}
- bin++;
- if (bin==newsize)
- bin=0;
}
-
}
}
free(ptr); //Free the memory of the old hash table
/* Prototypes for hash*/
chashtable_t *chashCreate(unsigned int size, float loadfactor);
-static unsigned int chashFunction(chashtable_t *table, unsigned int key);
+static unsigned int chashFunction(chashtable_t *table, unsigned int key, unsigned int i);
void chashInsert(chashtable_t *table, unsigned int key, void *val);
void *chashSearch(chashtable_t *table, unsigned int key); //returns val, NULL if not found
void chashResize(chashtable_t *table, unsigned int newsize);
return tmp;
}
+// Search for an address for a given oid
+/*#define INLINE inline __attribute__((always_inline))
+
+INLINE void * chashSearchI(chashtable_t *table, unsigned int key) {
+ //REMOVE HASH FUNCTION CALL TO MAKE SURE IT IS INLINED HERE
+ chashlistnode_t *node = &table->table[(key & table->mask)>>1];
+
+ do {
+ if(node->key == key) {
+ return node->val;
+ }
+ node = node->next;
+ } while(node != NULL);
+
+ return NULL;
+ }*/
+
+
/* This function finds the location of the objects involved in a transaction
* and returns the pointer to the object if found in a remote location */
objheader_t *transRead(transrecord_t *record, unsigned int oid) {
objheader_t *objcopy;
int size;
void *buf;
+ chashlistnode_t *node;
+ chashtable_t *table=record->lookupTable;
if(oid == 0) {
return NULL;
}
+
+ node= &table->table[(oid & table->mask)>>1];
+ do {
+ if(node->key == oid) {
+#ifdef TRANSSTATS
+ nchashSearch++;
+#endif
+#ifdef COMPILER
+ return &((objheader_t*)node->val)[1];
+#else
+ return node->val;
+#endif
+ }
+ node = node->next;
+ } while(node != NULL);
+
- if((objheader = chashSearch(record->lookupTable, oid)) != NULL) {
+ /*
+ if((objheader = chashSearchI(record->lookupTable, oid)) != NULL) {
#ifdef TRANSSTATS
nchashSearch++;
#endif
- /* Search local transaction cache */
#ifdef COMPILER
return &objheader[1];
#else
return objheader;
#endif
- } else if ((objheader = (objheader_t *) mhashSearch(oid)) != NULL) {
+ } else
+ */
+ if ((objheader = (objheader_t *) mhashSearch(oid)) != NULL) {
#ifdef TRANSSTATS
nmhashSearch++;
#endif
#endif
}
+#if 1
/* This function creates machine piles based on all machines involved in a
* transaction commit request */
plistnode_t *createPiles(transrecord_t *record) {
//if the first bin in hash table is empty
if(curr->key == 0)
break;
-
- if ((headeraddr = (objheader_t *) chashSearch(record->lookupTable, curr->key)) == NULL) {
- printf("Error: No such oid %s, %d\n", __FILE__, __LINE__);
- return NULL;
- }
+ headeraddr=(objheader_t *) curr->val;
//Get machine location for object id (and whether local or not)
if (STATUS(headeraddr) & NEW || (mhashSearch(curr->key) != NULL)) {
}
return pile;
}
+#else
+/* This function creates machine piles based on all machines involved in a
+ * transaction commit request */
+plistnode_t *createPiles(transrecord_t *record) {
+ int i;
+ plistnode_t *pile = NULL;
+ unsigned int machinenum;
+ objheader_t *headeraddr;
+ struct chashentry * ptr = record->lookupTable->table;
+ /* Represents number of bins in the chash table */
+ unsigned int size = record->lookupTable->size;
+
+ for(i = 0; i < size ; i++) {
+ struct chashentry * curr = & ptr[i];
+ /* Inner loop to traverse the linked list of the cache lookupTable */
+ //if the first bin in hash table is empty
+ if(curr->key == 0)
+ continue;
+ headeraddr=(objheader_t *) curr->ptr;
+
+ //Get machine location for object id (and whether local or not)
+ if (STATUS(headeraddr) & NEW || (mhashSearch(curr->key) != NULL)) {
+ machinenum = myIpAddr;
+ } else if ((machinenum = lhashSearch(curr->key)) == 0) {
+ printf("Error: No such machine %s, %d\n", __FILE__, __LINE__);
+ return NULL;
+ }
+
+ //Make machine groups
+ pile = pInsert(pile, headeraddr, machinenum, record->lookupTable->numelements);
+ }
+ return pile;
+}
+#endif
/* This function initiates the transaction commit process
* Spawns threads for each of the new connections with Participants