1 /****************************************************************************
3 [ParInit.c] Initialising the parallel RTS
5 P. Trinder, January 17th 1995.
6 An extension based on Kevin Hammond's GRAPH for PVM version
8 Adapted for the new RTS
10 ****************************************************************************/
12 #ifdef PAR /* whole file */
14 #define NON_POSIX_SOURCE /* so says Solaris */
21 /* Global conditions defined here. */
24 IAmMainThread = rtsFalse, /* Set for the main thread */
25 GlobalStopPending = rtsFalse; /* Terminating */
27 /* Task identifiers for various interesting global tasks. */
29 GLOBAL_TASK_ID IOTask = 0, /* The IO Task Id */
30 SysManTask = 0, /* The System Manager Task Id */
31 mytid = 0; /* This PE's Task Id */
33 REAL_TIME main_start_time; /* When the program started */
34 REAL_TIME main_stop_time; /* When the program finished */
35 jmp_buf exit_parallel_system; /* How to abort from the RTS */
40 /*rtsBool TraceSparks = rtsFalse; /* Enable the spark trace mode */
41 /*rtsBool SparkLocally = rtsFalse; /* Use local threads if possible */
42 /*rtsBool DelaySparks = rtsFalse; /* Use delayed sparking */
43 /*rtsBool LocalSparkStrategy = rtsFalse; /* Either delayed threads or local threads*/
44 /*rtsBool GlobalSparkStrategy = rtsFalse; /* Export all threads */
46 /*rtsBool DeferGlobalUpdates = rtsFalse; /* Defer updating of global nodes */
48 rtsBool fishing = rtsFalse; /* We have no fish out in the stream */
50 /* Initialisation Routines */
53 par_exit defines how to terminate the program. If the exit code is
54 non-zero (i.e. an error has occurred), the PE should not halt until
55 outstanding error messages have been processed. Otherwise, messages
56 might be sent to non-existent Task Ids. The infinite loop will actually
57 terminate, since STG_Exception will call myexit\tr{(0)} when
58 it received a PP_FINISH from the system manager task.
62 par_exit(I_ n) /* NB: "EXIT" is set to "myexit" for parallel world */
64 GlobalStopPending = rtsTrue;
65 SendOp(PP_FINISH, SysManTask);
69 WaitForPEOp(PP_FINISH, SysManTask);
71 /* fprintf(stderr,"PE %lx shutting down, %ld Threads run, %ld Sparks Ignored\n", (W_) mytid, threadId, sparksIgnored); */
72 fprintf(stderr,"PE %lx shutting down, %ld Threads run\n", (W_) mytid, threadId);
78 time_t time (time_t *);
81 initParallelSystem(void)
83 /* Don't buffer standard channels... */
87 srand48(time(NULL) * getpid()); /*Initialise Random-number generator seed*/
88 /* Used to select target of FISH message*/
94 *SynchroniseSystem synchronises the reduction task with the system
95 *manager, and initialises the Global address tables (LAGA & GALA)
101 SynchroniseSystem(void)
105 PEs = PEStartUp(nPEs);
107 /* Initialize global address tables */
110 /* Record the shortened the PE identifiers for LAGA etc. tables */
111 for (i = 0; i < nPEs; ++i)
112 registerTask(PEs[i]);
116 #endif /* PAR -- whole file */