0

I am using OpenMPI with the Intel C++ compiler on an Intel Ubuntu system. Whenever I try to replace new[] and delete[] calls with MPI_Alloc_mem and MPI_Free_mem calls, respectively, I always get a segmentation fault.

The MPI_Alloc_mem calls return MPI_SUCCESS. The segmentation fault occurs on the call to MPI_Free_mem. The MPI_Alloc_mem calls are with MPI_INFO_NULL. I explicitly typecast the void** and void* arguments in MPI_Alloc_mem and MPI_Free_memrespectively.

I have no idea why this happens. I'd appreciate any advice.

Rapptz
  • 20,807
  • 5
  • 72
  • 86

1 Answers1

0

First of all, unless you are going to use MPI-2 one-sided communication, there is absolutely no need to replace C++ memory management operators with MPI calls.

Second, the correct usage of MPI_ALLOC_MEM and MPI_FREE_MEM in C/C++ is as follows:

int *arr;

MPI_Alloc_mem(sizeof(int)*1000, MPI_INFO_NULL, &arr); // <-- here arr by address
...
MPI_Free_mem(arr);                                    // <-- here arr by value
Hristo Iliev
  • 72,659
  • 12
  • 135
  • 186