# Building mpi4py with Intel MPI on Windows

34 views

### maarten.b...@gmail.com

Aug 12, 2020, 7:10:00 AM8/12/20
to mpi4py

I'm trying to build mpi4py with Intel MPI on Windows 10. I first tried to install with pip but the installation kept defaulting to MSMPI, even though I removed it entirely. I also tried passing "MPICC=" flag. This didn't help either.
So I cloned the repo from bitbucket and I'm trying to build using setup. I added the following block to mpi.cfg:

[intelmpi]mpi_dir              = $(I_MPI_ROOT)\intel64mpicc = %(mpi_dir)s\bin\mpicc.batmpicxx = %(mpi_dir)s\bin\mpicxx.batinclude_dirs = %(mpi_dir)s\includelibraries = impi.liblibrary_dirs = %(mpi_dir)s\lib where I_MPI_ROOT evaluates to the location of intel MPI on my system. I called: python setup.py build --mpi=intelmpi Building fails. Checking the errors, there's a couple of things that catch my eye. First, the mpi compiler wrappers are not found: error:$(I_MPI_ROOT)\intel64\bin\mpicc.bat' not found
error: '$(I_MPI_ROOT)\intel64\bin\mpicxx.bat' not found I checked, the paths are correct. Using the full absolute path rather than$(I_MPI_ROOT) didn't help.

The script continues anyway, trying to build dependencies using the Visual C compiler on my system. Not sure if that is normal or a result from not finding the MPI compilers. Anyway, it fails on the first library, since library "lmpe.lib", cannot be found. Is this library supposed to be included with the MPI distribution?

Help would be appreciated.
Thanks,
Maarten

### Lisandro Dalcin

Aug 12, 2020, 9:57:06 AM8/12/20
On Wed, 12 Aug 2020 at 14:10, <maarten.b...@gmail.com> wrote:

I'm trying to build mpi4py with Intel MPI on Windows 10.

I never tried that. I'm not a windows user.

I first tried to install with pip but the installation kept defaulting to MSMPI, even though I removed it entirely.

Of course, those binary packages are built with MSMPI. They will not work with other MPI implementations.

I also tried passing "MPICC=" flag. This didn't help either.
So I cloned the repo from bitbucket and I'm trying to build using setup. I added the following block to mpi.cfg:

[intelmpi]mpi_dir              = $(I_MPI_ROOT)\intel64mpicc = %(mpi_dir)s\bin\mpicc.batmpicxx = %(mpi_dir)s\bin\mpicxx.batinclude_dirs = %(mpi_dir)s\includelibraries = impi.liblibrary_dirs = %(mpi_dir)s\lib where I_MPI_ROOT evaluates to the location of intel MPI on my system. I called: python setup.py build --mpi=intelmpi Building fails. Checking the errors, there's a couple of things that catch my eye. First, the mpi compiler wrappers are not found: error:$(I_MPI_ROOT)\intel64\bin\mpicc.bat' not found
error: '$(I_MPI_ROOT)\intel64\bin\mpicxx.bat' not found I checked, the paths are correct. Using the full absolute path rather than$(I_MPI_ROOT) didn't help.

Try setting mpi_dir this way:

mpi_dir = $I_MPI_ROOT\intel64 If that does not work, then use the full explicit path mpi_dir = C:\path\to\IntelMPI\intel64. I'm not really sure you can use that mpicc.bat batch file to build mpi4py. Look at the MSMPI sections in mpi.cfg, perhaps if you explicitly list the include and libraries, it will work. The script continues anyway, trying to build dependencies using the Visual C compiler on my system. Not sure if that is normal or a result from not finding the MPI compilers. Anyway, it fails on the first library, since library "lmpe.lib", cannot be found. Is this library supposed to be included with the MPI distribution? It is not a real failure, lack of lmpe.lib lib should not abort the build. It is an optional component. -- Lisandro Dalcin ============ Research Scientist Extreme Computing Research Center (ECRC) King Abdullah University of Science and Technology (KAUST) http://ecrc.kaust.edu.sa/ ### maarten.b...@gmail.com unread, Aug 13, 2020, 3:51:47 AM8/13/20 to mpi4py Thanks for your reply. I dove into it and found a few issues related to distutil functions.First, the split_quoted() function doesn't handle backslash path separators. It works fine with forward slashes. Second, the find_executable() function only finds .exe files, nothing else. This is a very old issue. I modified find_exe() in mpiconfig.py to fix the second problem. Now the compiler wrappers are recognized but still the MSVC compiler is used. Looking at the documentation for compilers in distutils, it seems that solving this would either require creating a subclass for intel compilers, or manually specifying the compiler options, like you suggested. Instead I downloaded and installed Intel distribution for Python. This includes a version of mpi4py built with Intel compilers, which works out of the box (unrelated problems aside). Still, since I don't like being tied to specific distribution, maybe I'll try to fix the problems at some point in the future. cheers, Maarten On Wednesday, August 12, 2020 at 3:57:06 PM UTC+2, Lisandro Dalcin wrote: ### Lisandro Dalcin unread, Aug 13, 2020, 5:35:00 AM8/13/20 to mpi...@googlegroups.com On Thu, 13 Aug 2020 at 10:51, <maarten.b...@gmail.com> wrote: Thanks for your reply. I dove into it and found a few issues related to distutil functions.First, the split_quoted() function doesn't handle backslash path separators. It works fine with forward slashes. Second, the find_executable() function only finds .exe files, nothing else. This is a very old issue. I modified find_exe() in mpiconfig.py to fix the second problem. Now the compiler wrappers are recognized but still the MSVC compiler is used. Yes, because the whole windows branch of my hacks did not accommodate for the usual MPI compiler wrappers we use in POSIX world. Please note that all that code predates the existence of Intel MPI for Windows. Looking at the documentation for compilers in distutils, it seems that solving this would either require creating a subclass for intel compilers, or manually specifying the compiler options, like you suggested. Can't you use Intel MPI with MSVC? Do you really need to add the Intel compiler to the combo? In short, can't you keep using MSVC to build mpi4py, passing include_dir/library_dir/libraries information? Instead I downloaded and installed Intel distribution for Python. This includes a version of mpi4py built with Intel compilers, which works out of the box (unrelated problems aside). Well, I guess that even Python itself is built with Intel compilers. Still, since I don't like being tied to specific distribution, maybe I'll try to fix the problems at some point in the future. Any help most welcome. It seems you really know the business, and the nightmare it is. As I said, I'm not a Windows developer, the best I could do was to set things up to use all-Microsoft stuff. ### maarten.b...@gmail.com unread, Aug 14, 2020, 3:17:58 AM8/14/20 to mpi4py You were right, using the MSVC compiler and linking against Intel MPI works fine. I removed the lines for mpicc and mpicxx from mpi.cfg: [intelmpi]mpi_dir =$I_MPI_ROOT/intel64include_dirs         = %(mpi_dir)s/includelibraries            = impilibrary_dirs         = %(mpi_dir)s/lib/release

Now it builds and installs!

Maarten

On Thursday, August 13, 2020 at 11:35:00 AM UTC+2, Lisandro Dalcin wrote:

### maarten.b...@gmail.com

Aug 14, 2020, 3:53:17 AM8/14/20
to mpi4py
The argument --mpi cannot be passed to setup.py with the "install" command. As a result, setup will default to MSMPI if it finds this, and rebuild if necessary. It seems the only way to install with Intel MPI is to remove MSMPI from the system.
cheers,
Maarten

### Lisandro Dalcin

Aug 14, 2020, 4:34:19 AM8/14/20
On Fri, 14 Aug 2020 at 10:53, <maarten.b...@gmail.com> wrote:
The argument --mpi cannot be passed to setup.py with the "install" command. As a result, setup will default to MSMPI if it finds this, and rebuild if necessary. It seems the only way to install with Intel MPI is to remove MSMPI from the system.

Well, the way to do it would be:

python setup.py build --mpi=intelmpi install

Another way:

set MPICFG=intelmpi
python setup.py install

Now that you figured how to make things work in intel MPI, I'm planning to update the example mpi.cfg.
I have a few questions.

* I noticed you wrote $I_MPI_ROOT/intel64 . Do backward slashes work? * In your intel MPI installation, does$I_MPI_ROOT contain an intel32 subdirectory with the stuff required for 32bits builds? Any chance you can try building with a Python 32bit version?

My plan is to add the following to mpi4py's mpi.cfg file:

# Intel MPI for Windows
# ---------------------
[intelmpi-windows-32bit]
mpi_dir              = $I_MPI_ROOT/intel32 include_dirs = %(mpi_dir)s/include libraries = impi library_dirs = %(mpi_dir)s/lib/release [intelmpi-windows-64bit] mpi_dir =$I_MPI_ROOT/intel32

include_dirs         = %(mpi_dir)s/include
libraries            = impi
library_dirs         = %(mpi_dir)s/lib/release

Note I'm adding the -windows-32/64bit tag. However, you can just keep passing --mpi=intelmpi or set MPICFG=intelmpi, the code in conf/mpiconfig.py will take care of resolving by platform and architecture.

Can you confirm the above configuration works?

BTW, are you ok if I add the following to the git commit message?

Co-authored-by: Maarten Braakhekke <maarten.b...@gmail.com>

### Maarten Braakhekke

Aug 14, 2020, 8:23:13 AM8/14/20
to mpi4py
There is no directory $I_MPI_ROOT/intel32 on my system. During the installation it is suggested that libraries for 32bit would also be installed, but I can't find them. I'll look into it because I also want to be able to build for 32bit. cheers, Maarten ### Lisandro Dalcin unread, Aug 14, 2020, 8:58:30 AM8/14/20 to mpi...@googlegroups.com On Fri, 14 Aug 2020 at 15:23, Maarten Braakhekke <maarten.b...@gmail.com> wrote: There is no directory$I_MPI_ROOT/intel32 on my system. During the installation it is suggested that libraries for 32bit would also be installed, but I can't find them. I'll look into it because I also want to be able to build for 32bit.

Since v5.1, it seems that 32bit libraries are no longer supported:

--

### Maarten Braakhekke

Aug 21, 2020, 5:39:18 AM8/21/20
to mpi4py
I finally got around to trying building with the settings you posted. As we discussed previously there is no intel32 directory. The last version of Intel MPI to support 32bit is 4.1 and this is not available for download any more. See my post on the Intel forum.
W.r.t. 64bit, the [intelmpi-windows-64bit] section you posted contained a typo--"intel32" should "intel64". Fixing that, it builds fine with passing --mpi=intelmpi. I also tried replacing the forward slashes with backward--this works too. I guess backward slashes are only an issue for specifying the compiler.

Fine with adding my name to the Git commit message--thanks.
If you have a version that searches for the $I_MPI_ROOT env variable I can test it. I think this variable added with the installation. I can check this. cheers, Maarten ### Lisandro Dalcin unread, Aug 21, 2020, 9:24:16 AM8/21/20 to mpi...@googlegroups.com On Fri, 21 Aug 2020 at 12:39, Maarten Braakhekke <maarten.b...@gmail.com> wrote: I finally got around to trying building with the settings you posted. As we discussed previously there is no intel32 directory. The last version of Intel MPI to support 32bit is 4.1 and this is not available for download any more. See my post on the Intel forum. W.r.t. 64bit, the [intelmpi-windows-64bit] section you posted contained a typo--"intel32" should "intel64". Fixing that, it builds fine with passing --mpi=intelmpi. I also tried replacing the forward slashes with backward--this works too. I guess backward slashes are only an issue for specifying the compiler. Yes, I catched that typo after my email. Also, it should be 'ia32' and not 'intel32' for the 32bit path. None: Now I'm using "impi" for the name, kind of what I do for "msmpi". If you have strong objections, I could revise that. Fine with adding my name to the Git commit message--thanks. Done, see branch below. If you have a version that searches for the$I_MPI_ROOT env variable I can test it. I think this variable added with the installation. I can check this.

Now please I need you to teste the following:

* First, make sure the%I_MPI_ROOT% environment variable is set.

* To test the mpi.cfg configuration:
python setup.py clean --all
python setup.py build --mpi=impi

* To test automatic configuration based on %I_MPI_ROOT%:
python setup.py clean --all
python setup.py build

Do them both work?

### Maarten Braakhekke

Aug 25, 2020, 2:55:57 PM8/25/20
to mpi4py
Both of the commands work.
I've never encountered the abbreviation "impi" before, so it might not be immediately obvious to people that it's Intel. But it's not a big deal--up to you.
Regarding the %I_MPI_ROOT% variable, there's an option "Intel MPI Environment Variables" (or something). I assume this needs to be selected to set it. But this is the case by default.

Cheers & thanks!
Maarten

PS If you need more help with testing on Windows let me know.

### Lisandro Dalcin

Aug 25, 2020, 3:26:42 PM8/25/20
On Tue, 25 Aug 2020 at 21:56, Maarten Braakhekke <maarten.b...@gmail.com> wrote:
Both of the commands work.
I've never encountered the abbreviation "impi" before, so it might not be immediately obvious to people that it's Intel. But it's not a big deal--up to you.

Do you think we should go for "intelmpi" instead? Not a big deal for me either, but I assume you have more experience using Intel MPI than I have. I'll wait for your final comments.

Regarding the %I_MPI_ROOT% variable, there's an option "Intel MPI Environment Variables" (or something). I assume this needs to be selected to set it. But this is the case by default.

Remember this is a default. Users installing mpi4py can set the environment variable manually pointing to the right location, then python -m pip install mpi4py. Although I understand such environment tweaks is not everyday practice for Windows users.

### Maarten Braakhekke

Aug 26, 2020, 6:35:37 AM8/26/20
to mpi4py
Let's go for intelmpi. A google search for "impi" resulted in one page on Intel MPI in the first 6 pages.
cheers,
Maarten

### Lisandro Dalcin

Aug 26, 2020, 7:37:16 AM8/26/20
On Wed, 26 Aug 2020 at 13:35, Maarten Braakhekke <maarten.b...@gmail.com> wrote:
Let's go for intelmpi. A google search for "impi" resulted in one page on Intel MPI in the first 6 pages.

OK, I fixed up my commits, and force pushed to the same branch.
Once you confirm everything works, this is good to go, I'll merge into master.

Regards,

--
You received this message because you are subscribed to the Google Groups "mpi4py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpi4py+un...@googlegroups.com.

### Maarten Braakhekke

Aug 27, 2020, 5:40:10 AM8/27/20
to mpi4py
With both build commands ("impi" replaced by "intelmpi" for the first) mpi4py builds fine. However, the optional libraries do not build. This was previously also the case but I forgot to mention this. I assume this is OK but I though I'd mention it anyway.

cheers,
Maarten

### Lisandro Dalcin

Aug 27, 2020, 6:00:14 AM8/27/20
On Thu, 27 Aug 2020 at 12:40, Maarten Braakhekke <maarten.b...@gmail.com> wrote:
With both build commands ("impi" replaced by "intelmpi" for the first) mpi4py builds fine.

Great! I'll merge the feature branch into master. Many thanks for your help.

However, the optional libraries do not build. This was previously also the case but I forgot to mention this. I assume this is OK but I though I'd mention it anyway.

Of course. These are optional components that require either MPE or VampirTrace libraries.

Warm regards,