Last active
February 16, 2023 04:15
-
-
Save scivision/bd9710c49b5b11d479675c261821af58 to your computer and use it in GitHub Desktop.
OpenMPI 4.x TMPDIR race vader unlink error workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is a dummy exmaple project. The actual workaround is in openmpi.cmake. | |
cmake_minimum_required(VERSION 3.14) | |
project(Workaround LANGUAGES C) | |
enable_testing() | |
include(openmpi.cmake) | |
set(MPI_DETERMINE_LIBRARY_VERSION true) | |
find_package(MPI COMPONENTS C REQUIRED) | |
message(STATUS "MPI Library Version: ${MPI_C_LIBRARY_VERSION_STRING}") | |
add_executable(my_mpi main.c) | |
add_test(NAME MyMPI | |
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} my_mpi) | |
get_property(tests DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS) | |
if(DEFINED mpi_tmpdir) | |
# enact the workaround | |
set_property(TEST ${tests} PROPERTY ENVIRONMENT TMPDIR=${mpi_tmpdir}) | |
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/open-mpi/ompi/issues/7393 | |
# https://github.com/gerlero/openfoam-app/pull/112 | |
# https://apple.stackexchange.com/a/287710 | |
# *** OpenMPI workaround | |
if(UNIX AND MPI_C_LIBRARY_VERSION_STRING MATCHES "Open[ ]?MPI")) | |
if(NOT DEFINED mpi_tmpdir) | |
execute_process(COMMAND mktemp -d /tmp/mpi-XXXXXXXX | |
RESULT_VARIABLE ret | |
OUTPUT_VARIABLE mpi_tmpdir | |
OUTPUT_STRIP_TRAILING_WHITESPACE | |
) | |
if(NOT ret EQUAL 0) | |
message(FATAL_ERROR "could not create MPI working dir via mktemp -d: ${ret}") | |
endif() | |
set(mpi_tmpdir ${mpi_tmpdir} CACHE PATH "MPI working dir") | |
message(STATUS "${ret}: Created MPI working dir ${mpi_tmpdir}") | |
endif() | |
endif() | |
# *** END OpenMPI workaround |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment