Actual source code: mpilong.c
2: #include <petscsys.h> /*I "petscsys.h" I*/
4: /*
5: Allows sending/receiving larger messages then 2 gigabytes in a single call
6: */
8: PetscErrorCode MPILong_Send(void *mess,PetscInt cnt, MPI_Datatype type,PetscMPIInt to, PetscMPIInt tag, MPI_Comm comm)
9: {
10: PetscErrorCode ierr;
11: static PetscInt CHUNKSIZE = 250000000; /* 250,000,000 */
12: PetscInt i,numchunks;
13: PetscMPIInt icnt;
16: numchunks = cnt/CHUNKSIZE + 1;
17: for (i=0; i<numchunks; i++) {
18: icnt = PetscMPIIntCast((i < numchunks-1) ? CHUNKSIZE : cnt - (numchunks-1)*CHUNKSIZE);
19: MPI_Send(mess,icnt,type,to,tag,comm);
20: if (type == MPIU_INT) {
21: mess = (void*) (((PetscInt*)mess) + CHUNKSIZE);
22: } else if (type == MPIU_SCALAR) {
23: mess = (void*) (((PetscScalar*)mess) + CHUNKSIZE);
24: } else SETERRQ(comm,PETSC_ERR_SUP,"No support for this datatype");
25: }
26: return(0);
27: }
29: PetscErrorCode MPILong_Recv(void *mess,PetscInt cnt, MPI_Datatype type,PetscMPIInt from, PetscMPIInt tag, MPI_Comm comm)
30: {
31: int ierr;
32: static PetscInt CHUNKSIZE = 250000000; /* 250,000,000 */
33: MPI_Status status;
34: PetscInt i,numchunks;
35: PetscMPIInt icnt;
38: numchunks = cnt/CHUNKSIZE + 1;
39: for (i=0; i<numchunks; i++) {
40: icnt = PetscMPIIntCast((i < numchunks-1) ? CHUNKSIZE : cnt - (numchunks-1)*CHUNKSIZE);
41: MPI_Recv(mess,icnt,type,from,tag,comm,&status);
42: if (type == MPIU_INT) {
43: mess = (void*) (((PetscInt*)mess) + CHUNKSIZE);
44: } else if (type == MPIU_SCALAR) {
45: mess = (void*) (((PetscScalar*)mess) + CHUNKSIZE);
46: } else SETERRQ(comm,PETSC_ERR_SUP,"No support for this datatype");
47: }
48: return(0);
49: }