Skip to content

Commit

Permalink
removes false positives in test for openmpi version
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelKoch committed Oct 31, 2022
1 parent 3ebf663 commit 2c05a79
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 16 deletions.
34 changes: 18 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ include(cmake/build_type_helpers.cmake)
include(cmake/build_helpers.cmake)
include(cmake/install_helpers.cmake)

if (MSVC)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()
if (MINGW OR CYGWIN)
if(MINGW OR CYGWIN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")
endif()

Expand Down Expand Up @@ -216,16 +216,18 @@ if(GINKGO_BUILD_MPI)
set(GINKGO_HAVE_GPU_AWARE_MPI OFF)
endif()

execute_process(COMMAND ${MPIEXEC_EXECUTABLE} --version
OUTPUT_VARIABLE mpiexec_output RESULT_VARIABLE mpiexec_result)
string(REGEX MATCH "[oO][pP][eE][nN].?[mM][pP][iI]" openmpi_match "${mpiexec_output}")
if(openmpi_match)
string(REGEX MATCH "([0-9]+\.?)+" openmpi_version "${mpiexec_output}")
try_run(uses_openmpi gko_result_unused
${PROJECT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/cmake/openmpi_test.cpp
LINK_LIBRARIES MPI::MPI_CXX
RUN_OUTPUT_VARIABLE openmpi_version
)
if(uses_openmpi)
if(openmpi_version VERSION_LESS "4.1")
message(WARNING
"OpenMPI v4.0.x has a bug that forces us to use blocking communication in our distributed "
"matrix class. To enable faster, non-blocking communication, consider updating your OpenMPI version or "
"switch to a different vendor.")
"OpenMPI v4.0.x has a bug that forces us to use blocking communication in our distributed "
"matrix class. To enable faster, non-blocking communication, consider updating your OpenMPI version or "
"switch to a different vendor.")
set(GINKGO_FORCE_SPMV_BLOCKING_COMM ON)
endif()
endif()
Expand Down Expand Up @@ -264,21 +266,21 @@ add_subdirectory(common) # Import list of unified kernel source files
if(GINKGO_BUILD_CUDA)
add_subdirectory(cuda) # High-performance kernels for NVIDIA GPUs
endif()
if (GINKGO_BUILD_REFERENCE)
if(GINKGO_BUILD_REFERENCE)
add_subdirectory(reference) # Reference kernel implementations
endif()
if(GINKGO_BUILD_HIP)
add_subdirectory(hip) # High-performance kernels for AMD or NVIDIA GPUs
endif()
if (GINKGO_BUILD_DPCPP)
if(GINKGO_BUILD_DPCPP)
add_subdirectory(dpcpp) # High-performance DPC++ kernels
endif()
if (GINKGO_BUILD_OMP)
if(GINKGO_BUILD_OMP)
add_subdirectory(omp) # High-performance omp kernels
endif()
add_subdirectory(core) # Core Ginkgo types and top-level functions
add_subdirectory(include) # Public API self-contained check
if (GINKGO_BUILD_TESTS)
if(GINKGO_BUILD_TESTS)
add_subdirectory(test) # Tests running on all executors
endif()

Expand Down Expand Up @@ -346,7 +348,7 @@ endif()
configure_file(${Ginkgo_SOURCE_DIR}/cmake/ginkgo.pc.in
${Ginkgo_BINARY_DIR}/ginkgo.pc.in @ONLY)
file(GENERATE OUTPUT ${Ginkgo_BINARY_DIR}/ginkgo_$<CONFIG>.pc
INPUT ${Ginkgo_BINARY_DIR}/ginkgo.pc.in)
INPUT ${Ginkgo_BINARY_DIR}/ginkgo.pc.in)

# WINDOWS NVCC has " inside the string, add escape character
# to avoid config problem.
Expand Down Expand Up @@ -379,7 +381,7 @@ endif()
file(MAKE_DIRECTORY "${GINKGO_TEST_INSTALL_BIN_DIR}")
file(MAKE_DIRECTORY "${GINKGO_TEST_EXPORTBUILD_BIN_DIR}")
set(TOOLSET "")
if (NOT "${CMAKE_GENERATOR_TOOLSET}" STREQUAL "")
if(NOT "${CMAKE_GENERATOR_TOOLSET}" STREQUAL "")
set(TOOLSET "-T${CMAKE_GENERATOR_TOOLSET}")
endif()
add_custom_target(test_install
Expand Down
44 changes: 44 additions & 0 deletions cmake/openmpi_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*******************************<GINKGO LICENSE>******************************
Copyright (c) 2017-2022, the Ginkgo authors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************<GINKGO LICENSE>*******************************/

#include <mpi.h>
#include <cstdio>
int main()
{
#if defined(OPEN_MPI) && OPEN_MPI
std::printf("%d.%d.%d", OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
OMPI_RELEASE_VERSION);
return 1;
#else
return 0;
#endif
}

0 comments on commit 2c05a79

Please sign in to comment.