diff --git a/src/base.hpp b/src/base.hpp index 310ce6cc28dfe2bfb0593d5866dbd71fabd34e76..31c9987685b91208e9137a97a79f63845806ad5d 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -29,22 +29,28 @@ inline void DEBUG_MSG(const char * format, ...) std::cerr << debug_message_buffer; } -inline void DEBUG_WAIT(MPI_Comm communicator) +inline void DEBUG_MSG_WAIT(MPI_Comm communicator, const char * format, ...) { + va_list argptr; + va_start(argptr, format); + sprintf( + debug_message_buffer, + "cpu%.4d ", + myrank); + vsnprintf( + debug_message_buffer + 8, + message_buffer_length - 8, + format, + argptr); + va_end(argptr); + std::cerr << debug_message_buffer; MPI_Barrier(communicator); } -#define DEBUG_WAIT_ALL() MPI_Barrier(MPI_COMM_WORLD) - -#define CHECK_POINT() DEBUG_MSG("%s %s", __FILE__, __LINE__) - #else #define DEBUG_MSG(...) -#define DEBUG_WAIT_ALL() -#define DEBUG_WAIT(...) - -#define CHECK_POINT() +#define DEBUG_MSG_WAIT(...) #endif//NDEBUG diff --git a/src/field_descriptor.cpp b/src/field_descriptor.cpp index ac9c28bf1418df9a2a6e8058e980d4a3abb048c6..35341f960c9b19118c00a0e47d5d78173a51f446 100644 --- a/src/field_descriptor.cpp +++ b/src/field_descriptor.cpp @@ -11,7 +11,6 @@ field_descriptor::field_descriptor( MPI_Comm COMM_TO_USE) { DEBUG_MSG("entered field_descriptor::field_descriptor\n"); - //CHECK_POINT(); this->comm = COMM_TO_USE; MPI_Comm_rank(this->comm, &this->myrank); MPI_Comm_size(this->comm, &this->nprocs); @@ -45,14 +44,14 @@ field_descriptor::field_descriptor( this->slice_size *= this->subsizes[i]; this->full_size *= this->sizes[i]; } - DEBUG_MSG( + DEBUG_MSG_WAIT( + this->comm, "inside field_descriptor constructor, about to call " "MPI_Type_create_subarray\n" "%d %d %d\n", this->sizes[0], this->subsizes[0], this->starts[0]); - DEBUG_WAIT_ALL(); int local_zero_array[this->nprocs], zero_array[this->nprocs]; for (int i=0; i<this->nprocs; i++) local_zero_array[i] = 0; @@ -130,27 +129,30 @@ field_descriptor::field_descriptor( field_descriptor::~field_descriptor() { - delete[] this->sizes; - delete[] this->subsizes; - delete[] this->starts; - delete[] this->rank; - DEBUG_MSG(this->io_comm == MPI_COMM_NULL ? "null\n" : "not null\n"); - DEBUG_WAIT_ALL(); - DEBUG_MSG("subsizes[0] = %d \n", this->subsizes[0]); - DEBUG_WAIT_ALL(); + DEBUG_MSG_WAIT( + MPI_COMM_WORLD, + this->io_comm == MPI_COMM_NULL ? "null\n" : "not null\n"); + DEBUG_MSG_WAIT( + MPI_COMM_WORLD, + "subsizes[0] = %d \n", this->subsizes[0]); if (this->subsizes[0] > 0) { - DEBUG_MSG("deallocating mpi_array_dtype\n"); - DEBUG_WAIT(this->io_comm); + DEBUG_MSG_WAIT( + this->io_comm, + "deallocating mpi_array_dtype\n"); MPI_Type_free(&this->mpi_array_dtype); } - DEBUG_WAIT_ALL(); if (this->nprocs != this->io_nprocs && this->io_myrank != MPI_PROC_NULL) { - DEBUG_MSG("freeing io_comm\n"); - DEBUG_WAIT(this->io_comm); + DEBUG_MSG_WAIT( + this->io_comm, + "freeing io_comm\n"); MPI_Comm_free(&this->io_comm); } + delete[] this->sizes; + delete[] this->subsizes; + delete[] this->starts; + delete[] this->rank; } int field_descriptor::read(