Skip to content

Commit

Permalink
#183: build: add local package find macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremiah Wilke authored and lifflander committed Apr 19, 2018
1 parent 037b893 commit fafde3f
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 9 deletions.
88 changes: 80 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -454,3 +522,7 @@ install(
COMPONENT dev
)

configure_file(cmake_config.h.in cmake_config.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})


28 changes: 28 additions & 0 deletions cmake-modules/SetCXXCompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -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()


3 changes: 3 additions & 0 deletions cmake_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

#define default_threading @DEFAULT_THREADING@

1 change: 1 addition & 0 deletions examples/hello_world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions examples/jacobi1d_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions examples/jacobi1d_recur_vc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 14 additions & 0 deletions share/parameters.ini
Original file line number Diff line number Diff line change
@@ -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
}
}

4 changes: 4 additions & 0 deletions src/collective/collective_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ RuntimePtrType CollectiveAnyOps<instance>::initialize(
using vt::runtime::Runtime;
using vt::runtime::eRuntimeInstance;

#pragma sst global rt
RuntimeInst<instance>::rt = std::make_unique<Runtime>(
argc, argv, num_workers, is_interop, comm
);

#pragma sst global rt
auto rt_ptr = RuntimeInst<instance>::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<instance>::rt->initialize();

return runtime::makeRuntimePtr(rt_ptr);
Expand Down Expand Up @@ -71,6 +74,7 @@ void CollectiveAnyOps<instance>::finalize(RuntimePtrType in_rt) {
using vt::runtime::Runtime;
using vt::runtime::eRuntimeInstance;

#pragma sst global rt
RuntimeInst<instance>::rt = nullptr;

if (instance == RuntimeInstType::DefaultInstance) {
Expand Down
4 changes: 3 additions & 1 deletion src/configs/debug/debug_masterconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#if !defined INCLUDED_DEBUG_MASTER_CONFIG
#define INCLUDED_DEBUG_MASTER_CONFIG

#include <cmake_config.h>

/*
* Define the compile-time configuration options. Eventually this will be
* partially defined with cmake options
Expand All @@ -21,7 +23,7 @@
#endif

#define backend_features backend_options_on( \
detector, openmp \
detector, default_threading \
)

#define backend_debug_contexts backend_options_on( \
Expand Down
1 change: 1 addition & 0 deletions src/group/region/group_region.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct Region {
using ListType = std::vector<BoundType>;
using ApplyFnType = std::function<void(RegionUPtrType)>;

virtual ~Region(){}
virtual SizeType getSize() const = 0;
virtual void sort() = 0;
virtual bool contains(NodeType const& node) = 0;
Expand Down
1 change: 1 addition & 0 deletions src/registry/auto/auto_registry_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RegistryT& getAutoRegistryGen();

template <typename RegistryT, typename>
inline RegistryT& getAutoRegistryGen() {
#pragma sst keep
static RegistryT reg;
return reg;
}
Expand Down
12 changes: 12 additions & 0 deletions src/sequence/seq_matcher.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ template <typename T>
template <typename MessageT, ActiveTypedFnType<MessageT>* f>
/*static*/ bool SeqMatcher<MessageT, f>::hasMatchingMsg(TagType const& tag) {
if (tag == no_tag) {
#pragma sst global seq_msg
auto& lst = SeqStateType<MessageT,f>::seq_msg;
return hasMatchingAnyNoTag(lst);
} else {
#pragma sst global seq_msg_tagged
auto& tagged_lst = SeqStateType<MessageT, f>::seq_msg_tagged;
return hasMatchingAnyTagged(tagged_lst, tag);
}
Expand All @@ -84,9 +86,11 @@ template <typename MessageT, ActiveTypedFnType<MessageT>* f>
template <typename MessageT, ActiveTypedFnType<MessageT>* f>
/*static*/ MessageT* SeqMatcher<MessageT, f>::getMatchingMsg(TagType const& tag) {
if (tag == no_tag) {
#pragma sst global seq_msg
auto& lst = SeqStateType<MessageT, f>::seq_msg;
return getMatchingAnyNoTag(lst);
} else {
#pragma sst global seq_msg_tagged
auto& tagged_lst = SeqStateType<MessageT, f>::seq_msg_tagged;
return getMatchingAnyTagged(tagged_lst, tag);
}
Expand All @@ -95,9 +99,11 @@ template <typename MessageT, ActiveTypedFnType<MessageT>* f>
template <typename MessageT, ActiveTypedFnType<MessageT>* f>
/*static*/ bool SeqMatcher<MessageT, f>::hasMatchingAction(TagType const& tag) {
if (tag == no_tag) {
#pragma sst global seq_action
auto& lst = SeqStateType<MessageT, f>::seq_action;
return hasMatchingAnyNoTag(lst);
} else {
#pragma sst global seq_action_tagged
auto& tagged_lst = SeqStateType<MessageT, f>::seq_action_tagged;
return hasMatchingAnyTagged(tagged_lst, tag);
}
Expand All @@ -109,9 +115,11 @@ SeqMatcher<MessageT, f>::getMatchingAction(TagType const& tag) {
assert(hasMatchingAction(tag) and "Must have matching action");

if (tag == no_tag) {
#pragma sst global seq_action
auto& lst = SeqStateType<MessageT, f>::seq_action;
return getMatchingAnyNoTag(lst);
} else {
#pragma sst global seq_action_tagged
auto& tagged_lst = SeqStateType<MessageT, f>::seq_action_tagged;
return getMatchingAnyTagged(tagged_lst, tag);
}
Expand All @@ -122,8 +130,10 @@ template <typename MessageT, ActiveTypedFnType<MessageT>* f>
MessageT* msg, TagType const& tag
) {
if (tag == no_tag) {
#pragma sst global seq_msg
SeqStateType<MessageT, f>::seq_msg.push_back(msg);
} else {
#pragma sst global seq_msg_tagged
SeqStateType<MessageT, f>::seq_msg_tagged[tag].push_back(msg);
}
}
Expand All @@ -139,9 +149,11 @@ template <typename FnT>
);

if (tag == no_tag) {
#pragma sst global seq_action
auto& lst = SeqStateType<MessageT,f>::seq_action;
lst.emplace_back(SeqActionType{seq_id,action});
} else {
#pragma sst global seq_action_tagged
auto& tagged_lst = SeqStateType<MessageT,f>::seq_action_tagged;
tagged_lst[tag].emplace_back(SeqActionType{seq_id,action});
}
Expand Down
12 changes: 12 additions & 0 deletions src/sequence/seq_matcher_virtual.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ template <typename T>
template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
/*static*/ bool SeqMatcherVirtual<VcT, MsgT, f>::hasMatchingMsg(TagType const& tag) {
if (tag == no_tag) {
#pragma sst global seq_msg
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_msg;
return hasMatchingAnyNoTag(lst);
} else {
#pragma sst global seq_msg_tagged
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_msg_tagged;
return hasMatchingAnyTagged(tagged_lst, tag);
}
Expand All @@ -86,9 +88,11 @@ template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
/*static*/ MsgT* SeqMatcherVirtual<VcT, MsgT, f>::getMatchingMsg(TagType const& tag) {
if (tag == no_tag) {
#pragma sst global seq_msg
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_msg;
return getMatchingAnyNoTag(lst);
} else {
#pragma sst global seq_msg_tagged
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_msg_tagged;
return getMatchingAnyTagged(tagged_lst, tag);
}
Expand All @@ -97,9 +101,11 @@ template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
/*static*/ bool SeqMatcherVirtual<VcT, MsgT, f>::hasMatchingAction(TagType const& tag) {
if (tag == no_tag) {
#pragma sst global seq_action
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action;
return hasMatchingAnyNoTag(lst);
} else {
#pragma sst global seq_action_tagged
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action_tagged;
return hasMatchingAnyTagged(tagged_lst, tag);
}
Expand All @@ -111,9 +117,11 @@ SeqMatcherVirtual<VcT, MsgT, f>::getMatchingAction(TagType const& tag) {
assert(hasMatchingAction(tag) and "Must have matching action");

if (tag == no_tag) {
#pragma sst global seq_action
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action;
return getMatchingAnyNoTag(lst);
} else {
#pragma sst global seq_action_tagged
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action_tagged;
return getMatchingAnyTagged(tagged_lst, tag);
}
Expand All @@ -124,8 +132,10 @@ template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
MsgT* msg, TagType const& tag
) {
if (tag == no_tag) {
#pragma sst global seq_msg
SeqStateVirtualType<VcT, MsgT, f>::seq_msg.push_back(msg);
} else {
#pragma sst global seq_msg_tagged
SeqStateVirtualType<VcT, MsgT, f>::seq_msg_tagged[tag].push_back(msg);
}
}
Expand All @@ -141,9 +151,11 @@ template <typename FnT>
);

if (tag == no_tag) {
#pragma sst global seq_action
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action;
lst.emplace_back(SeqActionType{seq_id,action});
} else {
#pragma sst global seq_action_tagged
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action_tagged;
tagged_lst[tag].emplace_back(SeqActionType{seq_id,action});
}
Expand Down
1 change: 1 addition & 0 deletions src/sequence/sequencer_virtual.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace vt { namespace seq {
template <typename SeqTag, template <typename> class SeqTrigger>
/*virtual*/ typename TaggedSequencerVrt<SeqTag, SeqTrigger>::SeqType
TaggedSequencerVrt<SeqTag, SeqTrigger>::getNextID() {
#pragma sst global seq_manager
return this->seq_manager->nextSeqID(true);
}

Expand Down
Loading

0 comments on commit fafde3f

Please sign in to comment.