1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* debugging tools */
#define MESG(x)\
printf("%s\n", x);\
#ifdef HAVE_PARALLEL
#define MPI_BANNER(mesg)\
{printf("================================\n");\
printf("Proc %d: ", myid); \
printf("*** %s\n", mesg);\
printf("================================\n");}
#else
#define MPI_BANNER(mesg)\
{printf("================================\n");\
printf("*** %s\n", mesg);\
printf("================================\n");}
#endif
#ifdef HAVE_PARALLEL
#define SYNC(comm)\
{MPI_BANNER("doing a SYNC"); MPI_Barrier(comm); MPI_BANNER("SYNC DONE");}
/* pause the process for a moment to allow debugger to attach if desired. */
/* Will pause more if greenlight file is not persent but will eventually */
/* continue. */
#include <sys/types.h>
#include <sys/stat.h>
void pause_proc(MPI_Comm comm, int myid, char* processor_name, int namelen,
int argc, char **argv)
{
int pid;
struct stat statbuf;
char greenlight[] = "go";
int maxloop = 10;
int time_int = 10;
/* check if an pause interval option is given */
if (--argc > 0 && isdigit(*++argv))
time_int = atoi(*argv);
pid = getpid();
printf("Proc %d (%*s): pid = %d\n",
myid, namelen, processor_name, pid);
if (myid == 0)
while ((stat(greenlight, &statbuf) == -1) && maxloop-- > 0){
printf("waiting(%ds) for file %s ...", time_int, greenlight);
fflush(stdout);
sleep(time_int);
}
MPI_Barrier(comm);
}
#endif /*HAVE_PARALLEL*/
|