Skip to content

Commit

Permalink
Use env variables instead of hardcoded paths for ms-mpi search (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
maksim-petukhov authored Sep 3, 2023
1 parent ce50128 commit 2bd9edf
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions src/tools/mpi.jam
Original file line number Diff line number Diff line change
Expand Up @@ -246,35 +246,60 @@ rule init ( mpicxx ? : options * : mpirun-with-options * )
if ! $(mpicxx) && [ os.on-windows ]
{
# Paths for Microsoft MPI
local ms_mpi_path_native = "C:\\Program Files\\Microsoft MPI" ;
local ms_mpi_sdk_path_native = "C:\\Program Files (x86)\\Microsoft SDKs\\MPI" ;
# Treat them explicitly as native OS path references
local ms_mpi_bin_native = [ os.environ MSMPI_BIN ] ;
if $(ms_mpi_bin_native)
{
ms_mpi_bin_native = [ path.make $(ms_mpi_bin_native) ] ;
ms_mpi_bin_native = [ path.native $(ms_mpi_bin_native) ] ;
}

local ms_mpi_inc_native = [ os.environ MSMPI_INC ] ;
if $(ms_mpi_inc_native)
{
ms_mpi_inc_native = [ path.make $(ms_mpi_inc_native) ] ;
ms_mpi_inc_native = [ path.native $(ms_mpi_inc_native) ] ;
}

# Path for Microsoft Compute Cluster Pack
local cluster_pack_path_native = "C:\\Program Files\\Microsoft Compute Cluster Pack" ;

# Try to auto-configure Microsoft MPI
if [ GLOB $(ms_mpi_path_native)\\Bin : mpiexec.exe ] &&
[ GLOB $(ms_mpi_sdk_path_native)\\Include : mpi.h ]
if $(ms_mpi_bin_native) &&
$(ms_mpi_inc_native) &&
[ GLOB $(ms_mpi_bin_native) : mpiexec.exe ] &&
[ GLOB $(ms_mpi_inc_native) : mpi.h ]
{
if $(.debug-configuration)
{
ECHO "Found Microsoft MPI: $(ms_mpi_path_native)" ;
ECHO "Found Microsoft MPI SDK: $(ms_mpi_sdk_path_native)" ;
ECHO "Found Microsoft MPI and Microsoft MPI SDK" ;
}

local ms_mpi_lib32 = [ os.environ MSMPI_LIB32 ] ;
if $(ms_mpi_lib32)
{
ms_mpi_lib32 = [ path.make $(ms_mpi_lib32) ] ;
}

local ms_mpi_lib64 = [ os.environ MSMPI_LIB64 ] ;
if $(ms_mpi_lib64)
{
ms_mpi_lib64 = [ path.make $(ms_mpi_lib64) ] ;
}

local ms_mpi_sdk_path = [ path.make $(ms_mpi_sdk_path_native) ] ;
local ms_mpi_inc = [ path.make $(ms_mpi_inc_native) ] ;

# Pick up either the 32-bit or 64-bit library, depending on which address
# model the user has selected. Default to 32-bit.
options = <include>$(ms_mpi_sdk_path)/Include
<address-model>64:<library-path>$(ms_mpi_sdk_path)/Lib/x64
<library-path>$(ms_mpi_sdk_path)/Lib/x86
options = <include>$(ms_mpi_inc)
<address-model>64:<library-path>$(ms_mpi_lib64)
<library-path>$(ms_mpi_lib32)
<find-static-library>msmpi
<toolset>msvc:<define>_SECURE_SCL=0
;

# Setup the "mpirun" equivalent (mpiexec)
.mpirun = "\"$(ms_mpi_path_native)\\Bin\\mpiexec.exe"\" ;
.mpirun = "\"$(ms_mpi_bin_native)\\mpiexec.exe"\" ;
.mpirun_flags = -n ;
}
# Try to auto-configure to the Microsoft Compute Cluster Pack
Expand Down Expand Up @@ -302,8 +327,7 @@ rule init ( mpicxx ? : options * : mpirun-with-options * )
}
else if $(.debug-configuration)
{
ECHO "Did not find Microsoft MPI in $(ms_mpi_path_native)" ;
ECHO " and/or Microsoft MPI SDK in $(ms_mpi_sdk_path_native)." ;
ECHO "Did not find Microsoft MPI and/or Microsoft MPI SDK" ;
ECHO "Did not find Microsoft Compute Cluster Pack in $(cluster_pack_path_native)." ;
}
}
Expand Down

0 comments on commit 2bd9edf

Please sign in to comment.