int ilow, iupper, slice, tslice, ttslice, Mm1, Nm1;
atomic {
- System.printString("Inside atomic 1\n");
N = M = G.length;
omega_over_four = omega * 0.25;
iupper = ((tmpid+1)*slice)+1;
if (iupper > Mm1) iupper = Mm1+1;
if (tmpid == (numthreads-1)) iupper = Mm1+1;
+ G[0]=global new double[N];
for(int i=ilow;i<iupper;i++) {
- G[i]=global new double[N];
+ G[i]=global new double[N];
}
}
Barrier.enterBarrier(barr);
atomic {
- Random rand=new Random();
- for(int i=ilow;i<iupper;i++) {
- double[] R=G[i];
- for(int j=0;j<M;j++)
- R[j]=rand.nextDouble() * 1e-6;
- }
+ Random rand=new Random();
+ double[] R = G[0];
+ for(int j=0;j<M;j++)
+ R[j]=rand.nextDouble() * 1e-6;
+ for(int i=ilow;i<iupper;i++) {
+ R=G[i];
+ for(int j=0;j<M;j++)
+ R[j]=rand.nextDouble() * 1e-6;
+ }
}
Barrier.enterBarrier(barr);
numbytes = send(fd, buffer, size, MSG_NOSIGNAL);
if (numbytes == -1) {
perror("send");
- exit(-1);
+ return;
}
buffer += numbytes;
size -= numbytes;
numbytes = recv(fd, buffer, size, 0);
if (numbytes == -1) {
perror("recv");
- exit(-1);
+ return;
}
buffer += numbytes;
size -= numbytes;
/* Send objects that are modified */
for(i = 0; i < tdata->buffer->f.nummod ; i++) {
int size;
- headeraddr = chashSearch(tdata->rec->lookupTable, tdata->buffer->oidmod[i]);
+ if((headeraddr = chashSearch(tdata->rec->lookupTable, tdata->buffer->oidmod[i])) == NULL) {
+ printf("%s() Error: No such oid %s, %d\n", __func__, __FILE__, __LINE__);
+ pthread_exit(NULL);
+ }
GETSIZE(size,headeraddr);
size+=sizeof(objheader_t);
send_data(sd, headeraddr, size);
int tmpsize;
headptr = (objheader_t *) chashSearch(localtdata->tdata->rec->lookupTable, localtdata->tdata->buffer->oidmod[i-numread]);
if (headptr == NULL) {
- printf("Error: handleLocalReq() returning NULL %s, %d\n", __FILE__, __LINE__);
- return NULL;
+ printf("Error: handleLocalReq() returning NULL, no such oid %s, %d\n", __FILE__, __LINE__);
+ return NULL;
}
oid = OID(headptr);
version = headptr->version;
objheader_t *objheader;
unsigned short numoffset[] ={0};
short fieldoffset[] ={};
-
+
if ((objheader = (objheader_t *) mhashSearch(oid)) == NULL) {
- if ((objheader = (objheader_t *) prehashSearch(oid)) == NULL) {
- prefetch(0, 1, &oid, numoffset, fieldoffset);
- pthread_mutex_lock(&pflookup.lock);
- while ((objheader = (objheader_t *) prehashSearch(oid)) == NULL) {
- pthread_cond_wait(&pflookup.cond, &pflookup.lock);
- }
- pthread_mutex_unlock(&pflookup.lock);
+ if ((objheader = (objheader_t *) prehashSearch(oid)) == NULL) {
+ unsigned int mid = lhashSearch(oid);
+ int sd = getSock2(transReadSockPool, mid);
+ char remotereadrequest[sizeof(char)+sizeof(unsigned int)];
+ remotereadrequest[0] = READ_REQUEST;
+ *((unsigned int *)(&remotereadrequest[1])) = oid;
+ send_data(sd, remotereadrequest, sizeof(remotereadrequest));
+
+ /* Read response from the Participant */
+ char control;
+ recv_data(sd, &control, sizeof(char));
+
+ if (control==OBJECT_NOT_FOUND) {
+ printf("Error: in %s() THIS SHOULD NOT HAPPEN.....EXIT PROGRAM\n", __func__);
+ fflush(stdout);
+ exit(-1);
+ } else {
+ /* Read object if found into local cache */
+ int size;
+ recv_data(sd, &size, sizeof(int));
+ pthread_mutex_lock(&prefetchcache_mutex);
+ if ((objheader = prefetchobjstrAlloc(size)) == NULL) {
+ printf("Error: %s() objstrAlloc error for copying into prefetch cache %s, %d\n", __func__, __FILE__, __LINE__);
+ pthread_exit(NULL);
+ }
+ pthread_mutex_unlock(&prefetchcache_mutex);
+ recv_data(sd, objheader, size);
+ prehashInsert(oid, objheader);
}
+ }
}
-
return TYPE(objheader);
}
#else
myIpAddr = getMyIpAddr("eth0");
#endif
-
-#ifdef CHECKTA
- printf("My ip address = %x", myIpAddr);
-#endif
myIndexInHostArray = findHost(myIpAddr);
if (myIndexInHostArray == -1)
{
return;
} else {
if(version <= ndata->versionarry[index]){
- printf("threadNotify(): New version %d has not changed since last version %s, %d\n", version, __FILE__, __LINE__);
+ printf("threadNotify(): New version %d has not changed since last version for oid = %d, %s, %d\n", version, oid, __FILE__, __LINE__);
return;
} else {
/* Clear from prefetch cache and free thread related data structure */
sin.sin_family= AF_INET;
sin.sin_port=htons(___port___);
sin.sin_addr.s_addr=htonl(*(int *)(((char *)&VAR(___address___)->___length___)+sizeof(int)));
-#if defined(THREADS)||define(DSTM)
+#if defined(THREADS)||defined(DSTM)
#ifdef PRECISE_GC
struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
#endif
do {
rc = connect(___fd___, (struct sockaddr *) &sin, sizeof(sin));
} while (rc<0 && errno==EINTR); /* repeat if interrupted */
-#if defined(THREADS)||define(DSTM)
+#if defined(THREADS)||defined(DSTM)
#ifdef PRECISE_GC
restartaftergc(tmp);
#endif
unsigned int sinlen=sizeof(sin);
int fd=VAR(___this___)->___fd___;
int newfd;
-#if defined(THREADS)||define(DSTM)
+#if defined(THREADS)||defined(DSTM)
#ifdef PRECISE_GC
struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
#endif
#endif
newfd=accept(fd, (struct sockaddr *)&sin, &sinlen);
-#if defined(THREADS)||define(DSTM)
+#if defined(THREADS)||defined(DSTM)
#ifdef PRECISE_GC
restartaftergc(tmp);
#endif
char * charstr=malloc(length);
-#if defined(THREADS)||define(DSTM)
+#if defined(THREADS)||defined(DSTM)
#ifdef PRECISE_GC
struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
#endif
do {
byteread=read(fd, charstr, length);
} while(byteread==-1&&errno==EINTR);
-#if defined(THREADS)||define(DSTM)
+#if defined(THREADS)||defined(DSTM)
#ifdef PRECISE_GC
restartaftergc(tmp);
#endif