Skip to content

Commit fafde3f

Browse files
Jeremiah Wilkelifflander
Jeremiah Wilke
authored andcommitted
#183: build: add local package find macro
1 parent 037b893 commit fafde3f

15 files changed

+168
-9
lines changed

CMakeLists.txt

+80-8
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,92 @@ find_package(MPI REQUIRED)
88

99
include_directories(${MPI_C_INCLUDE_PATH})
1010

11-
set(CMAKE_CXX_STANDARD 14)
11+
set(VIRTUAL_TRANSPORT_LIBRARY vt)
12+
set(FCONTEXT_LIBRARY fcontext)
13+
14+
include(cmake-modules/SetCXXCompilerFlags.cmake)
15+
set_darma_compiler_flags()
16+
17+
macro(require_pkg_directory pkg_name pkg_user_name)
18+
#message(STATUS "require_directory: name=${pkg_name}")
19+
option(${pkg_name}_DIR "Root folder for ${pkg_user_name} installation" OFF)
20+
if (NOT ${pkg_name}_DIR)
21+
message(FATAL_ERROR "Please specify ${pkg_user_name} library installation root with -D${pkg_name}_DIR=")
22+
endif()
23+
endmacro(require_pkg_directory)
24+
25+
macro(find_package_local pkg_name pkg_directory)
26+
message(STATUS "find_package_local: pkg name=\"${pkg_name}\", directory=\"${pkg_directory}\"")
27+
# search locally only for package
28+
find_package(
29+
${pkg_name}
30+
PATHS ${pkg_directory}
31+
REQUIRED
32+
NO_CMAKE_PACKAGE_REGISTRY
33+
NO_CMAKE_BUILDS_PATH
34+
NO_CMAKE_SYSTEM_PATH
35+
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
36+
)
37+
endmacro(find_package_local)
38+
39+
# require directories for these packages
40+
require_pkg_directory(darma_meld "DARMA meld")
41+
require_pkg_directory(darma_detector "DARMA detector")
42+
# find these required packages
43+
find_package_local(darma_meld "${darma_meld_DIR}/cmake")
44+
find_package_local(darma_detector "${darma_detector_DIR}/cmake")
45+
46+
# find_package(darma_meld PATHS ${darma_meld_DIR}/cmake)
47+
# find_package(darma_detector PATHS ${darma_detector_DIR}/cmake)
1248

13-
# OpenMP support
1449
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
50+
1551
include(${CMAKE_MODULE_PATH}/FindOpenMP.cmake)
1652

17-
if (OpenMP_FOUND)
53+
find_package(ZLIB REQUIRED)
54+
55+
if (ZLIB_FOUND)
56+
include_directories(${ZLIB_INCLUDE_DIRS})
57+
else()
58+
message("zlib is required for tracing")
59+
endif (ZLIB_FOUND)
60+
61+
function(config_for_std_thread)
62+
set(DEFAULT_THREADING stdthread)
63+
endfunction(config_for_std_thread)
64+
65+
function(config_for_openmp)
66+
set(DEFAULT_THREADING openmp)
1867
message("OpenMP has been found: ")
1968
message("\t Linker flags: ${OpenMP_EXE_LINKER_FLAGS}")
2069
message("\t C_FLAGS=${OpenMP_C_FLAGS}")
2170
message("\t CXX_FLAGS=${OpenMP_CXX_FLAGS}")
22-
23-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
2471
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
2572
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
26-
else()
27-
message("OpenMP not found: must use std::thread for workers.")
28-
endif (OpenMP_FOUND)
73+
endfunction(config_for_openmp)
74+
75+
option(USE_STD_THREAD
76+
"whether to force use of std::thread for threading"
77+
OFF)
78+
79+
option(USE_OPENMP
80+
"whether to force use of OpenMP for threading"
81+
OFF)
82+
83+
if (USE_STD_THREAD)
84+
message("Using std::thread for worker threading")
85+
config_for_std_thread()
86+
elseif(USE_OPENMP)
87+
config_for_openmp()
88+
if (NOT OpenMP_Found)
89+
message(FATAL_ERROR "requested OpenMP with -DUSE_OPENMP=On, but cannot find valid OpenMP in compiler")
90+
endif()
91+
elseif(OpenMP_FOUND) #no default specified
92+
config_for_openmp()
93+
else() #no default specified
94+
message("OpenMP not found: using std::thread for workers")
95+
config_for_std_thread()
96+
endif()
2997

3098
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
3199
set(PROJECT_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
@@ -454,3 +522,7 @@ install(
454522
COMPONENT dev
455523
)
456524

525+
configure_file(cmake_config.h.in cmake_config.h @ONLY)
526+
include_directories(${CMAKE_CURRENT_BINARY_DIR})
527+
528+
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Compiler-specific C++14 activation.
2+
# Call this from all CMakeLists.txt files that can be built independently.
3+
4+
macro(set_darma_compiler_flags)
5+
6+
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
7+
# 4.9.3 complains about std::min not being constexpr
8+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
9+
execute_process(
10+
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
11+
if (NOT (GCC_VERSION VERSION_GREATER 5 OR GCC_VERSION VERSION_EQUAL 5))
12+
message("${PROJECT_NAME} currently requires g++ 5 or greater. If you need it to work with 4.9, please complain.")
13+
endif ()
14+
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
15+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -ftemplate-depth=900")
16+
if (APPLE)
17+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
18+
endif ()
19+
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
20+
# 16.0.3 complains about std::min not being constexpr
21+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
22+
else ()
23+
message(FATAL_ERROR "Your C++ compiler may not support C++14.")
24+
endif ()
25+
26+
endmacro()
27+
28+

cmake_config.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
#define default_threading @DEFAULT_THREADING@
3+

examples/hello_world.cc

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ static void hello_world(HelloMsg* msg) {
1616
printf("%d: Hello from node %d\n", theContext()->getNode(), msg->from);
1717
}
1818

19+
#define sstmac_app_name hello_world_vt
1920
int main(int argc, char** argv) {
2021
CollectiveOps::initialize(argc, argv);
2122

examples/jacobi1d_node.cc

+2
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ static int exitEarly(NodeType node, int exit_code, char* reason) {
236236
return exit_code;
237237
}
238238

239+
#define sstmac_app_name jacobi1d_node_vt
240+
239241
int main(int argc, char** argv) {
240242
CollectiveOps::initialize(argc, argv);
241243

examples/jacobi1d_recur_vc.cc

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ static void create_jacobi1d(CreateJacobi1DMsg* msg, Jacobi1D* j1d) {
7979
}
8080
}
8181

82+
#define sstmac_app_name jacobi1d_recur_vc_vt
83+
8284
int main(int argc, char** argv) {
8385
CollectiveOps::initialize(argc, argv);
8486

share/parameters.ini

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
include debug.ini
2+
3+
node {
4+
app1 {
5+
launch_cmd = aprun -n 8 -N 1
6+
#name = hello_world_vt
7+
#name = jacobi1d_recur_vc_vt
8+
name = jacobi1d_node_vt
9+
iprobe_delay = 5us
10+
poll_delay = 1us
11+
argv = 128 2
12+
}
13+
}
14+

src/collective/collective_ops.cc

+4
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ RuntimePtrType CollectiveAnyOps<instance>::initialize(
2121
using vt::runtime::Runtime;
2222
using vt::runtime::eRuntimeInstance;
2323

24+
#pragma sst global rt
2425
RuntimeInst<instance>::rt = std::make_unique<Runtime>(
2526
argc, argv, num_workers, is_interop, comm
2627
);
2728

29+
#pragma sst global rt
2830
auto rt_ptr = RuntimeInst<instance>::rt.get();
2931
if (instance == RuntimeInstType::DefaultInstance) {
3032
// Set global variable for default instance for backward compatibility
3133
::vt::rt = rt_ptr;
3234
curRT = rt_ptr;
3335
}
36+
#pragma sst global rt
3437
RuntimeInst<instance>::rt->initialize();
3538

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

77+
#pragma sst global rt
7478
RuntimeInst<instance>::rt = nullptr;
7579

7680
if (instance == RuntimeInstType::DefaultInstance) {

src/configs/debug/debug_masterconfig.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#if !defined INCLUDED_DEBUG_MASTER_CONFIG
33
#define INCLUDED_DEBUG_MASTER_CONFIG
44

5+
#include <cmake_config.h>
6+
57
/*
68
* Define the compile-time configuration options. Eventually this will be
79
* partially defined with cmake options
@@ -21,7 +23,7 @@
2123
#endif
2224

2325
#define backend_features backend_options_on( \
24-
detector, openmp \
26+
detector, default_threading \
2527
)
2628

2729
#define backend_debug_contexts backend_options_on( \

src/group/region/group_region.h

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct Region {
2222
using ListType = std::vector<BoundType>;
2323
using ApplyFnType = std::function<void(RegionUPtrType)>;
2424

25+
virtual ~Region(){}
2526
virtual SizeType getSize() const = 0;
2627
virtual void sort() = 0;
2728
virtual bool contains(NodeType const& node) = 0;

src/registry/auto/auto_registry_general.h

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ RegistryT& getAutoRegistryGen();
2323

2424
template <typename RegistryT, typename>
2525
inline RegistryT& getAutoRegistryGen() {
26+
#pragma sst keep
2627
static RegistryT reg;
2728
return reg;
2829
}

src/sequence/seq_matcher.impl.h

+12
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ template <typename T>
7373
template <typename MessageT, ActiveTypedFnType<MessageT>* f>
7474
/*static*/ bool SeqMatcher<MessageT, f>::hasMatchingMsg(TagType const& tag) {
7575
if (tag == no_tag) {
76+
#pragma sst global seq_msg
7677
auto& lst = SeqStateType<MessageT,f>::seq_msg;
7778
return hasMatchingAnyNoTag(lst);
7879
} else {
80+
#pragma sst global seq_msg_tagged
7981
auto& tagged_lst = SeqStateType<MessageT, f>::seq_msg_tagged;
8082
return hasMatchingAnyTagged(tagged_lst, tag);
8183
}
@@ -84,9 +86,11 @@ template <typename MessageT, ActiveTypedFnType<MessageT>* f>
8486
template <typename MessageT, ActiveTypedFnType<MessageT>* f>
8587
/*static*/ MessageT* SeqMatcher<MessageT, f>::getMatchingMsg(TagType const& tag) {
8688
if (tag == no_tag) {
89+
#pragma sst global seq_msg
8790
auto& lst = SeqStateType<MessageT, f>::seq_msg;
8891
return getMatchingAnyNoTag(lst);
8992
} else {
93+
#pragma sst global seq_msg_tagged
9094
auto& tagged_lst = SeqStateType<MessageT, f>::seq_msg_tagged;
9195
return getMatchingAnyTagged(tagged_lst, tag);
9296
}
@@ -95,9 +99,11 @@ template <typename MessageT, ActiveTypedFnType<MessageT>* f>
9599
template <typename MessageT, ActiveTypedFnType<MessageT>* f>
96100
/*static*/ bool SeqMatcher<MessageT, f>::hasMatchingAction(TagType const& tag) {
97101
if (tag == no_tag) {
102+
#pragma sst global seq_action
98103
auto& lst = SeqStateType<MessageT, f>::seq_action;
99104
return hasMatchingAnyNoTag(lst);
100105
} else {
106+
#pragma sst global seq_action_tagged
101107
auto& tagged_lst = SeqStateType<MessageT, f>::seq_action_tagged;
102108
return hasMatchingAnyTagged(tagged_lst, tag);
103109
}
@@ -109,9 +115,11 @@ SeqMatcher<MessageT, f>::getMatchingAction(TagType const& tag) {
109115
assert(hasMatchingAction(tag) and "Must have matching action");
110116

111117
if (tag == no_tag) {
118+
#pragma sst global seq_action
112119
auto& lst = SeqStateType<MessageT, f>::seq_action;
113120
return getMatchingAnyNoTag(lst);
114121
} else {
122+
#pragma sst global seq_action_tagged
115123
auto& tagged_lst = SeqStateType<MessageT, f>::seq_action_tagged;
116124
return getMatchingAnyTagged(tagged_lst, tag);
117125
}
@@ -122,8 +130,10 @@ template <typename MessageT, ActiveTypedFnType<MessageT>* f>
122130
MessageT* msg, TagType const& tag
123131
) {
124132
if (tag == no_tag) {
133+
#pragma sst global seq_msg
125134
SeqStateType<MessageT, f>::seq_msg.push_back(msg);
126135
} else {
136+
#pragma sst global seq_msg_tagged
127137
SeqStateType<MessageT, f>::seq_msg_tagged[tag].push_back(msg);
128138
}
129139
}
@@ -139,9 +149,11 @@ template <typename FnT>
139149
);
140150

141151
if (tag == no_tag) {
152+
#pragma sst global seq_action
142153
auto& lst = SeqStateType<MessageT,f>::seq_action;
143154
lst.emplace_back(SeqActionType{seq_id,action});
144155
} else {
156+
#pragma sst global seq_action_tagged
145157
auto& tagged_lst = SeqStateType<MessageT,f>::seq_action_tagged;
146158
tagged_lst[tag].emplace_back(SeqActionType{seq_id,action});
147159
}

src/sequence/seq_matcher_virtual.impl.h

+12
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ template <typename T>
7575
template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
7676
/*static*/ bool SeqMatcherVirtual<VcT, MsgT, f>::hasMatchingMsg(TagType const& tag) {
7777
if (tag == no_tag) {
78+
#pragma sst global seq_msg
7879
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_msg;
7980
return hasMatchingAnyNoTag(lst);
8081
} else {
82+
#pragma sst global seq_msg_tagged
8183
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_msg_tagged;
8284
return hasMatchingAnyTagged(tagged_lst, tag);
8385
}
@@ -86,9 +88,11 @@ template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
8688
template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
8789
/*static*/ MsgT* SeqMatcherVirtual<VcT, MsgT, f>::getMatchingMsg(TagType const& tag) {
8890
if (tag == no_tag) {
91+
#pragma sst global seq_msg
8992
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_msg;
9093
return getMatchingAnyNoTag(lst);
9194
} else {
95+
#pragma sst global seq_msg_tagged
9296
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_msg_tagged;
9397
return getMatchingAnyTagged(tagged_lst, tag);
9498
}
@@ -97,9 +101,11 @@ template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
97101
template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
98102
/*static*/ bool SeqMatcherVirtual<VcT, MsgT, f>::hasMatchingAction(TagType const& tag) {
99103
if (tag == no_tag) {
104+
#pragma sst global seq_action
100105
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action;
101106
return hasMatchingAnyNoTag(lst);
102107
} else {
108+
#pragma sst global seq_action_tagged
103109
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action_tagged;
104110
return hasMatchingAnyTagged(tagged_lst, tag);
105111
}
@@ -111,9 +117,11 @@ SeqMatcherVirtual<VcT, MsgT, f>::getMatchingAction(TagType const& tag) {
111117
assert(hasMatchingAction(tag) and "Must have matching action");
112118

113119
if (tag == no_tag) {
120+
#pragma sst global seq_action
114121
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action;
115122
return getMatchingAnyNoTag(lst);
116123
} else {
124+
#pragma sst global seq_action_tagged
117125
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action_tagged;
118126
return getMatchingAnyTagged(tagged_lst, tag);
119127
}
@@ -124,8 +132,10 @@ template <typename VcT, typename MsgT, ActiveVrtTypedFnType<MsgT, VcT> *f>
124132
MsgT* msg, TagType const& tag
125133
) {
126134
if (tag == no_tag) {
135+
#pragma sst global seq_msg
127136
SeqStateVirtualType<VcT, MsgT, f>::seq_msg.push_back(msg);
128137
} else {
138+
#pragma sst global seq_msg_tagged
129139
SeqStateVirtualType<VcT, MsgT, f>::seq_msg_tagged[tag].push_back(msg);
130140
}
131141
}
@@ -141,9 +151,11 @@ template <typename FnT>
141151
);
142152

143153
if (tag == no_tag) {
154+
#pragma sst global seq_action
144155
auto& lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action;
145156
lst.emplace_back(SeqActionType{seq_id,action});
146157
} else {
158+
#pragma sst global seq_action_tagged
147159
auto& tagged_lst = SeqStateVirtualType<VcT, MsgT, f>::seq_action_tagged;
148160
tagged_lst[tag].emplace_back(SeqActionType{seq_id,action});
149161
}

src/sequence/sequencer_virtual.impl.h

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace vt { namespace seq {
1515
template <typename SeqTag, template <typename> class SeqTrigger>
1616
/*virtual*/ typename TaggedSequencerVrt<SeqTag, SeqTrigger>::SeqType
1717
TaggedSequencerVrt<SeqTag, SeqTrigger>::getNextID() {
18+
#pragma sst global seq_manager
1819
return this->seq_manager->nextSeqID(true);
1920
}
2021

0 commit comments

Comments
 (0)