3 #ifdef DIST /* whole file */
7 #include "ParallelRts.h"
8 #include "Parallel.h" // nPEs,allPEs,mytid
9 #include "HLC.h" //for sendReval
10 #include "LLC.h" //for pvm stuff
11 #include "FetchMe.h" // for BLOCKED_FETCH_info
12 #include "Storage.h" // for recordMutable
14 /* hopefully the result>0 */
15 StgWord32 cGetPECount(void)
19 /* return taskID, n is 1..count, n=1 is always the mainPE */
20 StgPEId cGetPEId(StgWord32 n)
24 /* return the taskID */
25 StgPEId cGetMyPEId(void)
29 /* return the taskID of the owning PE of an MVar/TSO:
30 - MVAR/TSOs get converted to REMOTE_REFs when shipped, and
31 there is no mechanism for using these REMOTE_REFs
35 StgPEId cGetCertainOwner(StgClosure *mv)
37 switch(get_itbl(mv)->type)
40 return mytid; // must be local
44 return ga->payload.gc.gtid; // I know its global address
46 barf("Dist.c:cGetCertainOwner() wrong closure type %s",info_type(mv));
49 /* for some additional fun, lets look up a certain host... */
50 StgPEId cGetHostOwner(StgByteArray h) //okay h is a C string
51 { int nArch,nHost,nTask,i;
53 struct pvmhostinfo *host;
54 struct pvmtaskinfo *task;
57 pvm_config(&nHost,&nArch,&host);
59 if(strcmp(host[i].hi_name,h)==0)
60 { dtid=host[i].hi_tid;
63 if(dtid==0) return 0; // no host of that name
66 { pvm_tasks(allPEs[i],&nTask,&task);
67 ASSERT(nTask==1); //cause we lookup a single task
68 if(task[0].ti_host==dtid)
71 return 0; //know host, put no PE on it
74 void cRevalIO(StgClosure *job,StgPEId p)
76 rtsPackBuffer *buffer=NULL;
78 ASSERT(get_itbl(job)->type==MVAR);
79 job=((StgMVar*)job)->value; // extract the job from the MVar
81 ASSERT(closure_THUNK(job)); // must be a closure!!!!!
84 buffer = PackNearbyGraph(job, END_TSO_QUEUE, &size,p);
85 ASSERT(buffer != (rtsPackBuffer *)NULL);
86 ASSERT(get_itbl(job)->type==RBH);
89 belch("@;~) %x doing revalIO to %x\n",
92 sendReval(p,size,buffer);
94 if (RtsFlags.ParFlags.ParStats.Global &&
95 RtsFlags.GcFlags.giveStats > NO_GC_STATS) {
96 globalParStats.tot_reval_mess++;
100 We turn job into a FETCHME_BQ so that the thread will block
103 Note: it will not receive an ACK, thus no GA.
106 ASSERT(get_itbl(job)->type==RBH);
108 /* put closure on mutables list, while it is still a RBH */
109 recordMutable((StgMutClosure *)job);
111 /* actually turn it into a FETCH_ME_BQ */
112 SET_INFO(job, &FETCH_ME_BQ_info);
113 ((StgFetchMe *)job)->ga = 0; //hope this won't make anyone barf!!!
114 ((StgBlockingQueue*)job)->blocking_queue=END_BQ_QUEUE;