doc/msg-tuto-src/masterworker2
doc/msg-tuto-src/masterworker3
doc/msg-tuto-src/masterworker4
-examples/msg/actions-comm/actions-comm
-examples/msg/actions-storage/actions-storage
examples/msg/async-wait/async-wait
examples/msg/async-waitall/async-waitall
examples/msg/async-waitany/async-waitany
-examples/msg/app-bittorrent/bittorrent
examples/msg/app-chainsend/chainsend
examples/msg/cloud-capping/cloud-capping
examples/msg/cloud-masterworker/cloud-masterworker
examples/msg/trace-process-migration/trace-process-migration
examples/msg/trace-platform/trace-platform
examples/msg/trace-host-user-variables/trace-host-user-variables
+examples/msg/*.pcap
+examples/msg/*.tr
examples/s4u/actions-comm/s4u-actions-comm
examples/s4u/actions-storage/s4u-actions-storage
examples/s4u/actor-create/s4u-actor-create
examples/s4u/actor-kill/s4u-actor-kill
examples/s4u/actor-migration/s4u-actor-migration
examples/s4u/actor-suspend/s4u-actor-suspend
+examples/s4u/app-bittorrent/s4u-bittorrent
examples/s4u/app-masterworker/s4u-app-masterworker
examples/s4u/app-pingpong/s4u-app-pingpong
examples/s4u/app-token-ring/s4u-app-token-ring
examples/s4u/dht-chord/s4u-dht-chord
examples/s4u/io/s4u-io
examples/s4u/mutex/s4u-mutex
+examples/s4u/plugin-hostload/s4u-plugin-hostload
examples/simdag/daxload/sd_daxload
examples/simdag/dag-dotload/sd_dag-dotload
examples/simdag/ptg-dotload/sd_ptg-dotload
examples/smpi/NAS/dt
examples/smpi/NAS/ep
examples/smpi/NAS/is
+examples/smpi/replay_multiple/deployment.xml
examples/smpi/replay_multiple/replay_multiple
examples/smpi/replay/one_trace
examples/smpi/ring_c
examples/smpi/trace_call_location/smpi_trace_call_location
testall
teshsuite/datadesc_usage.out
-teshsuite/java/semaphoreGC/semaphoreGC_compiled
-teshsuite/java/sleepHostOff/sleepHostOff_compiled
+teshsuite/java/semaphoregc/java-semaphoregc_compiled
+teshsuite/java/sleephostoff/java-sleephostoff_compiled
teshsuite/mc/dwarf/dwarf
teshsuite/mc/dwarf-expression/dwarf-expression
teshsuite/mc/random-bug/random-bug
teshsuite/mc/mutex-handling/mutex-handling
teshsuite/mc/mutex-handling/without-mutex-handling
+teshsuite/msg/actions-comm/actions-comm
+teshsuite/msg/actions-storage/actions-storage
+teshsuite/msg/app-bittorrent/bittorrent
teshsuite/msg/cloud-sharing/cloud-sharing
teshsuite/msg/concurrent_rw/concurrent_rw
teshsuite/msg/get_sender/get_sender
teshsuite/smpi/mpich3-test/f77/rma/winaccf
teshsuite/smpi/mpich3-test/f77/rma/winfencef
teshsuite/smpi/mpich3-test/f77/rma/wingetf
+teshsuite/smpi/mpich3-test/f77/rma/wingroupf
teshsuite/smpi/mpich3-test/f77/rma/winnamef
teshsuite/smpi/mpich3-test/f77/rma/winscale1f
teshsuite/smpi/mpich3-test/f77/topo/cartcrf
teshsuite/smpi/mpich3-test/f90/rma/winaccf90
teshsuite/smpi/mpich3-test/f90/rma/winfencef90
teshsuite/smpi/mpich3-test/f90/rma/wingetf90
+teshsuite/smpi/mpich3-test/f90/rma/wingroupf90
teshsuite/smpi/mpich3-test/f90/rma/winnamef90
teshsuite/smpi/mpich3-test/f90/rma/winscale1f90
teshsuite/smpi/mpich3-test/group/groupcreate
unit_tmgr
#########################################
## touched files to track the dependencies of java examples
-examples/java/app/bittorrent/java_app_bittorrent_compiled
-examples/java/app/centralizedmutex/java_app_centralizedmutex_compiled
-examples/java/app/masterworker/java_app_masterworker_compiled
-examples/java/app/pingpong/java_app_pingpong_compiled
-examples/java/app/tokenring/java_app_tokenring_compiled
-examples/java/async/yield/java_async_yield_compiled
-examples/java/async/dsend/java_async_dsend_compiled
-examples/java/async/waitall/java_async_waitall_compiled
-examples/java/dht/chord/java_dht_chord_compiled
-examples/java/dht/kademlia/java_dht_kademlia_compiled
-examples/java/cloud/masterworker/java_cloud_masterworker_compiled
-examples/java/cloud/migration/java_cloud_migration_compiled
-examples/java/energy/consumption/java_energy_consumption_compiled
-examples/java/energy/pstate/java_energy_pstate_compiled
-examples/java/energy/vm/java_energy_vm_compiled
-examples/java/io/file/java_io_file_compiled
-examples/java/io/storage/java_io_storage_compiled
-examples/java/process/kill/java_process_kill_compiled
-examples/java/process/migration/java_process_migration_compiled
-examples/java/process/suspend/java_process_suspend_compiled
-examples/java/process/startkilltime/java_process_startkilltime_compiled
-examples/java/task/priority/java_task_priority_compiled
-examples/java/trace/pingpong/java_trace_pingpong_compiled
+examples/java/app/bittorrent/java-app-bittorrent_compiled
+examples/java/app/centralizedmutex/java-app-centralizedmutex_compiled
+examples/java/app/masterworker/java-app-masterworker_compiled
+examples/java/app/pingpong/java-app-pingpong_compiled
+examples/java/app/tokenring/java-app-tokenring_compiled
+examples/java/async/yield/java-async-yield_compiled
+examples/java/async/dsend/java-async-dsend_compiled
+examples/java/async/waitall/java-async-waitall_compiled
+examples/java/dht/chord/java-dht-chord_compiled
+examples/java/dht/kademlia/java-dht-kademlia_compiled
+examples/java/cloud/masterworker/java-cloud-masterworker_compiled
+examples/java/cloud/migration/java-cloud-migration_compiled
+examples/java/energy/consumption/java-energy-consumption_compiled
+examples/java/energy/pstate/java-energy-pstate_compiled
+examples/java/energy/vm/java-energy-vm_compiled
+examples/java/io/file/java-io-file_compiled
+examples/java/io/storage/java-io-storage_compiled
+examples/java/process/kill/java-process-kill_compiled
+examples/java/process/migration/java-process-migration_compiled
+examples/java/process/suspend/java-process-suspend_compiled
+examples/java/process/startkilltime/java-process-startkilltime_compiled
+examples/java/task/priority/java-task-priority_compiled
+examples/java/trace/pingpong/java-trace-pingpong_compiled
/CMakeCache.txt
examples/smpi/mc/smpi_bugged1
examples/smpi/mc/smpi_bugged1_liveness
find_package(Boost COMPONENTS context)
set(Boost_FOUND 1) # This component is optional
if(Boost_CONTEXT_FOUND)
- if (Boost_VERSION LESS 105600)
- message("Found Boost.Context API v1")
- set(HAVE_BOOST_CONTEXTS 1)
- elseif(Boost_VERSION LESS 106100)
- message("Found Boost.Context API v2")
- set(HAVE_BOOST_CONTEXTS 2)
- else()
- message(" WARNING : our implementation of Boost context factory is not compatible with Boost >=1.61 yet.")
- set(HAVE_BOOST_CONTEXTS 0)
- endif()
+ message("Found Boost.Context")
+ set(HAVE_BOOST_CONTEXTS 1)
else()
message (" boost : found.")
message (" boost-context: missing. Install libboost-context-dev for this optional feature.")
set(GIT_VERSION "none, release version")
endif()
+### Setup gcc & clang flags
+if (NOT MSVC)
+ include(${CMAKE_HOME_DIRECTORY}/tools/cmake/GCCFlags.cmake)
+endif()
+
### Generate the required headers and scripts
#############################################
include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MaintainerMode.cmake)
include(${CMAKE_HOME_DIRECTORY}/tools/cmake/UnitTesting.cmake)
-### Setup gcc & clang flags
-if (NOT MSVC)
- include(${CMAKE_HOME_DIRECTORY}/tools/cmake/GCCFlags.cmake)
-endif()
-
### Make Libs
if(NOT WIN32)
include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MakeLib.cmake)
SimGrid (3.17) UNRELEASED (release target: September 22 2017)
+ The Drained Leaks release: (almost) no known leaks despite the tests.
+
+ Even very long simulations will preserve your memory: our testsuite
+ stresses SimGrid for over 45mn on fast machines, and there is only
+ one single known leak, of about 4kb.
+
+
S4U
- - Comm.detach(): start and forget about asynchronous emission
+ - Comm.detach(): start and forget about asynchronous emission. A cleanup
+ handler may be given to free resources if the comm cannot be completed.
- this_actor::send(mailbox) is now mailbox->put()
- New: simgrid::s4u::Comm::wait_all()
+ - New: Host.execute() for remote executions.
SURF
- Unused option network/sender-gap is removed.
- Deprecate MSG_task_isend_with_matching(): This unused feature
really complicates our internals. Will be removed in v3.20.
+ Simix
+ - Improved context termination. It is now possible to free resources, even
+ when a process is forcibly killed.
+ - ContextBoost: add support for Boost versions above 1.61.
+
+ XBT
+ - Bring back run-time option --cfg=exception/cutpath to remove exception
+ backtraces.
+
+ Misc
+ - Removed header files obsolete since SimGrid 3.12:
+ msg/datatypes.h, msg/msg.h, simdag/datatypes.h, simdag/simdag.h.
+ - Fix many bugs:
+ - #3: SD_exit should be made optional
+ - #120: Memory leak when the processes are forcefully killed
+ - #159: Threading test regression in Actor refcounting
+ - #170: simgrid::s4u::Comm::wait_any() returns too many comms
+ - #185: simgrid::s4u::Engine::instance()->shutdown() segfaults
+ - #186: Actor::killAll() segfaults if some process is blocked on wait()
+ - #191: VM migration and pstate
+ - #192: Updating the energy consumptions of all hosts crashes with VMs
+ - #195: All actors have PID=0 in the logs
+ - #204: Sometimes segfault with thread contexts and mmap privatization
+ - #222: Actor::kill() doesn't really kill and segfaults
+
SimGrid (3.16) Released June 22. 2017.
The Blooming Spring Release: developments are budding.
-/* Copyright (c) 2013-2014. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
if (fgets(line, 200, fpInput) == NULL)
printf("Error input file is empty!"); // Skipping first row
while (fgets(line, 200, fpInput) != NULL) {
- key = strtok(line, "\t");
+ char *saveptr = NULL; /* for strtok_r() */
+ key = strtok_r(line, "\t", &saveptr);
xbt_hist_t* data = xbt_dict_get_or_null(mydict, key);
if (data)
data = (xbt_hist_t*)xbt_new(xbt_hist_t, 1);
data->block_id = key;
- data->counts = atoi(strtok(NULL, "\t"));
- data->mean = atof(strtok(NULL, "\t"));
- data->n = atoi(strtok(NULL, "\t"));
+ data->counts = atoi(strtok_r(NULL, "\t", &saveptr));
+ data->mean = atof(strtok_r(NULL, "\t", &saveptr));
+ data->n = atoi(strtok_r(NULL, "\t", &saveptr));
data->breaks = (double*)malloc(sizeof(double) * data->n);
data->percentage = (double*)malloc(sizeof(double) * (data->n - 1));
for (int i = 0; i < data->n; i++)
- data->breaks[i] = atof(strtok(NULL, "\t"));
+ data->breaks[i] = atof(strtok_r(NULL, "\t", &saveptr));
for (int i = 0; i < (data->n - 1); i++)
- data->percentage[i] = atof(strtok(NULL, "\t"));
+ data->percentage[i] = atof(strtok_r(NULL, "\t", &saveptr));
xbt_dict_set(mydict, key, data, NULL);
}
}
while (fgets(line, MAX_LINE_INJ, fpInput) != NULL) {
- key = strtok(line, "\t");
+ char *saveptr = NULL; /* for strtok_r() */
+ key = strtok_r(line, "\t", &saveptr);
xbt_hist_t* data = xbt_dict_get_or_null(mydict, key);
if (data)
data = (xbt_hist_t*)xbt_new(xbt_hist_t, 1);
data->block_id = key;
- data->counts = atoi(strtok(NULL, "\t"));
- data->mean = atof(strtok(NULL, "\t"));
- data->n = atoi(strtok(NULL, "\t"));
+ data->counts = atoi(strtok_r(NULL, "\t", &saveptr));
+ data->mean = atof(strtok_r(NULL, "\t", &saveptr));
+ data->n = atoi(strtok_r(NULL, "\t", &saveptr));
data->breaks = (double*)malloc(sizeof(double) * data->n);
data->percentage = (double*)malloc(sizeof(double) * (data->n - 1));
for (int i = 0; i < data->n; i++)
- data->breaks[i] = atof(strtok(NULL, "\t"));
+ data->breaks[i] = atof(strtok_r(NULL, "\t", &saveptr));
for (int i = 0; i < (data->n - 1); i++) {
- data->percentage[i] = atof(strtok(NULL, "\t"));
+ data->percentage[i] = atof(strtok_r(NULL, "\t", &saveptr));
}
xbt_dict_set(mydict, key, data, NULL);
\subsection options_exception_cutpath Truncate local path from exception backtrace
\verbatim
---cfg=exceptions/cutpath:1
+--cfg=exception/cutpath:1
\endverbatim
This configuration option is used to remove the path from the
- it spaws a child process for the SimGrid simulator/maestro and the simulated
processes.
-They communicate using a `AF_UNIX` `SOCK_DGRAM` socket and exchange messages
+They communicate using a `AF_UNIX` `SOCK_SEQPACKET` socket and exchange messages
defined in `mc_protocol.h`. The `SIMGRID_MC_SOCKET_FD` environment variable it
set to the file descriptor of this socket in the child process.
-set(app_bittorrent_files Main Common Connection MessageTask Peer Tracker TrackerTask)
-set(app_centralizedmutex_files Main Coordinator GrantTask Node ReleaseTask RequestTask)
-set(app_masterworker_files Main Master Worker)
-set(app_pingpong_files Main PingPongTask Receiver Sender)
-set(app_tokenring_files Main RelayRunner)
-set(async_waitall_files Main Receiver Sender)
-set(async_yield_files Main Yielder)
-set(async_dsend_files Main Receiver Sender)
-set(cloud_masterworker_files Main Master Worker)
-set(cloud_migration_files Main Daemon Test TestHostOnOff XVM)
-set(dht_chord_files Main ChordTask Common FindSuccessorAnswerTask FindSuccessorTask
+set(app-bittorrent_files Main Common Connection MessageTask Peer Tracker TrackerTask)
+set(app-centralizedmutex_files Main Coordinator GrantTask Node ReleaseTask RequestTask)
+set(app-masterworker_files Main Master Worker)
+set(app-pingpong_files Main PingPongTask Receiver Sender)
+set(app-tokenring_files Main RelayRunner)
+set(async-waitall_files Main Receiver Sender)
+set(async-yield_files Main Yielder)
+set(async-dsend_files Main Receiver Sender)
+set(cloud-masterworker_files Main Master Worker)
+set(cloud-migration_files Main Daemon Test TestHostOnOff XVM)
+set(dht-chord_files Main ChordTask Common FindSuccessorAnswerTask FindSuccessorTask
GetPredecessorAnswerTask GetPredecessorTask Node NotifyTask)
-set(dht_kademlia_files Main Answer Bucket Common Contact FindNodeAnswerTask FindNodeTask
+set(dht-kademlia_files Main Answer Bucket Common Contact FindNodeAnswerTask FindNodeTask
KademliaTask Node PingAnswerTask PingTask RoutingTable)
-set(trace_pingpong_files Main PingPongTask Receiver Sender)
-set(energy_consumption_files Main EnergyConsumer)
-set(energy_pstate_files Main PstateRunner)
-set(energy_vm_files Main EnergyVMRunner)
-set(io_file_files Main Node)
-set(io_storage_files Main Client)
-set(process_kill_files Main Killer Victim)
-set(process_migration_files Main Emigrant Policeman)
-set(process_startkilltime_files Main Sleeper)
-set(process_suspend_files Main DreamMaster LazyGuy)
-set(task_priority_files Main Test)
+set(trace-pingpong_files Main PingPongTask Receiver Sender)
+set(energy-consumption_files Main EnergyConsumer)
+set(energy-pstate_files Main PstateRunner)
+set(energy-vm_files Main EnergyVMRunner)
+set(io-file_files Main Node)
+set(io-storage_files Main Client)
+set(process-kill_files Main Killer Victim)
+set(process-migration_files Main Emigrant Policeman)
+set(process-startkilltime_files Main Sleeper)
+set(process-suspend_files Main DreamMaster LazyGuy)
+set(task-priority_files Main Test)
-foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong app_tokenring async_yield async_waitall async_dsend
- cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_pstate energy_vm io_file io_storage
- process_kill process_migration process_startkilltime process_suspend task_priority trace_pingpong)
- string (REPLACE "_" "/" example_dir ${example})
+foreach (example app-bittorrent app-centralizedmutex app-masterworker app-pingpong app-tokenring async-yield async-waitall async-dsend
+ cloud-migration cloud-masterworker dht-chord dht-kademlia energy-consumption energy-pstate energy-vm io-file io-storage
+ process-kill process-migration process-startkilltime process-suspend task-priority trace-pingpong)
+ string (REPLACE "-" "/" example_dir ${example})
set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/${example_dir})
foreach (filename ${${example}_files} )
set( ${example}_sources "${${example}_sources}" "${srcdir}/${filename}.java")
if(enable_java)
add_custom_command(
- COMMENT "Building java_${example}..."
- OUTPUT ${example_dir}/java_${example}_compiled
+ COMMENT "Building java-${example}..."
+ OUTPUT ${example_dir}/java-${example}_compiled
DEPENDS ${example_sources} simgrid-java_jar ${SIMGRID_JAR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${example_dir}
COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} -d ${CMAKE_CURRENT_BINARY_DIR} ${${example}_sources}
- COMMAND ${CMAKE_COMMAND} -E remove ${example_dir}/java_${example}_compiled
- COMMAND ${CMAKE_COMMAND} -E touch ${example_dir}/java_${example}_compiled
+ COMMAND ${CMAKE_COMMAND} -E remove ${example_dir}/java-${example}_compiled
+ COMMAND ${CMAKE_COMMAND} -E touch ${example_dir}/java-${example}_compiled
)
- add_custom_target(${example} ALL DEPENDS ${example_dir}/java_${example}_compiled)
+ add_custom_target(java-${example} ALL DEPENDS ${example_dir}/java-${example}_compiled)
endif()
set(examples_src ${examples_src} ${${example}_sources})
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example_dir}/${example}.tesh)
${CMAKE_CURRENT_SOURCE_DIR}/task/priority/priority.xml PARENT_SCOPE)
if(enable_java)
- foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong app_tokenring async_yield async_waitall async_dsend
- cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_pstate energy_vm io_file io_storage
- process_kill process_migration process_startkilltime process_suspend task_priority trace_pingpong)
- string (REPLACE "_" "/" example_dir ${example})
+ foreach (example app-bittorrent app-centralizedmutex app-masterworker app-pingpong app-tokenring async-yield async-waitall async-dsend
+ cloud-migration cloud-masterworker dht-chord dht-kademlia energy-consumption energy-pstate energy-vm io-file io-storage
+ process-kill process-migration process-startkilltime process-suspend task-priority trace-pingpong)
+ string (REPLACE "-" "/" example_dir ${example})
ADD_TESH(java-${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java/${example_dir} ${CMAKE_HOME_DIRECTORY}/examples/java/${example_dir}/${example}.tesh)
endforeach()
endif()
ADD_TESH(msg-trace-${x} --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/trace-${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/trace-${x} trace-${x}.tesh)
endforeach()
-ADD_TESH_FACTORIES(msg-dht-kademlia-parallel "thread;ucontext;raw" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO} --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/dht-kademlia --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/dht-kademlia dht-kademlia.tesh)
+ADD_TESH_FACTORIES(msg-dht-kademlia-parallel "thread;ucontext;raw;boost" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO} --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/dht-kademlia --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/dht-kademlia dht-kademlia.tesh)
ADD_TESH_FACTORIES(msg-energy-pstate-ptask "thread;ucontext;raw;boost" --cfg host/model:ptask_L07 --log xbt_cfg.threshold:critical --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-pstate/energy-pstate.tesh)
ADD_TESH_FACTORIES(msg-energy-consumption-ptask "thread;ucontext;raw;boost" --cfg host/model:ptask_L07 --log xbt_cfg.threshold:critical --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-consumption/energy-consumption.tesh)
-ADD_TESH_FACTORIES(msg-energy-ptask "thread;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-ptask/energy-ptask.tesh)
+ADD_TESH_FACTORIES(msg-energy-ptask "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-ptask/energy-ptask.tesh)
ADD_TESH_FACTORIES(msg-plugin-hostload "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/ ${CMAKE_HOME_DIRECTORY}/examples/msg/plugin-hostload/plugin-hostload.tesh)
if(NOT WIN32)
ADD_TESH_FACTORIES(msg-maestro-set "thread" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/maestro-set/maestro-set.tesh)
set(examples_src ${examples_src} PARENT_SCOPE)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent.tesh
- ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord.tesh
${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord.tesh
${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait.tesh
${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany.tesh
int main(int argc, char *argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file [action_files]\n"
"\t# if all actions are in the same file\n"
"\tExample: %s msg_platform.xml msg_deployment.xml ",
argv[0], argv[0], argv[0]);
- e->loadPlatform(argv[1]);
- e->registerDefault(&simgrid::xbt::replay_runner);
- e->registerFunction<Replayer>("p0");
- e->registerFunction<Replayer>("p1");
- e->loadDeployment(argv[2]);
+ e.loadPlatform(argv[1]);
+ e.registerDefault(&simgrid::xbt::replay_runner);
+ e.registerFunction<Replayer>("p0");
+ e.registerFunction<Replayer>("p1");
+ e.loadDeployment(argv[2]);
/* Action registration */
xbt_replay_action_register("compute", Replayer::compute);
simgrid::xbt::action_fs = new std::ifstream(argv[3], std::ifstream::in);
}
- e->run();
+ e.run();
if (argv[3]) {
delete simgrid::xbt::action_fs;
simgrid::xbt::action_fs = nullptr;
}
- XBT_INFO("Simulation time %g", e->getClock());
+ XBT_INFO("Simulation time %g", e.getClock());
- delete e;
return 0;
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc > 3, "Usage: %s platform_file deployment_file [action_files]\n"
"\texample: %s platform.xml deployment.xml actions # if all actions are in the same file\n"
"\texample: %s platform.xml deployment.xml",
argv[0], argv[0], argv[0]);
- e->loadPlatform(argv[1]);
- e->registerDefault(&simgrid::xbt::replay_runner);
- e->registerFunction<Replayer>("p0");
- e->loadDeployment(argv[2]);
+ e.loadPlatform(argv[1]);
+ e.registerDefault(&simgrid::xbt::replay_runner);
+ e.registerFunction<Replayer>("p0");
+ e.loadDeployment(argv[2]);
/* Action registration */
xbt_replay_action_register("open", Replayer::open);
simgrid::xbt::action_fs = new std::ifstream(argv[3], std::ifstream::in);
}
- e->run();
+ e.run();
if (argv[3]) {
delete simgrid::xbt::action_fs;
simgrid::xbt::action_fs = nullptr;
}
- XBT_INFO("Simulation time %g", e->getClock());
+ XBT_INFO("Simulation time %g", e.getClock());
- delete e;
return 0;
}
-/* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
int main(int argc, char** argv)
{
/* When your program starts, you have to first start a new simulation engine, as follows */
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
/* Then you should load a platform file, describing your simulated platform */
- e->loadPlatform("../../platforms/small_platform.xml");
+ e.loadPlatform("../../platforms/small_platform.xml");
/* And now you have to ask SimGrid to actually start your actors.
*
simgrid::s4u::Actor::createActor("sender1", simgrid::s4u::Host::by_name("Tremblay"), Sender());
/* The second way is to first register your function, and then retrieve it */
- e->registerFunction<Sender>("sender"); // The sender is passed as a template parameter here
+ e.registerFunction<Sender>("sender"); // The sender is passed as a template parameter here
std::vector<std::string> args; // Here we declare the parameter that the actor will get
args.push_back("GloubiBoulga"); // Add a parameter to the set (we could have done it in the first approach too)
simgrid::s4u::Actor::createActor("sender2", simgrid::s4u::Host::by_name("Jupiter"), "sender", args);
/* The third way to start your actors is to use a deployment file. */
- e->registerFunction<Receiver>("receiver"); // You first have to register the actor as with the second approach
- e->loadDeployment("s4u-actor-create_d.xml"); // And then, you load the deployment file
+ e.registerFunction<Receiver>("receiver"); // You first have to register the actor as with the second approach
+ e.loadDeployment("s4u-actor-create_d.xml"); // And then, you load the deployment file
/* Once every actors are started in the engine, the simulation can start */
- e->run();
+ e.run();
/* Once the simulation is done, the program is ended */
- delete e;
-
return 0;
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
- e->loadPlatform(argv[1]);
+ e.loadPlatform(argv[1]);
simgrid::s4u::Actor::createActor("worker", simgrid::s4u::Host::by_name("Boivin"), worker);
simgrid::s4u::Actor::createActor("daemon", simgrid::s4u::Host::by_name("Tremblay"), my_daemon);
- e->run();
-
- delete e;
+ e.run();
return 0;
}
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_kill, "Messages specific for this s4u example");
+static int on_exit(void*, void*)
+{
+ XBT_INFO("I have been killed!");
+ return 0;
+}
+
static void victim()
{
+ simgrid::s4u::this_actor::onExit(on_exit, nullptr);
XBT_INFO("Hello!");
XBT_INFO("Suspending myself");
simgrid::s4u::this_actor::suspend(); /* - Start by suspending itself */
simgrid::s4u::Actor::createActor("victim", simgrid::s4u::Host::by_name("Fafard"), victim);
simgrid::s4u::this_actor::sleep_for(10); /* - Wait for 10 seconds */
- XBT_INFO("Resume process"); /* - Resume it from its suspended state */
+ XBT_INFO("Resume the victim"); /* - Resume it from its suspended state */
poor_victim->resume();
+ simgrid::s4u::this_actor::sleep_for(2);
- XBT_INFO("Kill process"); /* - and then kill it */
+ XBT_INFO("Kill the victim"); /* - and then kill it */
poor_victim->kill();
+ simgrid::s4u::this_actor::sleep_for(1);
+
+ XBT_INFO("Killing everybody but myself");
+ simgrid::s4u::Actor::killAll();
XBT_INFO("OK, goodbye now. I commit a suicide.");
simgrid::s4u::this_actor::kill();
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
- e->loadPlatform(argv[1]); /* - Load the platform description */
+ e.loadPlatform(argv[1]); /* - Load the platform description */
/* - Create and deploy killer process, that will create the victim process */
simgrid::s4u::Actor::createActor("killer", simgrid::s4u::Host::by_name("Tremblay"), killer);
+ simgrid::s4u::Actor::createActor("Alice", simgrid::s4u::Host::by_name("Jupiter"), victim);
+ simgrid::s4u::Actor::createActor("Bob", simgrid::s4u::Host::by_name("Ginette"), victim);
+ simgrid::s4u::Actor::createActor("Carol", simgrid::s4u::Host::by_name("Bourassa"), victim);
+ simgrid::s4u::Actor::createActor("Dave", simgrid::s4u::Host::by_name("Boivin"), victim);
- e->run(); /* - Run the simulation */
+ e.run(); /* - Run the simulation */
- XBT_INFO("Simulation time %g", e->getClock());
+ XBT_INFO("Simulation time %g", e.getClock());
- delete e;
return 0;
}
$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-kill ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n"
> [ 0.000000] (killer@Tremblay) Hello!
+> [ 0.000000] (Alice@Jupiter) Hello!
+> [ 0.000000] (Alice@Jupiter) Suspending myself
+> [ 0.000000] (Bob@Ginette) Hello!
+> [ 0.000000] (Bob@Ginette) Suspending myself
+> [ 0.000000] (Carol@Bourassa) Hello!
+> [ 0.000000] (Carol@Bourassa) Suspending myself
+> [ 0.000000] (Dave@Boivin) Hello!
+> [ 0.000000] (Dave@Boivin) Suspending myself
> [ 0.000000] (victim@Fafard) Hello!
> [ 0.000000] (victim@Fafard) Suspending myself
-> [ 10.000000] (killer@Tremblay) Resume process
-> [ 10.000000] (killer@Tremblay) Kill process
-> [ 10.000000] (killer@Tremblay) OK, goodbye now. I commit a suicide.
-> [ 10.000000] (maestro@) Simulation time 10
+> [ 10.000000] (killer@Tremblay) Resume the victim
+> [ 10.000000] (victim@Fafard) OK, OK. Let's work
+> [ 12.000000] (killer@Tremblay) Kill the victim
+> [ 12.000000] (victim@Fafard) I have been killed!
+> [ 13.000000] (killer@Tremblay) Killing everybody but myself
+> [ 13.000000] (Alice@Jupiter) I have been killed!
+> [ 13.000000] (Bob@Ginette) I have been killed!
+> [ 13.000000] (Carol@Bourassa) I have been killed!
+> [ 13.000000] (Dave@Boivin) I have been killed!
+> [ 13.000000] (killer@Tremblay) OK, goodbye now. I commit a suicide.
+> [ 13.000000] (maestro@) Simulation time 13
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
- e->loadPlatform(argv[1]); /* - Load the platform description */
+ e.loadPlatform(argv[1]); /* - Load the platform description */
/* - Create and deploy the emigrant and policeman processes */
simgrid::s4u::Actor::createActor("emigrant", simgrid::s4u::Host::by_name("Jacquelin"), emigrant);
checkpoint = simgrid::s4u::Mutex::createMutex(); /* - Initiate the mutex and conditions */
identification = simgrid::s4u::ConditionVariable::createConditionVariable();
- e->run();
+ e.run();
- XBT_INFO("Simulation time %g", e->getClock());
+ XBT_INFO("Simulation time %g", e.getClock());
- delete e;
return 0;
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
- e->loadPlatform(argv[1]); /* - Load the platform description */
+ e.loadPlatform(argv[1]); /* - Load the platform description */
std::vector<simgrid::s4u::Host*> list;
- e->getHostList(&list);
+ e.getHostList(&list);
simgrid::s4u::Actor::createActor("dream_master", list.front(), dream_master);
- e->run(); /* - Run the simulation */
+ e.run(); /* - Run the simulation */
- delete e;
return 0;
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
/* Check the arguments */
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file", argv[0]);
- e->loadPlatform(argv[1]);
+ e.loadPlatform(argv[1]);
HostBittorrent::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostBittorrent>();
for (auto const& host : list)
host->extension_set(new HostBittorrent(host));
- e->registerFunction<Tracker>("tracker");
- e->registerFunction<Peer>("peer");
- e->loadDeployment(argv[2]);
+ e.registerFunction<Tracker>("tracker");
+ e.registerFunction<Peer>("peer");
+ e.loadDeployment(argv[2]);
- e->run();
+ e.run();
- delete e;
return 0;
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
"\tExample: %s msg_platform.xml msg_deployment.xml\n",
argv[0], argv[0]);
- e->loadPlatform(argv[1]); /** - Load the platform description */
- e->registerFunction<Master>("master");
- e->registerFunction<Worker>("worker"); /** - Register the function to be executed by the processes */
- e->loadDeployment(argv[2]); /** - Deploy the application */
+ e.loadPlatform(argv[1]); /** - Load the platform description */
+ e.registerFunction<Master>("master");
+ e.registerFunction<Worker>("worker"); /** - Register the function to be executed by the processes */
+ e.loadDeployment(argv[2]); /** - Deploy the application */
- e->run(); /** - Run the simulation */
+ e.run(); /** - Run the simulation */
- XBT_INFO("Simulation time %g", e->getClock());
+ XBT_INFO("Simulation time %g", e.getClock());
- delete e;
return 0;
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
- e->loadPlatform(argv[1]);
+ e.loadPlatform(argv[1]);
std::vector<std::string> args;
args.push_back("Jupiter");
simgrid::s4u::Actor::createActor("pinger", simgrid::s4u::Host::by_name("Tremblay"), pinger, args);
simgrid::s4u::Actor::createActor("ponger", simgrid::s4u::Host::by_name("Jupiter"), ponger, args);
- e->run();
+ e.run();
- XBT_INFO("Total simulation time: %.3f", e->getClock());
- delete e;
+ XBT_INFO("Total simulation time: %.3f", e.getClock());
return 0;
}
int main(int argc, char** argv)
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]);
- e->loadPlatform(argv[1]);
+ e.loadPlatform(argv[1]);
- XBT_INFO("Number of hosts '%zu'", e->getHostCount());
+ XBT_INFO("Number of hosts '%zu'", e.getHostCount());
int id = 0;
std::vector<simgrid::s4u::Host*> list;
- e->getHostList(&list);
+ e.getHostList(&list);
for (auto const& host : list) {
/* - Give a unique rank to each host and create a @ref relay_runner process on each */
simgrid::s4u::Actor::createActor((std::to_string(id)).c_str(), host, RelayRunner());
id++;
}
- e->run();
- XBT_INFO("Simulation time %g", e->getClock());
+ e.run();
+ XBT_INFO("Simulation time %g", e.getClock());
- delete e;
return 0;
}
int main(int argc, char *argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
-
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
- e->registerFunction<sender>("sender");
- e->registerFunction<receiver>("receiver");
+ simgrid::s4u::Engine e(&argc, argv);
+ e.registerFunction<sender>("sender");
+ e.registerFunction<receiver>("receiver");
- e->loadPlatform(argv[1]);
- e->loadDeployment(argv[2]);
- e->run();
+ e.loadPlatform(argv[1]);
+ e.loadDeployment(argv[2]);
+ e.run();
return 0;
}
int main(int argc, char *argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
-
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
- e->registerFunction<sender>("sender");
- e->registerFunction<receiver>("receiver");
+ simgrid::s4u::Engine e(&argc, argv);
+ e.registerFunction<sender>("sender");
+ e.registerFunction<receiver>("receiver");
- e->loadPlatform(argv[1]);
- e->loadDeployment(argv[2]);
- e->run();
+ e.loadPlatform(argv[1]);
+ e.loadDeployment(argv[2]);
+ e.run();
return 0;
}
return i <= e;
}
+void ChordMessage::destroy(void* message)
+{
+ delete static_cast<ChordMessage*>(message);
+}
+
/* Initializes the current node as the first one of the system */
Node::Node(std::vector<std::string> args)
{
// send a "Notify" request to notify_id
XBT_DEBUG("Sending a 'Notify' request to %d", notify_id);
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(notify_id));
- mailbox->put_init(message, 10)->detach();
+ mailbox->put_init(message, 10)->detach(ChordMessage::destroy);
}
/* This function is called periodically. It checks the immediate successor of the current node. */
XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d",
message->issuer_host_name.c_str(), message->answer_to->getName(), message->request_id,
message->answer_id);
- message->answer_to->put_init(message, 10)->detach();
+ message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
} else {
// otherwise, forward the request to the closest preceding finger in my table
int closest = closestPrecedingFinger(message->request_id);
XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
message->request_id, closest);
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(closest));
- mailbox->put_init(message, 10)->detach();
+ mailbox->put_init(message, 10)->detach(ChordMessage::destroy);
}
break;
message->answer_id = pred_id_;
XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d",
message->issuer_host_name.c_str(), message->answer_to->getName(), message->answer_id);
- message->answer_to->put_init(message, 10)->detach();
+ message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
break;
case NOTIFY:
message->type = PREDECESSOR_ALIVE_ANSWER;
XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)", message->issuer_host_name.c_str(),
message->answer_to->getName());
- message->answer_to->put_init(message, 10)->detach();
+ message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
break;
default:
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc > 2, "Usage: %s [-nb_bits=n] [-timeout=t] platform_file deployment_file\n"
"\tExample: %s ../msg_platform.xml chord.xml\n",
argv[0], argv[0]);
options++;
}
- e->loadPlatform(options[0]);
+ e.loadPlatform(options[0]);
chord_init();
- e->registerFunction<Node>("node");
- e->loadDeployment(options[1]);
+ e.registerFunction<Node>("node");
+ e.loadDeployment(options[1]);
- e->run();
+ e.run();
- XBT_INFO("Simulated time: %g", e->getClock());
+ XBT_INFO("Simulated time: %g", e.getClock());
chord_exit();
- delete e;
return 0;
}
}
~ChordMessage() = default;
+
+ static void destroy(void* message);
};
class Node {
public:
explicit Node(std::vector<std::string> args);
+ Node(const Node&) = delete;
~Node();
void join(int known_id);
void leave();
}
now = simgrid::s4u::Engine::getClock();
}
- if (data != nullptr) {
- delete static_cast<ChordMessage*>(data);
+ if (comm_receive != nullptr) {
+ if (comm_receive->test())
+ delete static_cast<ChordMessage*>(data);
+ else
+ comm_receive->cancel();
}
// leave the ring
leave();
> [ 360.18115] (node@node-0.acme.org) Predecessor: 533744
> [ 420.23459] (node@node-2.acme.org) Well Guys! I Think it's time for me to leave ;)
> [ 425.22668] (node@node-0.acme.org) My new predecessor is 42
-> [ 475.23449] (node@node-0.acme.org) My new finger #0 is 42
-> [ 480.23439] (node@node-0.acme.org) My new predecessor is 16728096
-> [ 480.23439] (node@node-0.acme.org) My finger table:
-> [ 480.23439] (node@node-0.acme.org) Start | Succ
-> [ 480.23439] (node@node-0.acme.org) 3 | 42
-> [ 480.23439] (node@node-0.acme.org) 4 | 16509405
-> [ 480.23439] (node@node-0.acme.org) 6 | 533744
-> [ 480.23439] (node@node-0.acme.org) Predecessor: 16728096
-> [ 485.24209] (node@node-6.acme.org) My new finger #2 is 42
-> [ 485.24209] (node@node-6.acme.org) My finger table:
-> [ 485.24209] (node@node-6.acme.org) Start | Succ
-> [ 485.24209] (node@node-6.acme.org) 1 | 42
-> [ 485.24209] (node@node-6.acme.org) 2 | 42
-> [ 485.24209] (node@node-6.acme.org) 4 | 42
-> [ 485.24209] (node@node-6.acme.org) Predecessor: -1
-> [ 495.24970] (node@node-0.acme.org) My new finger #0 is 16728096
-> [ 575.26471] (node@node-6.acme.org) My new predecessor is 42
-> [ 575.26471] (node@node-6.acme.org) My finger table:
-> [ 575.26471] (node@node-6.acme.org) Start | Succ
-> [ 575.26471] (node@node-6.acme.org) 1 | 42
-> [ 575.26471] (node@node-6.acme.org) 2 | 42
-> [ 575.26471] (node@node-6.acme.org) 4 | 42
-> [ 575.26471] (node@node-6.acme.org) Predecessor: 42
-> [ 600.27202] (node@node-0.acme.org) My new finger #1 is 16728096
-> [ 600.27202] (node@node-0.acme.org) My finger table:
-> [ 600.27202] (node@node-0.acme.org) Start | Succ
-> [ 600.27202] (node@node-0.acme.org) 3 | 16728096
-> [ 600.27202] (node@node-0.acme.org) 4 | 16728096
-> [ 600.27202] (node@node-0.acme.org) 6 | 533744
-> [ 600.27202] (node@node-0.acme.org) Predecessor: 16728096
-> [ 720.36329] (node@node-0.acme.org) My new finger #2 is 16728096
-> [ 720.36329] (node@node-0.acme.org) My finger table:
-> [ 720.36329] (node@node-0.acme.org) Start | Succ
-> [ 720.36329] (node@node-0.acme.org) 3 | 16728096
-> [ 720.36329] (node@node-0.acme.org) 4 | 16728096
-> [ 720.36329] (node@node-0.acme.org) 6 | 16728096
-> [ 720.36329] (node@node-0.acme.org) Predecessor: 16728096
-> [ 855.46207] (node@node-6.acme.org) My new finger #2 is 16728096
-> [ 855.46207] (node@node-6.acme.org) My finger table:
-> [ 855.46207] (node@node-6.acme.org) Start | Succ
-> [ 855.46207] (node@node-6.acme.org) 1 | 42
-> [ 855.46207] (node@node-6.acme.org) 2 | 42
-> [ 855.46207] (node@node-6.acme.org) 4 | 16728096
-> [ 855.46207] (node@node-6.acme.org) Predecessor: 42
-> [ 860.46197] (node@node-6.acme.org) Well Guys! I Think it's time for me to leave ;)
-> [ 865.45406] (node@node-0.acme.org) My new predecessor is 42
-> [ 890.43115] (node@node-5.acme.org) Well Guys! I Think it's time for me to leave ;)
-> [ 915.45406] (node@node-0.acme.org) My new finger #0 is 42
-> [ 940.45356] (node@node-0.acme.org) My new finger #0 is 16509405
-> [ 990.45356] (node@node-0.acme.org) My new finger #1 is 16509405
-> [ 990.45356] (node@node-0.acme.org) My finger table:
-> [ 990.45356] (node@node-0.acme.org) Start | Succ
-> [ 990.45356] (node@node-0.acme.org) 3 | 16509405
-> [ 990.45356] (node@node-0.acme.org) 4 | 16509405
-> [ 990.45356] (node@node-0.acme.org) 6 | 16728096
-> [ 990.45356] (node@node-0.acme.org) Predecessor: 42
-> [1040.45356] (node@node-0.acme.org) Well Guys! I Think it's time for me to leave ;)
-> [1090.45356] (maestro@) Simulated time: 1090.45
+> [ 475.22668] (node@node-0.acme.org) My new finger #0 is 42
+> [ 480.22658] (node@node-0.acme.org) My new predecessor is 16728096
+> [ 480.22658] (node@node-0.acme.org) My finger table:
+> [ 480.22658] (node@node-0.acme.org) Start | Succ
+> [ 480.22658] (node@node-0.acme.org) 3 | 42
+> [ 480.22658] (node@node-0.acme.org) 4 | 16509405
+> [ 480.22658] (node@node-0.acme.org) 6 | 533744
+> [ 480.22658] (node@node-0.acme.org) Predecessor: 16728096
+> [ 485.23429] (node@node-6.acme.org) My new finger #2 is 42
+> [ 485.23429] (node@node-6.acme.org) My finger table:
+> [ 485.23429] (node@node-6.acme.org) Start | Succ
+> [ 485.23429] (node@node-6.acme.org) 1 | 42
+> [ 485.23429] (node@node-6.acme.org) 2 | 42
+> [ 485.23429] (node@node-6.acme.org) 4 | 42
+> [ 485.23429] (node@node-6.acme.org) Predecessor: -1
+> [ 495.24189] (node@node-0.acme.org) My new finger #0 is 16728096
+> [ 575.25691] (node@node-6.acme.org) My new predecessor is 42
+> [ 575.25691] (node@node-6.acme.org) My finger table:
+> [ 575.25691] (node@node-6.acme.org) Start | Succ
+> [ 575.25691] (node@node-6.acme.org) 1 | 42
+> [ 575.25691] (node@node-6.acme.org) 2 | 42
+> [ 575.25691] (node@node-6.acme.org) 4 | 42
+> [ 575.25691] (node@node-6.acme.org) Predecessor: 42
+> [ 600.26421] (node@node-0.acme.org) My new finger #1 is 16728096
+> [ 600.26421] (node@node-0.acme.org) My finger table:
+> [ 600.26421] (node@node-0.acme.org) Start | Succ
+> [ 600.26421] (node@node-0.acme.org) 3 | 16728096
+> [ 600.26421] (node@node-0.acme.org) 4 | 16728096
+> [ 600.26421] (node@node-0.acme.org) 6 | 533744
+> [ 600.26421] (node@node-0.acme.org) Predecessor: 16728096
+> [ 720.35548] (node@node-0.acme.org) My new finger #2 is 16728096
+> [ 720.35548] (node@node-0.acme.org) My finger table:
+> [ 720.35548] (node@node-0.acme.org) Start | Succ
+> [ 720.35548] (node@node-0.acme.org) 3 | 16728096
+> [ 720.35548] (node@node-0.acme.org) 4 | 16728096
+> [ 720.35548] (node@node-0.acme.org) 6 | 16728096
+> [ 720.35548] (node@node-0.acme.org) Predecessor: 16728096
+> [ 855.45426] (node@node-6.acme.org) My new finger #2 is 16728096
+> [ 855.45426] (node@node-6.acme.org) My finger table:
+> [ 855.45426] (node@node-6.acme.org) Start | Succ
+> [ 855.45426] (node@node-6.acme.org) 1 | 42
+> [ 855.45426] (node@node-6.acme.org) 2 | 42
+> [ 855.45426] (node@node-6.acme.org) 4 | 16728096
+> [ 855.45426] (node@node-6.acme.org) Predecessor: 42
+> [ 860.45416] (node@node-6.acme.org) Well Guys! I Think it's time for me to leave ;)
+> [ 865.44626] (node@node-0.acme.org) My new predecessor is 42
+> [ 890.42334] (node@node-5.acme.org) Well Guys! I Think it's time for me to leave ;)
+> [ 915.44626] (node@node-0.acme.org) My new finger #0 is 42
+> [ 940.44576] (node@node-0.acme.org) My new finger #0 is 16509405
+> [ 990.44576] (node@node-0.acme.org) My new finger #1 is 16509405
+> [ 990.44576] (node@node-0.acme.org) My finger table:
+> [ 990.44576] (node@node-0.acme.org) Start | Succ
+> [ 990.44576] (node@node-0.acme.org) 3 | 16509405
+> [ 990.44576] (node@node-0.acme.org) 4 | 16509405
+> [ 990.44576] (node@node-0.acme.org) 6 | 16728096
+> [ 990.44576] (node@node-0.acme.org) Predecessor: 42
+> [1040.44576] (node@node-0.acme.org) Well Guys! I Think it's time for me to leave ;)
+> [1090.44576] (maestro@) Simulated time: 1090.45
int main(int argc, char **argv)
{
- simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv);
- e->loadPlatform("../../platforms/storage/storage.xml");
+ simgrid::s4u::Engine e(&argc, argv);
+ e.loadPlatform("../../platforms/storage/storage.xml");
simgrid::s4u::Actor::createActor("host", simgrid::s4u::Host::by_name("denise"), MyHost());
- e->run();
- delete e;
+ e.run();
+
return 0;
}
int main(int argc, char **argv)
{
- simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv);
- e->loadPlatform("../../platforms/two_hosts.xml");
+ simgrid::s4u::Engine e(&argc, argv);
+ e.loadPlatform("../../platforms/two_hosts.xml");
simgrid::s4u::Actor::createActor("main", simgrid::s4u::Host::by_name("Tremblay"), master);
- e->run();
+ e.run();
- delete e;
return 0;
}
-/* Copyright (c) 2007-2010, 2013-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
int main(int argc, char* argv[])
{
sg_host_load_plugin_init();
- simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
- e->loadPlatform(argv[1]);
+ e.loadPlatform(argv[1]);
simgrid::s4u::Actor::createActor("load_test", simgrid::s4u::Host::by_name("MyHost1"), execute_load_test);
- e->run();
+ e.run();
XBT_INFO("Total simulation time: %.2f", simgrid::s4u::Engine::getClock());
- delete e;
return 0;
}
/** Start the comm, and ignore its result. It can be completely forgotten after that. */
void detach();
+ /** Start the comm, and ignore its result. It can be completely forgotten after that. */
+ void detach(void (*cleanFunction)(void*))
+ {
+ cleanFunction_ = cleanFunction;
+ detach();
+ }
/** Sets the maximal communication rate (in byte/sec). Must be done before start */
void setRate(double rate);
void routeTo(Host * dest, std::vector<Link*> * links, double* latency);
void routeTo(Host * dest, std::vector<surf::LinkImpl*> * links, double* latency);
+ /** Block the calling actor on an execution located on the called host
+ *
+ * It is not a problem if the actor is not located on the called host.
+ * The actor will not be migrated in this case. Such remote execution are easy in simulation.
+ */
+ void execute(double flops);
+
private:
simgrid::xbt::string name_ = "noname";
std::unordered_map<std::string, Storage*>* mounts = nullptr; // caching
/* Process creation/destruction callbacks */
typedef void (*void_pfn_smxprocess_t) (smx_actor_t);
-extern int smx_context_stack_size;
+extern unsigned smx_context_stack_size;
extern int smx_context_stack_size_was_set;
-extern int smx_context_guard_size;
+extern unsigned smx_context_guard_size;
extern int smx_context_guard_size_was_set;
SG_BEGIN_DECL()
-/* Copyright (c) 2004-2007, 2009-2011, 2013-2015. The SimGrid Team.
+/* Copyright (c) 2004-2007, 2009-2011, 2013-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
XBT_PUBLIC(void) xbt_heap_push(xbt_heap_t H, void *content, double key);
XBT_PUBLIC(void *) xbt_heap_pop(xbt_heap_t H);
-XBT_PUBLIC(void) xbt_heap_rm_elm(xbt_heap_t H, void *content, double key);
+XBT_PUBLIC(void *) xbt_heap_rm_elm(xbt_heap_t H, void *content, double key);
XBT_PUBLIC(double) xbt_heap_maxkey(xbt_heap_t H);
XBT_PUBLIC(void *) xbt_heap_maxcontent(xbt_heap_t H);
# Disable some rules on some files
-sonar.issue.ignore.multicriteria=j1,j2,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5a,c5b,f1
+sonar.issue.ignore.multicriteria=j1,j2,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5a,c5b,c6a,c6b,f1
# The Object.finalize() method should not be overriden
# But we need to clean the native memory with JNI
sonar.issue.ignore.multicriteria.c5b.ruleKey=cpp:S3659
sonar.issue.ignore.multicriteria.c5b.resourceKey=**/*.hpp
+# Dynamically allocated memory should be released
+# We have better ways to detect memleaks in SimGrid
+# This is not disabled in example/ because our code should be nice looking
+sonar.issue.ignore.multicriteria.c6a.ruleKey=cpp:S3584
+sonar.issue.ignore.multicriteria.c6a.resourceKey=src/**/*.cpp
+sonar.issue.ignore.multicriteria.c6a.ruleKey=cpp:S3584
+sonar.issue.ignore.multicriteria.c6a.resourceKey=teshsuite/**/*.cpp
# "reinterpret_cast" should not be used
# But we need this to interface C and Fortran
# Files to ignore from coverage analysis:
# - foreign test suites
# - platform files (I fail to get sonar ignore *.xml files)
-sonar.coverage.exclusions=teshsuite/smpi/isp/**,teshsuite/smpi/mpich3-test/**,examples/platforms/**
+# - Java code and examples
+sonar.coverage.exclusions=teshsuite/smpi/isp/**,teshsuite/smpi/mpich3-test/**,examples/platforms/**,src/bindings/java/**,examples/java/**
# Encoding of the source files
sonar.sourceEncoding=UTF-8
/* destroy all data structures of tracing (and free) */
PJ_container_free_all();
- recursiveDestroyType (PJ_type_get_root());
- PJ_container_release();
+ delete PJ_type_get_root();
rootType = nullptr;
/* close the trace files */
if (not mark_value)
THROWF (tracing_error, 1, "mark_value is nullptr");
- simgrid::instr::Type* type = PJ_type_get(mark_type, PJ_type_get_root());
+ simgrid::instr::Type* type = PJ_type_get_root()->getChild(mark_type);
if (not type) {
THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
}
mark_color = white;
XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color);
- simgrid::instr::Value rett(mark_value, mark_color, type);
+ new simgrid::instr::Value(mark_value, mark_color, type);
}
/** \ingroup TRACE_mark
THROWF (tracing_error, 1, "mark_value is nullptr");
//check if mark_type is already declared
- simgrid::instr::Type* type = PJ_type_get(mark_type, PJ_type_get_root());
+ simgrid::instr::Type* type = PJ_type_get_root()->getChild(mark_type);
if (not type) {
THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
}
char valuestr[100];
snprintf(valuestr, 100, "%g", value);
container_t container = PJ_container_get(resource);
- simgrid::instr::Type* type = PJ_type_get(variable, container->type_);
+ simgrid::instr::Type* type = container->type_->getChild(variable);
switch (what){
case INSTR_US_SET:
new simgrid::instr::SetVariableEvent(time, container, type, value);
void TRACE_host_set_state(const char* host, const char* state, const char* value_str)
{
container_t container = PJ_container_get(host);
- simgrid::instr::Type* type = PJ_type_get(state, container->type_);
+ simgrid::instr::Type* type = container->type_->getChild(state);
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(
value_str, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */
new simgrid::instr::SetStateEvent(MSG_get_clock(), container, type, val);
void TRACE_host_push_state(const char* host, const char* state, const char* value_str)
{
container_t container = PJ_container_get(host);
- simgrid::instr::Type* type = PJ_type_get(state, container->type_);
+ simgrid::instr::Type* type = container->type_->getChild(state);
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(
value_str, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */
new simgrid::instr::PushStateEvent(MSG_get_clock(), container, type, val);
void TRACE_host_pop_state (const char *host, const char *state)
{
container_t container = PJ_container_get(host);
- simgrid::instr::Type* type = PJ_type_get(state, container->type_);
+ simgrid::instr::Type* type = container->type_->getChild(state);
new simgrid::instr::PopStateEvent(MSG_get_clock(), container, type);
}
#include "src/instr/instr_private.h"
+#include <unordered_map>
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_containers, instr, "Paje tracing event system (containers)");
static container_t rootContainer = nullptr; /* the root container */
-static xbt_dict_t allContainers = nullptr; /* all created containers indexed by name */
+static std::unordered_map<std::string, simgrid::instr::Container*>
+ allContainers; /* all created containers indexed by name */
std::set<std::string> trivaNodeTypes; /* all host types defined */
std::set<std::string> trivaEdgeTypes; /* all link types defined */
return type_id++;
}
-void PJ_container_alloc ()
-{
- allContainers = xbt_dict_new_homogeneous(nullptr);
-}
-
-void PJ_container_release ()
-{
- xbt_dict_free (&allContainers);
-}
-
void PJ_container_set_root (container_t root)
{
rootContainer = root;
char as_typename[INSTR_DEFAULT_STR_SIZE];
snprintf(as_typename, INSTR_DEFAULT_STR_SIZE, "L%d", this->level_);
if (this->father_) {
- this->type_ = simgrid::instr::Type::getOrNull(as_typename, this->father_->type_);
+ this->type_ = this->father_->type_->getChildOrNull(as_typename);
if (this->type_ == nullptr) {
this->type_ = simgrid::instr::Type::containerNew(as_typename, this->father_->type_);
}
THROWF (tracing_error, 0, "new container kind is unknown.");
break;
}
- simgrid::instr::Type* type = simgrid::instr::Type::getOrNull(typeNameBuff, this->father_->type_);
+ simgrid::instr::Type* type = this->father_->type_->getChildOrNull(typeNameBuff);
if (type == nullptr){
this->type_ = simgrid::instr::Type::containerNew(typeNameBuff, this->father_->type_);
}else{
}
//register all kinds by name
- if (xbt_dict_get_or_null(allContainers, this->name_) != nullptr) {
+ if (not allContainers.emplace(this->name_, this).second) {
THROWF(tracing_error, 1, "container %s already present in allContainers data structure", this->name_);
}
- xbt_dict_set(allContainers, this->name_, this, nullptr);
XBT_DEBUG("Add container name '%s'", this->name_);
//register NODE types for triva configuration
}
// remove it from allContainers data structure
- xbt_dict_remove(allContainers, name_);
+ allContainers.erase(name_);
// free
xbt_free(name_);
xbt_dict_free(&children_);
}
-container_t PJ_container_get (const char *name)
+simgrid::instr::Container* PJ_container_get(const char* name)
{
container_t ret = PJ_container_get_or_null (name);
if (ret == nullptr){
return ret;
}
-container_t PJ_container_get_or_null (const char *name)
+simgrid::instr::Container* PJ_container_get_or_null(const char* name)
{
- return static_cast<container_t>(name != nullptr ? xbt_dict_get_or_null(allContainers, name) : nullptr);
+ auto cont = allContainers.find(name);
+ return cont == allContainers.end() ? nullptr : cont->second;
}
-container_t PJ_container_get_root ()
+simgrid::instr::Container* PJ_container_get_root()
{
return rootContainer;
}
rootContainer = nullptr;
//checks
- if (not xbt_dict_is_empty(allContainers)) {
+ if (not allContainers.empty()) {
THROWF(tracing_error, 0, "some containers still present even after destroying all of them");
}
}
}
}
-simgrid::instr::StartLinkEvent::~StartLinkEvent()
-{
- free(value);
- free(key);
-}
simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
container_t sourceContainer, const char* value, const char* key)
: StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1)
simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type,
container_t sourceContainer, const char* value, const char* key,
int size)
+ : container_(container)
+ , type_(type)
+ , sourceContainer_(sourceContainer)
+ , value_(value)
+ , key_(key)
+ , size_(size)
{
eventType_ = PAJE_StartLink;
this->timestamp_ = timestamp;
- this->type = type;
- this->container = container;
- this->sourceContainer = sourceContainer;
- this->value = xbt_strdup(value);
- this->key = xbt_strdup(key);
- this->size = size;
- XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__, (int)eventType_, this->timestamp_, this->value);
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__, (int)eventType_, this->timestamp_, this->value_.c_str());
insert_into_buffer (this);
}
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_ << " " << value;
- stream << " " << sourceContainer->id_ << " " << key;
+ stream << " " << type_->id_ << " " << container_->id_ << " " << value_;
+ stream << " " << sourceContainer_->id_ << " " << key_;
if (TRACE_display_sizes()) {
- stream << " " << size;
+ stream << " " << size_;
}
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
static simgrid::instr::Type* rootType = nullptr; /* the root type */
-void PJ_type_release ()
-{
- rootType = nullptr;
-}
-
simgrid::instr::Type* PJ_type_get_root()
{
return rootType;
this->values_ = xbt_dict_new_homogeneous(nullptr);
this->color_ = xbt_strdup(color);
- char str_id[INSTR_DEFAULT_STR_SIZE];
- snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
- this->id_ = xbt_strdup(str_id);
+ this->id_ = bprintf("%lld", instr_new_paje_id());
if (father != nullptr){
xbt_dict_set(father->children_, key, this, nullptr);
}
}
-void PJ_type_free(simgrid::instr::Type* type)
+simgrid::instr::Type::~Type()
{
simgrid::instr::Value* val;
char *value_name;
xbt_dict_cursor_t cursor = nullptr;
- xbt_dict_foreach (type->values_, cursor, value_name, val) {
+ xbt_dict_foreach (values_, cursor, value_name, val) {
XBT_DEBUG("free value %s, child of %s", val->name_, val->father_->name_);
- xbt_free(val);
+ delete val;
}
- xbt_dict_free(&type->values_);
- xbt_free(type->name_);
- xbt_free(type->id_);
- xbt_free(type->color_);
- xbt_dict_free(&type->children_);
- delete type;
-}
-
-void recursiveDestroyType(simgrid::instr::Type* type)
-{
- XBT_DEBUG("recursiveDestroyType %s", type->name_);
- xbt_dict_cursor_t cursor = nullptr;
+ xbt_dict_free(&values_);
simgrid::instr::Type* child;
char *child_name;
- xbt_dict_foreach (type->children_, cursor, child_name, child) {
- recursiveDestroyType (child);
+ xbt_dict_foreach (children_, cursor, child_name, child) {
+ delete child;
}
- PJ_type_free(type);
+ xbt_dict_free(&children_);
+ xbt_free(name_);
+ xbt_free(id_);
+ xbt_free(color_);
}
-simgrid::instr::Type* PJ_type_get(const char* name, simgrid::instr::Type* father)
+simgrid::instr::Type* simgrid::instr::Type::getChild(const char* name)
{
- simgrid::instr::Type* ret = simgrid::instr::Type::getOrNull(name, father);
- if (ret == nullptr){
- THROWF(tracing_error, 2, "type with name (%s) not found in father type (%s)", name, father->name_);
- }
+ simgrid::instr::Type* ret = this->getChildOrNull(name);
+ if (ret == nullptr)
+ THROWF(tracing_error, 2, "type with name (%s) not found in father type (%s)", name, this->name_);
return ret;
}
-simgrid::instr::Type* simgrid::instr::Type::getOrNull(const char* name, simgrid::instr::Type* father)
+simgrid::instr::Type* simgrid::instr::Type::getChildOrNull(const char* name)
{
- if (name == nullptr || father == nullptr){
- THROWF (tracing_error, 0, "can't get type with a nullptr name or from a nullptr father");
- }
+ xbt_assert(name != nullptr, "can't get type with a nullptr name");
simgrid::instr::Type* ret = nullptr;
simgrid::instr::Type* child;
char *child_name;
xbt_dict_cursor_t cursor = nullptr;
- xbt_dict_foreach (father->children_, cursor, child_name, child) {
+ xbt_dict_foreach (children_, cursor, child_name, child) {
if (strcmp(child->name_, name) == 0) {
- if (ret != nullptr){
+ if (ret != nullptr) {
THROWF (tracing_error, 0, "there are two children types with the same name?");
- }else{
+ } else {
ret = child;
}
}
if (name == nullptr || father == nullptr){
THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)");
}
- this->ret_ = xbt_new0(Value, 1);
- this->ret_->name_ = xbt_strdup(name);
- this->ret_->father_ = father;
- this->ret_->color_ = xbt_strdup(color);
+ this->name_ = xbt_strdup(name);
+ this->father_ = father;
+ this->color_ = xbt_strdup(color);
- char str_id[INSTR_DEFAULT_STR_SIZE];
- snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
- this->ret_->id_ = xbt_strdup(str_id);
+ this->id_ = bprintf("%lld", instr_new_paje_id());
- xbt_dict_set(father->values_, name, ret_, nullptr);
- XBT_DEBUG("new value %s, child of %s", ret_->name_, ret_->father_->name_);
- LogEntityValue(this->ret_);
+ xbt_dict_set(father->values_, name, this, nullptr);
+ XBT_DEBUG("new value %s, child of %s", name_, father_->name_);
+ LogEntityValue(this);
};
simgrid::instr::Value::~Value()
{
- /* FIXME: this should be cleanable
- xbt_free(name);
- xbt_free(color);
- xbt_free(id);
- */
+ xbt_free(name_);
+ xbt_free(color_);
+ xbt_free(id_);
}
simgrid::instr::Value* simgrid::instr::Value::get_or_new(const char* name, const char* color,
ret = Value::get(name, father);
}
catch(xbt_ex& e) {
- Value rett(name, color, father);
- ret = rett.ret_;
+ ret = new Value(name, color, father);
}
return ret;
}
#include "simgrid_config.h"
#include "src/internal_config.h"
#include <set>
+#include <string>
/* Need to define function drand48 for Windows */
/* FIXME: use _drand48() defined in src/surf/random_mgr.c instead */
xbt_dict_t children_;
xbt_dict_t values_; // valid for all types except variable and container
Type(const char* typeNameBuff, const char* key, const char* color, e_entity_types kind, Type* father);
- static Type* getOrNull(const char* name, Type* father);
+ ~Type();
+ Type* getChild(const char* name);
+ Type* getChildOrNull(const char* name);
+
static Type* containerNew(const char* name, Type* father);
static Type* eventNew(const char* name, Type* father);
static Type* variableNew(const char* name, const char* color, Type* father);
char* color_;
Type* father_;
- Value* ret_;
Value(const char* name, const char* color, Type* father);
~Value();
static Value* get_or_new(const char* name, const char* color, Type* father);
};
class StartLinkEvent : public PajeEvent {
- public:
- Container* container;
- Type* type;
- Container* sourceContainer;
- char* value;
- char* key;
- int size;
+ Container* container_;
+ Type* type_;
+ Container* sourceContainer_;
+ std::string value_;
+ std::string key_;
+ int size_;
- public:
- ~StartLinkEvent();
- StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, const char* value,
- const char* key);
- StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, const char* value,
- const char* key, int size);
- void print() override;
+public:
+ StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, const char* value,
+ const char* key);
+ StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, const char* value,
+ const char* key, int size);
+ void print() override;
};
class EndLinkEvent : public PajeEvent {
extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
XBT_PRIVATE long long int instr_new_paje_id ();
-XBT_PRIVATE void PJ_container_alloc ();
-XBT_PRIVATE void PJ_container_release ();
XBT_PUBLIC(container_t) PJ_container_get (const char *name);
-XBT_PUBLIC(container_t) PJ_container_get_or_null (const char *name);
+XBT_PUBLIC(simgrid::instr::Container*) PJ_container_get_or_null(const char* name);
XBT_PUBLIC(container_t) PJ_container_get_root ();
XBT_PUBLIC(void) PJ_container_set_root (container_t root);
XBT_PUBLIC(void) PJ_container_free_all (void);
XBT_PUBLIC(void) PJ_container_remove_from_parent (container_t container);
/* instr_paje_types.c */
-XBT_PRIVATE void PJ_type_release ();
XBT_PUBLIC(simgrid::instr::Type*) PJ_type_get_root();
-XBT_PUBLIC(simgrid::instr::Type*) PJ_type_get(const char* name, simgrid::instr::Type* father);
-XBT_PRIVATE XBT_PRIVATE void PJ_type_free(simgrid::instr::Type* type);
/* instr_config.c */
-XBT_PRIVATE void recursiveDestroyType(simgrid::instr::Type* type);
-
XBT_PRIVATE void TRACE_TI_start();
XBT_PRIVATE void TRACE_TI_end();
// check if key exists: if it doesn't, set the variable to zero and mark this in the dict
if (platform_variables.find(key) == platform_variables.end()) {
container_t container = PJ_container_get (resource);
- simgrid::instr::Type* type = PJ_type_get(variable, container->type_);
+ simgrid::instr::Type* type = container->type_->getChild(variable);
new simgrid::instr::SetVariableEvent(now, container, type, 0);
platform_variables[key] = std::string("");
}
if (TRACE_uncategorized()){
XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now+delta, resource, value);
container_t container = PJ_container_get (resource);
- simgrid::instr::Type* type = PJ_type_get("bandwidth_used", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("bandwidth_used");
instr_event (now, delta, type, container, value);
}
snprintf (category_type, INSTR_DEFAULT_STR_SIZE, "b%s", category);
XBT_DEBUG("CAT LINK [%f - %f] %s %s %f", now, now+delta, resource, category_type, value);
container_t container = PJ_container_get (resource);
- simgrid::instr::Type* type = PJ_type_get(category_type, container->type_);
+ simgrid::instr::Type* type = container->type_->getChild(category_type);
instr_event (now, delta, type, container, value);
}
}
//trace uncategorized host utilization
if (TRACE_uncategorized()){
XBT_DEBUG("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value);
- simgrid::instr::Type* type = PJ_type_get("power_used", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("power_used");
instr_event (now, delta, type, container, value);
}
char category_type[INSTR_DEFAULT_STR_SIZE];
snprintf (category_type, INSTR_DEFAULT_STR_SIZE, "p%s", category);
XBT_DEBUG("CAT HOST [%f - %f] %s %s %f", now, now+delta, resource, category_type, value);
- simgrid::instr::Type* type = PJ_type_get(category_type, container->type_);
+ simgrid::instr::Type* type = container->type_->getChild(category_type);
instr_event (now, delta, type, container, value);
}
}
void_pfn_smxprocess_t cleanup_func_ = nullptr;
smx_actor_t process_ = nullptr;
public:
+ class StopRequest {
+ /** @brief Exception launched to kill a process, in order to properly unwind its stack and release RAII stuff
+ *
+ * Nope, Sonar, this should not inherit of std::exception.
+ * Otherwise, users may accidentally catch it with a try {} catch (std::exception)
+ */
+ };
bool iwannadie;
Context(std::function<void()> code,
/* We are using the bottom of the stack to save some information, like the
* valgrind_stack_id. Define smx_context_usable_stack_size to give the remaining
- * size for the stack. */
+ * size for the stack. Round its value to a multiple of 16 (asan wants the stacks to be aligned this way). */
#if HAVE_VALGRIND_H
-# define smx_context_usable_stack_size \
- (smx_context_stack_size - sizeof(unsigned int)) /* for valgrind_stack_id */
+#define smx_context_usable_stack_size \
+ ((smx_context_stack_size - sizeof(unsigned int)) & ~0xf) /* for valgrind_stack_id */
#else
-# define smx_context_usable_stack_size smx_context_stack_size
+#define smx_context_usable_stack_size (smx_context_stack_size & ~0xf)
#endif
/** @brief Executes all the processes to run (in parallel if possible). */
#include "src/internal_config.h"
#include "src/kernel/context/ContextBoost.hpp"
+#if HAVE_SANITIZE_ADDRESS_FIBER_SUPPORT
+#include <sanitizer/asan_interface.h>
+#define ASAN_EVAL(expr) (expr)
+#define ASAN_START_SWITCH(fake_stack_save, bottom, size) __sanitizer_start_switch_fiber(fake_stack_save, bottom, size)
+#define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) \
+ __sanitizer_finish_switch_fiber(fake_stack_save, bottom_old, size_old)
+#else
+#define ASAN_EVAL(expr) (void)0
+#define ASAN_START_SWITCH(fake_stack_save, bottom, size) (void)0
+#define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) (void)(fake_stack_save)
+#endif
+
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
namespace simgrid {
void_pfn_smxprocess_t cleanup_func,
smx_actor_t process)
: BoostContext(std::move(code), cleanup_func, process) {}
- void stop() override;
void suspend() override;
};
void_pfn_smxprocess_t cleanup_func,
smx_actor_t process)
: BoostContext(std::move(code), cleanup_func, process) {}
- void stop() override;
void suspend() override;
void resume() override;
};
BoostContext::parallel_ = SIMIX_context_is_parallel();
if (BoostContext::parallel_) {
#if HAVE_THREAD_CONTEXTS
- int nthreads = SIMIX_context_get_nthreads();
- BoostContext::parmap_ = new simgrid::xbt::Parmap<smx_actor_t>(nthreads, SIMIX_context_get_parallel_mode());
+ BoostContext::parmap_ = nullptr;
BoostContext::workers_context_.clear();
- BoostContext::workers_context_.resize(nthreads, nullptr);
+ BoostContext::workers_context_.resize(SIMIX_context_get_nthreads(), nullptr);
BoostContext::maestro_context_ = nullptr;
xbt_os_thread_key_create(&BoostContext::worker_id_key_);
#else
BoostContextFactory::~BoostContextFactory()
{
#if HAVE_THREAD_CONTEXTS
- if (BoostContext::parmap_) {
- delete BoostContext::parmap_;
- BoostContext::parmap_ = nullptr;
- }
+ delete BoostContext::parmap_;
+ BoostContext::parmap_ = nullptr;
BoostContext::workers_context_.clear();
#endif
}
#if HAVE_THREAD_CONTEXTS
if (BoostContext::parallel_) {
BoostContext::threads_working_ = 0;
+ if (not BoostContext::parmap_)
+ BoostContext::parmap_ =
+ new simgrid::xbt::Parmap<smx_actor_t>(SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode());
BoostContext::parmap_->apply(
[](smx_actor_t process) {
BoostContext* context = static_cast<BoostContext*>(process->context);
// BoostContext
-static void smx_ctx_boost_wrapper(std::intptr_t arg)
+void BoostContext::smx_ctx_boost_wrapper(BoostContext::ctx_arg_type arg)
{
- BoostContext* context = (BoostContext*)(arg);
- (*context)();
- context->stop();
+#if BOOST_VERSION < 106100
+ BoostContext* context = reinterpret_cast<BoostContext*>(arg);
+#else
+ ASAN_FINISH_SWITCH(nullptr, &static_cast<BoostContext**>(arg.data)[0]->asan_stack_,
+ &static_cast<BoostContext**>(arg.data)[0]->asan_stack_size_);
+ static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
+ BoostContext* context = static_cast<BoostContext**>(arg.data)[1];
+#endif
+ try {
+ (*context)();
+ context->Context::stop();
+ } catch (StopRequest const&) {
+ XBT_DEBUG("Caught a StopRequest");
+ }
+ ASAN_EVAL(context->asan_stop_ = true);
+ context->suspend();
+}
+
+inline void BoostContext::smx_ctx_boost_jump_fcontext(BoostContext* from, BoostContext* to)
+{
+#if BOOST_VERSION < 105600
+ boost::context::jump_fcontext(from->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
+#elif BOOST_VERSION < 106100
+ boost::context::jump_fcontext(&from->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
+#else
+ BoostContext* ctx[2] = {from, to};
+ void* fake_stack;
+ ASAN_START_SWITCH(from->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
+ boost::context::detail::transfer_t arg = boost::context::detail::jump_fcontext(to->fc_, ctx);
+ ASAN_FINISH_SWITCH(fake_stack, &static_cast<BoostContext**>(arg.data)[0]->asan_stack_,
+ &static_cast<BoostContext**>(arg.data)[0]->asan_stack_size_);
+ static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
+#endif
}
BoostContext::BoostContext(std::function<void()> code,
// We need to pass the bottom of the stack to make_fcontext, depending on the stack direction it may be the lower
// or higher address:
#if PTH_STACKGROWTH == -1
- void* stack = static_cast<char*>(this->stack_) + smx_context_usable_stack_size - 1;
+ void* stack = static_cast<char*>(this->stack_) + smx_context_usable_stack_size;
#else
void* stack = this->stack_;
#endif
- this->fc_ = boost::context::make_fcontext(
- stack,
- smx_context_usable_stack_size,
- smx_ctx_boost_wrapper);
+ ASAN_EVAL(this->asan_stack_ = stack);
+#if BOOST_VERSION < 106100
+ this->fc_ = boost::context::make_fcontext(stack, smx_context_usable_stack_size, smx_ctx_boost_wrapper);
+#else
+ this->fc_ = boost::context::detail::make_fcontext(stack, smx_context_usable_stack_size, smx_ctx_boost_wrapper);
+#endif
} else {
-#if HAVE_BOOST_CONTEXTS == 1
+#if BOOST_VERSION < 105600
this->fc_ = new boost::context::fcontext_t();
#endif
if (BoostContext::maestro_context_ == nullptr)
BoostContext::~BoostContext()
{
-#if HAVE_BOOST_CONTEXTS == 1
+#if BOOST_VERSION < 105600
if (not this->stack_)
delete this->fc_;
#endif
// BoostSerialContext
+void BoostContext::stop()
+{
+ Context::stop();
+ throw StopRequest();
+}
+
void BoostContext::resume()
{
SIMIX_context_set_current(this);
-#if HAVE_BOOST_CONTEXTS == 1
- boost::context::jump_fcontext(maestro_context_->fc_, this->fc_, (intptr_t) this);
-#else
- boost::context::jump_fcontext(&maestro_context_->fc_, this->fc_, (intptr_t) this);
-#endif
+ smx_ctx_boost_jump_fcontext(maestro_context_, this);
}
void BoostSerialContext::suspend()
{
/* determine the next context */
- BoostSerialContext* next_context = nullptr;
- unsigned long int i = process_index_;
+ BoostSerialContext* next_context;
+ unsigned long int i = process_index_;
process_index_++;
if (i < simix_global->process_to_run.size()) {
XBT_DEBUG("No more process to run");
next_context = static_cast<BoostSerialContext*>(maestro_context_);
}
- SIMIX_context_set_current((smx_context_t) next_context);
-#if HAVE_BOOST_CONTEXTS == 1
- boost::context::jump_fcontext(this->fc_, next_context->fc_, (intptr_t) next_context);
-#else
- boost::context::jump_fcontext(&this->fc_, next_context->fc_, (intptr_t) next_context);
-#endif
-}
-
-void BoostSerialContext::stop()
-{
- BoostContext::stop();
- this->suspend();
+ SIMIX_context_set_current(static_cast<smx_context_t>(next_context));
+ smx_ctx_boost_jump_fcontext(this, next_context);
}
// BoostParallelContext
next_context = static_cast<BoostParallelContext*>(next_work.get()->context);
} else {
XBT_DEBUG("No more processes to run");
- uintptr_t worker_id = (uintptr_t)xbt_os_thread_get_specific(worker_id_key_);
+ uintptr_t worker_id = reinterpret_cast<uintptr_t>(xbt_os_thread_get_specific(worker_id_key_));
next_context = static_cast<BoostParallelContext*>(workers_context_[worker_id]);
}
- SIMIX_context_set_current(static_cast<smx_context_t> (next_context));
-#if HAVE_BOOST_CONTEXTS == 1
- boost::context::jump_fcontext(this->fc_, next_context->fc_, (intptr_t)(next_context));
-#else
- boost::context::jump_fcontext(&this->fc_, next_context->fc_, (intptr_t)(next_context));
-#endif
-}
-
-void BoostParallelContext::stop()
-{
- BoostContext::stop();
- this->suspend();
+ SIMIX_context_set_current(static_cast<smx_context_t>(next_context));
+ smx_ctx_boost_jump_fcontext(this, next_context);
}
void BoostParallelContext::resume()
{
uintptr_t worker_id = __sync_fetch_and_add(&threads_working_, 1);
- xbt_os_thread_set_specific(worker_id_key_, (void*) worker_id);
+ xbt_os_thread_set_specific(worker_id_key_, reinterpret_cast<void*>(worker_id));
BoostParallelContext* worker_context = static_cast<BoostParallelContext*>(SIMIX_context_self());
workers_context_[worker_id] = worker_context;
SIMIX_context_set_current(this);
-#if HAVE_BOOST_CONTEXTS == 1
- boost::context::jump_fcontext(worker_context->fc_, this->fc_, (intptr_t) this);
-#else
- boost::context::jump_fcontext(&worker_context->fc_, this->fc_, (intptr_t) this);
-#endif
+ smx_ctx_boost_jump_fcontext(worker_context, this);
}
#endif
#ifndef SIMGRID_SIMIX_BOOST_CONTEXT_HPP
#define SIMGRID_SIMIX_BOOST_CONTEXT_HPP
+#include <boost/version.hpp>
+#if BOOST_VERSION < 106100
+#include <boost/context/fcontext.hpp>
+#else
+#include <boost/context/detail/fcontext.hpp>
+#endif
#include <functional>
#include <vector>
static unsigned long process_index_;
static BoostContext* maestro_context_;
-#if HAVE_BOOST_CONTEXTS == 1
+#if BOOST_VERSION < 105600
boost::context::fcontext_t* fc_ = nullptr;
-#else
+ typedef intptr_t ctx_arg_type;
+#elif BOOST_VERSION < 106100
boost::context::fcontext_t fc_;
+ typedef intptr_t ctx_arg_type;
+#else
+ boost::context::detail::fcontext_t fc_;
+ typedef boost::context::detail::transfer_t ctx_arg_type;
#endif
+ static void smx_ctx_boost_wrapper(ctx_arg_type);
+ static void smx_ctx_boost_jump_fcontext(BoostContext*, BoostContext*);
+
+#if HAVE_SANITIZE_ADDRESS_FIBER_SUPPORT
+ const void* asan_stack_ = nullptr;
+ size_t asan_stack_size_ = 0;
+ bool asan_stop_ = false;
+#endif
+
void* stack_ = nullptr;
public:
friend BoostContextFactory;
void_pfn_smxprocess_t cleanup_func,
smx_actor_t process);
~BoostContext() override;
+ void stop() override;
virtual void resume();
private:
static void wrapper(int first, ...);
void RawContext::wrapper(void* arg)
{
RawContext* context = static_cast<RawContext*>(arg);
- (*context)();
- context->stop();
+ try {
+ (*context)();
+ context->Context::stop();
+ } catch (StopRequest const&) {
+ XBT_DEBUG("Caught a StopRequest");
+ }
+ context->suspend();
}
RawContext::RawContext(std::function<void()> code,
void RawContext::stop()
{
Context::stop();
- this->suspend();
+ throw StopRequest();
}
void RawContextFactory::run_all()
if (smx_ctx_thread_sem) /* parallel run */
xbt_os_sem_acquire(smx_ctx_thread_sem);
- (*context)();
- context->stop();
+ try {
+ (*context)();
+ context->Context::stop();
+ } catch (StopRequest const&) {
+ XBT_DEBUG("Caught a StopRequest");
+ }
+
+ if (smx_ctx_thread_sem)
+ xbt_os_sem_release(smx_ctx_thread_sem);
+ // Signal to the maestro that it has finished:
+ xbt_os_sem_release(context->end_);
+#ifndef WIN32
+ stack.ss_flags = SS_DISABLE;
+ sigaltstack(&stack, nullptr);
+#endif
return nullptr;
}
// Tell main that we have finished:
xbt_os_sem_release(context->end_);
+#ifndef WIN32
+ stack.ss_flags = SS_DISABLE;
+ sigaltstack(&stack, nullptr);
+#endif
return nullptr;
}
void ThreadContext::stop()
{
Context::stop();
- if (smx_ctx_thread_sem)
- xbt_os_sem_release(smx_ctx_thread_sem);
-
- // Signal to the maestro that it has finished:
- xbt_os_sem_release(this->end_);
-
- xbt_os_thread_exit(nullptr);
+ throw StopRequest();
}
void ThreadContext::suspend()
-/* Copyright (c) 2009-2015. The SimGrid Team.
+/* Copyright (c) 2009-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
UContext(std::function<void()> code,
void_pfn_smxprocess_t cleanup_func, smx_actor_t process);
~UContext() override;
+ void stop() override;
};
class SerialUContext : public UContext {
void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
: UContext(std::move(code), cleanup_func, process)
{}
- void stop() override;
void suspend() override;
void resume();
};
void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
: UContext(std::move(code), cleanup_func, process)
{}
- void stop() override;
void suspend() override;
void resume();
};
SIMIX_context_stack_delete(this->stack_);
}
+void UContext::stop()
+{
+ Context::stop();
+ throw StopRequest();
+}
}}} // namespace simgrid::kernel::context
static void smx_ctx_sysv_wrapper(int first, ...)
}
memcpy(&context, ctx_addr, sizeof(simgrid::kernel::context::UContext*));
- (*context)();
- context->stop();
+ try {
+ (*context)();
+ context->Context::stop();
+ } catch (simgrid::kernel::context::Context::StopRequest const&) {
+ XBT_DEBUG("Caught a StopRequest");
+ }
+ context->suspend();
}
namespace simgrid {
namespace kernel {
namespace context {
-void SerialUContext::stop()
-{
- Context::stop();
- this->suspend();
-}
-
void SerialUContext::suspend()
{
/* determine the next context */
swapcontext(&static_cast<SerialUContext*>(sysv_maestro_context)->uc_, &this->uc_);
}
-void ParallelUContext::stop()
-{
- UContext::stop();
- this->suspend();
-}
-
/** Run one particular simulated process on the current thread. */
void ParallelUContext::resume()
{
simgrid::mc::RemoteClient* process = &this->process();
if (process->running()) {
XBT_DEBUG("Killing process");
- kill(process->pid(), SIGTERM);
+ kill(process->pid(), SIGKILL);
process->terminate();
}
}
// process:
int res;
int sockets[2];
- res = socketpair(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0, sockets);
+ res = socketpair(AF_LOCAL, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sockets);
if (res == -1)
throw simgrid::xbt::errno_error("Could not create socketpair");
/* Check for deadlocks */
if (mc_model_checker->checkDeadlock()) {
MC_show_deadlock();
- throw new simgrid::mc::DeadlockError();
+ throw simgrid::mc::DeadlockError();
}
while (not stack_.empty()) {
int block = 0;
int fragment = 0;
HeapArea() {}
- HeapArea(int block)
- : valid(true), block(block) {}
- HeapArea(int block, int fragment = 0)
- : valid(true), block(block), fragment(fragment) {}
+ explicit HeapArea(int block) : valid(true), block(block) {}
+ HeapArea(int block, int fragment) : valid(true), block(block), fragment(fragment) {}
};
struct ProcessComparisonState {
int nb_diff1 = 0;
int nb_diff2 = 0;
int equal;
- int res_compare = 0;
/* Check busy blocks */
i1 = 1;
i2 = 1;
equal = 0;
- res_compare = 0;
/* Try first to associate to same block in the other heap */
if (heapinfo2->type == heapinfo1->type
&& state.equals_to2_(i1, 0).valid == 0) {
addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
- res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_block1, addr_block2, snapshot1,
- snapshot2, nullptr, nullptr, 0);
+ int res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_block1, addr_block2,
+ snapshot1, snapshot2, nullptr, nullptr, 0);
if (res_compare != 1) {
for (k = 1; k < heapinfo2->busy_block.size; k++)
state.equals_to2_(i1 + k, 0) = HeapArea(i1, -1);
continue;
}
- res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing,
- addr_block1, addr_block2, snapshot1, snapshot2,
- nullptr, nullptr, 0);
+ int res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_block1, addr_block2,
+ snapshot1, snapshot2, nullptr, nullptr, 0);
if (res_compare != 1) {
for (k = 1; k < heapinfo2b->busy_block.size; k++)
addr_frag2 =
(void *) ((char *) addr_block2 +
(j1 << heapinfo2->type));
- res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2, snapshot1,
- snapshot2, nullptr, nullptr, 0);
+ int res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2,
+ snapshot1, snapshot2, nullptr, nullptr, 0);
if (res_compare != 1)
equal = 1;
}
addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
addr_frag2 = (void*)((char*)addr_block2 + (j2 << heapinfo2b->type));
- res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2, snapshot2,
- snapshot2, nullptr, nullptr, 0);
+ int res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2,
+ snapshot2, snapshot2, nullptr, nullptr, 0);
if (res_compare != 1) {
equal = 1;
break;
if (not equal) {
XBT_DEBUG("Block %zu, fragment %zu not found (size_used = %zd, address = %p)\n", i1, j1,
heapinfo1->busy_frag.frag_size[j1], addr_frag1);
- i2 = state.heaplimit + 1;
i1 = state.heaplimit + 1;
nb_diff1++;
break;
{
simgrid::mc::RemoteClient* process = &mc_model_checker->process();
- int res_compare;
ssize_t block1;
- ssize_t frag1;
ssize_t block2;
- ssize_t frag2;
ssize_t size;
int check_ignore = 0;
- void* real_addr_block1;
- void* real_addr_block2;
- void* real_addr_frag1;
- void* real_addr_frag2;
int type_size = -1;
int offset1 = 0;
int offset2 = 0;
}
// Process address of the block:
- real_addr_block1 = (ADDR2UINT(block1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
- real_addr_block2 = (ADDR2UINT(block2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ void* real_addr_block1 = (ADDR2UINT(block1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ void* real_addr_block2 = (ADDR2UINT(block2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
if (type) {
if (type->full_type)
// TODO, lookup variable type from block type as done for fragmented blocks
- offset1 = (char*)area1 - (char*)real_addr_block1;
- offset2 = (char*)area2 - (char*)real_addr_block2;
-
if (state.equals_to1_(block1, 0).valid && state.equals_to2_(block2, 0).valid && state.blocksEqual(block1, block2)) {
if (match_pairs)
state.match_equals(previous);
return 0;
}
- frag1 = -1;
- frag2 = -1;
-
if (heapinfo1->busy_block.ignore > 0
&& heapinfo2->busy_block.ignore == heapinfo1->busy_block.ignore)
check_ignore = heapinfo1->busy_block.ignore;
} else if ((heapinfo1->type > 0) && (heapinfo2->type > 0)) { /* Fragmented block */
// Fragment number:
- frag1 = ((uintptr_t)(ADDR2UINT(area1) % (BLOCKSIZE))) >> heapinfo1->type;
- frag2 = ((uintptr_t)(ADDR2UINT(area2) % (BLOCKSIZE))) >> heapinfo2->type;
+ ssize_t frag1 = ((uintptr_t)(ADDR2UINT(area1) % (BLOCKSIZE))) >> heapinfo1->type;
+ ssize_t frag2 = ((uintptr_t)(ADDR2UINT(area2) % (BLOCKSIZE))) >> heapinfo2->type;
// Process address of the fragment:
- real_addr_frag1 = (void*)((char*)real_addr_block1 + (frag1 << heapinfo1->type));
- real_addr_frag2 = (void*)((char*)real_addr_block2 + (frag2 << heapinfo2->type));
+ void* real_addr_frag1 = (void*)((char*)real_addr_block1 + (frag1 << heapinfo1->type));
+ void* real_addr_frag2 = (void*)((char*)real_addr_block2 + (frag2 << heapinfo2->type));
// Check the size of the fragments against the size of the type:
if (type_size != -1) {
// The type of the variable is already known:
if (type) {
- new_type1 = type;
- new_type2 = type;
+ new_type1 = new_type2 = type;
}
// Type inference from the block type.
else if (state.types1_(block1, frag1) != nullptr || state.types2_(block2, frag2) != nullptr) {
/* Start comparison */
+ int res_compare;
if (type)
res_compare = compare_heap_area_with_type(state, process_index, area1, area2, snapshot1, snapshot2, previous, type,
size, check_ignore, pointer_level);
}
case SIMCALL_COMM_WAITANY: {
- xbt_dynar_t comms;
- simgrid::kernel::activity::CommImpl* act =
- static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
-
- comms = simcall_comm_waitany__get__comms(req);
-
+ xbt_dynar_t comms = simcall_comm_waitany__get__comms(req);
for (unsigned int index = 0; index < comms->used; ++index) {
- act = xbt_dynar_get_as(comms, index, simgrid::kernel::activity::CommImpl*);
+ simgrid::kernel::activity::CommImpl* act = xbt_dynar_get_as(comms, index, simgrid::kernel::activity::CommImpl*);
if (act->src_proc && act->dst_proc)
return true;
}
/** A channel for exchanging messages between model-checker and model-checked
*
* This abstracts away the way the messages are transferred. Currently, they
- * are sent over a (connected) `SOCK_DGRAM` socket.
+ * are sent over a (connected) `SOCK_SEQPACKET` socket.
*/
class Channel {
int socket_ = -1;
socklen_t socklen = sizeof(type);
if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &socklen) != 0)
xbt_die("Could not check socket type");
- if (type != SOCK_DGRAM)
+ if (type != SOCK_SEQPACKET)
xbt_die("Unexpected socket type %i", type);
XBT_DEBUG("Model-checked application found expected socket type");
/** Basic structure for a MC message
*
* The current version of the client/server protocol sends C structures over `AF_LOCAL`
- * `SOCK_DGRAM` sockets. This means that the protocol is ABI/architecture specific:
+ * `SOCK_SEQPACKET` sockets. This means that the protocol is ABI/architecture specific:
* we currently can't model-check a x86 process from a x86_64 process.
*
* Moreover the protocol is not stable. The same version of the library should be used
//start link
container_t msg = PJ_container_get (instr_process_id(process, str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_LINK", PJ_type_get_root());
+ simgrid::instr::Type* type = PJ_type_get_root()->getChild("MSG_PROCESS_LINK");
new simgrid::instr::StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
//destroy existing container of this process
//end link
msg = PJ_container_get(instr_process_id(process, str, len));
- type = PJ_type_get ("MSG_PROCESS_LINK", PJ_type_get_root());
+ type = PJ_type_get_root()->getChild("MSG_PROCESS_LINK");
new simgrid::instr::EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
}
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get("suspend", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type);
}
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get("sleep", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type);
}
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get("task_execute", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type);
}
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get("receive", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type);
char key[INSTR_DEFAULT_STR_SIZE];
snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
- type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root());
+ type = PJ_type_get_root()->getChild("MSG_PROCESS_TASK_LINK");
new simgrid::instr::EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
}
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get("send", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
char key[INSTR_DEFAULT_STR_SIZE];
snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
- type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root());
+ type = PJ_type_get_root()->getChild("MSG_PROCESS_TASK_LINK");
new simgrid::instr::StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
- simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_);
+ simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type);
}
}
vm->start();
if (TRACE_msg_vm_is_enabled()) {
container_t vm_container = PJ_container_get(vm->getCname());
- simgrid::instr::Type* type = PJ_type_get("MSG_VM_STATE", vm_container->type_);
+ simgrid::instr::Type* type = vm_container->type_->getChild("MSG_VM_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("start", "0 0 1", type); // start is blue
new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, type, val);
}
// start link
container_t msg = PJ_container_get(vm->getCname());
- simgrid::instr::Type* type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
+ simgrid::instr::Type* type = PJ_type_get_root()->getChild("MSG_VM_LINK");
new simgrid::instr::StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
// destroy existing container of this vm
// end link
msg = PJ_container_get(vm->getCname());
- type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
+ type = PJ_type_get_root()->getChild("MSG_VM_LINK");
new simgrid::instr::EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
}
if (TRACE_msg_vm_is_enabled()) {
container_t vm_container = PJ_container_get(vm->getCname());
- simgrid::instr::Type* type = PJ_type_get("MSG_VM_STATE", vm_container->type_);
+ simgrid::instr::Type* type = vm_container->type_->getChild("MSG_VM_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("suspend", "1 0 0", type); // suspend is red
new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, type, val);
}
if (TRACE_msg_vm_is_enabled()) {
container_t vm_container = PJ_container_get(vm->getCname());
- simgrid::instr::Type* type = PJ_type_get("MSG_VM_STATE", vm_container->type_);
+ simgrid::instr::Type* type = vm_container->type_->getChild("MSG_VM_STATE");
new simgrid::instr::PopStateEvent(MSG_get_clock(), vm_container, type);
}
}
// const double virt_overhead = 0.95;
const double virt_overhead = 1;
+static void hostStateChange(s4u::Host& host)
+{
+ if (host.isOff()) { // just turned off.
+ std::vector<s4u::VirtualMachine*> trash;
+ /* Find all VMs living on that host */
+ for (s4u::VirtualMachine* const& vm : VirtualMachineImpl::allVms_)
+ if (vm->getPm() == &host)
+ trash.push_back(vm);
+ for (s4u::VirtualMachine* vm : trash)
+ vm->pimpl_vm_->shutdown(SIMIX_process_self());
+ }
+}
+VMModel::VMModel()
+{
+ s4u::Host::onStateChange.connect(hostStateChange);
+}
+
double VMModel::nextOccuringEvent(double now)
{
/* TODO: update action's cost with the total cost of processes on the VM. */
THROW_IMPOSSIBLE;
break;
}
- XBT_VERB("Shuting down the VM %s even if it's not running but %s", piface_->getCname(), stateName);
+ XBT_VERB("Shutting down the VM %s even if it's not running but %s", piface_->getCname(), stateName);
}
xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
smx_actor_t smx_process;
smx_actor_t smx_process_safe;
xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
- XBT_DEBUG("kill %s", smx_process->cname());
+ XBT_DEBUG("kill %s@%s on behalf of %s which shutdown that VM.", smx_process->cname(), smx_process->host->getCname(),
+ issuer->cname());
SIMIX_process_kill(smx_process, issuer);
}
*/
class VMModel : public surf::HostModel {
public:
+ VMModel();
void ignoreEmptyVmInPmLMM() override{};
double nextOccuringEvent(double now) override;
return *mounts;
}
+void Host::execute(double flops)
+{
+ Host* host_list[1] = {this};
+ double flops_list[1] = {flops};
+ smx_activity_t s = simcall_execution_parallel_start(nullptr /*name*/, 1, host_list, flops_list,
+ nullptr /*comm_sizes */, -1.0, -1 /*timeout*/);
+ simcall_execution_wait(s);
+}
+
} // namespace simgrid
} // namespace s4u
if(schedule){
if (schedule_success) {
- const sg_host_t *workstations = sg_host_list ();
+ sg_host_t* workstations = sg_host_list();
for (auto const& elm : computers) {
SD_task_t previous_task = nullptr;
for (auto const& task : *elm.second) {
}
delete elm.second;
}
+ xbt_free(workstations);
} else {
XBT_WARN("The scheduling is ignored");
for (auto const& elm : computers)
SIMIX_process_on_exit_runall(process);
/* Unregister from the kill timer if any */
- if (process->kill_timer != nullptr)
+ if (process->kill_timer != nullptr) {
SIMIX_timer_remove(process->kill_timer);
+ process->kill_timer = nullptr;
+ }
xbt_os_mutex_acquire(simix_global->mutex);
// start the new process
ActorImpl* actor = simix_global->create_process_function(arg.name.c_str(), std::move(arg.code), arg.data, arg.host,
- arg.properties, nullptr);
+ arg.properties.get(), nullptr);
if (arg.kill_time >= 0)
simcall_process_set_kill_time(actor, arg.kill_time);
if (arg.auto_restart)
if (not context)
xbt_die("Not a suitable context");
- simix_global->cleanup_process_function(context->process());
-
- // Let maestro ignore we are still alive:
- // xbt_swag_remove(context->process(), simix_global->process_list);
-
- // TODO, Remove from proces list:
- // xbt_swag_remove(process, sg_host_simix(host)->process_list);
-
+ auto process = context->process();
+ simix_global->cleanup_process_function(process);
context->attach_stop();
- // delete context;
+ delete process;
}
/**
xbt_die("Unknown type of activity");
}
- /*
- switch (process->waiting_synchro->type) {
- case SIMIX_SYNC_JOIN:
- SIMIX_process_sleep_destroy(process->waiting_synchro);
- break;
- } */
-
process->waiting_synchro = nullptr;
}
if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), process) ==
if (reset_pid > 0)
simix_process_maxpid = reset_pid;
-
- SIMIX_context_runall();
-
- SIMIX_process_empty_trash();
}
void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest)
simcall->issuer->waiting_synchro = sync;
}
-static int SIMIX_process_join_finish(smx_process_exit_status_t status, void* synchro)
-{
- simgrid::kernel::activity::SleepImpl* sleep = static_cast<simgrid::kernel::activity::SleepImpl*>(synchro);
-
- if (sleep->surf_sleep) {
- sleep->surf_sleep->cancel();
-
- while (not sleep->simcalls.empty()) {
- smx_simcall_t simcall = sleep->simcalls.front();
- sleep->simcalls.pop_front();
- simcall_process_sleep__set__result(simcall, SIMIX_DONE);
- simcall->issuer->waiting_synchro = nullptr;
- if (simcall->issuer->suspended) {
- XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
- simcall->issuer->suspended = 0;
- simcall_HANDLER_process_suspend(simcall, simcall->issuer);
- } else {
- SIMIX_simcall_answer(simcall);
- }
- }
- sleep->surf_sleep->unref();
- sleep->surf_sleep = nullptr;
- }
- // intrusive_ptr_release(process); // FIXME: We are leaking here. See comment in SIMIX_process_join()
- return 0;
-}
-
smx_activity_t SIMIX_process_join(smx_actor_t issuer, smx_actor_t process, double timeout)
{
smx_activity_t res = issuer->sleep(timeout);
intrusive_ptr_add_ref(res.get());
- /* We are leaking the process here, but if we don't take the ref, we get a "use after free".
- * The correct solution would be to derivate the type SynchroSleep into a SynchroProcessJoin,
- * but the code is not clean enough for now for this.
- * The C API should first be properly replaced with the C++ one, which is a fair amount of work.
- */
- intrusive_ptr_add_ref(process);
SIMIX_process_on_exit(process,
[](void*, void* arg) {
- return simgrid::simix::kernelImmediate(
- [&] { return SIMIX_process_join_finish(SMX_EXIT_SUCCESS, arg); });
+ auto sleep = static_cast<simgrid::kernel::activity::SleepImpl*>(arg);
+ if (sleep->surf_sleep)
+ sleep->surf_sleep->finish(simgrid::surf::Action::State::done);
+ intrusive_ptr_release(sleep);
+ return 0;
},
- &*res);
+ res.get());
return res;
}
smx_process_exit_status_t exit_status = (process->context->iwannadie) ? SMX_EXIT_FAILURE : SMX_EXIT_SUCCESS;
while (not process->on_exit.empty()) {
s_smx_process_exit_fun_t exit_fun = process->on_exit.back();
- (exit_fun.fun)((void*)exit_status, exit_fun.arg);
process->on_exit.pop_back();
+ (exit_fun.fun)((void*)exit_status, exit_fun.arg);
}
}
void *data = nullptr;
sg_host_t host = nullptr;
double kill_time = 0.0;
- std::map<std::string, std::string>* properties = nullptr;
+ std::shared_ptr<std::map<std::string, std::string>> properties;
bool auto_restart = false;
};
(std::string("Possible values: ")+contexts_list()).c_str(),
context_factories[0].first);
-int smx_context_stack_size;
+unsigned smx_context_stack_size;
int smx_context_stack_size_was_set = 0;
-int smx_context_guard_size;
+unsigned smx_context_guard_size;
int smx_context_guard_size_was_set = 0;
#if HAVE_THREAD_LOCAL_STORAGE
static XBT_THREAD_LOCAL smx_context_t smx_current_context_parallel;
fprintf(stderr, "Access violation detected.\n"
"This probably comes from a programming error in your code, or from a stack\n"
"overflow. If you are certain of your code, try increasing the stack size\n"
- " --cfg=contexts/stack-size=XXX (current size is %d KiB).\n"
+ " --cfg=contexts/stack-size=XXX (current size is %u KiB).\n"
"\n"
"If it does not help, this may have one of the following causes:\n"
"a bug in SimGrid, a bug in the OS or a bug in a third-party libraries.\n"
}
/* Kill all processes (but maestro) */
SIMIX_process_killall(simix_global->maestro_process, 1);
+ SIMIX_context_runall();
+ SIMIX_process_empty_trash();
/* Exit the SIMIX network module */
SIMIX_mailbox_exit();
}
time = SIMIX_timer_next();
- if (time > -1.0 || simix_global->process_list.empty() == false) {
+ if (time > -1.0 || not simix_global->process_list.empty()) {
XBT_DEBUG("Calling surf_solve");
time = surf_solve(time);
XBT_DEBUG("Moving time ahead : %g", time);
} while (time > -1.0 || not simix_global->process_to_run.empty());
- if (simix_global->process_list.size() != 0) {
+ if (not simix_global->process_list.empty()) {
TRACE_end();
/** @brief cancels a timer that was added earlier */
void SIMIX_timer_remove(smx_timer_t timer) {
- xbt_heap_rm_elm(simix_timers, timer, timer->getDate());
+ delete static_cast<smx_timer_t>(xbt_heap_rm_elm(simix_timers, timer, timer->getDate()));
}
/** @brief Returns the date at which the timer will trigger (or 0 if nullptr timer) */
Host::~Host()
{
- /* Clean Simulator data */
+ /* All processes should be gone when the host is turned off (by the end of the simulation). */
if (xbt_swag_size(process_list) != 0) {
std::string msg = std::string("Shutting down host, but it's not empty:");
smx_actor_t process = nullptr;
for (auto const& arg : boot_processes) {
XBT_DEBUG("Booting Process %s(%s) right now", arg->name.c_str(), arg->host->getCname());
smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host,
- arg->properties, nullptr);
+ arg->properties.get(), nullptr);
if (arg->kill_time >= 0)
simcall_process_set_kill_time(actor, arg->kill_time);
if (arg->auto_restart)
smx_actor_t process = nullptr;
xbt_swag_foreach(process, host->process_list) {
SIMIX_process_kill(process, issuer);
- XBT_DEBUG("Killing %s@%s on behalf of %s", process->cname(), process->host->getCname(), issuer->cname());
+ XBT_DEBUG("Killing %s@%s on behalf of %s which turned off that host.", process->cname(),
+ process->host->getCname(), issuer->cname());
}
}
} else {
arg->data = data;
arg->host = host;
arg->kill_time = kill_time;
- arg->properties = properties;
+ arg->properties.reset(properties, [](decltype(properties)) {});
arg->auto_restart = auto_restart;
if (host->isOff() && watched_hosts.find(host->getCname()) == watched_hosts.end()) {
for (auto const& arg : process_list) {
XBT_DEBUG("Restarting Process %s@%s right now", arg->name.c_str(), arg->host->getCname());
smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host,
- arg->properties, nullptr);
+ arg->properties.get(), nullptr);
if (arg->kill_time >= 0)
simcall_process_set_kill_time(actor, arg->kill_time);
if (arg->auto_restart)
#define TRACE_AUTO_COLL(cat) \
if (TRACE_is_enabled()) { \
- simgrid::instr::Type* type = simgrid::instr::Type::getOrNull(#cat, PJ_type_get_root()); \
+ simgrid::instr::Type* type = PJ_type_get_root()->getChildOrNull(#cat); \
if (not type) { \
type = simgrid::instr::Type::eventNew(#cat, PJ_type_get_root()); \
} \
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
const char *color = instr_find_color (operation);
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(operation, color, type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type);
}
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get(str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
const char* color = instr_find_color("computing");
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type,
simgrid::instr::Value::get_or_new("computing", color, type));
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("computing", nullptr, type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
}
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type);
}
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
const char *color = instr_find_color ("sleeping");
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("sleeping", color, type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val);
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("sleeping", nullptr, type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
}
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type);
}
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("test", nullptr, type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
}
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type);
}
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
const char *color = instr_find_color (operation);
simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(operation, color, type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type);
}
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(src, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_LINK", PJ_type_get_root());
+ simgrid::instr::Type* type = PJ_type_get_root()->getChild("MPI_LINK");
XBT_DEBUG("Send tracing from %d to %d, tag %d, with key %s", src, dst, tag, key);
new simgrid::instr::StartLinkEvent(SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key, size);
}
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(dst, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
- simgrid::instr::Type* type = PJ_type_get("MPI_LINK", PJ_type_get_root());
+ simgrid::instr::Type* type = PJ_type_get_root()->getChild("MPI_LINK");
XBT_DEBUG("Recv tracing from %d to %d, tag %d, with key %s", src, dst, tag, key);
new simgrid::instr::EndLinkEvent(SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key);
}
}
/* ****************************** Functions related to the SMPI_SAMPLE_ macros ************************************/
-typedef struct {
+namespace {
+class SampleLocation : public std::string {
+public:
+ SampleLocation(bool global, const char* file, int line) : std::string(std::string(file) + ":" + std::to_string(line))
+ {
+ if (not global)
+ this->append(":" + std::to_string(smpi_process()->index()));
+ }
+};
+
+class LocalData {
+public:
double threshold; /* maximal stderr requested (if positive) */
double relstderr; /* observed stderr so far */
double mean; /* mean of benched times, to be used if the block is disabled */
double sum_pow2; /* sum of the square of the benched times (to compute the stderr) */
int iters; /* amount of requested iterations */
int count; /* amount of iterations done so far */
- int benching; /* 1: we are benchmarking; 0: we have enough data, no bench anymore */
-} local_data_t;
-
-std::unordered_map<std::string, local_data_t*> samples; /* Allocated on first use */
+ bool benching; /* true: we are benchmarking; false: we have enough data, no bench anymore */
-static std::string sample_location(int global, const char* file, int line)
-{
- if (global) {
- return std::string(file) + ":" + std::to_string(line);
- } else {
- return std::string(file) + ":" + std::to_string(line) + ":" + std::to_string(smpi_process()->index());
- }
+ bool need_more_benchs() const;
+};
}
-static int sample_enough_benchs(local_data_t *data) {
- int res = data->count >= data->iters;
- if (data->threshold>0.0) {
- if (data->count <2)
- res = 0; // not enough data
- if (data->relstderr > data->threshold)
- res = 0; // stderr too high yet
- }
+std::unordered_map<SampleLocation, LocalData, std::hash<std::string>> samples;
+
+bool LocalData::need_more_benchs() const
+{
+ bool res = (count < iters) || (threshold > 0.0 && (count < 2 || // not enough data
+ relstderr > threshold // stderr too high yet
+ ));
XBT_DEBUG("%s (count:%d iter:%d stderr:%f thres:%f mean:%fs)",
- (res?"enough benchs":"need more data"), data->count, data->iters, data->relstderr, data->threshold, data->mean);
+ (res ? "need more data" : "enough benchs"), count, iters, relstderr, threshold, mean);
return res;
}
void smpi_sample_1(int global, const char *file, int line, int iters, double threshold)
{
- std::string loc = sample_location(global, file, line);
+ SampleLocation loc(global, file, line);
smpi_bench_end(); /* Take time from previous, unrelated computation into account */
smpi_process()->set_sampling(1);
- auto ld = samples.find(loc);
- local_data_t* data;
- if (ld == samples.end()) {
- xbt_assert(threshold>0 || iters>0,
- "You should provide either a positive amount of iterations to bench, or a positive maximal stderr (or both)");
- data = static_cast<local_data_t*>(xbt_new(local_data_t, 1));
- data->count = 0;
- data->sum = 0.0;
- data->sum_pow2 = 0.0;
- data->iters = iters;
- data->threshold = threshold;
- data->benching = 1; // If we have no data, we need at least one
- data->mean = 0;
- samples[loc] = data;
+ auto insert = samples.emplace(loc, LocalData{
+ threshold, // threshold
+ 0.0, // relstderr
+ 0.0, // mean
+ 0.0, // sum
+ 0.0, // sum_pow2
+ iters, // iters
+ 0, // count
+ true // benching (if we have no data, we need at least one)
+ });
+ LocalData& data = insert.first->second;
+ if (insert.second) {
XBT_DEBUG("XXXXX First time ever on benched nest %s.", loc.c_str());
+ xbt_assert(threshold > 0 || iters > 0,
+ "You should provide either a positive amount of iterations to bench, or a positive maximal stderr (or both)");
} else {
- data = ld->second;
- if (data->iters != iters || data->threshold != threshold) {
+ if (data.iters != iters || data.threshold != threshold) {
XBT_ERROR("Asked to bench block %s with different settings %d, %f is not %d, %f. "
"How did you manage to give two numbers at the same line??",
- loc.c_str(), data->iters, data->threshold, iters, threshold);
+ loc.c_str(), data.iters, data.threshold, iters, threshold);
THROW_IMPOSSIBLE;
}
// if we already have some data, check whether sample_2 should get one more bench or whether it should emulate
// the computation instead
- data->benching = (sample_enough_benchs(data) == 0);
+ data.benching = data.need_more_benchs();
XBT_DEBUG("XXXX Re-entering the benched nest %s. %s", loc.c_str(),
- (data->benching ? "more benching needed" : "we have enough data, skip computes"));
+ (data.benching ? "more benching needed" : "we have enough data, skip computes"));
}
}
int smpi_sample_2(int global, const char *file, int line)
{
- std::string loc = sample_location(global, file, line);
+ SampleLocation loc(global, file, line);
int res;
- xbt_assert(not samples.empty(),
- "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
- local_data_t* data = samples.at(loc);
XBT_DEBUG("sample2 %s", loc.c_str());
+ auto sample = samples.find(loc);
+ if (sample == samples.end())
+ xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
+ LocalData& data = sample->second;
- if (data->benching==1) {
+ if (data.benching) {
// we need to run a new bench
XBT_DEBUG("benchmarking: count:%d iter:%d stderr:%f thres:%f; mean:%f",
- data->count, data->iters, data->relstderr, data->threshold, data->mean);
+ data.count, data.iters, data.relstderr, data.threshold, data.mean);
res = 1;
} else {
// Enough data, no more bench (either we got enough data from previous visits to this benched nest, or we just
//ran one bench and need to bail out now that our job is done). Just sleep instead
XBT_DEBUG("No benchmark (either no need, or just ran one): count >= iter (%d >= %d) or stderr<thres (%f<=%f)."
" apply the %fs delay instead",
- data->count, data->iters, data->relstderr, data->threshold, data->mean);
- smpi_execute(data->mean);
+ data.count, data.iters, data.relstderr, data.threshold, data.mean);
+ smpi_execute(data.mean);
smpi_process()->set_sampling(0);
res = 0; // prepare to capture future, unrelated computations
}
void smpi_sample_3(int global, const char *file, int line)
{
- std::string loc = sample_location(global, file, line);
+ SampleLocation loc(global, file, line);
- xbt_assert(not samples.empty(),
- "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
- local_data_t* data = samples.at(loc);
XBT_DEBUG("sample3 %s", loc.c_str());
+ auto sample = samples.find(loc);
+ if (sample == samples.end())
+ xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
+ LocalData& data = sample->second;
- if (data->benching==0)
+ if (not data.benching)
THROW_IMPOSSIBLE;
// ok, benchmarking this loop is over
xbt_os_threadtimer_stop(smpi_process()->timer());
// update the stats
- data->count++;
- double sample = xbt_os_timer_elapsed(smpi_process()->timer());
- data->sum += sample;
- data->sum_pow2 += sample * sample;
- double n = static_cast<double>(data->count);
- data->mean = data->sum / n;
- data->relstderr = sqrt((data->sum_pow2 / n - data->mean * data->mean) / n) / data->mean;
- if (sample_enough_benchs(data)==0) {
- data->mean = sample; // Still in benching process; We want sample_2 to simulate the exact time of this loop
+ data.count++;
+ double period = xbt_os_timer_elapsed(smpi_process()->timer());
+ data.sum += period;
+ data.sum_pow2 += period * period;
+ double n = static_cast<double>(data.count);
+ data.mean = data.sum / n;
+ data.relstderr = sqrt((data.sum_pow2 / n - data.mean * data.mean) / n) / data.mean;
+ if (data.need_more_benchs()) {
+ data.mean = period; // Still in benching process; We want sample_2 to simulate the exact time of this loop
// occurrence before leaving, not the mean over the history
}
- XBT_DEBUG("Average mean after %d steps is %f, relative standard error is %f (sample was %f)", data->count,
- data->mean, data->relstderr, sample);
+ XBT_DEBUG("Average mean after %d steps is %f, relative standard error is %f (sample was %f)",
+ data.count, data.mean, data.relstderr, period);
// That's enough for now, prevent sample_2 to run the same code over and over
- data->benching = 0;
+ data.benching = false;
}
extern "C" { /** These functions will be called from the user code **/
void smpi_bench_destroy()
{
- for (auto const& elm : samples)
- xbt_free(elm.second);
+ samples.clear();
}
#include <sys/mman.h>
#include <unistd.h>
+#include "src/internal_config.h"
#include "src/xbt/memory_map.hpp"
#include "private.h"
}
#endif
+#if HAVE_SANITIZE_ADDRESS
+#include <sanitizer/asan_interface.h>
+static void* asan_safe_memcpy(void* dest, void* src, size_t n)
+{
+ char* psrc = static_cast<char*>(src);
+ char* pdest = static_cast<char*>(dest);
+ for (size_t i = 0; i < n;) {
+ while (i < n && __asan_address_is_poisoned(psrc + i))
+ ++i;
+ if (i < n) {
+ char* p = static_cast<char*>(__asan_region_is_poisoned(psrc + i, n - i));
+ size_t j = p ? (p - psrc) : n;
+ memcpy(pdest + i, psrc + i, j - i);
+ i = j;
+ }
+ }
+ return dest;
+}
+#else
+#define asan_safe_memcpy(dest, src, n) memcpy(dest, src, n)
+#endif
/** Map a given SMPI privatization segment (make a SMPI process active) */
void smpi_switch_data_segment(int dest) {
#if HAVE_PRIVATIZATION
if(smpi_loaded_page==-1){//initial switch, do the copy from the real page here
for (int i=0; i< smpi_process_count(); i++){
- memcpy(smpi_privatization_regions[i].address, TOPAGE(smpi_start_data_exe), smpi_size_data_exe);
+ asan_safe_memcpy(smpi_privatization_regions[i].address, TOPAGE(smpi_start_data_exe), smpi_size_data_exe);
}
}
xbt_die("Impossible to unlink temporary file for memory mapping");
// initialize the values
- memcpy(address, TOPAGE(smpi_start_data_exe), smpi_size_data_exe);
+ asan_safe_memcpy(address, TOPAGE(smpi_start_data_exe), smpi_size_data_exe);
// store the address of the mapping for further switches
smpi_privatization_regions[i].file_descriptor = file_descriptor;
* This information is used by SMPI_SHARED_MALLOC to allocate some shared memory for all simulated processes.
*/
-class smpi_source_location {
+class smpi_source_location : public std::string {
public:
- smpi_source_location(const char* filename, int line)
- : filename(xbt_strdup(filename)), filename_length(strlen(filename)), line(line)
+ smpi_source_location(const char* filename, int line) : std::string(std::string(filename) + ":" + std::to_string(line))
{
}
-
- /** Pointer to a static string containing the file name */
- char* filename = nullptr;
- int filename_length = 0;
- int line = 0;
-
- bool operator==(smpi_source_location const& that) const
- {
- return filename_length == that.filename_length && line == that.line &&
- std::memcmp(filename, that.filename, filename_length) == 0;
- }
- bool operator!=(smpi_source_location const& that) const { return not(*this == that); }
-};
-}
-
-namespace std {
-
-template <> class hash<smpi_source_location> {
-public:
- typedef smpi_source_location argument_type;
- typedef std::size_t result_type;
- result_type operator()(smpi_source_location const& loc) const
- {
- return xbt_str_hash_ext(loc.filename, loc.filename_length) ^
- xbt_str_hash_ext((const char*)&loc.line, sizeof(loc.line));
- }
};
-}
-namespace{
-
-typedef struct {
+struct shared_data_t {
int fd = -1;
int count = 0;
-} shared_data_t;
+};
-std::unordered_map<smpi_source_location, shared_data_t> allocs;
-typedef std::unordered_map<smpi_source_location, shared_data_t>::value_type shared_data_key_type;
+std::unordered_map<smpi_source_location, shared_data_t, std::hash<std::string>> allocs;
+typedef decltype(allocs)::value_type shared_data_key_type;
-typedef struct {
+struct shared_metadata_t {
size_t size;
size_t allocated_size;
void *allocated_ptr;
std::vector<std::pair<size_t, size_t>> private_blocks;
shared_data_key_type* data;
-} shared_metadata_t;
+};
std::map<void*, shared_metadata_t> allocs_metadata;
std::map<std::string, void*> calls;
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
action->getLastUpdate(), now - action->getLastUpdate());
}
- action->finish();
+ action->finish(Action::State::done);
XBT_CDEBUG(surf_kernel, "Action %p finished", action);
/* set the remains to 0 due to precision problems when updating the remaining amount */
action->setRemains(0);
- action->setState(Action::State::done);
}
if (TRACE_is_enabled()) {
//defining the last timestamp that we can safely dump to trace file
if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
}
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
while ((xbt_heap_size(tiActionHeap_) > 0) && (xbt_heap_maxkey(tiActionHeap_) <= now)) {
CpuTiAction *action = static_cast<CpuTiAction*>(xbt_heap_pop(tiActionHeap_));
XBT_DEBUG("Action %p: finish", action);
- action->finish();
+ action->finish(Action::State::done);
/* set the remains to 0 due to precision problems when updating the remaining amount */
action->setRemains(0);
- action->setState(Action::State::done);
/* update remaining amount of all actions */
action->cpu_->updateRemainingAmount(surf_get_clock());
}
char link_typename[INSTR_DEFAULT_STR_SIZE];
snprintf(link_typename, INSTR_DEFAULT_STR_SIZE, "%s-%s%s-%s%s", father->type_->name_, src->type_->name_,
src->type_->id_, dst->type_->name_, dst->type_->id_);
- simgrid::instr::Type* link_type = simgrid::instr::Type::getOrNull(link_typename, father->type_);
- if (link_type == nullptr){
+ simgrid::instr::Type* link_type = father->type_->getChildOrNull(link_typename);
+ if (link_type == nullptr)
link_type = simgrid::instr::Type::linkNew(link_typename, father->type_, src->type_, dst->type_);
- }
//register EDGE types for triva configuration
trivaEdgeTypes.insert(link_type->name_);
const char* id = netzone.getCname();
if (PJ_container_get_root() == nullptr){
- PJ_container_alloc ();
container_t root = new simgrid::instr::Container(id, simgrid::instr::INSTR_AS, nullptr);
PJ_container_set_root (root);
if (TRACE_smpi_is_enabled()) {
- simgrid::instr::Type* mpi = simgrid::instr::Type::getOrNull("MPI", root->type_);
+ simgrid::instr::Type* mpi = root->type_->getChildOrNull("MPI");
if (mpi == nullptr){
mpi = simgrid::instr::Type::containerNew("MPI", root->type_);
if (not TRACE_smpi_is_grouped())
container_t container = new simgrid::instr::Container(link.name(), simgrid::instr::INSTR_LINK, father);
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
- simgrid::instr::Type* bandwidth = simgrid::instr::Type::getOrNull("bandwidth", container->type_);
- if (bandwidth == nullptr) {
+ simgrid::instr::Type* bandwidth = container->type_->getChildOrNull("bandwidth");
+ if (bandwidth == nullptr)
bandwidth = simgrid::instr::Type::variableNew("bandwidth", nullptr, container->type_);
- }
- simgrid::instr::Type* latency = simgrid::instr::Type::getOrNull("latency", container->type_);
- if (latency == nullptr) {
+ simgrid::instr::Type* latency = container->type_->getChildOrNull("latency");
+ if (latency == nullptr)
latency = simgrid::instr::Type::variableNew("latency", nullptr, container->type_);
- }
new simgrid::instr::SetVariableEvent(0, container, bandwidth, bandwidth_value);
new simgrid::instr::SetVariableEvent(0, container, latency, latency_value);
}
if (TRACE_uncategorized()) {
- simgrid::instr::Type* bandwidth_used = simgrid::instr::Type::getOrNull("bandwidth_used", container->type_);
- if (bandwidth_used == nullptr) {
+ simgrid::instr::Type* bandwidth_used = container->type_->getChildOrNull("bandwidth_used");
+ if (bandwidth_used == nullptr)
simgrid::instr::Type::variableNew("bandwidth_used", "0.5 0.5 0.5", container->type_);
- }
}
}
container_t container = new simgrid::instr::Container(host.getCname(), simgrid::instr::INSTR_HOST, father);
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
- simgrid::instr::Type* speed = simgrid::instr::Type::getOrNull("power", container->type_);
+ simgrid::instr::Type* speed = container->type_->getChildOrNull("power");
if (speed == nullptr){
speed = simgrid::instr::Type::variableNew("power", nullptr, container->type_);
}
new simgrid::instr::SetVariableEvent(0, container, speed, current_speed_state);
}
if (TRACE_uncategorized()){
- simgrid::instr::Type* speed_used = simgrid::instr::Type::getOrNull("power_used", container->type_);
+ simgrid::instr::Type* speed_used = container->type_->getChildOrNull("power_used");
if (speed_used == nullptr){
simgrid::instr::Type::variableNew("power_used", "0.5 0.5 0.5", container->type_);
}
}
if (TRACE_smpi_is_enabled() && TRACE_smpi_is_grouped()){
- simgrid::instr::Type* mpi = simgrid::instr::Type::getOrNull("MPI", container->type_);
+ simgrid::instr::Type* mpi = container->type_->getChildOrNull("MPI");
if (mpi == nullptr){
mpi = simgrid::instr::Type::containerNew("MPI", container->type_);
simgrid::instr::Type::stateNew("MPI_STATE", mpi);
}
if (TRACE_msg_process_is_enabled()) {
- simgrid::instr::Type* msg_process = simgrid::instr::Type::getOrNull("MSG_PROCESS", container->type_);
+ simgrid::instr::Type* msg_process = container->type_->getChildOrNull("MSG_PROCESS");
if (msg_process == nullptr){
msg_process = simgrid::instr::Type::containerNew("MSG_PROCESS", container->type_);
simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_PROCESS_STATE", msg_process);
- simgrid::instr::Value PJ_value("suspend", "1 0 1", state);
+ new simgrid::instr::Value("suspend", "1 0 1", state);
simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
simgrid::instr::Value::get_or_new("send", "0 0 1", state);
}
if (TRACE_msg_vm_is_enabled()) {
- simgrid::instr::Type* msg_vm = simgrid::instr::Type::getOrNull("MSG_VM", container->type_);
+ simgrid::instr::Type* msg_vm = container->type_->getChildOrNull("MSG_VM");
if (msg_vm == nullptr){
msg_vm = simgrid::instr::Type::containerNew("MSG_VM", container->type_);
simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_VM_STATE", msg_vm);
- simgrid::instr::Value PJ_value("suspend", "1 0 1", state);
+ new simgrid::instr::Value("suspend", "1 0 1", state);
simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
simgrid::instr::Value::get_or_new("send", "0 0 1", state);
simgrid::instr::Type* root)
{
if (not strcmp(root->name_, type_name)) {
- simgrid::instr::Value PJ_value(val, color, root);
+ new simgrid::instr::Value(val, color, root);
}
xbt_dict_cursor_t cursor = nullptr;
simgrid::instr::Type* child_type;
{
if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
container_t container = PJ_container_get(resource);
- simgrid::instr::Type* type = PJ_type_get("power", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("power");
new simgrid::instr::SetVariableEvent(date, container, type, speed);
}
}
{
if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
container_t container = PJ_container_get(resource);
- simgrid::instr::Type* type = PJ_type_get("bandwidth", container->type_);
+ simgrid::instr::Type* type = container->type_->getChild("bandwidth");
new simgrid::instr::SetVariableEvent(date, container, type, bandwidth);
}
}
// assume that flows that reached max_duration have remaining of 0
XBT_DEBUG("Action %p finished", action);
action->setRemains(0);
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
action->heapRemove(actionHeap_);
}
}
if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
}
if ((remains_ <= 0 && (lmm_get_variable_weight(getVariable()) > 0)) ||
((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0))) {
- finish();
- setState(Action::State::done);
+ finish(Action::State::done);
heapRemove(getModel()->getActionHeap());
}
if (((action->getRemainsNoUpdate() <= 0) ||
((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0)))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
}
if(sgFlow->finished_){
xbt_dynar_push(socket_to_destroy,&ns3Socket);
XBT_DEBUG("Destroy socket %p of action %p", ns3Socket, action);
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
} else {
/* Need to check that none of the model has failed */
int i = 0;
void *constraint_id = lmm_constraint_id(cnst);
if (static_cast<simgrid::surf::Resource*>(constraint_id)->isOff()) {
XBT_DEBUG("Action (%p) Failed!!", action);
- action->finish();
- action->setState(Action::State::failed);
+ action->finish(Action::State::failed);
break;
}
cnst = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
std::vector<std::string> args(process->argv, process->argv + process->argc);
std::function<void()> code = factory(std::move(args));
+ std::shared_ptr<std::map<std::string, std::string>> properties(process->properties);
smx_process_arg_t arg = nullptr;
arg->data = nullptr;
arg->host = host;
arg->kill_time = kill_time;
- arg->properties = process->properties;
+ arg->properties = properties;
host->extension<simgrid::simix::Host>()->boot_processes.push_back(arg);
arg->data = nullptr;
arg->host = host;
arg->kill_time = kill_time;
- arg->properties = process->properties;
+ arg->properties = properties;
XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->getCname(), start_time);
SIMIX_timer_set(start_time, [arg, auto_restart]() {
smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), std::move(arg->code), arg->data,
- arg->host, arg->properties, nullptr);
+ arg->host, arg->properties.get(), nullptr);
if (arg->kill_time >= 0)
simcall_process_set_kill_time(actor, arg->kill_time);
if (auto_restart)
XBT_DEBUG("Starting Process %s(%s) right now", arg->name.c_str(), host->getCname());
smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), std::move(code), nullptr, host,
- arg->properties, nullptr);
+ arg->properties.get(), nullptr);
/* The actor creation will fail if the host is currently dead, but that's fine */
if (actor != nullptr) {
SIMIX_process_auto_restart_set(actor, auto_restart);
}
}
- current_property_set = nullptr;
}
void sg_platf_new_peer(PeerCreationArgs* peer)
if (action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 &&
action->storage_->usedSize_ == action->storage_->getSize()) {
- action->finish();
- action->setState(Action::State::failed);
+ action->finish(Action::State::failed);
} else if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
- action->finish();
- action->setState(Action::State::done);
+ action->finish(Action::State::done);
}
}
}
xbt_free(category_);
}
-void Action::finish() {
+void Action::finish(Action::State state)
+{
finishTime_ = surf_get_clock();
+ setState(state);
}
Action::State Action::getState()
//FIXME: duplicated code
if (((remains_ <= 0) && (lmm_get_variable_weight(getVariable()) > 0)) ||
((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0))) {
- finish();
- setState(Action::State::done);
+ finish(Action::State::done);
heapRemove(getModel()->getActionHeap());
}
}
/** @brief Destructor */
virtual ~Action();
- /** @brief Mark that the action is now finished */
- void finish();
+ /**
+ * @brief Mark that the action is now finished
+ *
+ * @param state the new [state](\ref simgrid::surf::Action::State) of the current Action
+ */
+ void finish(Action::State state);
/** @brief Get the [state](\ref simgrid::surf::Action::State) of the current Action */
Action::State getState(); /**< get the state*/
/* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
-/* Copyright (c) 2004-2015. The SimGrid Team.
+/* Copyright (c) 2004-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
int routing;
};
-/* The default current property receiver. Setup in the corresponding opening callbacks. */
-extern std::map<std::string, std::string>* current_property_set;
-
/********** Routing **********/
void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb);
/*** END of the parsing cruft ***/
s_sg_platf_process_cbarg_t actor;
memset(&actor,0,sizeof(actor));
+ actor.properties = current_property_set;
+ current_property_set = nullptr;
+
actor.argc = argc;
actor.argv = (const char **)argv;
- actor.properties = current_property_set;
actor.host = A_surfxml_actor_host;
actor.function = A_surfxml_actor_function;
actor.start_time = surf_parse_get_double(A_surfxml_actor_start___time);
xbt_free(argv[i]);
xbt_free(argv);
argv = nullptr;
-
- current_property_set = nullptr;
}
void STag_surfxml_argument(){
xbt_automaton_propositional_symbol_t symbol = (xbt_automaton_propositional_symbol_t) * (void **) ps;
if (symbol->free_function)
symbol->free_function(symbol->data);
- xbt_free(symbol->pred);
xbt_automaton_propositional_symbol_free(symbol);
}
char* state_id_src;
static void new_state(char* id, int src){
-
+ char* saveptr = NULL; // for strtok_r()
char* id_copy = xbt_strdup(id);
- char* first_part = strtok(id_copy,"_");
+ char* first_part = strtok_r(id_copy, "_", &saveptr);
int type = 0 ; // -1=initial state; 0=intermediate state; 1=final state
if(strcmp(first_part,"accept")==0){
type = 1;
}else{
- char* second_part = strtok(NULL,"_");
+ char* second_part = strtok_r(NULL, "_", &saveptr);
if(strcmp(second_part,"init")==0){
type = -1;
}
-/* Copyright (c) 2005-2016. The SimGrid Team.
+/* Copyright (c) 2005-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <mutex>
#include <xbt/backtrace.hpp>
+#include <xbt/config.hpp>
+#include <xbt/ex.hpp>
#include <xbt/exception.hpp>
#include <xbt/log.h>
#include <xbt/log.hpp>
XBT_LOG(prio, "%s %s: %s", context, name.get(), exception.what());
// Do we have a backtrace?
- if (with_context != nullptr) {
+ if (with_context != nullptr && not xbt_cfg_get_boolean("exception/cutpath")) {
auto backtrace = simgrid::xbt::resolveBacktrace(
with_context->backtrace().data(), with_context->backtrace().size());
for (std::string const& s : backtrace)
static void showBacktrace(std::vector<xbt_backtrace_location_t>& bt)
{
+ if (xbt_cfg_get_boolean("exception/cutpath")) {
+ XBT_LOG(xbt_log_priority_critical, "Display of current backtrace disabled by --cfg=exception/cutpath.");
+ return;
+ }
std::vector<std::string> res = resolveBacktrace(&bt[0], bt.size());
XBT_LOG(xbt_log_priority_critical, "Current backtrace:");
for (std::string const& s : res)
return xbt_heap_pop(H);
}
+
/** @brief Remove an arbitrary element from the heap
- * @param H the heap we're working on
- * @param content the object you want to add to the heap
- * @param key the key associated to this object
+ * \param H the heap we're working on
+ * \param content the object you want to remove from the heap
+ * \param key the key associated to this object
+ * \return the removed element if found, NULL otherwise
*/
-void xbt_heap_rm_elm(xbt_heap_t H, void *content, double key) {
+void *xbt_heap_rm_elm(xbt_heap_t H, void *content, double key)
+{
int i=0;
while (i < H->count && (KEY(H, i) != key || CONTENT(H, i) != content))
i++;
- if (i == H->count)
- return;
- xbt_heap_remove(H,i);
+ return xbt_heap_remove(H, i);
}
/**
xbt_assert(ev->priority < sizeof(xbt_log_priority_names), "Priority %d is greater than the biggest allowed value",
ev->priority);
- do {
+ while (1) {
xbt_log_appender_t appender = cat->appender;
- if (!appender)
- continue; /* No appender, try next */
-
- xbt_assert(cat->layout, "No valid layout for the appender of category %s", cat->name);
-
- /* First, try with a static buffer */
- if (XBT_LOG_STATIC_BUFFER_SIZE) {
- char buff[XBT_LOG_STATIC_BUFFER_SIZE];
- ev->buffer = buff;
- ev->buffer_size = sizeof buff;
- va_start(ev->ap, fmt);
- int done = cat->layout->do_layout(cat->layout, ev, fmt);
- va_end(ev->ap);
- if (done) {
- appender->do_append(appender, buff);
- continue; /* Ok, that worked: go next */
+ if (appender != NULL) {
+ xbt_assert(cat->layout, "No valid layout for the appender of category %s", cat->name);
+
+ /* First, try with a static buffer */
+ int done = 0;
+ if (XBT_LOG_STATIC_BUFFER_SIZE) {
+ char buff[XBT_LOG_STATIC_BUFFER_SIZE];
+ ev->buffer = buff;
+ ev->buffer_size = sizeof buff;
+ va_start(ev->ap, fmt);
+ done = cat->layout->do_layout(cat->layout, ev, fmt);
+ va_end(ev->ap);
+ if (done)
+ appender->do_append(appender, buff);
}
- }
- /* The static buffer was too small, use a dynamically expanded one */
- ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE;
- ev->buffer = xbt_malloc(ev->buffer_size);
- while (1) {
- va_start(ev->ap, fmt);
- int done = cat->layout->do_layout(cat->layout, ev, fmt);
- va_end(ev->ap);
- if (done)
- break; /* Got it */
- ev->buffer_size *= 2;
- ev->buffer = xbt_realloc(ev->buffer, ev->buffer_size);
+ if (!done) {
+ /* The static buffer was too small, use a dynamically expanded one */
+ ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE;
+ ev->buffer = xbt_malloc(ev->buffer_size);
+ while (1) {
+ va_start(ev->ap, fmt);
+ done = cat->layout->do_layout(cat->layout, ev, fmt);
+ va_end(ev->ap);
+ if (done)
+ break; /* Got it */
+ ev->buffer_size *= 2;
+ ev->buffer = xbt_realloc(ev->buffer, ev->buffer_size);
+ }
+ appender->do_append(appender, ev->buffer);
+ xbt_free(ev->buffer);
+ }
}
- appender->do_append(appender, ev->buffer);
- xbt_free(ev->buffer);
- } while (cat->additivity && (cat = cat->parent, 1));
+ if (!cat->additivity)
+ break;
+ cat = cat->parent;
+ }
}
#undef XBT_LOG_DYNAMIC_BUFFER_SIZE
line[read - 1] = '\0';
/* Tokenize the line using spaces as delimiters and store each token in lfields array. We expect 5 tokens for 6 fields */
+ char* saveptr = nullptr; // for strtok_r()
char* lfields[6];
- lfields[0] = strtok(line, " ");
+ lfields[0] = strtok_r(line, " ", &saveptr);
int i;
for (i = 1; i < 6 && lfields[i - 1] != nullptr; i++) {
- lfields[i] = std::strtok(nullptr, " ");
+ lfields[i] = strtok_r(nullptr, " ", &saveptr);
}
/* Check to see if we got the expected amount of columns */
/* Ok we are good enough to try to get the info we need */
/* First get the start and the end address of the map */
- char *tok = std::strtok(lfields[0], "-");
+ char* tok = strtok_r(lfields[0], "-", &saveptr);
if (tok == nullptr)
xbt_die("Start and end address of the map are not concatenated by a hyphen (-). Recovery impossible.");
if (*endptr != '\0')
xbt_abort();
- tok = std::strtok(nullptr, "-");
+ tok = strtok_r(nullptr, "-", &saveptr);
if (tok == nullptr)
xbt_abort();
xbt_abort();
/* Get the device major:minor bytes */
- tok = std::strtok(lfields[3], ":");
+ tok = strtok_r(lfields[3], ":", &saveptr);
if (tok == nullptr)
xbt_abort();
if (*endptr != '\0')
xbt_abort();
- tok = std::strtok(nullptr, ":");
+ tok = strtok_r(nullptr, ":", &saveptr);
if (tok == nullptr)
xbt_abort();
-set(semaphoreGC_files SemaphoreGC)
-set(sleepHostOff_files SleepHostOff)
+set(semaphoregc_files SemaphoreGC)
+set(sleephostoff_files SleepHostOff)
-foreach(example semaphoreGC sleepHostOff)
+foreach(example semaphoregc sleephostoff)
foreach (filename ${${example}_files} )
set(sources "${${example}_sources}" "${CMAKE_CURRENT_SOURCE_DIR}/${example}/${filename}.java")
endforeach()
if(enable_java)
add_custom_command(
COMMENT "Building ${example}..."
- OUTPUT ${example}_compiled
+ OUTPUT java-${example}_compiled
DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} -d ${CMAKE_CURRENT_BINARY_DIR} ${sources}
- COMMAND ${CMAKE_COMMAND} -E remove ${example}/${example}_compiled
- COMMAND ${CMAKE_COMMAND} -E touch ${example}/${example}_compiled
+ COMMAND ${CMAKE_COMMAND} -E remove ${example}/java-${example}_compiled
+ COMMAND ${CMAKE_COMMAND} -E touch ${example}/java-${example}_compiled
)
- add_custom_target(${example} ALL DEPENDS ${example}_compiled)
- set_target_properties(${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
+ add_custom_target(java-${example} ALL DEPENDS java-${example}_compiled)
+ set_target_properties(java-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
endif()
set(examples_src ${examples_src} ${sources})
endforeach()
set(tesh_files ${tesh_files} PARENT_SCOPE)
if(enable_java)
- ADD_TESH(tesh-java-semaphoreGC --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/semaphoreGC ${CMAKE_HOME_DIRECTORY}/teshsuite/java/semaphoreGC/semaphoreGC.tesh)
- ADD_TESH(tesh-java-sleepHostOff --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/sleepHostOff ${CMAKE_HOME_DIRECTORY}/teshsuite/java/sleepHostOff/sleepHostOff.tesh)
+ ADD_TESH(tesh-java-semaphoregc --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/semaphoregc ${CMAKE_HOME_DIRECTORY}/teshsuite/java/semaphoregc/semaphoregc.tesh)
+ ADD_TESH(tesh-java-sleephostoff --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/sleephostoff ${CMAKE_HOME_DIRECTORY}/teshsuite/java/sleephostoff/sleephostoff.tesh)
endif()
* This was reported as bug #19893 on gforge.
*/
-package semaphoreGC;
+package semaphoregc;
import org.simgrid.msg.*;
import org.simgrid.msg.Process;
public static void main(String[] args) throws Exception {
Msg.init(args);
if (args.length < 1) {
- Msg.info("Usage: java -cp simgrid.jar:. semaphoreGC.SemaphoreGC <deployment.xml>");
+ Msg.info("Usage: java -cp simgrid.jar:. semaphoregc.SemaphoreGC <deployment.xml>");
System.exit(1);
}
Msg.createEnvironment(args[0]);
! timeout 15
-$ java -classpath ${classpath:=.} semaphoreGC.SemaphoreGC ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.4r]%e(%i:%P@%h)%e%m%n"
+$ java -classpath ${classpath:=.} semaphoregc.SemaphoreGC ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.4r]%e(%i:%P@%h)%e%m%n"
> [ 0.0000] (0:maestro@) Using regular java threads.
> [ 0.0000] (1:SemCreator@Fafard) Creating 50 new Semaphores, yielding and triggering a GC after each
> [ 500.0000] (1:SemCreator@Fafard) It worked, we survived. The test is passed.
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-package sleepHostOff;
+package sleephostoff;
import org.simgrid.msg.*;
import org.simgrid.msg.Process;
Msg.init(args);
if (args.length < 1) {
- Msg.info("Usage: java -cp simgrid.jar:. sleepHostOff.SleepHostOff <platform.xml>");
+ Msg.info("Usage: java -cp simgrid.jar:. sleephostoff.SleepHostOff <platform.xml>");
System.exit(1);
}
-$ java -classpath ${classpath:=.} sleepHostOff.SleepHostOff ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ java -classpath ${classpath:=.} sleephostoff.SleepHostOff ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (0:maestro@) Using regular java threads.
> [ 0.000000] (1:TestRunner@Fafard) **** **** **** ***** ***** Test Sleep ***** ***** **** **** ****
> [ 0.000000] (1:TestRunner@Fafard) Test sleep: Create a process on Tremblay that simply make periodic sleep, turn off Tremblay
-$ ${bindir:=.}/../../examples/msg/app-masterworker/app-masterworker ${srcdir:=.}/../../examples/platforms/small_platform.lua ${srcdir:=.}/../../examples/msg/app-masterworker/app-masterworker_d.xml
+$ ${bindir:=.}/msg/app-masterworker/app-masterworker ${srcdir:=.}/../../examples/platforms/small_platform.lua ${srcdir:=.}/../../examples/msg/app-masterworker/app-masterworker_d.xml
> [Tremblay:master:(1) 0.000000] [msg_app_masterworker/INFO] Got 5 workers and 20 tasks to process
> [Tremblay:master:(1) 0.000000] [msg_app_masterworker/INFO] Sending "Task_0" (of 20) to mailbox "worker-0"
> [Tremblay:master:(1) 0.002265] [msg_app_masterworker/INFO] Sending "Task_1" (of 20) to mailbox "worker-1"
> [Bourassa:worker:(6) 5.133855] [msg_app_masterworker/INFO] I'm done. See you!
> [5.133855] [msg_app_masterworker/INFO] Simulation time 5.13386
-$ $SG_TEST_EXENV ${bindir:=.}/../../examples/msg/app-token-ring/app-token-ring ${srcdir:=.}/../../examples/platforms/routing_cluster.lua "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/msg/app-token-ring/app-token-ring ${srcdir:=.}/../../examples/platforms/routing_cluster.lua "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (0:maestro@) Number of hosts '6'
> [ 0.000000] (1:0@host1) Host "0" send 'Token' to Host "1"
> [ 0.017354] (2:1@host2) Host "1" received "Token"
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp2.5-hbp1.5.xml PARENT_SCOPE)
foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel task_listen_from trace_integration)
- ADD_TESH_FACTORIES(tesh-msg-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
+ ADD_TESH_FACTORIES(tesh-msg-${x} "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
endforeach()
foreach(x actions-comm actions-storage app-bittorrent)
ADD_TESH(tesh-msg-${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
endforeach()
-ADD_TESH_FACTORIES(tesh-app-bittorrent-parallel "thread;ucontext;raw" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/msg/app-bittorrent --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/app-bittorrent app-bittorrent.tesh)
+ADD_TESH_FACTORIES(tesh-app-bittorrent-parallel "thread;ucontext;raw;boost" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/msg/app-bittorrent --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/app-bittorrent app-bittorrent.tesh)
xbt_dynar_t tests;
int tasks_done = 0;
+static void task_cleanup_handler(void *task)
+{
+ if (task)
+ MSG_task_destroy(task);
+}
+
static int process_daemon(int argc, char *argv[])
{
+ msg_process_t self = MSG_process_self();
XBT_INFO(" Start daemon on %s (%f)", MSG_host_get_name(MSG_host_self()), MSG_host_get_speed(MSG_host_self()));
for(;;){
msg_task_t task = MSG_task_create("daemon", MSG_host_get_speed(MSG_host_self()), 0, NULL);
+ MSG_process_set_data(self, task);
XBT_INFO(" Execute daemon");
MSG_task_execute(task);
+ MSG_process_set_data(self, NULL);
MSG_task_destroy(task);
tasks_done ++;
}
const char * mailbox = "comm";
XBT_INFO(" Start TX");
msg_task_t task = MSG_task_create("COMM", 0, 100000000, NULL);
- MSG_task_isend(task, mailbox);
+ MSG_task_dsend(task, mailbox, task_cleanup_handler);
// We should wait a bit (if not the process will end before the communication, hence an exception on the other side).
MSG_process_sleep(30);
XBT_INFO(" TX done");
msg_error_t error = MSG_task_receive(&(task), mailbox);
if (error==MSG_OK) {
XBT_INFO(" Receive message: %s", task->name);
+ MSG_task_destroy(task);
} else if (error==MSG_HOST_FAILURE) {
XBT_INFO(" Receive message: HOST_FAILURE");
} else if (error==MSG_TRANSFER_FAILURE) {
MSG_process_sleep(10);
XBT_INFO(" Turn Jupiter off");
MSG_host_off(jupiter);
- XBT_INFO("Test 5 seems ok, cool !(number of Process : %d, it should be 2", MSG_process_get_number());
+ XBT_INFO("Test 5 seems ok (number of Process: %d, it should be 2)", MSG_process_get_number());
}
test =6;
if (xbt_dynar_search_or_negative(tests, &test)!=-1){
+ MSG_process_set_data_cleanup(NULL); /* FIXME: we are leaking here, but removing this line changes the test output */
XBT_INFO("Test 6: Turn on Jupiter, assign a VM on Jupiter, launch a process inside the VM, and turn off the node");
// Create VM0
MSG_create_environment(argv[1]);
+ MSG_process_set_data_cleanup(task_cleanup_handler);
MSG_process_create("test_launcher", test_launcher, NULL, MSG_get_host_by_name("Tremblay"));
res = MSG_main();
XBT_INFO("Simulation time %g", MSG_get_clock());
+ xbt_dynar_free(&tests);
return res != MSG_OK;
}
> [Tremblay:commTX:(3) 10.000000] [msg_test/INFO] Start TX
> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] number of processes: 3
> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Turn Jupiter off
-> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test 5 seems ok, cool !(number of Process : 2, it should be 2
+> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test 5 seems ok (number of Process: 2, it should be 2)
> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test done. See you!
> [Tremblay:commTX:(3) 40.000000] [msg_test/INFO] TX done
> [40.000000] [msg_test/INFO] Simulation time 40
## Some need to be run with all factories, some need not tesh to run
foreach(x actor concurrent_rw)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
- ADD_TESH_FACTORIES(tesh-s4u-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
+ ADD_TESH_FACTORIES(tesh-s4u-${x} "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
endforeach()
foreach(x host_on_off_wait listen_async pid storage_client_server)
ADD_TESH(tesh-simix-factory-default --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simix/check_defaults --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/check_defaults factory_thread.tesh)
ENDIF()
+if (NOT enable_memcheck AND NOT enable_address_sanitizer)
+ ADD_TESH_FACTORIES(stack-overflow "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simix/stack_overflow --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/stack_overflow stack_overflow.tesh)
+endif()
if (NOT enable_memcheck)
-ADD_TESH_FACTORIES(stack-overflow "thread;ucontext;boost;raw" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simix/stack_overflow --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/stack_overflow stack_overflow.tesh)
-ADD_TESH_FACTORIES(generic-simcalls "thread;ucontext;boost;raw" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simix/generic_simcalls --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/generic_simcalls generic_simcalls.tesh)
+ ADD_TESH_FACTORIES(generic-simcalls "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simix/generic_simcalls --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/generic_simcalls generic_simcalls.tesh)
endif()
foreach (factory raw thread boost ucontext)
-/* Copyright (c) 2016. The SimGrid Team.
+/* Copyright (c) 2016-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
XBT_INFO("kernel, returned");
// Synchronize on a successful Future<void>:
- simgrid::simix::kernelSync([&] {
+ simgrid::simix::kernelSync([] {
return kernel_wait_until(10).then([](simgrid::kernel::Future<void> future) {
future.get();
XBT_INFO("kernelSync with void");
// Synchronize on a failing Future<void>:
try {
- simgrid::simix::kernelSync([&] {
+ simgrid::simix::kernelSync([] {
return kernel_wait_until(20).then([](simgrid::kernel::Future<void> future) {
future.get();
throw std::runtime_error("Exception throwed from kernel_defer");
}
// Synchronize on a successul Future<int> and get the value:
- int res = simgrid::simix::kernelSync([&] {
+ int res = simgrid::simix::kernelSync([] {
return kernel_wait_until(30).then([](simgrid::kernel::Future<void> future) {
future.get();
XBT_INFO("kernelSync with value");
XBT_INFO("kernelSync with value returned with %i", res);
// Synchronize on a successul Future<int> and get the value:
- simgrid::simix::Future<int> future = simgrid::simix::kernelAsync([&] {
+ simgrid::simix::Future<int> future = simgrid::simix::kernelAsync([] {
return kernel_wait_until(50).then([](simgrid::kernel::Future<void> future) {
future.get();
XBT_INFO("kernelAsync with value");
XBT_INFO("kernelAsync with value returned with %i", res);
// Synchronize on a successul Future<int> and get the value:
- future = simgrid::simix::kernelAsync([&] {
+ future = simgrid::simix::kernelAsync([] {
return kernel_wait_until(60).then([](simgrid::kernel::Future<void> future) {
future.get();
XBT_INFO("kernelAsync with value");
no-error-wait-any_src3
no-error-wait-any_src4
no-error-waitany-any_src
- partial-recv
sendrecv-deadlock
send-recv-ok
irecv-isend-ok
set(umpire_tests_passing_broken
irecv-isend-ok2
+ partial-recv
)
# These are supposed to deadlock but ISP does not find deadlock
endif()
# Test MPICH selector: dlopen privatization and PTHREAD if exists (without priv and with raw if not)
- if(HAVE_PRIVATIZATION AND HAVE_THREAD_CONTEXTS)
- ADD_TEST(test-smpi-mpich3-coll-mpich-thread-dlopen ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:thread -execarg=--cfg=smpi/coll-selector:mpich -execarg=--cfg=smpi/privatization:dlopen)
- SET_TESTS_PROPERTIES(test-smpi-mpich3-coll-mpich-thread-dlopen PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
+ if(HAVE_PRIVATIZATION AND HAVE_BOOST_CONTEXTS)
+ ADD_TEST(test-smpi-mpich3-coll-mpich-boost-dlopen ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:boost -execarg=--cfg=smpi/coll-selector:mpich -execarg=--cfg=smpi/privatization:dlopen)
+ SET_TESTS_PROPERTIES(test-smpi-mpich3-coll-mpich-boost-dlopen PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
else()
if(HAVE_RAW_CONTEXTS)
ADD_TEST(test-smpi-mpich3-coll-mpich-raw ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:raw -execarg=--cfg=smpi/coll-selector:mpich -execarg=--cfg=smpi/privatization:${HAVE_PRIVATIZATION})
tools/cmake/scripts/update_tesh.pl
tools/cmake/UnitTesting.cmake
tools/cmake/src/internal_config.h.in
+ tools/cmake/test_prog/prog_asan.cpp
tools/cmake/test_prog/prog_gnu_dynlinker.c
tools/cmake/test_prog/prog_makecontext.c
tools/cmake/test_prog/prog_mutex_timedlock.c
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=address")
set(TESH_OPTION --enable-sanitizers)
+ try_compile(HAVE_SANITIZE_ADDRESS ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_asan.cpp)
+ try_compile(HAVE_SANITIZE_ADDRESS_FIBER_SUPPORT ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_asan.cpp
+ COMPILE_DEFINITIONS -DCHECK_FIBER_SUPPORT)
+else()
+ set(HAVE_SANITIZE_ADDRESS FALSE CACHE INTERNAL "")
+ set(HAVE_SANITIZE_ADDRESS_FIBER_SUPPORT FALSE CACHE INTERNAL "")
endif()
if(enable_thread_sanitizer)
if(SIMGRID_HAVE_LUA)
ADD_CUSTOM_TARGET(link_simgrid_lua ALL
DEPENDS simgrid
- ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
- ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
- ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
- )
- add_custom_command(
- OUTPUT ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
- ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
- ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
- COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
- COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
-
- COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
- COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
-
- COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
- COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
)
SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY} ${DL_LIBRARY}")
endif()
IF(SIMGRID_HAVE_LUA)
# Tests testing simulation from C but using lua for platform files. Executed like this
# ~$ ./masterslave platform.lua deploy.lua
- ADD_TESH(lua-platform-masterslave --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/lua --cd ${CMAKE_BINARY_DIR}/examples/lua ${CMAKE_HOME_DIRECTORY}/teshsuite/lua/lua_platforms.tesh)
- SET_TESTS_PROPERTIES(lua-platform-masterslave PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/examples/lua/?.so")
+ ADD_TESH(lua-platform-masterslave --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/lua --cd ${CMAKE_BINARY_DIR}/examples ${CMAKE_HOME_DIRECTORY}/teshsuite/lua/lua_platforms.tesh)
+ SET_TESTS_PROPERTIES(lua-platform-masterslave PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/lib/lib?.${LIB_EXE}")
ENDIF()
ADD_TEST(testall ${CMAKE_BINARY_DIR}/testall)
else()
set(EXTRA_DIST ${EXTRA_DIST} src/surf/trace_mgr_test.cpp)
-endif()
\ No newline at end of file
+endif()
/* Warning: The file internal_config.h is AUTOMATICALLY GENERATED by Cmake.
* Edit the template instead: tools/cmake/src/internal_config.h.in */
-/* Copyright (c) 2004-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* <valgrind/valgrind.h> */
#cmakedefine01 HAVE_VALGRIND_H
+/* Address Sanitizer */
+#cmakedefine01 HAVE_SANITIZE_ADDRESS
+#cmakedefine01 HAVE_SANITIZE_ADDRESS_FIBER_SUPPORT
+
/* Time portability */
/* Function gettimeofday */
#cmakedefine01 HAVE_GETTIMEOFDAY
--- /dev/null
+/* Copyright (c) 2017. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+/* Check availability of AddressSanitizer */
+
+#if defined(__has_feature)
+#define HAS_FEATURE(x) __has_feature(x)
+#else
+#define HAS_FEATURE(x) 0
+#endif
+
+#if not HAS_FEATURE(address_sanitizer) && not defined(__SANITIZE_ADDRESS__)
+#error "ASan feature not found."
+#endif
+
+#include <sanitizer/asan_interface.h>
+
+#if defined(CHECK_FIBER_SUPPORT)
+// Verify the existence of the fiber annotation interface, with the expected signature
+void (*start_fiber)(void**, const void*, size_t) = __sanitizer_start_switch_fiber;
+void (*finish_fiber)(void*, const void**, size_t*) = __sanitizer_finish_switch_fiber;
+#endif
+
+int main(void)
+{
+}
{
Memory leak in cmake
Memcheck:Leak
+ match-leak-kinds:reachable
+ ...
+ fun:_Znwm
+ fun:_ZN4Json5Value13nullSingletonEv
+ obj:*/libjsoncpp.so*
...
- obj:cmake
+ fun:_dl_init
}
# There's a constant leak of 56 bytes in the depths of libc which
#SMPI leaks the dlopen handle used to load the program
{
- dlopen handle leaks (1/2)
+ dlopen handle leaks (1/3)
Memcheck:Leak
match-leak-kinds:reachable
fun:malloc
}
{
- dlopen handle leaks (2/2)
+ dlopen handle leaks (2/3)
Memcheck:Leak
match-leak-kinds:reachable
fun:calloc
fun:dlopen@@GLIBC_*
}
+{
+ dlopen handle leaks (3/3)
+ Memcheck:Leak
+ match-leak-kinds:reachable
+ fun:realloc
+ ...
+ fun:dlopen@@GLIBC_*
+}
+
# Memory leaks appearing to be in libcgraph. They can be seen with the
# following simple program:
# ,----
group1.add_argument('teshfile', nargs='?', help='Name of teshfile, stdin if omitted')
group1.add_argument('--cd', metavar='some/directory', help='ask tesh to switch the working directory before launching the tests')
group1.add_argument('--setenv', metavar='var=value', action='append', help='set a specific environment variable')
- group1.add_argument('--cfg', metavar='arg', help='add parameter --cfg=arg to each command line')
- group1.add_argument('--log', metavar='arg', help='add parameter --log=arg to each command line')
+ group1.add_argument('--cfg', metavar='arg', action='append', help='add parameter --cfg=arg to each command line')
+ group1.add_argument('--log', metavar='arg', action='append', help='add parameter --log=arg to each command line')
group1.add_argument('--ignore-jenkins', action='store_true', help='ignore all cruft generated on SimGrid continous integration servers')
group1.add_argument('--wrapper', metavar='arg', help='Run each command in the provided wrapper (eg valgrind)')
group1.add_argument('--keep', action='store_true', help='Keep the obtained output when it does not match the expected one')
if options.ignore_jenkins:
print("Ignore all cruft seen on SimGrid's continous integration servers")
+ # Note: regexps should match at the beginning of lines
TeshState().ignore_regexps_common = [
- re.compile("^profiling:"),
- re.compile(".*WARNING: ASan doesn\'t fully support"),
- re.compile("Unable to clean temporary file C:.*"),
+ re.compile("profiling:"),
+ re.compile("Unable to clean temporary file C:"),
re.compile(".*Configuration change: Set \'contexts/"),
- re.compile(".*Picked up JAVA_TOOL_OPTIONS.*"),
- re.compile("Picked up _JAVA_OPTIONS: .*"),
-
- re.compile("==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top:"),
+ re.compile("Picked up JAVA_TOOL_OPTIONS: "),
+ re.compile("Picked up _JAVA_OPTIONS: "),
+ re.compile("==[0-9]+== ?WARNING: ASan doesn\'t fully support"),
+ re.compile("==[0-9]+== ?WARNING: ASan is ignoring requested __asan_handle_no_return: stack top:"),
re.compile("False positive error reports may follow"),
- re.compile("For details see http://code.google.com/p/address-sanitizer/issues/detail?id=189"),
-
+ re.compile("For details see http://code.google.com/p/address-sanitizer/issues/detail\\?id=189"),
+ re.compile("For details see https://github.com/google/sanitizers/issues/189"),
re.compile("Python runtime initialized with LC_CTYPE=C .*"),
]
TeshState().jenkins = True # This is a Jenkins build
setenv(e)
if options.cfg is not None:
- TeshState().args_suffix += " --cfg="+options.cfg
+ for c in options.cfg:
+ TeshState().args_suffix += " --cfg=" + c
if options.log is not None:
- TeshState().args_suffix += " --log="+options.log
+ for l in options.log:
+ TeshState().args_suffix += " --log=" + l
if options.wrapper is not None:
TeshState().wrapper = options.wrapper