Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
replace old and counter-intuitive simdag-throttling example by modern comm-throttling
[simgrid.git] / examples / cpp / CMakeLists.txt
1
2 # Regular examples: with only one source and tested with all factories by default
3 #################################################################################
4 ### Define the examples' specificities
5
6 set(_app-bittorrent_sources app-bittorrent/s4u-bittorrent.cpp app-bittorrent/s4u-bittorrent.hpp
7                             app-bittorrent/s4u-peer.cpp app-bittorrent/s4u-peer.hpp
8                             app-bittorrent/s4u-tracker.cpp app-bittorrent/s4u-tracker.hpp)
9 set(_dht-chord_sources    dht-chord/s4u-dht-chord.cpp dht-chord/s4u-dht-chord.hpp dht-chord/s4u-dht-chord-node.cpp)
10 set(_dht-kademlia_sources dht-kademlia/s4u-dht-kademlia.cpp dht-kademlia/s4u-dht-kademlia.hpp
11                           dht-kademlia/node.cpp dht-kademlia/node.hpp
12                           dht-kademlia/routing_table.cpp dht-kademlia/routing_table.hpp
13                           dht-kademlia/answer.cpp dht-kademlia/answer.hpp dht-kademlia/message.hpp)
14
15 set(_actor-stacksize_factories "^thread") # Threads ignore modifications of the stack size
16
17 # The maestro-set example only works for threads and when not using windows.
18 set(_maestro-set_factories "thread")
19 if(WIN32)
20   set(_maestro-set_disable 1)
21 endif()
22
23 set(MC_regular_tests mc-bugged1 mc-bugged2 mc-failing-assert mc-electric-fence)
24 foreach (example ${MC_regular_tests})
25   if(NOT SIMGRID_HAVE_MC)
26     set(_${example}_disable 1)
27   endif()
28   set(_${example}_factories "^thread")
29 endforeach()
30
31 if(SIMGRID_HAVE_MC)
32    add_executable       (s4u-mc-bugged1-liveness  EXCLUDE_FROM_ALL mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
33    target_link_libraries(s4u-mc-bugged1-liveness  simgrid)
34    set_target_properties(s4u-mc-bugged1-liveness PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness)
35    add_dependencies(tests-mc s4u-mc-bugged1-liveness)
36
37   if(HAVE_C_STACK_CLEANER)
38     add_executable       (s4u-mc-bugged1-liveness-cleaner-on  EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
39     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-on  simgrid)
40     set_target_properties(s4u-mc-bugged1-liveness-cleaner-on  PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fstack-cleaner")
41     add_dependencies(tests-mc s4u-mc-bugged1-liveness-cleaner-on)
42
43     add_executable       (s4u-mc-bugged1-liveness-cleaner-off EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
44     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-off simgrid)
45     set_target_properties(s4u-mc-bugged1-liveness-cleaner-off PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fno-stack-cleaner")
46     add_dependencies(tests-mc s4u-mc-bugged1-liveness-cleaner-off)
47   endif()
48 endif()
49
50 if(SIMGRID_HAVE_NS3)
51   add_executable       (s4u-network-ns3 EXCLUDE_FROM_ALL network-ns3/s4u-network-ns3.cpp)
52   target_link_libraries(s4u-network-ns3 simgrid)
53   set_target_properties(s4u-network-ns3  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/network-ns3)
54   add_dependencies(tests s4u-network-ns3)
55   add_executable       (s4u-network-ns3-wifi EXCLUDE_FROM_ALL network-ns3-wifi/s4u-network-ns3-wifi.cpp)
56   target_link_libraries(s4u-network-ns3-wifi simgrid)
57   set_target_properties(s4u-network-ns3-wifi  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/network-ns3-wifi)
58   add_dependencies(tests s4u-network-ns3-wifi)
59 endif()
60
61 # Deal with each example
62
63 foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
64                  actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
65                  app-bittorrent app-chainsend app-token-ring
66                  comm-pingpong comm-ready comm-serialize comm-suspend comm-wait comm-waitany comm-waitall comm-waituntil
67                  comm-dependent comm-host2host comm-failure comm-throttling
68                  cloud-capping cloud-migration cloud-simple
69                  dag-failure dag-simple
70                  dht-chord dht-kademlia
71                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
72                  engine-filtering engine-run-partial
73                  exec-async exec-basic exec-dvfs exec-remote exec-waitany exec-waitfor exec-dependent exec-unassigned
74                  exec-ptask-multicore exec-cpu-nonlinear exec-cpu-factors exec-failure
75                  maestro-set
76                  mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert
77                  network-wifi
78                  io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent
79                  platform-failures platform-profile platform-properties
80                  plugin-host-load plugin-link-load plugin-prodcons
81                  replay-comm replay-io
82                  routing-get-clusters
83                  synchro-barrier synchro-condition-variable synchro-condition-variable-waituntil synchro-mutex synchro-semaphore
84                  clusters-multicpu network-factors network-nonlinear)
85
86   # Use default source file unless specified otherwise
87   if(NOT DEFINED _${example}_sources)
88     set(_${example}_sources ${example}/s4u-${example}.cpp)
89   endif()
90
91   if(NOT DEFINED _${example}_disable)
92     add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${_${example}_sources})
93     add_dependencies     (tests s4u-${example})
94     add_dependencies     (s4u-${example} platf_cpp)
95     target_link_libraries(s4u-${example} simgrid)
96     set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
97
98     # Use default factories unless specified otherwise
99     if(NOT DEFINED _${example}_factories)
100       set(_${example}_factories "*")
101     endif()
102 #    message("Factories of ${example}: ${_${example}_factories}")
103
104     ADD_TESH_FACTORIES(s4u-${example} "${_${example}_factories}"
105                                       --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
106                                       --setenv libdir=${CMAKE_BINARY_DIR}/lib
107                                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
108                                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
109                                       ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
110   else()
111     message(STATUS "Example ${example} disabled, thus not compiled.")
112     unset(_${example}_disable)
113   endif()
114
115   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
116   foreach(file ${_${example}_sources})
117     set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
118   endforeach()
119
120   unset(_${example}_factories)
121   unset(_${example}_sources)
122 endforeach()
123
124
125 # Specific examples
126 ###################
127
128 # MASTERWORKERS EXAMPLE
129 foreach(variant fun class)
130   add_executable       (s4u-app-masterworkers-${variant} EXCLUDE_FROM_ALL app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
131   target_link_libraries(s4u-app-masterworkers-${variant} simgrid)
132   set_target_properties(s4u-app-masterworkers-${variant} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-masterworkers)
133   add_dependencies(tests s4u-app-masterworkers-${variant})
134
135   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
136 endforeach()
137 set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers.tesh)
138
139 # Model-checking
140 if(SIMGRID_HAVE_MC)
141   foreach (example ${MC_regular_tests})
142     if(NOT DEFINED _${example}_disable)
143       add_dependencies(tests-mc s4u-${example})
144     endif()
145   endforeach()
146
147   # Model-checking liveness
148   IF(HAVE_UCONTEXT_CONTEXTS AND SIMGRID_PROCESSOR_x86_64) # liveness model-checking works only on 64bits (for now ...)
149     add_dependencies(tests-mc s4u-mc-bugged1-liveness)
150     ADD_TESH(s4u-mc-bugged1-liveness-ucontext     --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness
151                                                   --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
152                                                   --cd ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness
153                                                   ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh)
154
155 # This example hit the 5' timeout on CI, disable it for now
156 #    ADD_TESH(s4u-mc-bugged1-liveness-visited-ucontext --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness
157 #                                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
158 #                                                      --cd ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness
159 #                                                       ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh)
160     IF(HAVE_C_STACK_CLEANER)
161       add_dependencies(tests-mc s4u-mc-bugged1-liveness-stack-cleaner)
162       # This test checks if the stack cleaner is making a difference:
163       ADD_TEST(s4u-mc-bugged1-liveness-stack-cleaner ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
164                                                      ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/
165                                                      ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness/)
166     ENDIF()
167   ENDIF()
168
169 #  if (enable_coverage)
170 #    SET_TESTS_PROPERTIES(mc-bugged1-liveness-visited-ucontext PROPERTIES RUN_SERIAL "TRUE")
171 #  endif()
172 ENDIF()
173
174 # The tests the parallel variant of of DHTs
175
176 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
177   # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
178   # play well with Ucontexts on 64bit SunOS (at least on x86_64).
179   set(parallel-factories "^ucontext")
180 else()
181   set(parallel-factories "*")
182 endif()
183
184 foreach(example app-bittorrent app-masterworkers
185                 dht-chord dht-kademlia
186                 )
187   ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
188                                              --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
189                                              --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
190                                              --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
191                                              ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
192 endforeach()
193
194 # ns3-tests
195 if(SIMGRID_HAVE_NS3)
196   ADD_TESH_FACTORIES(s4u-network-ns3 "*"
197                                      --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/cpp
198                                      --setenv bindir=${CMAKE_BINARY_DIR}/examples/cpp
199                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
200                                      ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3.tesh)
201   ADD_TESH_FACTORIES(s4u-network-ns3-wifi "*"
202                                      --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/cpp
203                                      --setenv bindir=${CMAKE_BINARY_DIR}/examples/cpp
204                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
205                                      ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3-wifi/s4u-network-ns3-wifi.tesh)
206 endif()
207 # Examples not accepting factories
208 ##################################
209
210 foreach (example exec-ptask trace-categories trace-masterworkers trace-platform trace-process-migration
211                  trace-host-user-variables trace-link-user-variables trace-route-user-variables)
212   add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
213   target_link_libraries(s4u-${example} simgrid)
214   set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
215   add_dependencies(tests s4u-${example})
216
217   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
218   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
219
220   ADD_TESH(s4u-${example} --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
221                           --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
222                           --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
223                           --cd ${CMAKE_CURRENT_BINARY_DIR}/${example}
224                           ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
225 endforeach()
226
227 if (NOT enable_memcheck AND NOT WIN32)
228   ADD_TESH(simix-breakpoint --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/comm-pingpong
229                             --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
230                             ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/simix-breakpoint.tesh)
231 endif()
232
233 if(enable_coverage AND SIMGRID_HAVE_MC)
234   foreach (example mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert)
235     ADD_TEST(cover-${example} ${CMAKE_CURRENT_BINARY_DIR}/${example}/s4u-${example} ${CMAKE_HOME_DIRECTORY}/examples/platforms/model_checker_platform.xml)
236   endforeach()
237   ADD_TEST(cover-mc-bugged1-liveness ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness ${CMAKE_HOME_DIRECTORY}/examples/platforms/small_platform.xml 1 1001)
238 endif()
239
240 # Add all extra files to the archive
241 ####################################
242 set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp
243                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/s4u-network-ns3.cpp
244                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3-wifi/s4u-network-ns3-wifi.cpp              PARENT_SCOPE)
245 set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/simix-breakpoint.tesh
246                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh
247                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh
248                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/s4u-network-ns3.tesh
249                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3-wifi/s4u-network-ns3-wifi.tesh             PARENT_SCOPE)
250 set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
251                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
252                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-yield/s4u-actor-yield_d.xml
253                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
254                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
255                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-suspend/s4u-comm-suspend_d.xml
256                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-wait/s4u-comm-wait_d.xml
257                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitany/s4u-comm-waitany_d.xml
258                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitall/s4u-comm-waitall_d.xml
259                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-ready/s4u-comm-ready_d.xml
260                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waituntil/s4u-comm-waituntil_d.xml
261                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
262                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
263                                   ${CMAKE_CURRENT_SOURCE_DIR}/energy-boot/platform_boot.xml
264                                   ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
265                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-properties/s4u-platform-properties_d.xml
266                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-platform-failures_d.xml
267                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split_d.xml
268                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm_d.xml
269                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io_d.xml
270                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml
271                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml
272                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links_d.xml
273                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/crosstraffic_d.xml
274                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/dogbone_d.xml
275                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
276                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml                PARENT_SCOPE)
277 set(bin_files     ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
278                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
279                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/promela_bugged1_liveness PARENT_SCOPE)
280 set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
281                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
282                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
283                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt                  PARENT_SCOPE)
284