Skip to content

Commit

Permalink
Merge pull request SCOREC#74 from SCOREC/cws/simModSuiteLatest
Browse files Browse the repository at this point in the history
support latest version of simmodsuite and rhel8 systems
  • Loading branch information
cwsmith authored Nov 15, 2023
2 parents 90bf005 + 124d390 commit 050c804
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 48 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ if ((Omega_h_MEM_SPACE_DEVICE AND Omega_h_MEM_SPACE_HOSTPINNED) OR
endif()

bob_option(Omega_h_USE_MPI "Use MPI for parallelism" OFF)
if(Omega_h_USE_SimModSuite AND NOT Omega_h_USE_MPI)
message(FATAL_ERROR "Omega_h_USE_MPI must be enabled if Omega_h_USE_SimModSuite is enabled")
endif()
bob_option(Omega_h_USE_OpenMP "Whether to use OpenMP" "${Kokkos_HAS_OpenMP}")
bob_option(Omega_h_USE_CUDA "Whether to use CUDA" "${Kokkos_HAS_CUDA}")

Expand Down
72 changes: 51 additions & 21 deletions cmake/FindSimModSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,24 @@
# include/*.h
# lib/ARCHOS/*.a

set(SIM_MPI "" CACHE STRING "MPI implementation used for SimPartitionWrapper")
if(SIM_MPI MATCHES "^$")
message(FATAL_ERROR "SIM_MPI is not defined... libSimPartitionWrapper-$SIM_MPI.a should exist in the SimModSuite lib directory")
if (Omega_h_USE_MPI)
set(SIM_MPI "" CACHE STRING "MPI implementation used for SimPartitionWrapper")
if(SIM_MPI MATCHES "^$")
message(FATAL_ERROR "SIM_MPI is not defined... libSimPartitionWrapper-$SIM_MPI.a should exist in the SimModSuite lib directory")
endif()
endif()

macro(simLibCheckBootstrap libs)
simLibCheck(${libs} TRUE)
string(FIND "${SIMMODSUITE_LIBS}" "/lib/" archStart)
string(FIND "${SIMMODSUITE_LIBS}" "/libSim" archEnd)
math(EXPR archStart "${archStart}+5")
math(EXPR len "${archEnd}-${archStart}")
string(SUBSTRING "${SIMMODSUITE_LIBS}" "${archStart}" "${len}" SIM_ARCHOS)
message(STATUS "SIM_ARCHOS ${SIM_ARCHOS}")
set(SIMMODSUITE_LIBS "")
endmacro(simLibCheckBootstrap)

macro(simLibCheck libs isRequired)
foreach(lib ${libs})
unset(simlib CACHE)
Expand Down Expand Up @@ -84,7 +97,7 @@ string(REGEX REPLACE
"${SIM_VERSION}")

set(MIN_VALID_SIM_VERSION 16.0.210606)
set(MAX_VALID_SIM_VERSION 17.0.220403)
set(MAX_VALID_SIM_VERSION 2023.1-231028)
if( ${SKIP_SIMMETRIX_VERSION_CHECK} )
message(STATUS "Skipping Simmetrix SimModSuite version check."
" This may result in undefined behavior")
Expand All @@ -98,22 +111,19 @@ message(STATUS "Building with SimModSuite ${SIM_DOT_VERSION}")

set(SIMMODSUITE_LIBS "")

set(SIM_BOOTSTRAP_LIB_NAME
SimPartitionedMesh-mpi)
if (Omega_h_USE_MPI)
set(SIM_BOOTSTRAP_LIB_NAME SimPartitionedMesh-mpi)
else()
set(SIM_BOOTSTRAP_LIB_NAME SimPartitionedMesh)
endif()

simLibCheck("${SIM_BOOTSTRAP_LIB_NAME}" TRUE)
simLibCheckBootstrap("${SIM_BOOTSTRAP_LIB_NAME}")

string(FIND "${SIMMODSUITE_LIBS}" "/lib/" archStart)
string(FIND "${SIMMODSUITE_LIBS}" "/libSim" archEnd)
math(EXPR archStart "${archStart}+5")
math(EXPR len "${archEnd}-${archStart}")
string(SUBSTRING "${SIMMODSUITE_LIBS}" "${archStart}" "${len}" SIM_ARCHOS)
message(STATUS "SIM_ARCHOS ${SIM_ARCHOS}")

option(SIM_PARASOLID "Use Parasolid through Simmetrix" OFF)
if (SIM_PARASOLID)
set(MIN_SIM_PARASOLID_VERSION 290)
set(MAX_SIM_PARASOLID_VERSION 330)
set(MAX_SIM_PARASOLID_VERSION 360)
foreach(version RANGE
${MAX_SIM_PARASOLID_VERSION}
${MIN_SIM_PARASOLID_VERSION} -10)
Expand Down Expand Up @@ -157,12 +167,19 @@ set(SIM_OPT_LIB_NAMES

simLibCheck("${SIM_OPT_LIB_NAMES}" FALSE)

set(SIM_CORE_LIB_NAMES
SimPartitionedMesh-mpi
SimMeshing
SimMeshTools
SimModel
SimPartitionWrapper-${SIM_MPI})
if (Omega_h_USE_MPI)
set(SIM_CORE_LIB_NAMES
SimPartitionedMesh-mpi
SimMeshing
SimMeshTools
SimModel
SimPartitionWrapper-${SIM_MPI})
else()
set(SIM_CORE_LIB_NAMES
SimMeshing
SimMeshTools
SimModel)
endif()

simLibCheck("${SIM_CORE_LIB_NAMES}" TRUE)

Expand All @@ -171,10 +188,23 @@ if (UNIX AND NOT APPLE)
set(SIMMODSUITE_LIBS ${SIMMODSUITE_LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif()

if (SIM_ARCHOS STREQUAL x64_rhel8_gcc83)
find_library(XDR_LIB tirpc)
if(XDR_LIB)
message(STATUS "Found XDR_LIB ${XDR_LIB}")
set(SIMMODSUITE_LIBS ${SIMMODSUITE_LIBS} ${XDR_LIB})
else()
message(FATAL_ERROR "The libtirpc library was not found. It defines xdr symbols "
"(e.g., xdrmem_create) that are need by SimModSuite on systems using "
"glibc newer than 2.32. Note, glibc starting with 2.26 could optionally "
"have been built without the xdr symbols.")
endif()
endif()

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set SIMMODSUITE_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(SIMMODSUITE DEFAULT_MSG
find_package_handle_standard_args(SimModSuite DEFAULT_MSG
SIMMODSUITE_LIBS SIMMODSUITE_INCLUDE_DIR
SIMMODSUITE_MAJOR_VERSION SIMMODSUITE_MINOR_VERSION)

Expand Down
2 changes: 0 additions & 2 deletions src/Omega_h_meshsim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "Omega_h_mesh.hpp"
#include "Omega_h_adj.hpp"

#include "SimPartitionedMesh.h"
#include "SimModel.h"
#include "SimUtil.h"
#include "SimDiscrete.h"
Expand Down Expand Up @@ -639,7 +638,6 @@ void read_internal(pMesh m, Mesh* mesh, pMeshNex numbering) {

Mesh readImpl(filesystem::path const& mesh_fname, filesystem::path const& mdl_fname,
filesystem::path const& numbering_fname, CommPtr comm) {
SimPartitionedMesh_start(NULL,NULL);
SimModel_start();
Sim_readLicenseFile(NULL);
SimDiscrete_start(0);
Expand Down
52 changes: 30 additions & 22 deletions src/mixed_writeMesh.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
#include "MeshSim.h"
#include "SimDiscrete.h"
#include "SimMessages.h"
#include "SimError.h"
#include "SimErrorCodes.h"
#include "SimMeshingErrorCodes.h"
#include "SimDiscreteErrorCodes.h"
#include <iostream>
using namespace std;

#include "Omega_h_comm.hpp"
#include "Omega_h_mesh.hpp"
#include "Omega_h_file.hpp"
#include "Omega_h_simConfig.h"
using namespace Omega_h;

#if SIMMODSUITE_MAJOR_VERSION >= 18 && SIMMODSUITE_MINOR_VERSION >= 220930
#include "SimInfo.h"
#include "SimInfoCodes.h"
#define SIM_ERROR(suffix,err) SimInfo_##suffix(err)
typedef pSimInfo pSimError;
#else
#include "SimError.h"
#include "SimErrorCodes.h"
#define SIM_ERROR(suffix,err) SimError_##suffix(err)
#endif

void messageHandler(int type, const char *msg)
{
switch (type) {
Expand Down Expand Up @@ -104,9 +112,9 @@ void hex_gen(CommPtr comm, std::string const mesh_dir) {
vReturn, eReturn, mesh_path.c_str(), model_path.c_str());
} catch (pSimError err) {
cerr<<"SimModSuite error caught:"<<endl;
cerr<<" Error code: "<<SimError_code(err)<<endl;
cerr<<" Error string: "<<SimError_toString(err)<<endl;
SimError_delete(err);
cerr<<" Error code: "<<SIM_ERROR(code,err)<<endl;
cerr<<" Error string: "<<SIM_ERROR(toString,err)<<endl;
SIM_ERROR(delete,err);
} catch (...) {
cerr<<"Unhandled exception caught"<<endl;
}
Expand Down Expand Up @@ -134,9 +142,9 @@ void wedge_gen(CommPtr comm, std::string const mesh_dir) {
vReturn, eReturn, mesh_path.c_str(), model_path.c_str());
} catch (pSimError err) {
cerr<<"SimModSuite error caught:"<<endl;
cerr<<" Error code: "<<SimError_code(err)<<endl;
cerr<<" Error string: "<<SimError_toString(err)<<endl;
SimError_delete(err);
cerr<<" Error code: "<<SIM_ERROR(code,err)<<endl;
cerr<<" Error string: "<<SIM_ERROR(toString,err)<<endl;
SIM_ERROR(delete,err);
} catch (...) {
cerr<<"Unhandled exception caught"<<endl;
}
Expand Down Expand Up @@ -164,9 +172,9 @@ void pyramid_gen(CommPtr comm, std::string const mesh_dir) {
vReturn, eReturn, mesh_path.c_str(), model_path.c_str());
} catch (pSimError err) {
cerr<<"SimModSuite error caught:"<<endl;
cerr<<" Error code: "<<SimError_code(err)<<endl;
cerr<<" Error string: "<<SimError_toString(err)<<endl;
SimError_delete(err);
cerr<<" Error code: "<<SIM_ERROR(code,err)<<endl;
cerr<<" Error string: "<<SIM_ERROR(toString,err)<<endl;
SIM_ERROR(delete,err);
} catch (...) {
cerr<<"Unhandled exception caught"<<endl;
}
Expand Down Expand Up @@ -195,9 +203,9 @@ void tetOnWedge_gen(CommPtr comm, std::string const mesh_dir) {
vReturn, eReturn, mesh_path.c_str(), model_path.c_str());
} catch (pSimError err) {
cerr<<"SimModSuite error caught:"<<endl;
cerr<<" Error code: "<<SimError_code(err)<<endl;
cerr<<" Error string: "<<SimError_toString(err)<<endl;
SimError_delete(err);
cerr<<" Error code: "<<SIM_ERROR(code,err)<<endl;
cerr<<" Error string: "<<SIM_ERROR(toString,err)<<endl;
SIM_ERROR(delete,err);
} catch (...) {
cerr<<"Unhandled exception caught"<<endl;
}
Expand Down Expand Up @@ -229,9 +237,9 @@ void pymOnHex_gen(CommPtr comm, std::string const mesh_dir) {
vReturn, eReturn, mesh_path.c_str(), model_path.c_str());
} catch (pSimError err) {
cerr<<"SimModSuite error caught:"<<endl;
cerr<<" Error code: "<<SimError_code(err)<<endl;
cerr<<" Error string: "<<SimError_toString(err)<<endl;
SimError_delete(err);
cerr<<" Error code: "<<SIM_ERROR(code,err)<<endl;
cerr<<" Error string: "<<SIM_ERROR(toString,err)<<endl;
SIM_ERROR(delete,err);
} catch (...) {
cerr<<"Unhandled exception caught"<<endl;
}
Expand Down Expand Up @@ -266,9 +274,9 @@ void allType_gen(CommPtr comm, std::string const mesh_dir) {
vReturn, eReturn, mesh_path.c_str(), model_path.c_str());
} catch (pSimError err) {
cerr<<"SimModSuite error caught:"<<endl;
cerr<<" Error code: "<<SimError_code(err)<<endl;
cerr<<" Error string: "<<SimError_toString(err)<<endl;
SimError_delete(err);
cerr<<" Error code: "<<SIM_ERROR(code,err)<<endl;
cerr<<" Error string: "<<SIM_ERROR(toString,err)<<endl;
SIM_ERROR(delete,err);
} catch (...) {
cerr<<"Unhandled exception caught"<<endl;
}
Expand Down

0 comments on commit 050c804

Please sign in to comment.