Logo AND Algorithmique Numérique Distribuée

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