You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a case where I'm using MPI inside a DLL file. It serves like an API which means that MPI_Finalize() must be called only once, from inside the DLL, in the end of its caller program. To accomplish this I've put MPI_Finalize() in a function that is marked with __attribute__((destructor)), so its code will execute upon unloading of the DLL.
However, the program hangs there, and MPI_Finalize() never returns. My setup is (although the issue was reproducible in other PC as well):
Windows 10 Pro Version 21H1 (OS Build 19043.1237).
MS-MPI Version 10.1.12498.18.
Build with gcc 10.1.0 using mingw64 from MSYS2 with target x86_64-w64-mingw32.
I have managed to reproduce the issue in a minimal example:
myapi.cpp (The DLL code)
#include<stdio.h>
#include<stdint.h>
#include<mpi.h>voidbin_destructor() __attribute__((destructor));
voidbin_destructor(){
int initialized;
MPI_Initialized(&initialized);
int finalized;
MPI_Finalized(&finalized);
printf("*** %s. Line %d ***\n", __FILE__, __LINE__); fflush(stdout);
if(initialized && (!finalized)){
printf("*** %s. Line %d, Finalizing MPI...", __FILE__, __LINE__); fflush(stdout);
MPI_Finalize(); // <-- It hangs hereprintf("Done. ***\n"); fflush(stdout);
}
printf("*** %s. Line %d ***\n", __FILE__, __LINE__); fflush(stdout);
}
extern"C" __stdcall __declspec(dllexport) int MyAPI(constint n){
int initialized;
MPI_Initialized(&initialized);
if( !initialized ) MPI_Init(NULL, NULL); // Initialize only once.printf("*** %s. Line %d n=%d ***\n", __FILE__, __LINE__, n); fflush(stdout);
return0;
}
Hi all.
I have a case where I'm using MPI inside a DLL file. It serves like an API which means that MPI_Finalize() must be called only once, from inside the DLL, in the end of its caller program. To accomplish this I've put MPI_Finalize() in a function that is marked with
__attribute__((destructor))
, so its code will execute upon unloading of the DLL.However, the program hangs there, and MPI_Finalize() never returns. My setup is (although the issue was reproducible in other PC as well):
Windows 10 Pro Version 21H1 (OS Build 19043.1237).
MS-MPI Version 10.1.12498.18.
Build with gcc 10.1.0 using mingw64 from MSYS2 with target x86_64-w64-mingw32.
I have managed to reproduce the issue in a minimal example:
compiling with
compiling with
When I run the program serially, e.g. $>main.exe , the output is:
When I run the program in parallel, even with only 1 process, e.g. $>mpiexec -np 1 main.exe , the output is:
..and it hangs there.
Any help so I can explain & resolve this behavior is greatly appreciated.
Best regards,
George
The text was updated successfully, but these errors were encountered: