Permalink
Browse files

Add MT switch for Visual Studio; do not let windows.h to defined min/…

…max macros from mpi.h; fix uninitialized values from MPI
  • Loading branch information...
kirill-terekhov committed Sep 7, 2017
1 parent 8cbbb1c commit feabb62de5475ed2c3ddffd269e46f3a8d1e6c27
Showing with 19 additions and 5 deletions.
  1. +11 −0 CMakeLists.txt
  2. +3 −0 Source/Headers/inmost_common.h
  3. +4 −5 Source/Mesh/parallel.cpp
  4. +1 −0 inmost-config.cmake.in
@@ -39,9 +39,20 @@ option(USE_SOLVER_SUPERLU "Use SuperLU solver" OFF)
#option(USE_AUTODIFF_ASMJIT "Use AsmJit for automatic differentiation" OFF)
#option(USE_AUTODIFF_EXPRESSION_TEMPLATES "Use c++ expression templates for automatic differentiation" OFF)
if( MSVC )
option(USE_MT "Use /MT switch instead of /MD switch for libraries generated with Visual Studio" OFF)
endif( MSVC )
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_find/")
if( USE_MT )
set(CompilerFlags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif( USE_MT )
if(TEST_FORTRAN_ANI3D)
include(CheckLanguage)
check_language(Fortran)
@@ -81,6 +81,7 @@
#include <omp.h>
#endif
#if defined(USE_MPI)
#define NOMINMAX
#include <mpi.h>
#if !defined(MSMPI_VER) && !defined(MPIO_INCLUDE) && defined(USE_MPI_FILE) && !defined(OMPI_PROVIDE_MPI_FILE_INTERFACE)
#include <mpio.h> //some versions of MPI doesn't include that
@@ -112,6 +113,7 @@
#define INMOST_MPI_Comm int
#define INMOST_MPI_Group int
#define INMOST_MPI_COMM_WORLD 0
#define INMOST_MPI_COMM_SELF 0
#define INMOST_MPI_BYTE 0
#define INMOST_MPI_INT 0
#define INMOST_MPI_DOUBLE 0
@@ -125,6 +127,7 @@
#define INMOST_MPI_Comm MPI_Comm
#define INMOST_MPI_Group MPI_Group
#define INMOST_MPI_COMM_WORLD MPI_COMM_WORLD
#define INMOST_MPI_COMM_SELF MPI_COMM_SELF
#define INMOST_MPI_BYTE MPI_BYTE
#define INMOST_MPI_INT MPI_INT
#define INMOST_MPI_DOUBLE MPI_DOUBLE
@@ -3706,15 +3706,14 @@ namespace INMOST
int mpirank = GetProcessorRank(),mpisize = GetProcessorsNumber(), rand_num = randomizer.Number()+1;
int mpi_tag;
int max_tag = 32767;
int flag;
int flag = 0;
int * p_max_tag;
#if defined(USE_MPI2)
MPI_Comm_get_attr(comm,MPI_TAG_UB,&p_max_tag,&flag);
#else //USE_MPI2
MPI_Attr_get(comm,MPI_TAG_UB,&p_max_tag,&flag);
#endif //USE_MPI2
max_tag = *p_max_tag;
assert( flag );
if( flag ) max_tag = *p_max_tag;
recv_reqs.resize(recv_bufs.size());
send_reqs.resize(send_bufs.size());
REPORT_VAL("strategy",parallel_strategy);
@@ -3825,14 +3824,14 @@ namespace INMOST
int mpirank = GetProcessorRank(),mpisize = GetProcessorsNumber(), rand_num = randomizer.Number()+1;
int mpi_tag;
int max_tag = 32767;
int flag;
int flag = 0;
int * p_max_tag;
#if defined(USE_MPI2)
MPI_Comm_get_attr(comm,MPI_TAG_UB,&p_max_tag,&flag);
#else //USE_MPI2
MPI_Attr_get(comm,MPI_TAG_UB,&p_max_tag,&flag);
#endif //USE_MPI2
max_tag = *p_max_tag;
if( flag ) max_tag = *p_max_tag;
std::vector<int> send_recv_size(send_bufs.size()+recv_bufs.size());
std::vector<INMOST_MPI_Request> reqs(send_bufs.size()+recv_bufs.size());
for(i = 0; i < send_bufs.size(); i++) send_recv_size[i+recv_bufs.size()] = static_cast<int>(send_bufs[i].second.size());
@@ -33,6 +33,7 @@ set(USE_SOLVER_METIS @USE_SOLVER_METIS@)
set(USE_SOLVER_TRILINOS @USE_SOLVER_TRILINOS@)
set(USE_SOLVER_PETSC @USE_SOLVER_PETSC@)
set(USE_SOLVER_SUPERLU @USE_SOLVER_SUPERLU@)
set(USE_MT @USE_MT@)
if( USE_OMP )
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} @OpenMP_C_FLAGS@")

0 comments on commit feabb62

Please sign in to comment.