File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ find_package(OpenMP)
4444message (STATUS "Building examples ..." )
4545set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR} /example)
4646
47+ set (EXAMPLE_EXE_LINKER_FLAGS Threads::Threads)
48+
4749if (OpenMP_FOUND)
4850 set (EXAMPLE_CXX_FLAGS ${OpenMP_CXX_FLAGS} )
4951 set (EXAMPLE_EXE_LINKER_FLAGS ${OpenMP_CXX_FLAGS} ${OpenMP_EXE_LINKER_FLAGS} )
@@ -56,11 +58,15 @@ message(STATUS "EXAMPLE_CXX_FLAGS: " ${EXAMPLE_CXX_FLAGS})
5658message (STATUS "EXAMPLE_EXE_LINKER_FLAGS: " ${EXAMPLE_EXE_LINKER_FLAGS} )
5759
5860add_executable (simple example/simple.cpp )
59- target_link_libraries (simple Threads::Threads )
61+ target_link_libraries (simple ${EXAMPLE_EXE_LINKER_FLAGS} )
6062
6163add_executable (matrix example/matrix.cpp )
6264target_compile_options (matrix PRIVATE ${EXAMPLE_CXX_FLAGS} )
63- target_link_libraries (matrix ${EXAMPLE_EXE_LINKER_FLAGS} Threads::Threads )
65+ target_link_libraries (matrix ${EXAMPLE_EXE_LINKER_FLAGS} )
66+
67+ add_executable (dag example/dag.cpp )
68+ target_compile_options (dag PRIVATE ${EXAMPLE_CXX_FLAGS} )
69+ target_link_libraries (matrix ${EXAMPLE_EXE_LINKER_FLAGS} )
6470
6571
6672# -----------------------------------------------------------------------------
Original file line number Diff line number Diff line change 1+ #include " taskflow.hpp"
2+
3+ #define MIN_PER_RANK 1 // fatness
4+ #define MAX_PER_RANK 10
5+ #define MIN_RANKS 1 // height
6+ #define MAX_RANKS 20
7+ #define PERCENT 20 // chance to have an edge
8+
9+ int main (void ) {
10+
11+ ::srand (0 );
12+
13+ int nodes = 0 ;
14+ int ranks = MIN_RANKS + (rand () % (MAX_RANKS - MIN_RANKS + 1 ));
15+
16+ printf (" digraph G {\n " );
17+
18+ for (int i = 0 ; i < ranks; i++) {
19+ /* New nodes of 'higher' rank than all nodes generated till now. */
20+ int new_nodes = MIN_PER_RANK + (rand () % (MAX_PER_RANK - MIN_PER_RANK + 1 ));
21+ /* Edges from old nodes ('nodes') to new ones ('new_nodes'). */
22+ for (int j = 0 ; j < nodes; j++) {
23+ for (int k = 0 ; k < new_nodes; k++) {
24+ if ((rand () % 100 ) < PERCENT) {
25+ printf (" %d -> %d;\n " , j, k + nodes); /* An Edge. */
26+ }
27+ }
28+ }
29+ nodes += new_nodes; /* Accumulate into old node set. */
30+ }
31+
32+ printf (" }\n " );
33+ return 0 ;
34+ }
You can’t perform that action at this time.
0 commit comments