Skip to content

Commit

Permalink
Add MT switch for Visual Studio; do not let windows.h to defined min/…
Browse files Browse the repository at this point in the history
…max macros from mpi.h; fix uninitialized values from MPI
  • Loading branch information
kirill-terekhov committed Sep 7, 2017
1 parent 8cbbb1c commit feabb62
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions Source/Headers/inmost_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 4 additions & 5 deletions Source/Mesh/parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions inmost-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@")
Expand Down

0 comments on commit feabb62

Please sign in to comment.