14 #define _XOPEN_SOURCE 700
24 #include <sys/types.h>
33 #include "sion_error_handler.h"
51 size_t sion_coll_fwrite_mpi(
const void *data,
size_t size,
size_t nitems,
int sid) {
52 return(sion_coll_fwrite(data,size,nitems,sid));
57 size_t sion_coll_fread_mpi(
void *data,
size_t size,
size_t nitems,
int sid) {
58 return(sion_coll_fread(data,size,nitems,sid));
63 int sion_paropen_comms_mpi(
char *fname,
64 const char *file_mode,
67 MPI_Comm lComm, sion_int64 *chunksize, sion_int32 *fsblksize,
int *globalrank, FILE **fileptr,
char *newfname)
70 return(
sion_paropen_mpi(fname,file_mode,numFiles,gComm,&lComm,chunksize,fsblksize,globalrank,fileptr,&newfname));
73 int sion_paropen_multi_mpi(
char *fname,
74 const char *file_mode,
77 MPI_Comm *lComm, sion_int64 *chunksize, sion_int32 *fsblksize,
int *globalrank, FILE **fileptr,
char *newfname)
79 return(
sion_paropen_mpi(fname,file_mode,numFiles,gComm,lComm,chunksize,fsblksize,globalrank,fileptr,&newfname));
84 int sion_startof_transaction_mpi(
int sid ) {
85 int rc = SION_SUCCESS;
86 int grank, lrank, lsize, blocksize, step=0;
87 MPI_Comm gComm, lComm;
95 return(_sion_errorprint_mpi(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"sion_parclose_mpi: invalid sion_filedesc %d", sid));
100 gComm=gcommgroup->comm;
101 lComm=lcommgroup->comm;
102 MPI_Comm_rank(gComm, &grank);
103 MPI_Comm_rank(lComm, &lrank);
104 MPI_Comm_size(lComm, &lsize);
107 if (t) blocksize= atoi(t);
108 else if(lsize>128) blocksize= 32;
109 else if(lsize>64) blocksize= 16;
110 else if(lsize>16) blocksize= 8;
111 else blocksize=lsize;
112 lcommgroup->blocksize=blocksize;
114 DPRINTFTS(grank,
"enter start of transaction of sid");
115 DPRINTFP((1,
"sion_startof_transaction_mpi", grank,
"enter start of transaction of sid %d blocksize=%d lrank=%d\n", sid,blocksize,lrank));
119 if(lrank>blocksize) {
120 if(sion_filedesc->
filenumber==0) fprintf(stderr,
"sion_startof_transaction_mpi ts=%8.4fs on grank=%5d lrank=%3d waiting for message from %5d\n",
_sion_get_time()-lcommgroup->ts,
121 grank,lrank,lrank-blocksize);
122 MPI_Recv(&step, 1, MPI_INT, lrank-blocksize, 1430, lComm, &status);
125 lcommgroup->step=step;
126 if(sion_filedesc->
filenumber==0) fprintf(stderr,
"sion_startof_transaction_mpi ts=%8.4fs on grank=%5d lrank=%3d starting transaction (blocksize=%d, step=%d)\n",
_sion_get_time()-lcommgroup->ts,
127 grank,lrank,blocksize,step);
128 DPRINTFP((1,
"sion_startof_transaction_mpi", grank,
"leave start of transaction of sid %d\n", sid));
129 DPRINTFTS(grank,
"leave start of transaction of sid");
133 int sion_endof_transaction_mpi (
int sid ) {
134 int rc = SION_SUCCESS;
135 int grank, lrank, lsize, blocksize, step=1;
136 MPI_Comm gComm, lComm;
142 return(_sion_errorprint_mpi(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"sion_parclose_mpi: invalid sion_filedesc %d", sid));
147 gComm=gcommgroup->comm;
148 lComm=lcommgroup->comm;
149 MPI_Comm_rank(gComm, &grank);
150 MPI_Comm_rank(lComm, &lrank);
151 MPI_Comm_size(lComm, &lsize);
153 blocksize=lcommgroup->blocksize;
154 step= lcommgroup->step+1;
156 DPRINTFTS(grank,
"enter end of transaction of sid");
157 DPRINTFP((1,
"sion_endof_transaction_mpi", grank,
"enter end of transaction of sid %d blocksize=%d lrank=%d\n", sid,blocksize,lrank));
160 if(lrank+blocksize<lsize) {
161 if(sion_filedesc->
filenumber==0) fprintf(stderr,
"sion_endof_transaction_mpi ts=%8.4fs on grank=%5d lrank=%3d sending step %2d to %5d\n",
_sion_get_time()-lcommgroup->ts,
162 grank,lrank,step,lrank+blocksize);
163 MPI_Send(&step, 1, MPI_INT, lrank+blocksize, 1430, lComm);
166 if(sion_filedesc->
filenumber==0) fprintf(stderr,
"sion_endof_transaction_mpi ts=%8.4fs on grank=%5d lrank=%3d end of transaction step=%2d\n",
_sion_get_time()-lcommgroup->ts,
169 DPRINTFP((1,
"sion_endof_transaction_mpi", grank,
"leave end of transaction of sid %d\n", sid));
170 DPRINTFTS(grank,
"leave end of transaction of sid");
void * _sion_vcdtovcon(int sid)
int _sion_vcdtype(int sid)
#define SION_FILEDESCRIPTOR
char * _sion_getenv(const char *name)
int sion_paropen_mpi(const char *fname, const char *file_mode, int *numFiles, MPI_Comm gComm, const MPI_Comm *lComm, sion_int64 *chunksize, sion_int32 *fsblksize, int *globalrank, FILE **fileptr, char **newfname)
Open a sion file using MPI.
double _sion_get_time(void)
Returns the current time as a double.
Sion File Descriptor Structure.