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 55 56 57 58 59 60 61
|
#ifdef SPRNG_MPI
#include <mpi.h>
#endif
#include <time.h>
#include "interface.h"
#ifdef __STDC__
void get_proc_info_mpi(int *myid, int *nprocs)
#else
void get_proc_info_mpi(myid, nprocs)
int *myid, *nprocs;
#endif
{
#ifdef SPRNG_MPI
MPI_Comm_rank(MPI_COMM_WORLD, myid);
MPI_Comm_size(MPI_COMM_WORLD, nprocs);
#else
*myid = 0;
*nprocs = 1;
#endif
}
#ifdef __STDC__
int make_new_seed_mpi(void)
#else
int make_new_seed_mpi()
#endif
{
#ifdef SPRNG_MPI
unsigned int temp2;
int myid, nprocs;
MPI_Comm newcomm;
MPI_Comm_dup(MPI_COMM_WORLD, &newcomm); /* create a temporary communicator */
MPI_Comm_rank(newcomm, &myid);
MPI_Comm_size(newcomm, &nprocs);
if(myid == 0)
temp2 = make_new_seed();
MPI_Bcast(&temp2,1,MPI_UNSIGNED,0,newcomm);
MPI_Comm_free(&newcomm);
return temp2;
#else
return make_new_seed();
#endif
}
#if 0
main()
{
printf("%u\n", make_new_seed());
printf("%u\n", make_new_seed());
}
#endif
|