From 96e34180ae01f550207b5384ff5aa1e93c4ac51c Mon Sep 17 00:00:00 2001 From: Alexander van Amesfoort <amesfoort@astron.nl> Date: Mon, 22 Aug 2016 12:46:45 +0000 Subject: [PATCH] Task #9127: COBALT: fix MPI incompat with 1.10. Remain compat w/ 1.6 (missing MPI Send const qual) --- .../Cobalt/InputProc/src/Transpose/MPIUtil.cc | 68 +++++++++++-------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/RTCP/Cobalt/InputProc/src/Transpose/MPIUtil.cc b/RTCP/Cobalt/InputProc/src/Transpose/MPIUtil.cc index 30b90c677c1..9276d970891 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) { -- GitLab