Skip to content

Commit 4615278

Browse files
authored
Use find_package for MPI (ROCm#92)
* Use find_package for MPI * Minor fixes
1 parent 959cc19 commit 4615278

File tree

2 files changed

+15
-80
lines changed

2 files changed

+15
-80
lines changed

‎CMakeLists.txt‎

Lines changed: 14 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,6 @@
33
# ########################################################################
44
#Adding pthread flag for linking
55
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
6-
macro(check_mpi mpi_compiler mpi_lib_a mpi_lib_so mpi_bin_dir mpi_base_lib_dir mpi_inc_dir)
7-
find_program(MPI_MPICXX ${mpi_compiler} PATHS ${mpi_bin_dir} NO_DEFAULT_PATH)
8-
if (MPI_MPICXX)
9-
message ("-- ${mpi_compiler} found @ ${MPI_MPICXX}")
10-
find_file(MPI_H mpi.h PATHS ${mpi_inc_dir} NO_DEFAULT_PATH)
11-
message ("-- mpi.h is in ${MPI_H}")
12-
find_file(MPI_LIB NAMES ${mpi_lib_so} ${mpi_lib_a} PATHS ${mpi_base_lib_dir} PATH_SUFFIXES lib lib64 lib/x86_64-linux-gnu NO_DEFAULT_PATH)
13-
message ("-- libmpi is ${MPI_LIB}")
14-
if (NOT MPI_H OR NOT MPI_LIB)
15-
set (MPI_MPICXX "MPI_MPICXX-NOTFOUND")
16-
set (MPI_H "MPI_H-NOTFOUND")
17-
set (MPI_LIB "MPI_LIB-NOTFOUND")
18-
else()
19-
add_definitions(-DMPI_SUPPORT)
20-
include_directories(${mpi_inc_dir})
21-
link_libraries(${MPI_LIB})
22-
endif()
23-
else()
24-
message ("-- ${mpi_compiler} not found")
25-
endif()
26-
endmacro()
276

287
cmake_minimum_required(VERSION 3.16.3 FATAL_ERROR)
298

@@ -51,8 +30,7 @@ include(ROCMCheckTargetIds)
5130
include(ROCMClients)
5231

5332
# Build variables
54-
option(NO_MPI "Build RCCL-tests without MPI support.")
55-
option(MPI_PATH "Use MPI in the specified directory.")
33+
option(USE_MPI "Build RCCL-tests with MPI support.")
5634

5735
# Default GPU architectures to build
5836
#==================================================================================================
@@ -84,64 +62,23 @@ set(GPU_TARGETS "${SUPPORTED_GPUS}" CACHE STRING "List of specific GPU architect
8462
message(STATUS "Compiling for ${GPU_TARGETS}")
8563

8664
find_package(RCCL HINTS CONFIG REQUIRED PATHS "${ROCM_PATH}")
65+
if (RCCL_FOUND)
66+
message(STATUS "RCCL version : ${RCCL_VERSION}")
67+
message(STATUS "RCCL include path : ${RCCL_INCLUDE_DIRS}")
68+
message(STATUS "RCCL libraries : ${RCCL_LIBRARIES}")
69+
endif()
8770

88-
if (NOT NO_MPI)
89-
# CHECK for MPI Path first. User requested this directory explicitely
90-
if (MPI_PATH)
91-
set(mpi_spec_bin_dir "${MPI_PATH}/bin")
92-
set(mpi_spec_inc_dir "${MPI_PATH}/include")
93-
check_mpi(mpicxx libmpi.a libmpi.so ${mpi_spec_bin_dir} ${MPI_PATH} ${mpi_spec_inc_dir})
94-
if (NOT MPI_MPICXX)
95-
# Since the user explicitely requested this directory, abort if something went wrong.
96-
MESSAGE(FATAL_ERROR "Could not find MPI in ${MPI_PATH}")
97-
endif()
98-
endif()
99-
100-
# Check for MPICH Ubuntu installation
101-
if (NOT MPI_MPICXX)
102-
check_mpi(mpicxx.mpich libmpich.a libmpich.so /usr/bin /usr /usr/include/x86_64-linux-gnu/mpich)
103-
endif()
104-
105-
# Check for Open MPI Ubuntu installation
106-
if (NOT MPI_MPICXX)
107-
check_mpi(mpicxx.openmpi libmpi.a libmpi.so /usr/bin /usr/lib/x86_64-linux-gnu/openmpi /usr/lib/x86_64-linux-gnu/openmpi/include)
108-
endif()
109-
110-
# Check for MPICH RHEL installation
111-
if (NOT MPI_MPICXX)
112-
check_mpi(mpicxx libmpich.a libmpich.so /usr/lib64/mpich/bin /usr/lib64/mpich /usr/include/mpich-x86_64)
113-
endif()
114-
115-
# Check for Open MPI RHEL installation
116-
if (NOT MPI_MPICXX)
117-
check_mpi(mpicxx libmpi.a libmpi.so /usr/lib64/openmpi/bin /usr/lib64/openmpi /usr/include/openmpi-x64_64)
118-
endif()
119-
120-
# Check for MPICH SLES installation
121-
if (NOT MPI_MPICXX)
122-
check_mpi(mpicxx libmpich.a libmpich.so /usr/lib64/mpi/gcc/mpich/bin /usr/lib64/mpi/gcc/mpich /usr/lib64/mpi/gcc/mpich/include)
123-
endif()
124-
125-
# Check for Open MPI v4 SLES installation
126-
if (NOT MPI_MPICXX)
127-
check_mpi(mpicxx libmpi.a libmpi.so /usr/lib64/mpi/gcc/openmpi4/bin /usr/lib64/mpi/gcc/openmpi4 /usr/lib64/mpi/gcc/openmpi4/include)
128-
endif()
129-
130-
# Check for Open MPI v3 SLES installation
131-
if (NOT MPI_MPICXX)
132-
check_mpi(mpicxx libmpi.a libmpi.so /usr/lib64/mpi/gcc/openmpi3/bin /usr/lib64/mpi/gcc/openmpi3 /usr/lib64/mpi/gcc/openmpi3/include)
133-
endif()
134-
135-
# Check for Open MPI v2 SLES installation
136-
if (NOT MPI_MPICXX)
137-
check_mpi(mpicxx libmpi.a libmpi.so /usr/lib64/mpi/gcc/openmpi2/bin /usr/lib64/mpi/gcc/openmpi2 /usr/lib64/mpi/gcc/openmpi2/include)
138-
endif()
139-
140-
if (NOT MPI_MPICXX)
71+
if (USE_MPI)
72+
find_package(MPI REQUIRED)
73+
if (MPI_FOUND)
74+
message(STATUS "MPI include path : ${MPI_CXX_INCLUDE_PATH}")
75+
message(STATUS "MPI libraries : ${MPI_CXX_LIBRARIES}")
76+
add_definitions(-DMPI_SUPPORT)
77+
else()
14178
message ("-- no MPI library found")
14279
endif()
14380
else()
144-
message ("-- MPI support explicitely disabled")
81+
message ("-- MPI support disabled")
14582
endif()
14683

14784
set(ROCM_USE_DEV_COMPONENT OFF) # This repo doesn't have a dev component

‎README.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ $ make
3030
When using the cmake build procedure, please make sure that RCCL has also been built using cmake (i.e. not using the install.sh script), since cmake will check
3131
for cmake target and config files that are created during the RCCL build.
3232

33-
Using the cmake method also has the advantage that the build is automatically checking for MPI installations, i.e. it is not necessary to explicitly request
34-
MPI builds. A user can request to use a particular MPI library by using the MPI_PATH variable. MPI support can be explicitely disabled by adding the -DNO_MPI=1
35-
flag to the cmake command line.
33+
Using the cmake method also has the advantage that the build is automatically checking for MPI installations. The tests can be compiled with MPI support by adding the `-DUSE_MPI=ON` flag to the cmake command line. A user can request to use a particular MPI library by setting the environment variable `MPI_HOME` or add the path of the MPI library to the cmake prefix path with `-DCMAKE_PREFIX_PATH`.
3634

3735

3836
## Usage

0 commit comments

Comments
 (0)