Last active
May 23, 2017 19:09
-
-
Save mazhe/02243b975761a64eb1476db133f461d5 to your computer and use it in GitHub Desktop.
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
From 0117f90620f451e1d58414b5ca3f3b5eadaba618 Mon Sep 17 00:00:00 2001 | |
From: Matthieu Volat <mazhe@alkumuna.eu> | |
Date: Tue, 23 May 2017 19:12:20 +0200 | |
Subject: [PATCH 1/6] Flush output of energy tests. | |
That'll ensure in order output. | |
--- | |
examples/smpi/energy/f77/sef.f | 2 ++ | |
examples/smpi/energy/f90/sef90.f90 | 2 ++ | |
2 files changed, 4 insertions(+) | |
diff --git a/examples/smpi/energy/f77/sef.f b/examples/smpi/energy/f77/sef.f | |
index b4aba21dd..4cbc5a364 100644 | |
--- a/examples/smpi/energy/f77/sef.f | |
+++ b/examples/smpi/energy/f77/sef.f | |
@@ -53,6 +53,8 @@ | |
& rank, ']',' Energy consumed (Joules): ', e | |
end do | |
+ flush(6) | |
+ | |
call MPI_Finalize(ierr) | |
if (ierr .ne. MPI_SUCCESS) then | |
print *, 'MPI_Finalize failed:', ierr | |
diff --git a/examples/smpi/energy/f90/sef90.f90 b/examples/smpi/energy/f90/sef90.f90 | |
index ebd5485a6..e4f04a3c1 100644 | |
--- a/examples/smpi/energy/f90/sef90.f90 | |
+++ b/examples/smpi/energy/f90/sef90.f90 | |
@@ -52,6 +52,8 @@ program main | |
rank, '] Energy consumed (Joules): ', e | |
end do | |
+ flush(6) | |
+ | |
call MPI_Finalize(ierr) | |
if (ierr .ne. MPI_SUCCESS) then | |
print *, 'MPI_Finalize failed:', ierr | |
-- | |
2.13.0 | |
From 835df4e1493cf6b21c886ed95e57d04ed4ed950d Mon Sep 17 00:00:00 2001 | |
From: Matthieu Volat <mazhe@alkumuna.eu> | |
Date: Tue, 23 May 2017 19:15:16 +0200 | |
Subject: [PATCH 2/6] Use FindThreads to check for pthreading | |
It will prefer using threading as library if possible, and fallback | |
on -pthread only if necessary, which some compilers/systems | |
do not support anymore. | |
--- | |
CMakeLists.txt | 6 ++++-- | |
tools/cmake/MakeLib.cmake | 5 ++--- | |
2 files changed, 6 insertions(+), 5 deletions(-) | |
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index 06d2f1c03..cde287ef9 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -60,6 +60,9 @@ if(APPLE AND (CMAKE_C_COMPILER_VERSION VERSION_LESS "4.6")) | |
set(HAVE_UCONTEXT_H 0) | |
endif() | |
+### Check threading support | |
+set(CMAKE_THREAD_PREFER_PTHREAD TRUE) | |
+find_package(Threads) | |
### Setup Options | |
include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Option.cmake) | |
@@ -274,7 +277,6 @@ endif() | |
# Checks for header libraries functions. | |
CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_POSIX_GETTIME) | |
-CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_PTHREAD) | |
if(NOT APPLE) # OS X El Capitan deprecates this function | |
CHECK_LIBRARY_EXISTS(pthread sem_init "" HAVE_SEM_INIT_LIB) | |
endif() | |
@@ -460,7 +462,7 @@ endif() | |
### Initialize of CONTEXT THREADS | |
set(HAVE_THREAD_CONTEXTS 0) | |
-if(HAVE_PTHREAD) | |
+if(CMAKE_USE_PTHREADS_INIT) | |
### Test that we have a way to create semaphores | |
if(HAVE_SEM_OPEN_LIB) | |
diff --git a/tools/cmake/MakeLib.cmake b/tools/cmake/MakeLib.cmake | |
index 1378bd485..d116926c7 100644 | |
--- a/tools/cmake/MakeLib.cmake | |
+++ b/tools/cmake/MakeLib.cmake | |
@@ -34,9 +34,8 @@ if (HAVE_BOOST_CONTEXTS) | |
set(SIMGRID_DEP "${SIMGRID_DEP} ${Boost_CONTEXT_LIBRARY}") | |
endif() | |
-if(HAVE_PTHREAD AND ${HAVE_THREAD_CONTEXTS} AND NOT APPLE) | |
- # Clang on recent Mac OS X is not happy about -pthread. | |
- SET(SIMGRID_DEP "${SIMGRID_DEP} -pthread") | |
+if(CMAKE_USE_PTHREADS_INIT AND ${HAVE_THREAD_CONTEXTS}) | |
+ set(SIMGRID_DEP "${SIMGRID_DEP} ${CMAKE_THREAD_LIBS_INIT}") | |
endif() | |
if(SIMGRID_HAVE_LUA) | |
-- | |
2.13.0 | |
From c8f686027faae2d9531a455205ad54f49f81e7d2 Mon Sep 17 00:00:00 2001 | |
From: Matthieu Volat <mazhe@alkumuna.eu> | |
Date: Tue, 23 May 2017 19:19:05 +0200 | |
Subject: [PATCH 3/6] Handle some litteral string -> char* casts. | |
It's 100% legit in C, but icc seems to process it like C++, and | |
since simgrid is being ported to C++, well... | |
--- | |
src/xbt/xbt_os_thread.c | 4 ++-- | |
1 file changed, 2 insertions(+), 2 deletions(-) | |
diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c | |
index 7bd87a6ac..613869ac8 100644 | |
--- a/src/xbt/xbt_os_thread.c | |
+++ b/src/xbt/xbt_os_thread.c | |
@@ -96,7 +96,7 @@ void xbt_os_thread_mod_preinit(void) | |
main_thread = xbt_new(s_xbt_os_thread_t, 1); | |
main_thread->name = NULL; | |
main_thread->detached = 0; | |
- main_thread->name = (char *) "main"; | |
+ main_thread->name = xbt_strdup("main"); | |
main_thread->param = NULL; | |
main_thread->start_routine = NULL; | |
main_thread->extra_data = NULL; | |
@@ -234,7 +234,7 @@ void xbt_os_thread_setguardsize(int guard_size) | |
const char *xbt_os_thread_self_name(void) | |
{ | |
xbt_os_thread_t me = xbt_os_thread_self(); | |
- return me ? me->name : "main"; | |
+ return me ? (const char *)me->name : "main"; | |
} | |
void xbt_os_thread_join(xbt_os_thread_t thread, void **thread_return) | |
-- | |
2.13.0 | |
From 652e0616eb78a22be42bbdc4b26747a5912f0e7d Mon Sep 17 00:00:00 2001 | |
From: Matthieu Volat <mazhe@alkumuna.eu> | |
Date: Tue, 23 May 2017 19:20:54 +0200 | |
Subject: [PATCH 4/6] Define worker_function more rigourously to | |
xbt_main_func_t. | |
--- | |
examples/msg/energy-vm/energy-vm.c | 4 +++- | |
1 file changed, 3 insertions(+), 1 deletion(-) | |
diff --git a/examples/msg/energy-vm/energy-vm.c b/examples/msg/energy-vm/energy-vm.c | |
index 8a2011dc9..9b5d84bfa 100644 | |
--- a/examples/msg/energy-vm/energy-vm.c | |
+++ b/examples/msg/energy-vm/energy-vm.c | |
@@ -9,7 +9,9 @@ | |
XBT_LOG_NEW_DEFAULT_CATEGORY(energy_vm, "Messages of this example"); | |
-static int worker_func() { | |
+static int worker_func(int argc, char *argv[]) { | |
+ (void)argc; | |
+ (void)argv; | |
msg_task_t task1 = MSG_task_create("t1", 300E6, 0, NULL); | |
MSG_task_execute (task1); | |
MSG_task_destroy(task1); | |
-- | |
2.13.0 | |
From e32fb8bc5ed84ab576d7f9aa571b7e8cd9525894 Mon Sep 17 00:00:00 2001 | |
From: Matthieu Volat <mazhe@alkumuna.eu> | |
Date: Tue, 23 May 2017 19:42:18 +0200 | |
Subject: [PATCH 5/6] Only use -Wno-format-nonliteral if compiler is GCC or | |
Clang. | |
--- | |
tools/cmake/GCCFlags.cmake | 10 ++++++++-- | |
1 file changed, 8 insertions(+), 2 deletions(-) | |
diff --git a/tools/cmake/GCCFlags.cmake b/tools/cmake/GCCFlags.cmake | |
index 6615daadb..01ece5c26 100644 | |
--- a/tools/cmake/GCCFlags.cmake | |
+++ b/tools/cmake/GCCFlags.cmake | |
@@ -14,12 +14,18 @@ set(optCFLAGS "") | |
set(warnCXXFLAGS "") | |
if(enable_compile_warnings) | |
- set(warnCFLAGS "-fno-common -Wall -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral") | |
+ set(warnCFLAGS "-fno-common -Wall -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing") | |
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang|GCC") | |
+ set(warnCFLAGS "${warnCFLAGS} -Wno-format-nonliteral") | |
+ endif() | |
if(CMAKE_COMPILER_IS_GNUCC) | |
set(warnCFLAGS "${warnCFLAGS} -Wclobbered -Wno-error=clobbered -Wno-unused-local-typedefs -Wno-error=attributes") | |
endif() | |
- set(warnCXXFLAGS "${warnCFLAGS} -Wall -Wextra -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral") | |
+ set(warnCXXFLAGS "${warnCFLAGS} -Wall -Wextra -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing") | |
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GCC") | |
+ set(warnCXXFLAGS "${warnCXXFLAGS} -Wno-format-nonliteral") | |
+ endif() | |
if(CMAKE_COMPILER_IS_GNUCXX) | |
set(warnCXXFLAGS "${warnCXXFLAGS} -Wclobbered -Wno-error=clobbered -Wno-unused-local-typedefs -Wno-error=attributes") | |
endif() | |
-- | |
2.13.0 | |
From 62f2cd0b4f9c2ac8084fafffd691a2cd4f1b59f4 Mon Sep 17 00:00:00 2001 | |
From: Matthieu Volat <mazhe@alkumuna.eu> | |
Date: Tue, 23 May 2017 20:10:18 +0200 | |
Subject: [PATCH 6/6] Add support for flang and ifort Fortran compilers. | |
Require to properly set flags/libs in the wrappers. | |
Tested with flang under FreeBSD and ifort under Linux. | |
--- | |
CMakeLists.txt | 17 +++++++++++++++-- | |
src/smpi/smpif90.in | 6 +++--- | |
src/smpi/smpiff.in | 6 +++--- | |
tools/cmake/GCCFlags.cmake | 7 ++++++- | |
4 files changed, 27 insertions(+), 9 deletions(-) | |
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index cde287ef9..8fede4c2b 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -80,8 +80,21 @@ if ((NOT DEFINED enable_smpi) OR enable_smpi) | |
if(CMAKE_Fortran_COMPILER) | |
# Fortran compiler detected: save it, then replace by smpiff | |
- set(SAVED_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "The real Fortran compiler") | |
+ set(SMPI_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "The real Fortran compiler") | |
set(CMAKE_Fortran_COMPILER smpiff) | |
+ | |
+ # Set flags/libs to be used in smpiff | |
+ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") | |
+ set(SMPI_Fortran_FLAGS "\"-fpic\" \"-ff2c\" \"-fno-second-underscore\"") | |
+ set(SMPI_Fortran_LIBS "\"-lgfortran\"") | |
+ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") | |
+ set(SMPI_Fortran_FLAGS "\"-fPIC\" \"-nofor-main\"") | |
+ set(SMPI_Fortran_LIBS "\"-lifcore\"") | |
+ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI") # flang | |
+ set(SMPI_Fortran_FLAGS "\"-fPIC\"") | |
+ set(SMPI_Fortran_LIBS "") | |
+ endif() | |
+ | |
set(SMPI_FORTRAN 1) | |
endif(CMAKE_Fortran_COMPILER) | |
@@ -943,7 +956,7 @@ else() | |
endif() | |
endif() | |
if(CMAKE_Fortran_COMPILER) | |
- message(" Compiler: Fortran ...........: ${SAVED_Fortran_COMPILER} (id: ${CMAKE_Fortran_COMPILER_ID})") | |
+ message(" Compiler: Fortran ...........: ${SMPI_Fortran_COMPILER} (id: ${CMAKE_Fortran_COMPILER_ID})") | |
message(" version .............: ${CMAKE_Fortran_COMPILER_VERSION}") | |
endif() | |
message(" Linker: .....................: ${CMAKE_LINKER}") | |
diff --git a/src/smpi/smpif90.in b/src/smpi/smpif90.in | |
index 459cac3a0..22869c30b 100644 | |
--- a/src/smpi/smpif90.in | |
+++ b/src/smpi/smpif90.in | |
@@ -9,15 +9,15 @@ | |
SIMGRID_VERSION="@SIMGRID_VERSION_STRING@" | |
SIMGRID_GITHASH="@SIMGRID_GITHASH@" | |
-F90=@SAVED_Fortran_COMPILER@ | |
+F90=@SMPI_Fortran_COMPILER@ | |
INCLUDEARGS="@includeflag@" | |
CMAKE_LINKARGS="-L@libdir@" | |
@SMPITOOLS_SH@ | |
-list_set FFLAGS "-fpic" "-ff2c" "-fno-second-underscore" | |
-list_set LINKARGS "-shared" "-lsimgrid" "-lm" "-lgfortran" | |
+list_set FFLAGS @SMPI_Fortran_FLAGS@ | |
+list_set LINKARGS "-shared" "-lsimgrid" @SMPI_Fortran_LIBS@ "-lm" | |
list_set TMPFILES | |
main_name=main | |
diff --git a/src/smpi/smpiff.in b/src/smpi/smpiff.in | |
index f78ffbda4..eb28bc8f4 100644 | |
--- a/src/smpi/smpiff.in | |
+++ b/src/smpi/smpiff.in | |
@@ -9,15 +9,15 @@ | |
SIMGRID_VERSION="@SIMGRID_VERSION_STRING@" | |
SIMGRID_GITHASH="@SIMGRID_GITHASH@" | |
-F77=@SAVED_Fortran_COMPILER@ | |
+F77=@SMPI_Fortran_COMPILER@ | |
INCLUDEARGS="@includeflag@" | |
CMAKE_LINKARGS="-L@libdir@" | |
@SMPITOOLS_SH@ | |
-list_set FFLAGS "-fpic" "-ff2c" "-fno-second-underscore" | |
-list_set LINKARGS "-shared" "-lsimgrid" "-lm" "-lgfortran" | |
+list_set FFLAGS @SMPI_Fortran_FLAGS@ | |
+list_set LINKARGS "-shared" "-lsimgrid" @SMPI_Fortran_LIBS@ "-lm" | |
list_set TMPFILES | |
main_name=main | |
diff --git a/tools/cmake/GCCFlags.cmake b/tools/cmake/GCCFlags.cmake | |
index 01ece5c26..82c286ec8 100644 | |
--- a/tools/cmake/GCCFlags.cmake | |
+++ b/tools/cmake/GCCFlags.cmake | |
@@ -38,7 +38,12 @@ if(enable_compile_warnings) | |
# the one specific to C but refused by C++ | |
set(warnCFLAGS "${warnCFLAGS} -Wmissing-prototypes") | |
- set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall") | |
+ if(CMAKE_Fotran_COMPILER_ID MATCHES "GCC|PGI") | |
+ set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall") | |
+ endif() | |
+ if(CMAKE_Fotran_COMPILER_ID MATCHES "Intel") | |
+ set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -warn all") | |
+ endif() | |
set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint") | |
endif() | |
-- | |
2.13.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment