1 #ifdef SPRNG_MPI
2 #include <mpi.h>
3 #endif /* SPRNG_MPI */
4 #include <time.h>
5 #include "interface.h"
6
7
8 #ifdef __STDC__
get_proc_info_mpi(int * myid,int * nprocs)9 void get_proc_info_mpi(int *myid, int *nprocs)
10 #else
11 void get_proc_info_mpi(myid, nprocs)
12 int *myid, *nprocs;
13 #endif
14 {
15 #ifdef SPRNG_MPI
16 MPI_Comm_rank(MPI_COMM_WORLD, myid);
17 MPI_Comm_size(MPI_COMM_WORLD, nprocs);
18 #else
19 *myid = 0;
20 *nprocs = 1;
21 #endif
22 }
23
24
25 #ifdef __STDC__
make_new_seed_mpi(void)26 int make_new_seed_mpi(void)
27 #else
28 int make_new_seed_mpi()
29 #endif
30 {
31 #ifdef SPRNG_MPI
32 unsigned int temp2;
33 int myid, nprocs;
34 MPI_Comm newcomm;
35
36 MPI_Comm_dup(MPI_COMM_WORLD, &newcomm); /* create a temporary communicator */
37
38 MPI_Comm_rank(newcomm, &myid);
39 MPI_Comm_size(newcomm, &nprocs);
40
41 if(myid == 0)
42 temp2 = make_new_seed();
43
44 MPI_Bcast(&temp2,1,MPI_UNSIGNED,0,newcomm);
45
46 MPI_Comm_free(&newcomm);
47
48 return temp2;
49 #else
50 return make_new_seed();
51 #endif
52 }
53
54
55 /* HAS ;-) */
56 #ifdef SPRNG_MPI_TEST
main()57 main()
58 {
59 printf("%u\n", make_new_seed());
60 printf("%u\n", make_new_seed());
61 }
62 #endif
63