locked
How to wrap the MPI code into a DLL RRS feed

  • Question

  • I have an MPI/OpenMP code which compiles and runs well. I would like to wrap the code to DLL and use other language to call the DLL. I have already wrapped my algorithm with OpenMP(parallel threads) to the DLL and it can run well. but the MPI must be started by "mpiexec" command. so, if I wrap the MPI code into a DLL, I can't run the MPI. Can you give me some advice or alternative approaches?

    Thank you!                   

    Monday, August 21, 2017 1:33 AM

Answers

  • Hi,

    If you wrap your MPI code into a DLL (e.g. mylibrary.dll), any application that is linked against your dll (e.g. myapp.exe) can just be launched by mpiexec (e.g. mpiexec -n 2 myapp.exe). Another way would be for you to call CreateProcess within the DLL itself to launch mpiexec, but this is nontrivial.

    If you don't want to involve mpiexec altogether you can look into MPI Dynamic Process using MPI_Comm_connect and MPI_Comm_accept. You can take a look at the example given in the MPI Standard on how to use them

    http://mpi-forum.org/docs/mpi-2.2/mpi22-report/node218.htm#Node218

    Let us know if you still have more questions.

    Anh


    Monday, August 21, 2017 10:31 PM

All replies

  • Hi,

    If you wrap your MPI code into a DLL (e.g. mylibrary.dll), any application that is linked against your dll (e.g. myapp.exe) can just be launched by mpiexec (e.g. mpiexec -n 2 myapp.exe). Another way would be for you to call CreateProcess within the DLL itself to launch mpiexec, but this is nontrivial.

    If you don't want to involve mpiexec altogether you can look into MPI Dynamic Process using MPI_Comm_connect and MPI_Comm_accept. You can take a look at the example given in the MPI Standard on how to use them

    http://mpi-forum.org/docs/mpi-2.2/mpi22-report/node218.htm#Node218

    Let us know if you still have more questions.

    Anh


    Monday, August 21, 2017 10:31 PM
  • hi,

    firstly, thank you for your replying and I have read the MPI standard. then, I have also meet some problems.  the DLL(e.g. mylibray.dll) is called by LabVIEW software, which is Graphical programming language. so I can't launched my LabVIEW codes by "mpiexec". According to MPI standard, the MPI_Comm_connect and MPI_Comm_accept functions are used. Am I wrapping the "Server code" into "mylibrary.dll" and I run the LabVIEW code which is embedded the "mylibrary.dll". the "Client code"(.exe file)  will run parallel process and send the data to "Server code".

    I also find another function like "MPI_Comm_spaw". the parent and child processes are used to create process. is this the "CreateProcess within DLL itself to launch mpiexec", you said?

    I am sorry to ask so easy problems. I am a newer to MPI.

    thank you,

    Wang Gang

    Tuesday, August 22, 2017 7:03 AM
  • In order to use MPI_Comm_spawn you most likely also need to have mpiexec/smpd running. If your DLL absolutely cannot deal with mpiexec I think MPI_Comm_spawn isn't an option.

    I think the only viable solution would be MPI_Comm_accept and MPI_Comm_connect. Can you describe a bit more about your design and we might be able to offer more specific suggestions? (if this is something that you don't want to disclose in the public forum, you can send an email to our team at askmpi @ Microsoft.com)

    Thursday, August 24, 2017 6:14 PM
  • I will send an email to you for the specific suggestion ASAP. Thanks in advance.

    Wang Gang

    Friday, August 25, 2017 1:07 AM