Skip to content

Commit 111d775

Browse files
committed
Better windows introspection
- If `SIGKILL` missing, try `-D_POSIX` - If windows (CMake `WIN32` for 32 & 64 bit windows) and `I_MPI_VERSION` `#define`d then pass `-DUSE_GCC` to adjust MPI type-defs
1 parent 1fecba2 commit 111d775

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

src/mpi/CMakeLists.txt

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mod)
22

3-
if (MINGW)
4-
add_definitions(-D_POSIX)
5-
endif()
6-
73
if (NOT MPI_C_FOUND)
84
find_package(MPI REQUIRED)
95

@@ -42,8 +38,32 @@ endif()
4238
#----------------------------------------------------------------------
4339
# Test if MPI implementation provides features needed for failed images
4440
#----------------------------------------------------------------------
45-
set(NEEDED_SYMBOLS MPIX_ERR_PROC_FAILED;MPIX_ERR_REVOKED;MPIX_Comm_failure_ack;MPIX_Comm_failure_get_acked;MPIX_Comm_shrink;MPIX_Comm_agree)
4641
set(MPI_HAS_FAULT_TOL_EXT YES)
42+
43+
CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
44+
if (NOT HAVE_SIGNAL_H)
45+
set(MPI_HAS_FAULT_TOL_EXT NO)
46+
message( FATAL_ERROR "Currently, OpenCoarrays cannot build without signal.h")
47+
endif()
48+
49+
include(CheckSymbolExists)
50+
CHECK_SYMBOL_EXISTS(SIGKILL "signal.h" HAVE_SIGKILL)
51+
if(NOT HAVE_SIGKILL) # try -D_POSIX, needed for mingw-w64, maybe others, see #435
52+
# https://github.com/sourceryinstitute/OpenCoarrays/issues/435#issuecomment-323592433
53+
list( APPEND CMAKE_REQUIRED_DEFINITIONS -D_POSIX)
54+
CHECK_SYMBOL_EXISTS(SIGKILL "signal.h" HAVE_SIGKILL)
55+
if(HAVE_SIGKILL)
56+
add_definitions(-D_POSIX)
57+
endif()
58+
endif()
59+
60+
if (NOT HAVE_SIGKILL)
61+
set(MPI_HAS_FAULT_TOL_EXT NO)
62+
message (FATAL_ERROR "Currently, OpenCoarrays cannot build without SIGKILL from signal.h")
63+
endif()
64+
65+
set(NEEDED_SYMBOLS MPIX_ERR_PROC_FAILED;MPIX_ERR_REVOKED;MPIX_Comm_failure_ack;MPIX_Comm_failure_get_acked;MPIX_Comm_shrink;MPIX_Comm_agree)
66+
4767
set(old_cmake_required_includes "${CMAKE_REQUIRED_INCLUDES}")
4868
if(CMAKE_REQUIRED_INCLUDES)
4969
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES};${MPI_C_INCLUDE_PATH})
@@ -69,7 +89,7 @@ if(HAVE_MPI_EXT)
6989
add_definitions(-DHAVE_MPI_EXT_H)
7090
set(MPI_HEADERS ${MPI_HEADERS};mpi-ext.h)
7191
endif()
72-
include(CheckSymbolExists)
92+
7393
foreach(symbol ${NEEDED_SYMBOLS})
7494
CHECK_SYMBOL_EXISTS(${symbol} ${MPI_HEADERS} HAVE_${symbol})
7595
if(NOT HAVE_${symbol})
@@ -93,6 +113,16 @@ if(CAF_ENABLE_FAILED_IMAGES)
93113
add_definitions(-DUSE_FAILED_IMAGES)
94114
endif()
95115

116+
#---------------------------------------------------
117+
# Windows Intel MPI compatibility, see GH issue #435
118+
#---------------------------------------------------
119+
CHECK_SYMBOL_EXISTS(I_MPI_VERSION mpi.h HAVE_Intel_MPI)
120+
if(HAVE_Intel_MPI AND WIN32)
121+
add_definitions(-DUSE_GCC)
122+
endif()
123+
124+
125+
96126
# Determine whether and how to include OpenCoarrays module based on if the Fortran MPI compiler:
97127
# - workds
98128
# - is compatible with the fortran compiler used to build the MPI implementation

0 commit comments

Comments
 (0)