diff --git a/RTCP/Cobalt/InputProc/src/Transpose/MPIUtil.cc b/RTCP/Cobalt/InputProc/src/Transpose/MPIUtil.cc index 30b90c677c1e844f8fef0a8e31bf332aeae0bce7..9276d97089104232d28b244da14c752241597605 100644 --- a/RTCP/Cobalt/InputProc/src/Transpose/MPIUtil.cc +++ b/RTCP/Cobalt/InputProc/src/Transpose/MPIUtil.cc @@ -126,44 +126,56 @@ namespace LOFAR { MPIAllocator mpiAllocator; - namespace { - typedef int (*MPI_SEND)(void *, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request*); - - // Generic send method - MPI_Request Guarded_MPI_Send(MPI_SEND sendMethod, const void *ptr, size_t numBytes, int destRank, int tag) { - DEBUG("SEND: size " << numBytes << " tag " << hex << tag << dec << " to " << destRank); - - ASSERT(numBytes > 0); - ASSERT(tag >= 0); // Silly MPI requirement - - //SmartPtr<ScopedLock> sl = MPI_threadSafe() ? 0 : new ScopedLock(MPIMutex); - - MPI_Request request; - - int error; - - error = sendMethod(const_cast<void*>(ptr), numBytes, MPI_BYTE, destRank, tag, MPI_COMM_WORLD, &request); - ASSERT(error == MPI_SUCCESS); - - return request; - } - } - - MPI_Request Guarded_MPI_Issend(const void *ptr, size_t numBytes, int destRank, int tag) { - return Guarded_MPI_Send(::MPI_Issend, ptr, numBytes, destRank, tag); + DEBUG("SEND: size " << numBytes << " tag " << hex << tag << dec << " to " << destRank); + ASSERT(numBytes > 0); + ASSERT(tag >= 0); // Silly MPI requirement (Reason: MPI_ANY_TAG is -1, but only for receivers) + //SmartPtr<ScopedLock> sl = MPI_threadSafe() ? 0 : new ScopedLock(MPIMutex); + + MPI_Request request; + // const_cast is for missing const in protos in OpenMPI <=1.6 (1.10 is fixed, not sure in between) + int error = ::MPI_Issend(const_cast<void*>(ptr), numBytes, MPI_BYTE, destRank, tag, MPI_COMM_WORLD, &request); + ASSERT(error == MPI_SUCCESS); + return request; } MPI_Request Guarded_MPI_Irsend(const void *ptr, size_t numBytes, int destRank, int tag) { - return Guarded_MPI_Send(::MPI_Irsend, ptr, numBytes, destRank, tag); + DEBUG("SEND: size " << numBytes << " tag " << hex << tag << dec << " to " << destRank); + ASSERT(numBytes > 0); + ASSERT(tag >= 0); // Silly MPI requirement (Reason: MPI_ANY_TAG is -1, but only for receivers) + //SmartPtr<ScopedLock> sl = MPI_threadSafe() ? 0 : new ScopedLock(MPIMutex); + + MPI_Request request; + // const_cast is for missing const in protos in OpenMPI <=1.6 (1.10 is fixed, not sure in between) + int error = ::MPI_Irsend(const_cast<void*>(ptr), numBytes, MPI_BYTE, destRank, tag, MPI_COMM_WORLD, &request); + ASSERT(error == MPI_SUCCESS); + return request; } MPI_Request Guarded_MPI_Ibsend(const void *ptr, size_t numBytes, int destRank, int tag) { - return Guarded_MPI_Send(::MPI_Ibsend, ptr, numBytes, destRank, tag); + DEBUG("SEND: size " << numBytes << " tag " << hex << tag << dec << " to " << destRank); + ASSERT(numBytes > 0); + ASSERT(tag >= 0); // Silly MPI requirement (Reason: MPI_ANY_TAG is -1, but only for receivers) + //SmartPtr<ScopedLock> sl = MPI_threadSafe() ? 0 : new ScopedLock(MPIMutex); + + MPI_Request request; + // const_cast is for missing const in protos in OpenMPI <=1.6 (1.10 is fixed, not sure in between) + int error = ::MPI_Ibsend(const_cast<void*>(ptr), numBytes, MPI_BYTE, destRank, tag, MPI_COMM_WORLD, &request); + ASSERT(error == MPI_SUCCESS); + return request; } MPI_Request Guarded_MPI_Isend(const void *ptr, size_t numBytes, int destRank, int tag) { - return Guarded_MPI_Send(::MPI_Isend, ptr, numBytes, destRank, tag); + DEBUG("SEND: size " << numBytes << " tag " << hex << tag << dec << " to " << destRank); + ASSERT(numBytes > 0); + ASSERT(tag >= 0); // Silly MPI requirement (Reason: MPI_ANY_TAG is -1, but only for receivers) + //SmartPtr<ScopedLock> sl = MPI_threadSafe() ? 0 : new ScopedLock(MPIMutex); + + MPI_Request request; + // const_cast is for missing const in protos in OpenMPI <=1.6 (1.10 is fixed, not sure in between) + int error = ::MPI_Isend(const_cast<void*>(ptr), numBytes, MPI_BYTE, destRank, tag, MPI_COMM_WORLD, &request); + ASSERT(error == MPI_SUCCESS); + return request; } MPI_Request Guarded_MPI_Irecv(void *ptr, size_t numBytes, int srcRank, int tag) {