From fafde3f2476eda544edc624f74fabadfe965ef31 Mon Sep 17 00:00:00 2001 From: Jeremiah Wilke Date: Wed, 7 Mar 2018 01:07:11 -0800 Subject: [PATCH] #183: build: add local package find macro --- CMakeLists.txt | 88 ++++++++++++++++++++--- cmake-modules/SetCXXCompilerFlags.cmake | 28 ++++++++ cmake_config.h.in | 3 + examples/hello_world.cc | 1 + examples/jacobi1d_node.cc | 2 + examples/jacobi1d_recur_vc.cc | 2 + share/parameters.ini | 14 ++++ src/collective/collective_ops.cc | 4 ++ src/configs/debug/debug_masterconfig.h | 4 +- src/group/region/group_region.h | 1 + src/registry/auto/auto_registry_general.h | 1 + src/sequence/seq_matcher.impl.h | 12 ++++ src/sequence/seq_matcher_virtual.impl.h | 12 ++++ src/sequence/sequencer_virtual.impl.h | 1 + src/vrt/collection/manager.impl.h | 4 ++ 15 files changed, 168 insertions(+), 9 deletions(-) create mode 100644 cmake-modules/SetCXXCompilerFlags.cmake create mode 100644 cmake_config.h.in create mode 100644 share/parameters.ini diff --git a/CMakeLists.txt b/CMakeLists.txt index 419c3d9db1..e42fd0995a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,24 +8,92 @@ find_package(MPI REQUIRED) include_directories(${MPI_C_INCLUDE_PATH}) -set(CMAKE_CXX_STANDARD 14) +set(VIRTUAL_TRANSPORT_LIBRARY vt) +set(FCONTEXT_LIBRARY fcontext) + +include(cmake-modules/SetCXXCompilerFlags.cmake) +set_darma_compiler_flags() + +macro(require_pkg_directory pkg_name pkg_user_name) + #message(STATUS "require_directory: name=${pkg_name}") + option(${pkg_name}_DIR "Root folder for ${pkg_user_name} installation" OFF) + if (NOT ${pkg_name}_DIR) + message(FATAL_ERROR "Please specify ${pkg_user_name} library installation root with -D${pkg_name}_DIR=") + endif() +endmacro(require_pkg_directory) + +macro(find_package_local pkg_name pkg_directory) + message(STATUS "find_package_local: pkg name=\"${pkg_name}\", directory=\"${pkg_directory}\"") + # search locally only for package + find_package( + ${pkg_name} + PATHS ${pkg_directory} + REQUIRED + NO_CMAKE_PACKAGE_REGISTRY + NO_CMAKE_BUILDS_PATH + NO_CMAKE_SYSTEM_PATH + NO_CMAKE_SYSTEM_PACKAGE_REGISTRY + ) +endmacro(find_package_local) + +# require directories for these packages +require_pkg_directory(darma_meld "DARMA meld") +require_pkg_directory(darma_detector "DARMA detector") +# find these required packages +find_package_local(darma_meld "${darma_meld_DIR}/cmake") +find_package_local(darma_detector "${darma_detector_DIR}/cmake") + +# find_package(darma_meld PATHS ${darma_meld_DIR}/cmake) +# find_package(darma_detector PATHS ${darma_detector_DIR}/cmake) -# OpenMP support set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules) + include(${CMAKE_MODULE_PATH}/FindOpenMP.cmake) -if (OpenMP_FOUND) +find_package(ZLIB REQUIRED) + +if (ZLIB_FOUND) + include_directories(${ZLIB_INCLUDE_DIRS}) +else() + message("zlib is required for tracing") +endif (ZLIB_FOUND) + +function(config_for_std_thread) + set(DEFAULT_THREADING stdthread) +endfunction(config_for_std_thread) + +function(config_for_openmp) + set(DEFAULT_THREADING openmp) message("OpenMP has been found: ") message("\t Linker flags: ${OpenMP_EXE_LINKER_FLAGS}") message("\t C_FLAGS=${OpenMP_C_FLAGS}") message("\t CXX_FLAGS=${OpenMP_CXX_FLAGS}") - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") -else() - message("OpenMP not found: must use std::thread for workers.") -endif (OpenMP_FOUND) +endfunction(config_for_openmp) + +option(USE_STD_THREAD + "whether to force use of std::thread for threading" + OFF) + +option(USE_OPENMP + "whether to force use of OpenMP for threading" + OFF) + +if (USE_STD_THREAD) + message("Using std::thread for worker threading") + config_for_std_thread() +elseif(USE_OPENMP) + config_for_openmp() + if (NOT OpenMP_Found) + message(FATAL_ERROR "requested OpenMP with -DUSE_OPENMP=On, but cannot find valid OpenMP in compiler") + endif() +elseif(OpenMP_FOUND) #no default specified + config_for_openmp() +else() #no default specified + message("OpenMP not found: using std::thread for workers") + config_for_std_thread() +endif() set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(PROJECT_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib) @@ -454,3 +522,7 @@ install( COMPONENT dev ) +configure_file(cmake_config.h.in cmake_config.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + + diff --git a/cmake-modules/SetCXXCompilerFlags.cmake b/cmake-modules/SetCXXCompilerFlags.cmake new file mode 100644 index 0000000000..9c358a1df1 --- /dev/null +++ b/cmake-modules/SetCXXCompilerFlags.cmake @@ -0,0 +1,28 @@ +# Compiler-specific C++14 activation. +# Call this from all CMakeLists.txt files that can be built independently. + +macro(set_darma_compiler_flags) + +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + # 4.9.3 complains about std::min not being constexpr + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") + execute_process( + COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) + if (NOT (GCC_VERSION VERSION_GREATER 5 OR GCC_VERSION VERSION_EQUAL 5)) + message("${PROJECT_NAME} currently requires g++ 5 or greater. If you need it to work with 4.9, please complain.") + endif () +elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -ftemplate-depth=900") + if (APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + endif () +elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel") + # 16.0.3 complains about std::min not being constexpr + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") +else () + message(FATAL_ERROR "Your C++ compiler may not support C++14.") +endif () + +endmacro() + + diff --git a/cmake_config.h.in b/cmake_config.h.in new file mode 100644 index 0000000000..9429d87b21 --- /dev/null +++ b/cmake_config.h.in @@ -0,0 +1,3 @@ + +#define default_threading @DEFAULT_THREADING@ + diff --git a/examples/hello_world.cc b/examples/hello_world.cc index da75d3c4c0..b4a4ca4317 100644 --- a/examples/hello_world.cc +++ b/examples/hello_world.cc @@ -16,6 +16,7 @@ static void hello_world(HelloMsg* msg) { printf("%d: Hello from node %d\n", theContext()->getNode(), msg->from); } +#define sstmac_app_name hello_world_vt int main(int argc, char** argv) { CollectiveOps::initialize(argc, argv); diff --git a/examples/jacobi1d_node.cc b/examples/jacobi1d_node.cc index 3446c6c8bb..925eac3c2c 100644 --- a/examples/jacobi1d_node.cc +++ b/examples/jacobi1d_node.cc @@ -236,6 +236,8 @@ static int exitEarly(NodeType node, int exit_code, char* reason) { return exit_code; } +#define sstmac_app_name jacobi1d_node_vt + int main(int argc, char** argv) { CollectiveOps::initialize(argc, argv); diff --git a/examples/jacobi1d_recur_vc.cc b/examples/jacobi1d_recur_vc.cc index 108d18205e..9da25152b4 100644 --- a/examples/jacobi1d_recur_vc.cc +++ b/examples/jacobi1d_recur_vc.cc @@ -79,6 +79,8 @@ static void create_jacobi1d(CreateJacobi1DMsg* msg, Jacobi1D* j1d) { } } +#define sstmac_app_name jacobi1d_recur_vc_vt + int main(int argc, char** argv) { CollectiveOps::initialize(argc, argv); diff --git a/share/parameters.ini b/share/parameters.ini new file mode 100644 index 0000000000..a6382558ce --- /dev/null +++ b/share/parameters.ini @@ -0,0 +1,14 @@ +include debug.ini + +node { + app1 { + launch_cmd = aprun -n 8 -N 1 + #name = hello_world_vt + #name = jacobi1d_recur_vc_vt + name = jacobi1d_node_vt + iprobe_delay = 5us + poll_delay = 1us + argv = 128 2 + } +} + diff --git a/src/collective/collective_ops.cc b/src/collective/collective_ops.cc index 4f5e65e550..e240aa29bc 100644 --- a/src/collective/collective_ops.cc +++ b/src/collective/collective_ops.cc @@ -21,16 +21,19 @@ RuntimePtrType CollectiveAnyOps::initialize( using vt::runtime::Runtime; using vt::runtime::eRuntimeInstance; +#pragma sst global rt RuntimeInst::rt = std::make_unique( argc, argv, num_workers, is_interop, comm ); +#pragma sst global rt auto rt_ptr = RuntimeInst::rt.get(); if (instance == RuntimeInstType::DefaultInstance) { // Set global variable for default instance for backward compatibility ::vt::rt = rt_ptr; curRT = rt_ptr; } +#pragma sst global rt RuntimeInst::rt->initialize(); return runtime::makeRuntimePtr(rt_ptr); @@ -71,6 +74,7 @@ void CollectiveAnyOps::finalize(RuntimePtrType in_rt) { using vt::runtime::Runtime; using vt::runtime::eRuntimeInstance; +#pragma sst global rt RuntimeInst::rt = nullptr; if (instance == RuntimeInstType::DefaultInstance) { diff --git a/src/configs/debug/debug_masterconfig.h b/src/configs/debug/debug_masterconfig.h index a0d0cff5d3..af345703bb 100644 --- a/src/configs/debug/debug_masterconfig.h +++ b/src/configs/debug/debug_masterconfig.h @@ -2,6 +2,8 @@ #if !defined INCLUDED_DEBUG_MASTER_CONFIG #define INCLUDED_DEBUG_MASTER_CONFIG +#include + /* * Define the compile-time configuration options. Eventually this will be * partially defined with cmake options @@ -21,7 +23,7 @@ #endif #define backend_features backend_options_on( \ - detector, openmp \ + detector, default_threading \ ) #define backend_debug_contexts backend_options_on( \ diff --git a/src/group/region/group_region.h b/src/group/region/group_region.h index a669914e22..b5918cadd7 100644 --- a/src/group/region/group_region.h +++ b/src/group/region/group_region.h @@ -22,6 +22,7 @@ struct Region { using ListType = std::vector; using ApplyFnType = std::function; + virtual ~Region(){} virtual SizeType getSize() const = 0; virtual void sort() = 0; virtual bool contains(NodeType const& node) = 0; diff --git a/src/registry/auto/auto_registry_general.h b/src/registry/auto/auto_registry_general.h index 7783391bc2..0dc76e253a 100644 --- a/src/registry/auto/auto_registry_general.h +++ b/src/registry/auto/auto_registry_general.h @@ -23,6 +23,7 @@ RegistryT& getAutoRegistryGen(); template inline RegistryT& getAutoRegistryGen() { +#pragma sst keep static RegistryT reg; return reg; } diff --git a/src/sequence/seq_matcher.impl.h b/src/sequence/seq_matcher.impl.h index a6659a2b7a..277dff6b3b 100644 --- a/src/sequence/seq_matcher.impl.h +++ b/src/sequence/seq_matcher.impl.h @@ -73,9 +73,11 @@ template template * f> /*static*/ bool SeqMatcher::hasMatchingMsg(TagType const& tag) { if (tag == no_tag) { +#pragma sst global seq_msg auto& lst = SeqStateType::seq_msg; return hasMatchingAnyNoTag(lst); } else { +#pragma sst global seq_msg_tagged auto& tagged_lst = SeqStateType::seq_msg_tagged; return hasMatchingAnyTagged(tagged_lst, tag); } @@ -84,9 +86,11 @@ template * f> template * f> /*static*/ MessageT* SeqMatcher::getMatchingMsg(TagType const& tag) { if (tag == no_tag) { +#pragma sst global seq_msg auto& lst = SeqStateType::seq_msg; return getMatchingAnyNoTag(lst); } else { +#pragma sst global seq_msg_tagged auto& tagged_lst = SeqStateType::seq_msg_tagged; return getMatchingAnyTagged(tagged_lst, tag); } @@ -95,9 +99,11 @@ template * f> template * f> /*static*/ bool SeqMatcher::hasMatchingAction(TagType const& tag) { if (tag == no_tag) { + #pragma sst global seq_action auto& lst = SeqStateType::seq_action; return hasMatchingAnyNoTag(lst); } else { +#pragma sst global seq_action_tagged auto& tagged_lst = SeqStateType::seq_action_tagged; return hasMatchingAnyTagged(tagged_lst, tag); } @@ -109,9 +115,11 @@ SeqMatcher::getMatchingAction(TagType const& tag) { assert(hasMatchingAction(tag) and "Must have matching action"); if (tag == no_tag) { +#pragma sst global seq_action auto& lst = SeqStateType::seq_action; return getMatchingAnyNoTag(lst); } else { +#pragma sst global seq_action_tagged auto& tagged_lst = SeqStateType::seq_action_tagged; return getMatchingAnyTagged(tagged_lst, tag); } @@ -122,8 +130,10 @@ template * f> MessageT* msg, TagType const& tag ) { if (tag == no_tag) { +#pragma sst global seq_msg SeqStateType::seq_msg.push_back(msg); } else { +#pragma sst global seq_msg_tagged SeqStateType::seq_msg_tagged[tag].push_back(msg); } } @@ -139,9 +149,11 @@ template ); if (tag == no_tag) { +#pragma sst global seq_action auto& lst = SeqStateType::seq_action; lst.emplace_back(SeqActionType{seq_id,action}); } else { +#pragma sst global seq_action_tagged auto& tagged_lst = SeqStateType::seq_action_tagged; tagged_lst[tag].emplace_back(SeqActionType{seq_id,action}); } diff --git a/src/sequence/seq_matcher_virtual.impl.h b/src/sequence/seq_matcher_virtual.impl.h index 70c7edea39..1b8d84c338 100644 --- a/src/sequence/seq_matcher_virtual.impl.h +++ b/src/sequence/seq_matcher_virtual.impl.h @@ -75,9 +75,11 @@ template template *f> /*static*/ bool SeqMatcherVirtual::hasMatchingMsg(TagType const& tag) { if (tag == no_tag) { +#pragma sst global seq_msg auto& lst = SeqStateVirtualType::seq_msg; return hasMatchingAnyNoTag(lst); } else { +#pragma sst global seq_msg_tagged auto& tagged_lst = SeqStateVirtualType::seq_msg_tagged; return hasMatchingAnyTagged(tagged_lst, tag); } @@ -86,9 +88,11 @@ template *f> template *f> /*static*/ MsgT* SeqMatcherVirtual::getMatchingMsg(TagType const& tag) { if (tag == no_tag) { +#pragma sst global seq_msg auto& lst = SeqStateVirtualType::seq_msg; return getMatchingAnyNoTag(lst); } else { +#pragma sst global seq_msg_tagged auto& tagged_lst = SeqStateVirtualType::seq_msg_tagged; return getMatchingAnyTagged(tagged_lst, tag); } @@ -97,9 +101,11 @@ template *f> template *f> /*static*/ bool SeqMatcherVirtual::hasMatchingAction(TagType const& tag) { if (tag == no_tag) { +#pragma sst global seq_action auto& lst = SeqStateVirtualType::seq_action; return hasMatchingAnyNoTag(lst); } else { +#pragma sst global seq_action_tagged auto& tagged_lst = SeqStateVirtualType::seq_action_tagged; return hasMatchingAnyTagged(tagged_lst, tag); } @@ -111,9 +117,11 @@ SeqMatcherVirtual::getMatchingAction(TagType const& tag) { assert(hasMatchingAction(tag) and "Must have matching action"); if (tag == no_tag) { +#pragma sst global seq_action auto& lst = SeqStateVirtualType::seq_action; return getMatchingAnyNoTag(lst); } else { +#pragma sst global seq_action_tagged auto& tagged_lst = SeqStateVirtualType::seq_action_tagged; return getMatchingAnyTagged(tagged_lst, tag); } @@ -124,8 +132,10 @@ template *f> MsgT* msg, TagType const& tag ) { if (tag == no_tag) { +#pragma sst global seq_msg SeqStateVirtualType::seq_msg.push_back(msg); } else { +#pragma sst global seq_msg_tagged SeqStateVirtualType::seq_msg_tagged[tag].push_back(msg); } } @@ -141,9 +151,11 @@ template ); if (tag == no_tag) { +#pragma sst global seq_action auto& lst = SeqStateVirtualType::seq_action; lst.emplace_back(SeqActionType{seq_id,action}); } else { +#pragma sst global seq_action_tagged auto& tagged_lst = SeqStateVirtualType::seq_action_tagged; tagged_lst[tag].emplace_back(SeqActionType{seq_id,action}); } diff --git a/src/sequence/sequencer_virtual.impl.h b/src/sequence/sequencer_virtual.impl.h index e7a0f77411..fe4607dd9f 100644 --- a/src/sequence/sequencer_virtual.impl.h +++ b/src/sequence/sequencer_virtual.impl.h @@ -15,6 +15,7 @@ namespace vt { namespace seq { template class SeqTrigger> /*virtual*/ typename TaggedSequencerVrt::SeqType TaggedSequencerVrt::getNextID() { +#pragma sst global seq_manager return this->seq_manager->nextSeqID(true); } diff --git a/src/vrt/collection/manager.impl.h b/src/vrt/collection/manager.impl.h index e63e99a11c..200c93d82d 100644 --- a/src/vrt/collection/manager.impl.h +++ b/src/vrt/collection/manager.impl.h @@ -203,6 +203,8 @@ void CollectionManager::sendMsg( theTerm()->produce(term::any_epoch_sentinel); + + #pragma sst global proxy_container_ auto& holder_container = EntireHolder::proxy_container_; auto holder = holder_container.find(col_proxy); if (holder != holder_container.end()) { @@ -271,6 +273,7 @@ bool CollectionManager::insertCollectionElement( HandlerType const& map_han, VirtualProxyType const& proxy, bool const& is_migrated_in, NodeType const& migrated_from ) { + #pragma sst global proxy_container_ auto& holder_container = EntireHolder::proxy_container_; auto holder_iter = holder_container.find(proxy); auto const& found_holder = holder_iter != holder_container.end(); @@ -615,6 +618,7 @@ template CollectionHolder* CollectionManager::findColHolder( VirtualProxyType const& proxy ) { + #pragma sst global proxy_container_ auto& holder_container = EntireHolder::proxy_container_; auto holder_iter = holder_container.find(proxy); auto const& found_holder = holder_iter != holder_container.end();