Skip to content

Commit 69b0e25

Browse files
updated doc/readme/cmakelist
1 parent d19f135 commit 69b0e25

5 files changed

Lines changed: 82 additions & 53 deletions

File tree

CMakeLists.txt

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ MESSAGE(STATUS "CMAKE_ROOT: " ${CMAKE_ROOT})
55
# Project name
66
project(Cpp-Taskflow VERSION 2.0.0)
77

8-
# Enable memory test
9-
include(CTest)
10-
118
# Turn on the verbose
129
set(CMAKE_VERBOSE_MAKEFILE ON)
1310

@@ -40,9 +37,13 @@ Cpp-Taskflow currently supports the following compilers:\n\
4037
endif()
4138

4239
# CXX target properties
43-
set(CMAKE_CXX_STANDARD 17)
44-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
45-
set(CMAKE_CXX_EXTENSIONS OFF)
40+
#set(CMAKE_CXX_STANDARD 17)
41+
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
42+
#set(CMAKE_CXX_EXTENSIONS OFF)
43+
44+
# installation path
45+
set(TF_INC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
46+
set(TF_LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
4647

4748
message(STATUS "CMAKE_HOST_SYSTEM: ${CMAKE_HOST_SYSTEM}")
4849
message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
@@ -60,25 +61,34 @@ message(STATUS "PROJECT_NAME: " ${PROJECT_NAME})
6061
message(STATUS "TF_BUILD_EXAMPLES: " ${TF_BUILD_EXAMPLES})
6162
message(STATUS "TF_BUILD_TESTS: " ${TF_BUILD_TESTS})
6263
message(STATUS "TF_BUILD_BENCHMARKS: " ${TF_BUILD_BENCHMARKS})
64+
message(STATUS "TF_INC_INSTALL_DIR: " ${TF_INC_INSTALL_DIR})
65+
message(STATUS "TF_LIB_INSTALL_DIR: " ${TF_LIB_INSTALL_DIR})
6366

6467
# add the binary tree to the search path for include files
6568
include_directories(${PROJECT_SOURCE_DIR})
6669
include_directories(doctest)
6770

71+
# -----------------------------------------------------------------------------
72+
# 3rd-party package include
73+
# -----------------------------------------------------------------------------
74+
75+
# Enable test
76+
include(CTest)
77+
6878
# Find pthread package
6979
find_package(Threads REQUIRED)
7080

71-
## Find OpenMP package
72-
#include(FindOpenMP)
73-
#
74-
#if(OpenMP_CXX_FOUND)
75-
# message(STATUS "OpenMP_CXX_SPEC_DATE: ${OpenMP_CXX_SPEC_DATE}")
76-
# message(STATUS "OpenMP_CXX_VERSION: ${OpenMP_CXX_VERSION}")
77-
# message(STATUS "OpenMP_CXX_FLAGS: ${OpenMP_CXX_FLAGS}")
78-
# message(STATUS "OpenMP_CXX_LIB_NAMES: ${OpenMP_CXX_LIB_NAMES}")
79-
#else(OpenMP_CXX_FOUND)
80-
# message(WARNING "OpenMP CXX not found")
81-
#endif(OpenMP_CXX_FOUND)
81+
# -----------------------------------------------------------------------------
82+
# Cpp-Taskflow library interface
83+
# -----------------------------------------------------------------------------
84+
85+
add_library(${PROJECT_NAME} INTERFACE)
86+
87+
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
88+
target_include_directories(${PROJECT_NAME} INTERFACE
89+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
90+
$<INSTALL_INTERFACE:include/>
91+
)
8292

8393
# -----------------------------------------------------------------------------
8494
# Example program
@@ -91,44 +101,44 @@ message(STATUS "Building examples ...")
91101
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/example)
92102

93103
add_executable(simple example/simple.cpp)
94-
target_link_libraries(simple Threads::Threads)
104+
target_link_libraries(simple ${PROJECT_NAME} Threads::Threads)
95105

96106
add_executable(subflow example/subflow.cpp)
97-
target_link_libraries(subflow Threads::Threads)
107+
target_link_libraries(subflow ${PROJECT_NAME} Threads::Threads)
98108

99109
add_executable(debug example/debug.cpp)
100-
target_link_libraries(debug Threads::Threads)
110+
target_link_libraries(debug ${PROJECT_NAME} Threads::Threads)
101111

102112
add_executable(emplace example/emplace.cpp)
103-
target_link_libraries(emplace Threads::Threads)
113+
target_link_libraries(emplace ${PROJECT_NAME} Threads::Threads)
104114

105115
add_executable(reduce example/reduce.cpp)
106-
target_link_libraries(reduce Threads::Threads)
116+
target_link_libraries(reduce ${PROJECT_NAME} Threads::Threads)
107117

108118
add_executable(threadpool example/threadpool.cpp)
109-
target_link_libraries(threadpool Threads::Threads)
119+
target_link_libraries(threadpool ${PROJECT_NAME} Threads::Threads)
110120

111121
add_executable(taskflow example/taskflow.cpp)
112-
target_link_libraries(taskflow Threads::Threads)
122+
target_link_libraries(taskflow ${PROJECT_NAME} Threads::Threads)
113123

114124
add_executable(matrix example/matrix.cpp)
115-
target_link_libraries(matrix Threads::Threads)
125+
target_link_libraries(matrix ${PROJECT_NAME} Threads::Threads)
116126

117127
add_executable(parallel_for example/parallel_for.cpp)
118-
target_link_libraries(parallel_for Threads::Threads)
128+
target_link_libraries(parallel_for ${PROJECT_NAME} Threads::Threads)
119129

120130
add_executable(threadpool_cxx14 example/threadpool_cxx14.cpp)
121131
set_property(TARGET threadpool_cxx14 PROPERTY CXX_STANDARD 14)
122132
target_link_libraries(threadpool_cxx14 Threads::Threads)
123133

124134
add_executable(multiple_dispatch example/multiple_dispatch.cpp)
125-
target_link_libraries(multiple_dispatch Threads::Threads)
135+
target_link_libraries(multiple_dispatch ${PROJECT_NAME} Threads::Threads)
126136

127137
add_executable(dispatch example/dispatch.cpp)
128-
target_link_libraries(dispatch Threads::Threads)
138+
target_link_libraries(dispatch ${PROJECT_NAME} Threads::Threads)
129139

130140
add_executable(executor example/executor.cpp)
131-
target_link_libraries(executor Threads::Threads)
141+
target_link_libraries(executor ${PROJECT_NAME} Threads::Threads)
132142

133143
endif()
134144

@@ -146,7 +156,7 @@ set(TF_UTEST_DIR ${PROJECT_SOURCE_DIR}/unittest)
146156

147157
# unittest for taskflow
148158
add_executable(taskflow_test_tmp unittest/taskflow.cpp)
149-
target_link_libraries(taskflow_test_tmp Threads::Threads)
159+
target_link_libraries(taskflow_test_tmp ${PROJECT_NAME} Threads::Threads)
150160
set_target_properties(taskflow_test_tmp PROPERTIES OUTPUT_NAME "taskflow")
151161
add_test(builder ${TF_UTEST_DIR}/taskflow -tc=Builder)
152162
add_test(dispatch ${TF_UTEST_DIR}/taskflow -tc=Dispatch)
@@ -160,7 +170,7 @@ add_test(detached_subflow ${TF_UTEST_DIR}/taskflow -tc=DetachedSubflow)
160170

161171
# unittest for threadpool
162172
add_executable(threadpool_test_tmp unittest/threadpool.cpp)
163-
target_link_libraries(threadpool_test_tmp Threads::Threads)
173+
target_link_libraries(threadpool_test_tmp ${PROJECT_NAME} Threads::Threads)
164174
set_target_properties(threadpool_test_tmp PROPERTIES OUTPUT_NAME "threadpool")
165175
add_test(WorkerQueue.OneThread ${TF_UTEST_DIR}/threadpool -tc=WorkerQueue.OneThread)
166176
add_test(WorkerQueue.TwoThread ${TF_UTEST_DIR}/threadpool -tc=WorkerQueue.TwoThread)
@@ -207,20 +217,6 @@ endif()
207217
# create find_package(Cpp-Taskflow CONFIG)
208218
# -----------------------------------------------------------------------------
209219

210-
add_library(${PROJECT_NAME} INTERFACE)
211-
212-
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
213-
target_include_directories(${PROJECT_NAME} INTERFACE
214-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
215-
$<INSTALL_INTERFACE:include/>
216-
)
217-
218-
set(TF_INC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
219-
set(TF_LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
220-
221-
message(STATUS "TF_INC_INSTALL_DIR: " ${TF_INC_INSTALL_DIR})
222-
message(STATUS "TF_LIB_INSTALL_DIR: " ${TF_LIB_INSTALL_DIR})
223-
224220
# install header
225221
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/taskflow DESTINATION ${TF_INC_INSTALL_DIR})
226222

@@ -235,7 +231,11 @@ export(
235231
export(PACKAGE ${PROJECT_NAME})
236232

237233
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets)
238-
install(EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}:: DESTINATION ${TF_LIB_INSTALL_DIR}/cmake)
234+
install(
235+
EXPORT ${PROJECT_NAME}Targets
236+
NAMESPACE ${PROJECT_NAME}::
237+
DESTINATION ${TF_LIB_INSTALL_DIR}/cmake
238+
)
239239

240240
# set up config
241241
include(CMakePackageConfigHelpers)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,8 @@ Cpp-Taskflow is being actively developed and contributed by the following people
805805
- [Glen Fraser](https://github.com/totalgee) created a standalone C++14-compatible [threadpool](./taskflow/threadpool/threadpool_cxx14.hpp) for taskflow; various other fixes and examples
806806
- [Guannan Guo](https://github.com/gguo4) added different threadpool implementations to enhance the performance for taskflow
807807
- [Patrik Huber][Patrik Huber] helped fixed typos in the documentation
808-
- [ForgeMistress][ForgeMistress] provided API ideas about sharing the executor to avoid thread over-subscriptiong issues.
808+
- [ForgeMistress][ForgeMistress] provided API ideas about sharing the executor to avoid thread over-subscriptiong issues
809+
- [Alexander Neumann](https://github.com/Neumann-A) helped modify the cmake build to make Cpp-Taskflow importable from external cmake projects
809810

810811
Meanwhile, we appreciate the support from many organizations for our development on Cpp-Taskflow.
811812
Please [let me know][email me] if I forgot someone!

doc/cookbook/dispatch.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ task dependency graph.
88
+ [Graph and Topology](#graph-and-topology)
99
+ [Blocking Execution](#blocking-execution)
1010
+ [Non-blocking Execution](#non-blocking-execution)
11-
+ [Wait on Topologies](#wait-on-topologies)
11+
+ [Wait for Topologies](#wait-for-topologies)
1212
+ [Lifetime of a Graph](#lifetime-of-a-graph)
1313
+ [Example 1: Multiple Dispatches](#example-1-multiple-dispatches)
1414
+ [Example 2: Connect Two Dependency Graphs](#example-2-connect-two-dependency-graphs)
@@ -61,7 +61,7 @@ Non-blocking methods allow the program to perform other computations
6161
that can overlap the graph execution.
6262
6363
```cpp
64-
1: tf::Taskflow tf(4);
64+
1: tf::Taskflow tf;
6565
2:
6666
3: auto A = tf.silent_emplace([] () { std::cout << "Task A\n"; });
6767
4: auto B = tf.silent_emplace([] () { std::cout << "Task B\n"; });
@@ -81,12 +81,25 @@ Debrief:
8181
+ Line 8-9 performs some computations to overlap the execution of task A and task B
8282
+ Line 10 blocks the program until this topology finishes
8383

84+
The method `dispatch` has a overload that takes a callable object to execute when
85+
the dispatched graph finishes.
86+
87+
```cpp
88+
1: tf::Taskflow tf;
89+
2:
90+
3: int counter {0};
91+
4:
92+
5: auto A = tf.silent_emplace([&] () { counter++; });
93+
6:
94+
7: tf.dispatch([&] () { assert(counter == 1); })
95+
```
96+
8497
If you do not care the status of a dispatched graph,
8598
use the method `silent_dispatch`.
8699
This method does not return anything.
87100
88101
```cpp
89-
1: tf::Taskflow tf(4);
102+
1: tf::Taskflow tf;
90103
2:
91104
3: auto A = tf.silent_emplace([] () { std::cout << "TaskA\n"; });
92105
4: auto B = tf.silent_emplace([] () { std::cout << "TaskB\n"; });
@@ -97,7 +110,20 @@ This method does not return anything.
97110
9: // ...
98111
```
99112

100-
# Wait on Topologies
113+
Similarly, the method `silent_dispatch` has an overload that takes a cllable to execute
114+
when the dispatched graph finishes.
115+
116+
```cpp
117+
1: tf::Taskflow tf;
118+
2:
119+
3: int counter {0};
120+
4:
121+
5: auto A = tf.silent_emplace([&] () { counter++; });
122+
6:
123+
7: tf.silent_dispatch([&] () { assert(counter == 1); })
124+
```
125+
126+
# Wait for Topologies
101127
102128
Unlike `wait_for_all`, calling `dispatch` or `silent_dispatch`
103129
will not clean up the topologies upon completion.

doc/home.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Cpp-Taskflow Project
33

44
+ [Motivation behind Cpp-Taskflow](project/motivation.md)
5-
+ [Toward a New Task Parallel Library](project/necessity.md)
5+
+ [Toward a New Parallel Task Programming Library](project/necessity.md)
66

77
# Cookbook
88

@@ -26,11 +26,13 @@
2626

2727
+ [GitHub issue][Github issues]
2828
+ [Frequently Asked Questions](faq.md)
29+
+ [Showcase Presentation][Showcase]
2930

3031

3132
* * *
3233

3334
[README]: ../README.md
35+
[Showcase]: https://cpp-taskflow.github.io/
3436
[Github issues]: https://github.com/cpp-taskflow/cpp-taskflow/issues
3537
[Github pull requests]: https://github.com/cpp-taskflow/cpp-taskflow/pulls
3638

doc/project/necessity.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Toward a New Task Parallel Library
1+
# Toward a Parallel Task Programming Library
22

33
We discuss in this page why we decide to develop a new tasking library,
44
rather than sticking with existing frameworks.

0 commit comments

Comments
 (0)