1 /* -----------------------------------------------------------------------------
2 * $Id: FetchMe.c,v 1.2 1998/12/02 13:29:03 simonm Exp $
4 * Entry code for a FETCH_ME closure
6 * ---------------------------------------------------------------------------*/
8 #ifdef PAR /* all of it */
14 /* -----------------------------------------------------------------------------
17 A FETCH_ME closure represents data that currently resides on
18 another PE. We issue a fetch message, and wait for the data to be
20 -------------------------------------------------------------------------- */
22 INFO_TABLE(FETCH_ME_info, FETCH_ME_entry, 0,2, FETCH_ME, const, EF_,0,0);
24 STGFUN(FETCH_ME_entry)
31 STGCALL0(void,(),GranSimBlock); /* Do this before losing its TSO_LINK */
35 ASSERT(rGA->loc.gc.gtid != mytid);
37 /* Turn the FETCH_ME into a FETCH_ME_BQ, and place the current thread
38 * on the blocking queue.
40 R1.cl->header.info = FETCH_ME_BQ_info;
41 CurrentTSO->link = END_TSO_QUEUE;
42 ((StgBlackHole *)R1.cl)->blocking_queue = CurrentTSO;
44 #ifdef 0 /* unknown junk... needed? --SDM */
46 QP_Event1("GR", CurrentTSO);
49 if (RTSflags.ParFlags.granSimStats) {
50 /* Note that CURRENT_TIME may perform an unsafe call */
51 TIME now = CURRENT_TIME;
52 TSO_EXECTIME(CurrentTSO) += now - TSO_BLOCKEDAT(CurrentTSO);
53 TSO_FETCHCOUNT(CurrentTSO)++;
54 TSO_QUEUE(CurrentTSO) = Q_FETCHING;
55 TSO_BLOCKEDAT(CurrentTSO) = now;
56 /* DumpGranEventAndNode(GR_FETCH, CurrentTSO, (SAVE_R1).p,
57 taskIDtoPE(rGA->loc.gc.gtid)); */
58 DumpRawGranEvent(CURRENT_PROC,taskIDtoPE(rGA->loc.gc.gtid),GR_FETCH,
59 CurrentTSO,(SAVE_R1).p,0);
62 /* Phil T. claims that this was a workaround for a hard-to-find
63 * bug, hence I'm leaving it out for now --SDM
65 /* Assign a brand-new global address to the newly created FMBQ */
66 lGA = MakeGlobal((SAVE_R1).p, rtsFalse);
67 splitWeight(&fmbqGA, lGA);
68 ASSERT(fmbqGA.weight == 1L << (BITS_IN(unsigned) - 1));
71 /* I *hope* it's ok to call this from STG land. --SDM */
72 STGCALL3(sendFetch, rGA, &fmbqGA, 0/*load*/);
74 BLOCK_NP(1); /* back to the scheduler */
79 /* -----------------------------------------------------------------------------
82 On the first entry of a FETCH_ME closure, we turn the closure into
83 a FETCH_ME_BQ, which behaves just like a black hole. Any thread
84 entering the FETCH_ME_BQ will be placed in the blocking queue.
85 When the data arrives from the remote PE, all waiting threads are
86 woken up and the FETCH_ME_BQ is overwritten with the fetched data.
87 -------------------------------------------------------------------------- */
89 INFO_TABLE(FETCH_ME_BQ_info, BLACKHOLE_entry,0,2,BLACKHOLE,const,EF_,0,0);