From: Martin Quinson Date: Fri, 2 Jun 2017 15:04:57 +0000 (+0200) Subject: Merge pull request #179 from Takishipp/signals X-Git-Tag: v3.16~153 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/29d98d1ceb682fbc4c734a92353be4b0bcd5d17b?hp=eff6e71fac6ed5fa431bec9d4bd5bad22e9a0244 Merge pull request #179 from Takishipp/signals call sg_instr_new_host via signal call --- diff --git a/.gitignore b/.gitignore index c5eea27e85..f1b3b52d48 100644 --- a/.gitignore +++ b/.gitignore @@ -122,7 +122,6 @@ 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-yield/async-yield examples/msg/async-wait/async-wait examples/msg/async-waitall/async-waitall examples/msg/async-waitany/async-waitany @@ -155,6 +154,7 @@ examples/msg/process-join/process-join examples/msg/process-migration/process-migration examples/msg/process-startkilltime/process-startkilltime examples/msg/process-suspend/process-suspend +examples/msg/process-yield/process-yield examples/msg/app-masterworker/app-masterworker examples/msg/mc/bugged1 examples/msg/mc/bugged1_liveness @@ -248,6 +248,7 @@ 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/cloud-sharing/cloud-sharing teshsuite/msg/concurrent_rw/concurrent_rw teshsuite/msg/get_sender/get_sender teshsuite/msg/host_on_off/host_on_off @@ -259,6 +260,7 @@ teshsuite/msg/pid/pid teshsuite/msg/process/process teshsuite/msg/storage_client_server/storage_client_server teshsuite/msg/task_destroy_cancel/task_destroy_cancel +teshsuite/msg/task_listen_from/task_listen_from teshsuite/msg/trace_integration/trace_integration teshsuite/simdag/availability/availability teshsuite/simdag/basic-link-test/basic-link-test diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fede4c2b3..58d7dbb5de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,10 +156,6 @@ if(NOT PYTHONINTERP_FOUND) message(FATAL_ERROR "Please install Python (version 3 or higher).") endif() -if (APPLE) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -endif() SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) ### Compute the include paths diff --git a/ChangeLog b/ChangeLog index 449c17d607..8562356777 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ SimGrid (3.16) UNRELEASED Portability status: - FreeBSD: Disable SMPI mmap privatization, switch automatically to dlopen. - Mac, BSD: dlopen+thread broken, switch automatically to raw contexts. + - Java JAR file should be finally fully working on Mac OSX too. XML platforms: Switch to platform v4.1 format. * This is (mainly) a backward compatible change: v4 are valid v4.1 files @@ -25,6 +26,9 @@ SimGrid (3.16) UNRELEASED simulation round, s/he has to allocate and free a dynar and use it as argument to this function. The former SD_simulate (double how_long) now returns void. + Virtual Machines + - Allow multicore VMs, along with the correct sharing computations + MSG - The netzone are now available from the MSG API. The old names still work, but are now deprecated. diff --git a/doc/doxygen/options.doc b/doc/doxygen/options.doc index 3fad32cb85..6a94beb730 100644 --- a/doc/doxygen/options.doc +++ b/doc/doxygen/options.doc @@ -1218,13 +1218,8 @@ It can be done by using XBT. Go to \ref XBT_log for more details. \section options_index Index of all existing configuration options \note - Almost all options are defined in src/simgrid/sg_config.c. You may - want to check this file, too, but this index should be somewhat complete - for the moment (May 2015). - -\note - \b Please \b note: You can also pass the command-line option "--help" and - "--help-cfg" to an executable that uses simgrid. + The full list can be retrieved by passing "--help" and + "--help-cfg" to an executable that uses SimGrid. - \c clean-atexit: \ref options_generic_clean_atexit diff --git a/examples/java/dht/chord/Node.java b/examples/java/dht/chord/Node.java index 1817ab36cf..87c4e50e34 100644 --- a/examples/java/dht/chord/Node.java +++ b/examples/java/dht/chord/Node.java @@ -330,9 +330,9 @@ public class Node extends Process { // Performs a find successor request to a random id. private void randomLookup() { - int id = 1337; - //Msg.info("Making a lookup request for id " + id); - findSuccessor(id); + int dest = 1337; + //Msg.info("Making a lookup request for id " + dest); + findSuccessor(dest); } /** diff --git a/examples/java/dht/kademlia/Answer.java b/examples/java/dht/kademlia/Answer.java index c339c3b21c..7a348311e8 100644 --- a/examples/java/dht/kademlia/Answer.java +++ b/examples/java/dht/kademlia/Answer.java @@ -59,7 +59,7 @@ public class Answer { /* Returns if the destination has been found */ public boolean destinationFound() { - if (nodes.size() < 1) { + if (nodes.isEmpty()) { return false; } Contact tail = nodes.get(0); diff --git a/examples/msg/app-bittorrent/peer.c b/examples/msg/app-bittorrent/peer.c index 40a8256a13..959e5230d3 100644 --- a/examples/msg/app-bittorrent/peer.c +++ b/examples/msg/app-bittorrent/peer.c @@ -454,7 +454,7 @@ void remove_current_piece(peer_t peer, connection_t remote_peer, unsigned int cu void update_pieces_count_from_bitfield(peer_t peer, unsigned int bitfield) { for (int i = 0; i < FILE_PIECES; i++) { - if ((bitfield & (1U << i))) { + if (bitfield & (1U << i)) { peer->pieces_count[i]++; } } diff --git a/examples/msg/cloud-two-tasks/cloud-two-tasks.c b/examples/msg/cloud-two-tasks/cloud-two-tasks.c index c9afd7c6db..6ba0ebec62 100644 --- a/examples/msg/cloud-two-tasks/cloud-two-tasks.c +++ b/examples/msg/cloud-two-tasks/cloud-two-tasks.c @@ -62,9 +62,9 @@ static int master_main(int argc, char *argv[]) launch_computation_worker(vm0); while(MSG_get_clock()<100) { - if (atask != NULL) - XBT_INFO("aTask remaining duration: %g", MSG_task_get_flops_amount(atask)); - MSG_process_sleep(1); + if (atask != NULL) + XBT_INFO("aTask remaining duration: %g", MSG_task_get_flops_amount(atask)); + MSG_process_sleep(1); } MSG_process_sleep(10000); @@ -73,23 +73,13 @@ static int master_main(int argc, char *argv[]) return 1; } -static void launch_master(msg_host_t host) -{ - const char *pr_name = "master_"; - char **argv = xbt_new(char *, 2); - argv[0] = xbt_strdup(pr_name); - argv[1] = NULL; - - MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv); -} - int main(int argc, char *argv[]){ MSG_init(&argc, argv); xbt_assert(argc == 2); MSG_create_environment(argv[1]); - launch_master(MSG_host_by_name("Fafard")); + MSG_process_create("master_", master_main, NULL, MSG_host_by_name("Fafard")); int res = MSG_main(); XBT_INFO("Bye (simulation time %g)", MSG_get_clock()); diff --git a/examples/msg/energy-vm/energy-vm.c b/examples/msg/energy-vm/energy-vm.c index 0ec0344cc7..68ca470078 100644 --- a/examples/msg/energy-vm/energy-vm.c +++ b/examples/msg/energy-vm/energy-vm.c @@ -25,9 +25,9 @@ static int dvfs(int argc, char *argv[]) /* Host 1 */ XBT_INFO("Creating and starting two VMs"); - msg_vm_t vm_host1 = MSG_vm_create(host1, "vm_host1", 2048, 10, 50); + msg_vm_t vm_host1 = MSG_vm_create(host1, "vm_host1", 1, 2048, 10, 50); MSG_vm_start(vm_host1); - msg_vm_t vm_host3 = MSG_vm_create(host3, "vm_host3", 2048, 10, 50); + msg_vm_t vm_host3 = MSG_vm_create(host3, "vm_host3", 1, 2048, 10, 50); MSG_vm_start(vm_host3); XBT_INFO("Create two tasks on Host1: one inside a VM, the other directly on the host"); diff --git a/examples/msg/mc/bugged1.c b/examples/msg/mc/bugged1.c index 77e429b75d..d85f8990db 100644 --- a/examples/msg/mc/bugged1.c +++ b/examples/msg/mc/bugged1.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2010-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2010-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. */ diff --git a/examples/msg/mc/bugged1_liveness.c b/examples/msg/mc/bugged1_liveness.c index fda05544cf..47107f0fca 100644 --- a/examples/msg/mc/bugged1_liveness.c +++ b/examples/msg/mc/bugged1_liveness.c @@ -1,14 +1,13 @@ -/* Copyright (c) 2012-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-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. */ -/***************** Centralized Mutual Exclusion Algorithm *********************/ -/* This example implements a centralized mutual exclusion algorithm. */ -/* Bug : CS requests of client 1 not satisfied */ -/* LTL property checked : G(r->F(cs)); (r=request of CS, cs=CS ok) */ -/******************************************************************************/ +/***************** Centralized Mutual Exclusion Algorithm *******************/ +/* This example implements a centralized mutual exclusion algorithm. */ +/* Bug : CS requests of client 1 not satisfied */ +/* LTL property checked : G(r->F(cs)); (r=request of CS, cs=CS ok) */ +/****************************************************************************/ #ifdef GARBAGE_STACK #include @@ -38,8 +37,9 @@ static void garbage_stack(void) { static int coordinator(int argc, char *argv[]) { - int CS_used = 0; - msg_task_t task = NULL, answer = NULL; + int CS_used = 0; + msg_task_t task = NULL; + msg_task_t answer = NULL; xbt_dynar_t requests = xbt_dynar_new(sizeof(char *), NULL); char *req; @@ -88,7 +88,8 @@ static int client(int argc, char *argv[]) int my_pid = MSG_process_get_PID(MSG_process_self()); char *my_mailbox = xbt_strdup(argv[1]); - msg_task_t grant = NULL, release = NULL; + msg_task_t grant = NULL; + msg_task_t release = NULL; while(1){ XBT_INFO("Ask the request"); diff --git a/examples/msg/mc/bugged2.c b/examples/msg/mc/bugged2.c index 9087da3cc2..90dba114cb 100644 --- a/examples/msg/mc/bugged2.c +++ b/examples/msg/mc/bugged2.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2010-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2010-2015. 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. */ @@ -19,16 +18,15 @@ static int server(int argc, char *argv[]) { msg_task_t task1 = NULL; msg_task_t task2 = NULL; - long val1, val2; MSG_task_receive(&task1, "mymailbox"); - val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s"); + long val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s"); MSG_task_destroy(task1); task1 = NULL; XBT_INFO("Received %lu", val1); MSG_task_receive(&task2, "mymailbox"); - val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s"); + long val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s"); MSG_task_destroy(task2); task2 = NULL; XBT_INFO("Received %lu", val2); diff --git a/examples/msg/mc/bugged3.c b/examples/msg/mc/bugged3.c index 3d8d7364a9..879c37d9ea 100644 --- a/examples/msg/mc/bugged3.c +++ b/examples/msg/mc/bugged3.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2010-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2010-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. */ @@ -21,7 +20,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(bugged3, "this example"); static int server(int argc, char *argv[]) { - msg_task_t task1,task2; + msg_task_t task1 = NULL; + msg_task_t task2 = NULL; msg_comm_t comm1 = MSG_task_irecv(&task1, "mymailbox1"); msg_comm_t comm2 = MSG_task_irecv(&task2, "mymailbox2"); diff --git a/examples/msg/mc/electric_fence.c b/examples/msg/mc/electric_fence.c index 7d32c04d4c..b8b2c5313c 100644 --- a/examples/msg/mc/electric_fence.c +++ b/examples/msg/mc/electric_fence.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-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. */ @@ -21,7 +20,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(electric_fence, "Example to check the soundness of static int server(int argc, char *argv[]) { - msg_task_t task1 = NULL, task2 = NULL; + msg_task_t task1 = NULL; + msg_task_t task2 = NULL; msg_comm_t comm_received1 = MSG_task_irecv(&task1, "mymailbox"); msg_comm_t comm_received2 = MSG_task_irecv(&task2, "mymailbox"); diff --git a/examples/simdag/availability/sd_availability.c b/examples/simdag/availability/sd_availability.c index b85738c095..1d9c75c775 100644 --- a/examples/simdag/availability/sd_availability.c +++ b/examples/simdag/availability/sd_availability.c @@ -94,7 +94,6 @@ int main(int argc, char **argv) } xbt_dynar_reset(changed_tasks); } - SD_exit(); xbt_free(hosts); xbt_dynar_free(&changed_tasks); return 0; diff --git a/examples/simdag/dag-dotload/sd_dag-dotload.c b/examples/simdag/dag-dotload/sd_dag-dotload.c index 11260d929d..6baccb0fbc 100644 --- a/examples/simdag/dag-dotload/sd_dag-dotload.c +++ b/examples/simdag/dag-dotload/sd_dag-dotload.c @@ -33,7 +33,6 @@ int main(int argc, char **argv) dot = SD_dotload(argv[2]); if(dot == NULL){ XBT_CRITICAL("No dot loaded. Do you have a cycle in your graph?"); - SD_exit(); exit(2); } @@ -104,6 +103,5 @@ int main(int argc, char **argv) fclose(out); /* exit */ - SD_exit(); return 0; } diff --git a/examples/simdag/daxload/sd_daxload.c b/examples/simdag/daxload/sd_daxload.c index 45cbd05d48..e3af5411e6 100644 --- a/examples/simdag/daxload/sd_daxload.c +++ b/examples/simdag/daxload/sd_daxload.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) if (!dax){ XBT_ERROR("A problem occurred during DAX parsing (cycle or syntax). Do not continue this test"); free(tracefilename); - SD_exit(); + exit(255); } @@ -108,6 +108,5 @@ int main(int argc, char **argv) fclose(out); xbt_dynar_free_container(&dax); - SD_exit(); return 0; } diff --git a/examples/simdag/fail/sd_fail.c b/examples/simdag/fail/sd_fail.c index 1cc34e7032..2d3c9f6ce4 100644 --- a/examples/simdag/fail/sd_fail.c +++ b/examples/simdag/fail/sd_fail.c @@ -85,6 +85,5 @@ int main(int argc, char **argv) SD_task_get_finish_time(task)); SD_task_destroy(task); - SD_exit(); return 0; } diff --git a/examples/simdag/goal/goal_test.c b/examples/simdag/goal/goal_test.c index 290e5f3b55..6dfc394840 100644 --- a/examples/simdag/goal/goal_test.c +++ b/examples/simdag/goal/goal_test.c @@ -99,7 +99,6 @@ int main(int argc, char **argv) { xbt_dynar_free(&done); xbt_dynar_free(&reclaimed); - SD_exit(); XBT_INFO("Done. Bailing out"); return 0; } diff --git a/examples/simdag/properties/sd_properties.c b/examples/simdag/properties/sd_properties.c index 94186bd93a..697c10c83d 100644 --- a/examples/simdag/properties/sd_properties.c +++ b/examples/simdag/properties/sd_properties.c @@ -72,6 +72,5 @@ int main(int argc, char **argv) /* Test if properties are displayed by sg_host_dump */ sg_host_dump(h2); - SD_exit(); return 0; } diff --git a/examples/simdag/ptg-dotload/sd_ptg-dotload.c b/examples/simdag/ptg-dotload/sd_ptg-dotload.c index 4104475845..e6b45de68d 100644 --- a/examples/simdag/ptg-dotload/sd_ptg-dotload.c +++ b/examples/simdag/ptg-dotload/sd_ptg-dotload.c @@ -27,7 +27,6 @@ int main(int argc, char **argv){ /* load the DOT file */ dot = SD_PTG_dotload(argv[2]); if(dot == NULL){ - SD_exit(); xbt_die("No dot load may be you have a cycle in your graph"); } @@ -56,7 +55,5 @@ int main(int argc, char **argv){ } xbt_dynar_free_container(&dot); - /* exit */ - SD_exit(); return 0; } diff --git a/examples/simdag/schedule-dotload/sd_schedule-dotload.c b/examples/simdag/schedule-dotload/sd_schedule-dotload.c index 67a27934e9..aa77528c9f 100644 --- a/examples/simdag/schedule-dotload/sd_schedule-dotload.c +++ b/examples/simdag/schedule-dotload/sd_schedule-dotload.c @@ -34,7 +34,6 @@ int main(int argc, char **argv) if(!dot){ XBT_CRITICAL("The dot file with the provided scheduling is wrong," " more information with the option : --log=sd_dotparse.thres:verbose"); - SD_exit(); exit(2); } @@ -81,7 +80,5 @@ int main(int argc, char **argv) fclose(out); xbt_dynar_free_container(&dot); - /* exit */ - SD_exit(); return 0; } diff --git a/examples/simdag/scheduling/sd_scheduling.c b/examples/simdag/scheduling/sd_scheduling.c index a949e7319c..870583652f 100644 --- a/examples/simdag/scheduling/sd_scheduling.c +++ b/examples/simdag/scheduling/sd_scheduling.c @@ -250,7 +250,5 @@ int main(int argc, char **argv) } xbt_free(hosts); - /* exit */ - SD_exit(); return 0; } diff --git a/examples/simdag/test/sd_test.cpp b/examples/simdag/test/sd_test.cpp index bef939ba5b..0a698f8611 100644 --- a/examples/simdag/test/sd_test.cpp +++ b/examples/simdag/test/sd_test.cpp @@ -140,7 +140,6 @@ int main(int argc, char **argv) SD_task_destroy(taskD); XBT_DEBUG("Tasks destroyed. Exiting SimDag..."); - SD_exit(); xbt_free((sg_host_t*)hosts); return 0; } diff --git a/examples/simdag/throttling/sd_throttling.c b/examples/simdag/throttling/sd_throttling.c index cbef569998..dd9e0a45b6 100644 --- a/examples/simdag/throttling/sd_throttling.c +++ b/examples/simdag/throttling/sd_throttling.c @@ -74,7 +74,6 @@ int main(int argc, char **argv) SD_task_destroy(taskE); XBT_DEBUG("Tasks destroyed. Exiting SimDag..."); - SD_exit(); xbt_free(hosts); return 0; } diff --git a/examples/simdag/typed_tasks/sd_typed_tasks.c b/examples/simdag/typed_tasks/sd_typed_tasks.c index f74df77ece..f86c64a1af 100644 --- a/examples/simdag/typed_tasks/sd_typed_tasks.c +++ b/examples/simdag/typed_tasks/sd_typed_tasks.c @@ -74,6 +74,5 @@ int main(int argc, char **argv) xbt_dynar_free_container(&changed_tasks); xbt_free(hosts); - SD_exit(); return 0; } diff --git a/examples/smpi/mc/bugged1.c b/examples/smpi/mc/bugged1.c index 3d2e0e9d64..5b5e03e3c5 100644 --- a/examples/smpi/mc/bugged1.c +++ b/examples/smpi/mc/bugged1.c @@ -1,7 +1,6 @@ /* A simple bugged MPI_ISend and MPI_IRecv test */ -/* Copyright (c) 2009, 2011, 2013-2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2009-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. */ @@ -12,11 +11,12 @@ int main(int argc, char **argv) { - int recv_buff, err, size, rank; + int size; + int rank; MPI_Status status; /* Initialize MPI */ - err = MPI_Init(&argc, &argv); + int err = MPI_Init(&argc, &argv); if (err != MPI_SUCCESS) { printf("MPI initialization failed!\n"); exit(1); @@ -33,6 +33,7 @@ int main(int argc, char **argv) if (rank == 0) { printf("MPI_ISend / MPI_IRecv Test \n"); + int recv_buff; for (int i = 0; i < size - 1; i++) { MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); printf("Message received from %d\n", recv_buff); diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 9515436c61..ff78fe381a 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -9,21 +9,11 @@ #ifdef __cplusplus +#include "s4u/forward.hpp" #include "xbt/base.h" #include namespace simgrid { -namespace s4u { -class Actor; -class Comm; -class Host; -class Link; -class Mailbox; -class NetZone; - -XBT_PUBLIC(void) intrusive_ptr_release(Comm* c); -XBT_PUBLIC(void) intrusive_ptr_add_ref(Comm* c); -} namespace kernel { namespace activity { class ActivityImpl; diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index 9a6efb706f..98580d402a 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -491,8 +491,9 @@ XBT_PUBLIC(void) MSG_vm_set_params(msg_vm_t vm, vm_params_t params); // TODO add VDI later XBT_PUBLIC(msg_vm_t) MSG_vm_create_core(msg_host_t location, const char *name); +XBT_PUBLIC(msg_vm_t) MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount); XBT_PUBLIC(msg_vm_t) -MSG_vm_create(msg_host_t ind_pm, const char* name, int ramsize, int mig_netspeed, int dp_intensity); +MSG_vm_create(msg_host_t ind_pm, const char* name, int coreAmount, int ramsize, int mig_netspeed, int dp_intensity); XBT_PUBLIC(void) MSG_vm_destroy(msg_vm_t vm); diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 665f2c85fe..ab1dd5e1a9 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -119,13 +119,13 @@ public: /** DO NOT USE DIRECTLY (@todo: these should be protected, once our code is clean) */ kernel::routing::NetPoint* pimpl_netpoint = nullptr; - /*** Called on each newly created object */ + /*** Called on each newly created host */ static simgrid::xbt::signal onCreation; - /*** Called just before destructing an object */ + /*** Called just before destructing an host */ static simgrid::xbt::signal onDestruction; - /*** Called when the machine is turned on or off */ + /*** Called when the machine is turned on or off (called AFTER the change) */ static simgrid::xbt::signal onStateChange; - /*** Called when the speed of the machine is changed + /*** Called when the speed of the machine is changed (called AFTER the change) * (either because of a pstate switch or because of an external load event coming from the profile) */ static simgrid::xbt::signal onSpeedChange; }; diff --git a/include/simgrid/s4u/Mutex.hpp b/include/simgrid/s4u/Mutex.hpp index 05199bd889..0d1f2277a0 100644 --- a/include/simgrid/s4u/Mutex.hpp +++ b/include/simgrid/s4u/Mutex.hpp @@ -37,7 +37,7 @@ XBT_PUBLIC_CLASS Mutex { friend ConditionVariable; friend simgrid::simix::MutexImpl; simgrid::simix::MutexImpl* mutex_; - Mutex(simgrid::simix::MutexImpl * mutex) : mutex_(mutex) {} + explicit Mutex(simgrid::simix::MutexImpl * mutex) : mutex_(mutex) {} /* refcounting of the intrusive_ptr is delegated to the implementation object */ friend void intrusive_ptr_add_ref(Mutex* mutex) diff --git a/include/simgrid/s4u/VirtualMachine.hpp b/include/simgrid/s4u/VirtualMachine.hpp index 2085fae28a..d9d3ba72a6 100644 --- a/include/simgrid/s4u/VirtualMachine.hpp +++ b/include/simgrid/s4u/VirtualMachine.hpp @@ -35,7 +35,7 @@ XBT_PUBLIC_CLASS VirtualMachine : public s4u::Host { public: - explicit VirtualMachine(const char* name, s4u::Host* hostPm); + explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount); // No copy/move VirtualMachine(VirtualMachine const&) = delete; diff --git a/include/simgrid/s4u/forward.hpp b/include/simgrid/s4u/forward.hpp index 10c8d856bb..cc29359308 100644 --- a/include/simgrid/s4u/forward.hpp +++ b/include/simgrid/s4u/forward.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2016-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. */ @@ -7,6 +7,7 @@ #define SIMGRID_S4U_FORWARD_HPP #include +#include namespace simgrid { namespace s4u { @@ -19,12 +20,16 @@ class Comm; using CommPtr = boost::intrusive_ptr; class Engine; class Host; +class Link; class Mailbox; using MailboxPtr = boost::intrusive_ptr; class Mutex; +class NetZone; class Storage; +XBT_PUBLIC(void) intrusive_ptr_release(Comm* c); +XBT_PUBLIC(void) intrusive_ptr_add_ref(Comm* c); } } diff --git a/include/simgrid/simdag.h b/include/simgrid/simdag.h index 25d8009348..b317441903 100644 --- a/include/simgrid/simdag.h +++ b/include/simgrid/simdag.h @@ -140,7 +140,14 @@ XBT_PUBLIC(int) SD_task_dependency_exists(SD_task_t src, SD_task_t dst); * * @{ */ -XBT_PUBLIC(void) SD_init(int *argc, char **argv); + +#define SD_init(argc, argv) \ + do { \ + sg_version_check(SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH); \ + SD_init_nocheck(argc, argv); \ + } while (0) + +XBT_PUBLIC(void) SD_init_nocheck(int *argc, char **argv); XBT_PUBLIC(void) SD_config(const char *key, const char *value); XBT_PUBLIC(void) SD_create_environment(const char *platform_file); XBT_PUBLIC(void) SD_simulate(double how_long); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 78dbe75a3d..64f9aac67b 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -110,8 +110,6 @@ typedef enum { /* Process creation/destruction callbacks */ typedef void (*void_pfn_smxprocess_t) (smx_actor_t); -/* for auto-restart function */ -typedef void (*void_pfn_sghost_t) (sg_host_t); extern int smx_context_stack_size; extern int smx_context_stack_size_was_set; @@ -226,8 +224,6 @@ XBT_PUBLIC(smx_activity_t) SIMIX_comm_get_send_match(smx_mailbox_t mbox, int (*m XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data); XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data); XBT_PUBLIC(void) SIMIX_comm_finish(smx_activity_t synchro); -XBT_PUBLIC(smx_activity_t) SIMIX_comm_ref(smx_activity_t comm); -XBT_PUBLIC(void) SIMIX_comm_unref(smx_activity_t comm); /******************************************************************************/ /* SIMIX simcalls */ diff --git a/include/xbt/config.h b/include/xbt/config.h index fa0b5d4ecc..1131871c98 100644 --- a/include/xbt/config.h +++ b/include/xbt/config.h @@ -12,8 +12,6 @@ #include #include -SG_BEGIN_DECL() - /** @addtogroup XBT_config * @brief Changing the configuration of SimGrid components (grounding feature) * @@ -67,6 +65,8 @@ typedef simgrid::config::Config* xbt_cfg_t; typedef void* xbt_cfg_t; #endif +SG_BEGIN_DECL() + XBT_PUBLIC(void) xbt_cfg_set_parse(const char *options); /* Set the value of the cell \a name in \a cfg with the provided value.*/ diff --git a/src/bindings/java/jmsg_vm.cpp b/src/bindings/java/jmsg_vm.cpp index fc5da71197..d7e9ea12b6 100644 --- a/src/bindings/java/jmsg_vm.cpp +++ b/src/bindings/java/jmsg_vm.cpp @@ -65,20 +65,21 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv *env, jobject jvm MSG_vm_set_bound(vm, bound); } -JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jvm, jobject jhost, jstring jname, - jint jramsize, jint jmig_netspeed, jint jdp_intensity) +JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jVm, jobject jHost, jstring jname, + jint coreAmount, jint jramsize, jint jmig_netspeed, + jint jdp_intensity) { - msg_host_t host = jhost_get_native(env, jhost); + msg_host_t host = jhost_get_native(env, jHost); const char* name = env->GetStringUTFChars(jname, 0); - msg_vm_t vm = MSG_vm_create(host, name, static_cast(jramsize), static_cast(jmig_netspeed), - static_cast(jdp_intensity)); + msg_vm_t vm = MSG_vm_create(host, name, static_cast(coreAmount), static_cast(jramsize), + static_cast(jmig_netspeed), static_cast(jdp_intensity)); env->ReleaseStringUTFChars(jname, name); - jvm_bind(env, jvm, vm); - jvm = env->NewWeakGlobalRef(jvm); + jvm_bind(env, jVm, vm); + jVm = env->NewWeakGlobalRef(jVm); // We use the extension level of the host, even if that's somehow disturbing - vm->extension_set(JAVA_HOST_LEVEL, (void*)jvm); + vm->extension_set(JAVA_HOST_LEVEL, (void*)jVm); } JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass cls_arg) diff --git a/src/bindings/java/jmsg_vm.h b/src/bindings/java/jmsg_vm.h index 19da959be2..d6fec6c1e1 100644 --- a/src/bindings/java/jmsg_vm.h +++ b/src/bindings/java/jmsg_vm.h @@ -38,7 +38,7 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isResuming(JNIEnv* env, jobject j JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv* env, jobject jvm, jdouble bound); JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jvm, jobject jhost, jstring jname, - jint jramsize, jint dprate, jint mig_netspeed); + jint coreAmount, jint jramsize, jint dprate, jint mig_netspeed); JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclass cls, jstring jname); JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_nativeFinalize(JNIEnv* env, jobject jvm); JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_start(JNIEnv* env, jobject jvm); diff --git a/src/bindings/java/org/simgrid/msg/VM.java b/src/bindings/java/org/simgrid/msg/VM.java index 8338a79c50..99f3a3add3 100644 --- a/src/bindings/java/org/simgrid/msg/VM.java +++ b/src/bindings/java/org/simgrid/msg/VM.java @@ -11,10 +11,18 @@ public class VM extends Host { // No need to declare a new bind variable: we use the one inherited from the super class Host private Host currentHost; + private int coreAmount = 1; /** Create a `basic' VM (i.e. 1GB of RAM, other values are not taken into account). */ public VM(Host host, String name) { - this(host,name,1024, 0, 0); + this(host,name, /*coreAmount*/1, 1024, 0, 0); + } + + public VM(Host host, String name, int coreAmount) { + this(host,name, coreAmount, 1024, 0, 0); + } + public VM(Host host, String name, int ramSize, int migNetSpeed, int dpIntensity){ + this(host, name, /*coreAmount*/1, ramSize, migNetSpeed, dpIntensity); } /** @@ -25,11 +33,12 @@ public class VM extends Host { * @param migNetSpeed (network bandwith allocated for migrations in MB/s, if you don't know put zero ;)) * @param dpIntensity (dirty page percentage according to migNetSpeed, [0-100], if you don't know put zero ;)) */ - public VM(Host host, String name, int ramSize, int migNetSpeed, int dpIntensity){ + public VM(Host host, String name, int coreAmount, int ramSize, int migNetSpeed, int dpIntensity){ super(); super.name = name; this.currentHost = host; - create(host, name, ramSize, migNetSpeed, dpIntensity); + this.coreAmount = coreAmount; + create(host, name, coreAmount, ramSize, migNetSpeed, dpIntensity); } /** Retrieve the list of all existing VMs */ @@ -68,13 +77,18 @@ public class VM extends Host { /** Returns whether the given VM is currently suspended */ public native int isSuspended(); + /** Returns the amount of virtual CPUs provided */ + public int getCoreAmount() { + return coreAmount; + } + /** * Natively implemented method create the VM. * @param ramSize size of the RAM that should be allocated (in MB) * @param migNetSpeed (network bandwith allocated for migrations in MB/s, if you don't know put zero ;)) * @param dpIntensity (dirty page intensity, a percentage of migNetSpeed [0-100], if you don't know put zero ;)) */ - private native void create(Host host, String name, int ramSize, int migNetSpeed, int dpIntensity); + private native void create(Host host, String name, int coreAmount, int ramSize, int migNetSpeed, int dpIntensity); /** diff --git a/src/kernel/activity/ActivityImpl.cpp b/src/kernel/activity/ActivityImpl.cpp index 08e2a63924..77e657063f 100644 --- a/src/kernel/activity/ActivityImpl.cpp +++ b/src/kernel/activity/ActivityImpl.cpp @@ -10,18 +10,16 @@ simgrid::kernel::activity::ActivityImpl::~ActivityImpl() = default; void simgrid::kernel::activity::ActivityImpl::ref() { - refcount++; + // Atomic operation! Do not split in two instructions! + xbt_assert(refcount_ != 0); + refcount_++; } -bool simgrid::kernel::activity::ActivityImpl::unref() +void simgrid::kernel::activity::ActivityImpl::unref() { - xbt_assert(refcount > 0, - "This activity has a negative refcount! You can only call test() or wait() once per activity."); - - refcount--; - if (refcount>0) - return false; - delete this; - - return true; + xbt_assert(refcount_ > 0, + "This activity has a negative refcount! You can only call test() or wait() once per activity."); + refcount_--; + if (refcount_ == 0) + delete this; } diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index 13c284a285..e14429663e 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -34,28 +34,21 @@ namespace activity { // boost::intrusive_ptr support: friend void intrusive_ptr_add_ref(ActivityImpl * activity) { - // Atomic operation! Do not split in two instructions! - auto previous = (activity->refcount_)++; - xbt_assert(previous != 0); - (void)previous; + activity->ref(); } friend void intrusive_ptr_release(ActivityImpl * activity) { - // Atomic operation! Do not split in two instructions! - auto count = --(activity->refcount_); - if (count == 0) - delete activity; + activity->unref(); } - /** @brief Increase the refcount */ + /** @brief Increases the refcount */ void ref(); - /** @brief Reduce the refcount; returns true if the object was destroyed */ - bool unref(); + /** @brief Reduces the refcount */ + void unref(); private: std::atomic_int_fast32_t refcount_{1}; - int refcount = 1; }; }}} // namespace simgrid::kernel::activity diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 58182eaf3f..85ccbea5c1 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -62,7 +62,7 @@ void simgrid::kernel::activity::CommImpl::cancel() if (state == SIMIX_WAITING) { mbox->remove(this); state = SIMIX_CANCELED; - SIMIX_comm_unref(this); + this->unref(); } else if (not MC_is_active() /* when running the MC there are no surf actions */ && not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) { @@ -124,6 +124,6 @@ void simgrid::kernel::activity::CommImpl::post() /* if there are simcalls associated with the synchro, then answer them */ if (not simcalls.empty()) { SIMIX_comm_finish(this); - SIMIX_comm_unref(this); + this->unref(); } } diff --git a/src/mc/checker/CommunicationDeterminismChecker.cpp b/src/mc/checker/CommunicationDeterminismChecker.cpp index 15d1ccd3cc..2410b9d1dc 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.cpp +++ b/src/mc/checker/CommunicationDeterminismChecker.cpp @@ -360,7 +360,7 @@ void CommunicationDeterminismChecker::prepare() /* Get an enabled actor and insert it in the interleave set of the initial state */ for (auto& actor : mc_model_checker->process().actors()) if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) - initial_state->interleave(actor.copy.getBuffer()); + initial_state->addInterleavingSet(actor.copy.getBuffer()); stack_.push_back(std::move(initial_state)); } @@ -488,7 +488,7 @@ void CommunicationDeterminismChecker::main() /* Get enabled actors and insert them in the interleave set of the next state */ for (auto& actor : mc_model_checker->process().actors()) if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) - next_state->interleave(actor.copy.getBuffer()); + next_state->addInterleavingSet(actor.copy.getBuffer()); if (dot_output != nullptr) fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", diff --git a/src/mc/checker/LivenessChecker.cpp b/src/mc/checker/LivenessChecker.cpp index 0dda3dd3b1..f65fff1d61 100644 --- a/src/mc/checker/LivenessChecker.cpp +++ b/src/mc/checker/LivenessChecker.cpp @@ -316,7 +316,7 @@ std::shared_ptr LivenessChecker::newPair(Pair* current_pair, xbt_automaton /* Get enabled actors and insert them in the interleave set of the next graph_state */ for (auto& actor : mc_model_checker->process().actors()) if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) - next_pair->graph_state->interleave(actor.copy.getBuffer()); + next_pair->graph_state->addInterleavingSet(actor.copy.getBuffer()); next_pair->requests = next_pair->graph_state->interleaveSize(); /* FIXME : get search_cycle value for each accepting state */ if (next_pair->automaton_state->type == 1 || (current_pair && current_pair->search_cycle)) diff --git a/src/mc/checker/SafetyChecker.cpp b/src/mc/checker/SafetyChecker.cpp index d38281572c..4256b56a26 100644 --- a/src/mc/checker/SafetyChecker.cpp +++ b/src/mc/checker/SafetyChecker.cpp @@ -162,12 +162,14 @@ void SafetyChecker::run() if (visitedState_ == nullptr) { /* Get an enabled process and insert it in the interleave set of the next state */ - for (auto& actor : mc_model_checker->process().actors()) - if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) { - next_state->interleave(actor.copy.getBuffer()); + for (auto& remoteActor : mc_model_checker->process().actors()) { + auto actor = remoteActor.copy.getBuffer(); + if (simgrid::mc::actor_is_enabled(actor)) { + next_state->addInterleavingSet(actor); if (reductionMode_ == simgrid::mc::ReductionMode::dpor) - break; + break; // With DPOR, we take the first enabled transition } + } if (dot_output != nullptr) std::fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", @@ -231,7 +233,7 @@ void SafetyChecker::backtrack() } if (not prev_state->actorStates[issuer->pid].isDone()) - prev_state->interleave(issuer); + prev_state->addInterleavingSet(issuer); else XBT_DEBUG("Process %p is in done set", req->issuer); @@ -321,7 +323,7 @@ SafetyChecker::SafetyChecker(Session& session) : Checker(session) /* Get an enabled actor and insert it in the interleave set of the initial state */ for (auto& actor : mc_model_checker->process().actors()) if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) { - initial_state->interleave(actor.copy.getBuffer()); + initial_state->addInterleavingSet(actor.copy.getBuffer()); if (reductionMode_ != simgrid::mc::ReductionMode::none) break; } diff --git a/src/mc/mc_state.h b/src/mc/mc_state.h index d807e28976..e4eb0d9d30 100644 --- a/src/mc/mc_state.h +++ b/src/mc/mc_state.h @@ -137,9 +137,7 @@ struct XBT_PRIVATE State { State(unsigned long state_number); std::size_t interleaveSize() const; - void interleave(smx_actor_t actor) { - this->actorStates[actor->pid].consider(); - } + void addInterleavingSet(smx_actor_t actor) { this->actorStates[actor->pid].consider(); } Transition getTransition() const; }; diff --git a/src/msg/msg_global.cpp b/src/msg/msg_global.cpp index 3f4d5431af..2dd6fc906b 100644 --- a/src/msg/msg_global.cpp +++ b/src/msg/msg_global.cpp @@ -66,7 +66,7 @@ void MSG_init_nocheck(int *argc, char **argv) { XBT_DEBUG("ADD MSG LEVELS"); MSG_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, (void_f_pvoid_t) __MSG_storage_destroy); - if(xbt_cfg_get_boolean("clean-atexit")) + if (xbt_cfg_get_boolean("clean-atexit")) atexit(MSG_exit); } diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index 3f416bc8c6..3e2eda2192 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -270,7 +270,6 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, d simcall_comm_recv(MSG_process_self()->getImpl(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate); XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name()); (*task)->simdata->setNotUsed(); - SIMIX_comm_unref((*task)->simdata->comm); } catch (xbt_ex& e) { switch (e.category) { @@ -490,7 +489,7 @@ int MSG_comm_test(msg_comm_t comm) if (finished && comm->task_received != nullptr) { /* I am the receiver */ (*comm->task_received)->simdata->setNotUsed(); - SIMIX_comm_unref(comm->s_comm); + comm->s_comm->unref(); } } catch (xbt_ex& e) { @@ -558,7 +557,7 @@ int MSG_comm_testany(xbt_dynar_t comms) if (status == MSG_OK && comm->task_received != nullptr) { /* I am the receiver */ (*comm->task_received)->simdata->setNotUsed(); - SIMIX_comm_unref(comm->s_comm); + comm->s_comm->unref(); } } @@ -587,7 +586,7 @@ msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout) { try { simcall_comm_wait(comm->s_comm, timeout); - SIMIX_comm_unref(comm->s_comm); + comm->s_comm->unref(); if (comm->task_received != nullptr) { /* I am the receiver */ @@ -672,7 +671,7 @@ int MSG_comm_waitany(xbt_dynar_t comms) if (comm->task_received != nullptr) { /* I am the receiver */ (*comm->task_received)->simdata->setNotUsed(); - SIMIX_comm_unref(comm->s_comm); + comm->s_comm->unref(); } return finished_index; @@ -800,7 +799,7 @@ msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, doubl simcall_set_category(comm, task->category); t_simdata->comm = static_cast(comm); simcall_comm_wait(comm, timeout); - SIMIX_comm_unref(comm); + comm->unref(); } catch (xbt_ex& e) { switch (e.category) { @@ -874,7 +873,7 @@ int MSG_task_listen_from(const char *alias) if (not comm) return -1; - return MSG_process_get_PID( static_cast(comm->src_data)->simdata->sender ); + return MSG_process_get_PID(static_cast(comm->src_buff)->simdata->sender); } /** \ingroup msg_task_usage diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 4ba76638cd..8d59a21358 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -58,7 +58,8 @@ void MSG_vm_get_params(msg_vm_t vm, vm_params_t params) /* **** Check state of a VM **** */ static inline int __MSG_vm_is_state(msg_vm_t vm, e_surf_vm_state_t state) { - return static_cast(vm)->pimpl_vm_->getState() == state; + simgrid::s4u::VirtualMachine* castedVm = static_cast(vm); + return castedVm->pimpl_vm_ != nullptr && castedVm->pimpl_vm_->getState() == state; } /** @brief Returns whether the given VM has just created, not running. @@ -98,11 +99,12 @@ int MSG_vm_is_suspended(msg_vm_t vm) * @ingroup msg_VMs* * @param pm Physical machine that will host the VM * @param name Must be unique + * @param coreAmount Must be >= 1 * @param ramsize [TODO] * @param mig_netspeed Amount of Mbyte/s allocated to the migration (cannot be larger than net_cap). Use 0 if unsure. * @param dp_intensity Dirty page percentage according to migNetSpeed, [0-100]. Use 0 if unsure. */ -msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int ramsize, int mig_netspeed, int dp_intensity) +msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int coreAmount, int ramsize, int mig_netspeed, int dp_intensity) { simgrid::vm::VmHostExt::ensureVmExtInstalled(); @@ -110,7 +112,7 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int ramsize, int mig_net double host_speed = MSG_host_get_speed(pm); double update_speed = (static_cast(dp_intensity)/100) * mig_netspeed; - msg_vm_t vm = MSG_vm_create_core(pm, name); + msg_vm_t vm = MSG_vm_create_multicore(pm, name, coreAmount); s_vm_params_t params; memset(¶ms, 0, sizeof(params)); params.ramsize = static_cast(ramsize) * 1024 * 1024; @@ -128,7 +130,7 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int ramsize, int mig_net return vm; } -/** @brief Create a new VM object. The VM is not yet started. The resource of the VM is allocated upon MSG_vm_start(). +/** @brief Create a new VM object with the default parameters * @ingroup msg_VMs* * * A VM is treated as a host. The name of the VM must be unique among all hosts. @@ -138,7 +140,19 @@ msg_vm_t MSG_vm_create_core(msg_host_t pm, const char* name) xbt_assert(sg_host_by_name(name) == nullptr, "Cannot create a VM named %s: this name is already used by an host or a VM", name); - return new simgrid::s4u::VirtualMachine(name, pm); + return new simgrid::s4u::VirtualMachine(name, pm, 1); +} +/** @brief Create a new VM object with the default parameters, but with a specified amount of cores + * @ingroup msg_VMs* + * + * A VM is treated as a host. The name of the VM must be unique among all hosts. + */ +msg_vm_t MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount) +{ + xbt_assert(sg_host_by_name(name) == nullptr, + "Cannot create a VM named %s: this name is already used by an host or a VM", name); + + return new simgrid::s4u::VirtualMachine(name, pm, coreAmount); } /** @brief Destroy a VM. Destroy the VM object from the simulation. @@ -153,9 +167,6 @@ void MSG_vm_destroy(msg_vm_t vm) if (MSG_vm_is_running(vm)) MSG_vm_shutdown(vm); - xbt_assert(MSG_vm_is_created(vm) || __MSG_vm_is_state(vm, SURF_VM_STATE_DESTROYED), - "shutdown the given VM before destroying it"); - /* Then, destroy the VM object */ simgrid::simix::kernelImmediate([vm]() { vm->destroy(); @@ -171,7 +182,7 @@ void MSG_vm_destroy(msg_vm_t vm) /** @brief Start a vm (i.e., boot the guest operating system) * @ingroup msg_VMs * - * If the VM cannot be started (because of memory overprovisionning), an exception is generated. + * If the VM cannot be started (because of memory over-provisioning), an exception is generated. */ void MSG_vm_start(msg_vm_t vm) { diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index a678568321..0a64e685b7 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -38,7 +38,9 @@ simgrid::xbt::signal onVmStateChange; std::deque VirtualMachineImpl::allVms_; /* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead. - * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system. */ + * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system. + * FIXME: add a configuration flag for this + */ // const double virt_overhead = 0.95; const double virt_overhead = 1; @@ -65,7 +67,7 @@ double VMModel::nextOccuringEvent(double now) * * Equation 1 was solved in the physical machine layer. * Equation 2 is solved in the virtual machine layer (here). - * X1 must be passed to the virtual machine laye as a constraint value. + * X1 must be passed to the virtual machine layer as a constraint value. **/ /* iterate for all virtual machines */ @@ -73,7 +75,8 @@ double VMModel::nextOccuringEvent(double now) surf::Cpu* cpu = ws_vm->pimpl_cpu; xbt_assert(cpu, "cpu-less host"); - double solved_value = ws_vm->pimpl_vm_->action_->getVariable()->value; + double solved_value = ws_vm->pimpl_vm_->action_->getVariable() + ->value; // this is X1 in comment above, what this VM got in the sharing on the PM XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->cname(), ws_vm->pimpl_vm_->getPm()->cname()); // TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution. @@ -84,9 +87,9 @@ double VMModel::nextOccuringEvent(double now) } /* 2. Calculate resource share at the virtual machine layer. */ - adjustWeightOfDummyCpuActions(); + ignoreEmptyVmInPmLMM(); - /* 3. Ready. Get the next occuring event */ + /* 3. Ready. Get the next occurring event */ return surf_cpu_model_vm->nextOccuringEvent(now); } @@ -94,15 +97,16 @@ double VMModel::nextOccuringEvent(double now) * Resource * ************/ -VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM) - : HostImpl(piface), hostPM_(host_PM) +VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM, + int coreAmount) + : HostImpl(piface), hostPM_(host_PM), coreAmount_(coreAmount) { /* Register this VM to the list of all VMs */ allVms_.push_back(piface); /* We create cpu_action corresponding to a VM process on the host operating system. */ /* TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */ - action_ = host_PM->pimpl_cpu->execution_start(0); + action_ = host_PM->pimpl_cpu->execution_start(0, coreAmount); /* Initialize the VM parameters */ params_.ramsize = 0; @@ -219,7 +223,7 @@ void VirtualMachineImpl::shutdown(smx_actor_t issuer) case SURF_VM_STATE_DESTROYED: stateName = "destroyed"; break; - case SURF_VM_STATE_RUNNING: + default: /* SURF_VM_STATE_RUNNING or unexpected values */ THROW_IMPOSSIBLE; break; } @@ -264,7 +268,8 @@ void VirtualMachineImpl::setPm(s4u::Host* destination) /* Update vcpu's action for the new pm */ /* create a cpu action bound to the pm model at the destination. */ - surf::CpuAction* new_cpu_action = static_cast(destination->pimpl_cpu->execution_start(0)); + surf::CpuAction* new_cpu_action = + static_cast(destination->pimpl_cpu->execution_start(0, this->coreAmount_)); if (action_->getRemainsNoUpdate() > 0) XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->getRemainsNoUpdate()); diff --git a/src/plugins/vm/VirtualMachineImpl.hpp b/src/plugins/vm/VirtualMachineImpl.hpp index d9b4ed6549..d9371762d4 100644 --- a/src/plugins/vm/VirtualMachineImpl.hpp +++ b/src/plugins/vm/VirtualMachineImpl.hpp @@ -55,7 +55,7 @@ XBT_PUBLIC_CLASS VirtualMachineImpl : public surf::HostImpl friend simgrid::s4u::VirtualMachine; public: - explicit VirtualMachineImpl(s4u::VirtualMachine* piface, s4u::Host* host); + explicit VirtualMachineImpl(s4u::VirtualMachine * piface, s4u::Host * host, int coreAmount); ~VirtualMachineImpl(); /** @brief Suspend the VM */ @@ -100,6 +100,7 @@ public: private: s_vm_params_t params_; + int coreAmount_; protected: e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED; @@ -114,7 +115,7 @@ protected: */ class VMModel : public surf::HostModel { public: - void adjustWeightOfDummyCpuActions() override{}; + void ignoreEmptyVmInPmLMM() override{}; double nextOccuringEvent(double now) override; void updateActionsState(double /*now*/, double /*delta*/) override{}; diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 261f63a68b..070acd9610 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -13,11 +13,11 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_vm, "S4U virtual machines"); namespace simgrid { namespace s4u { -VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm) : Host(name) +VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount) + : Host(name), pimpl_vm_(new vm::VirtualMachineImpl(this, pm, coreAmount)) { XBT_DEBUG("Create VM %s", name); - pimpl_vm_ = new vm::VirtualMachineImpl(this, pm); /* Currently, a VM uses the network resource of its physical host */ pimpl_netpoint = pm->pimpl_netpoint; // Create a VCPU for this VM @@ -56,7 +56,7 @@ VirtualMachine::~VirtualMachine() bool VirtualMachine::isMigrating() { - return pimpl_vm_->isMigrating; + return pimpl_vm_ && pimpl_vm_->isMigrating; } double VirtualMachine::getRamsize() { diff --git a/src/s4u/s4u_comm.cpp b/src/s4u/s4u_comm.cpp index 4ecb4e698d..d8c635be1a 100644 --- a/src/s4u/s4u_comm.cpp +++ b/src/s4u/s4u_comm.cpp @@ -24,7 +24,7 @@ Comm::~Comm() xbt_backtrace_display_current(); } if (pimpl_) - SIMIX_comm_unref(pimpl_); + pimpl_->unref(); } s4u::CommPtr Comm::send_init(s4u::MailboxPtr chan) diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index f44d4ade92..61fdcf53b0 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -152,7 +152,7 @@ const char *__get_state_name(e_SD_task_state_t state){ * \param argv argument list * \see SD_create_environment(), SD_exit() */ -void SD_init(int *argc, char **argv) +void SD_init_nocheck(int *argc, char **argv) { xbt_assert(sd_global == nullptr, "SD_init() already called"); @@ -161,9 +161,9 @@ void SD_init(int *argc, char **argv) surf_init(argc, argv); xbt_cfg_setdefault_string("host/model", "ptask_L07"); - + if(xbt_cfg_get_boolean("clean-atexit")) + atexit(SD_exit); if (_sg_cfg_exit_asap) { - SD_exit(); exit(0); } } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 2930fc1aed..ad1998e5af 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -111,7 +111,7 @@ void SIMIX_process_cleanup(smx_actor_t process) if (comm->detached) XBT_DEBUG("Don't destroy it since it's a detached comm and I'm the sender"); else - SIMIX_comm_unref(comm); + comm->unref(); } else if (comm->dst_proc == process) { XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p", comm, (int)comm->state, comm->src_proc, comm->dst_proc); @@ -121,7 +121,6 @@ void SIMIX_process_cleanup(smx_actor_t process) /* the comm will be freed right now, remove it from the sender */ comm->src_proc->comms.remove(comm); } - // SIMIX_comm_unref(comm); } else { xbt_die("Communication synchro %p is in my list but I'm not the sender nor the receiver", synchro); } @@ -444,7 +443,7 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) { auto i = boost::range::find(process->waiting_synchro->simcalls, &process->simcall); if (i != process->waiting_synchro->simcalls.end()) process->waiting_synchro->simcalls.remove(&process->simcall); - SIMIX_comm_unref(comm); + comm->unref(); } else if (sleep != nullptr) { SIMIX_process_sleep_destroy(process->waiting_synchro); diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 9ac82e3064..b9e5ced9c9 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -58,7 +58,7 @@ _find_matching_comm(boost::circular_buffer_space_optimized* dequ XBT_DEBUG("Found a matching communication synchro %p", comm); if (remove_matching) deque->erase(it); - SIMIX_comm_ref(comm); + comm->ref(); #if SIMGRID_HAVE_MC comm->mbox_cpy = comm->mbox; #endif @@ -115,16 +115,17 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx //this mailbox is for small messages, which have to be sent right now other_comm->state = SIMIX_READY; other_comm->dst_proc=mbox->permanent_receiver.get(); - other_comm = static_cast(SIMIX_comm_ref(other_comm)); + other_comm->ref(); mbox->done_comm_queue.push_back(other_comm); - XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, &(other_comm)); + XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, other_comm); }else{ mbox->push(this_comm); } } else { XBT_DEBUG("Receive already pushed"); - SIMIX_comm_unref(this_comm); + this_comm->unref(); + this_comm->unref(); other_comm->state = SIMIX_READY; other_comm->type = SIMIX_COMM_READY; @@ -192,6 +193,7 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void * //communication already done, get it inside the list of completed comms if (mbox->permanent_receiver != nullptr && not mbox->done_comm_queue.empty()) { + this_synchro->unref(); XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication"); //find a match in the list of already received comms other_comm = _find_matching_comm(&mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro, @@ -207,9 +209,10 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void * other_comm->state = SIMIX_DONE; other_comm->type = SIMIX_COMM_DONE; other_comm->mbox = nullptr; + other_comm->unref(); } - SIMIX_comm_unref(other_comm); - SIMIX_comm_unref(this_synchro); + other_comm->unref(); + this_synchro->unref(); } } else { /* Prepare a comm describing us, so that it gets passed to the user-provided filter of other side */ @@ -232,8 +235,8 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void * other_comm->state = SIMIX_READY; other_comm->type = SIMIX_COMM_READY; - SIMIX_comm_unref(this_synchro); - SIMIX_comm_unref(this_synchro); + this_synchro->unref(); + this_synchro->unref(); } dst_proc->comms.push_back(other_comm); } @@ -292,9 +295,9 @@ smx_activity_t SIMIX_comm_iprobe(smx_actor_t dst_proc, smx_mailbox_t mbox, int t } if(other_synchro) - SIMIX_comm_unref(other_synchro); + other_synchro->unref(); - SIMIX_comm_unref(this_comm); + this_comm->unref(); return other_synchro; } @@ -718,18 +721,3 @@ void SIMIX_comm_copy_data(smx_activity_t synchro) /* (this function might be called from both communication ends) */ comm->copied = 1; } - -/** Increase the refcount for this comm */ -smx_activity_t SIMIX_comm_ref(smx_activity_t comm) -{ - if (comm != nullptr) - intrusive_ptr_add_ref(comm); - return comm; -} - -/** Decrease the refcount for this comm */ -void SIMIX_comm_unref(smx_activity_t comm) -{ - if (comm != nullptr) - intrusive_ptr_release(comm); -} diff --git a/src/simix/smx_synchro_private.h b/src/simix/smx_synchro_private.h index 37b5f1339e..c263d25463 100644 --- a/src/simix/smx_synchro_private.h +++ b/src/simix/smx_synchro_private.h @@ -32,9 +32,8 @@ public: friend void intrusive_ptr_add_ref(MutexImpl* mutex) { // Atomic operation! Do not split in two instructions! - auto previous = (mutex->refcount_)++; + XBT_ATTRIB_UNUSED auto previous = (mutex->refcount_)++; xbt_assert(previous != 0); - (void) previous; } friend void intrusive_ptr_release(MutexImpl* mutex) { diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index b8ca1e8dd9..0833a45c1d 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -25,7 +25,7 @@ namespace surf { * constraint (capacity) of the VM in the PM layer. If the VM does not have any * active task, the dummy CPU action must be deactivated, so that the VM does * not get any CPU share in the PM layer. */ -void HostModel::adjustWeightOfDummyCpuActions() +void HostModel::ignoreEmptyVmInPmLMM() { /* iterate for all virtual machines */ for (s4u::VirtualMachine* ws_vm : vm::VirtualMachineImpl::allVms_) { @@ -38,12 +38,11 @@ void HostModel::adjustWeightOfDummyCpuActions() /* some tasks exist on this VM */ XBT_DEBUG("set the weight of the dummy CPU action on PM to 1"); - /* FIXME: we should use lmm_update_variable_weight() ? */ /* FIXME: If we assign 1.05 and 0.05, the system makes apparently wrong values. */ ws_vm->pimpl_vm_->action_->setPriority(1); } else { - /* no task exits on this VM */ + /* no task exist on this VM */ XBT_DEBUG("set the weight of the dummy CPU action on PM to 0"); ws_vm->pimpl_vm_->action_->setPriority(0); diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 4d7c3ea990..06936554df 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -48,7 +48,7 @@ class HostModel : public Model { public: HostModel() : Model() {} - virtual void adjustWeightOfDummyCpuActions(); + virtual void ignoreEmptyVmInPmLMM(); virtual Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double rate); }; diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 5bf8fe015e..7d4e26ea27 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -113,7 +113,8 @@ void CpuCas01::onSpeedChange() { while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) { CpuCas01Action* action = static_cast(lmm_variable_id(var)); - lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak); + lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), + action->requestedCore() * speed_.scale * speed_.peak); } Cpu::onSpeedChange(); @@ -163,10 +164,15 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value) } } +/** @brief Start a new execution on this CPU lasting @size flops and using one core */ CpuAction *CpuCas01::execution_start(double size) { return new CpuCas01Action(model(), size, isOff(), speed_.scale * speed_.peak, constraint()); } +CpuAction* CpuCas01::execution_start(double size, int requestedCores) +{ + return new CpuCas01Action(model(), size, isOff(), speed_.scale * speed_.peak, constraint(), requestedCores); +} CpuAction *CpuCas01::sleep(double duration) { @@ -201,9 +207,10 @@ CpuAction *CpuCas01::sleep(double duration) /********** * Action * **********/ - -CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint) - : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1)) +CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint, + int requestedCore) + : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1)) + , requestedCore_(requestedCore) { if (model->getUpdateMechanism() == UM_LAZY) { indexHeap_ = -1; @@ -213,6 +220,16 @@ CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double sp lmm_expand(model->getMaxminSystem(), constraint, getVariable(), 1.0); } +CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint) + : CpuCas01Action(model, cost, failed, speed, constraint, 1) +{ +} + +int CpuCas01Action::requestedCore() +{ + return requestedCore_; +} + CpuCas01Action::~CpuCas01Action()=default; } diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index 0955ce2572..6309e17c75 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -41,6 +41,7 @@ public: ~CpuCas01() override; void apply_event(tmgr_trace_event_t event, double value) override; CpuAction *execution_start(double size) override; + CpuAction* execution_start(double size, int requestedCore) override; CpuAction *sleep(double duration) override; bool isUsed() override; @@ -58,8 +59,13 @@ class CpuCas01Action: public CpuAction { friend CpuAction *CpuCas01::execution_start(double size); friend CpuAction *CpuCas01::sleep(double duration); public: + CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint, int coreAmount); CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint); ~CpuCas01Action() override; + int requestedCore(); + +private: + int requestedCore_ = 1; }; } diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index c36600b68c..07aa7ab9e1 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -81,6 +81,19 @@ public: */ virtual simgrid::surf::Action *execution_start(double size)=0; + /** + * @brief Execute some quantity of computation on more than one core + * + * @param size The value of the processing amount (in flop) needed to process + * @param requestedCores The desired amount of cores. Must be >= 1 + * @return The CpuAction corresponding to the processing + */ + virtual simgrid::surf::Action* execution_start(double size, int requestedCores) + { + THROW_UNIMPLEMENTED; + return nullptr; + } + /** * @brief Make a process sleep for duration (in seconds) * diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index 1712ea9121..e11489fd3a 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -46,7 +46,7 @@ namespace simgrid { namespace surf { double HostCLM03Model::nextOccuringEvent(double now){ - adjustWeightOfDummyCpuActions(); + ignoreEmptyVmInPmLMM(); double min_by_cpu = surf_cpu_model_pm->nextOccuringEvent(now); double min_by_net = surf_network_model->nextOccuringEventIsIdempotent() ? surf_network_model->nextOccuringEvent(now) : -1; diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index c315bb1002..81c55be208 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -30,25 +30,25 @@ namespace simgrid { int LinkImpl::linksCount() { return links->size(); + } + /** @brief Returns a list of all existing links */ + LinkImpl** LinkImpl::linksList() + { + LinkImpl** res = xbt_new(LinkImpl*, (int)links->size()); + int i = 0; + for (auto kv : *links) { + res[i] = kv.second; + i++; } - /** @brief Returns a list of all existing links */ - LinkImpl** LinkImpl::linksList() - { - LinkImpl** res = xbt_new(LinkImpl*, (int)links->size()); - int i = 0; - for (auto kv : *links) { - res[i] = kv.second; - i++; - } - return res; - } - /** @brief destructor of the static data */ - void LinkImpl::linksExit() - { - for (auto kv : *links) - (kv.second)->destroy(); - delete links; - } + return res; + } + /** @brief destructor of the static data */ + void LinkImpl::linksExit() + { + for (auto kv : *links) + (kv.second)->destroy(); + delete links; + } } } diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index aedde294bd..2cf77d2ed5 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -69,6 +69,7 @@ static void clusterCreation_cb(sg_platf_cluster_cbarg_t cluster) NetPointNs3* host_src = sg_host_by_name(host_id)->pimpl_netpoint->extension(); xbt_assert(host_src, "Cannot find a NS3 host of name %s", host_id); + // Any NS3 route is symmetrical ns3_add_link(host_src, host_dst, bw, lat); delete host_dst; @@ -108,9 +109,8 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin xbt_assert(host_src != nullptr, "Network element %s does not seem to be NS3-ready", src->cname()); xbt_assert(host_dst != nullptr, "Network element %s does not seem to be NS3-ready", dst->cname()); + // Any NS3 route is symmetrical ns3_add_link(host_src, host_dst, link_bdw, link_lat); - if (symmetrical) - ns3_add_link(host_dst, host_src, link_bdw, link_lat); xbt_free(link_bdw); xbt_free(link_lat); @@ -163,7 +163,7 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel() { simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) { pt->extension_set(new NetPointNs3()); - + XBT_VERB("SimGrid's %s is known as node %d within NS3", pt->cname(), pt->extension()->node_num); }); simgrid::surf::on_cluster.connect(&clusterCreation_cb); simgrid::s4u::onPlatformCreated.connect(&postparse_cb); @@ -466,7 +466,6 @@ void ns3_add_link(NetPointNs3* src, NetPointNs3* dst, char* bw, char* lat) { ns3::PointToPointHelper pointToPoint; - ns3::NetDeviceContainer netA; ns3::Ipv4AddressHelper address; int srcNum = src->node_num; @@ -479,6 +478,7 @@ void ns3_add_link(NetPointNs3* src, NetPointNs3* dst, char* bw, char* lat) pointToPoint.SetDeviceAttribute ("DataRate", ns3::StringValue (bw)); pointToPoint.SetChannelAttribute ("Delay", ns3::StringValue (lat)); + ns3::NetDeviceContainer netA; netA.Add(pointToPoint.Install (a, b)); char * adr = bprintf("%d.%d.0.0",number_of_networks,number_of_links); diff --git a/src/surf/plugins/host_energy.cpp b/src/surf/plugins/host_energy.cpp index c1f8842167..9a441b93ac 100644 --- a/src/surf/plugins/host_energy.cpp +++ b/src/surf/plugins/host_energy.cpp @@ -137,7 +137,7 @@ void HostEnergy::update() double previous_energy = this->total_energy; double instantaneous_consumption; - if (host->isOff()) + if (this->pstate == -1) // The host was off at the beginning of this time interval instantaneous_consumption = this->watts_off; else instantaneous_consumption = this->getCurrentWattsValue(cpu_load); @@ -148,10 +148,13 @@ void HostEnergy::update() this->total_energy = previous_energy + energy_this_step; this->last_updated = finish_time; - this->pstate = host->pstate(); + XBT_DEBUG( "[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J", host->cname(), start_time, finish_time, host->pimpl_cpu->speed_.peak, previous_energy, energy_this_step); + + /* Save data for the upcoming time interval: whether it's on/off and the pstate if it's on */ + this->pstate = host->isOn() ? host->pstate() : -1; } HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host(ptr), last_updated(surf_get_clock()) diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 042c185efd..c960134bbf 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -316,7 +316,7 @@ void CpuL07::onSpeedChange() { Action* action = static_cast(lmm_variable_id(var)); lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak); - } + } Cpu::onSpeedChange(); } diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 7ebcf63047..f318471add 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -261,31 +261,31 @@ static inline void surf_storage_free(void *r) delete static_cast(r); } -void sg_version_check(int lib_version_major,int lib_version_minor,int lib_version_patch) { - if ((lib_version_major != SIMGRID_VERSION_MAJOR) || (lib_version_minor != SIMGRID_VERSION_MINOR)) { - fprintf(stderr, +void sg_version_check(int lib_version_major, int lib_version_minor, int lib_version_patch) +{ + if ((lib_version_major != SIMGRID_VERSION_MAJOR) || (lib_version_minor != SIMGRID_VERSION_MINOR)) { + fprintf(stderr, "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, " + "and then linked against SimGrid %d.%d.%d. Please fix this.\n", + lib_version_major, lib_version_minor, lib_version_patch, SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, + SIMGRID_VERSION_PATCH); + abort(); + } + if (lib_version_patch != SIMGRID_VERSION_PATCH) { + if (SIMGRID_VERSION_PATCH >= 90 || lib_version_patch >= 90) { + fprintf( + stderr, "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, " - "and then linked against SimGrid %d.%d.%d. Please fix this.\n", - lib_version_major,lib_version_minor,lib_version_patch, - SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH); + "and then linked against SimGrid %d.%d.%d. \n" + "One of them is a development version, and should not be mixed with the stable release. Please fix this.\n", + lib_version_major, lib_version_minor, lib_version_patch, SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, + SIMGRID_VERSION_PATCH); abort(); } - if (lib_version_patch != SIMGRID_VERSION_PATCH) { - if(SIMGRID_VERSION_PATCH >= 90 || lib_version_patch >=90){ - fprintf(stderr, - "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, " - "and then linked against SimGrid %d.%d.%d. \n" - "One of them is a development version, and should not be mixed with the stable release. Please fix this.\n", - lib_version_major,lib_version_minor,lib_version_patch, - SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH); - abort(); - } - fprintf(stderr, - "Warning: Your program was compiled with SimGrid version %d.%d.%d, " - "and then linked against SimGrid %d.%d.%d. Proceeding anyway.\n", - lib_version_major,lib_version_minor,lib_version_patch, - SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH); - } + fprintf(stderr, "Warning: Your program was compiled with SimGrid version %d.%d.%d, " + "and then linked against SimGrid %d.%d.%d. Proceeding anyway.\n", + lib_version_major, lib_version_minor, lib_version_patch, SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, + SIMGRID_VERSION_PATCH); + } } void sg_version_get(int* ver_major, int* ver_minor, int* ver_patch) diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 12611da1da..ac88aa5092 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -1102,7 +1102,7 @@ void surf_parse_open(const char *file) xbt_free(dir); surf_file_to_parse = surf_fopen(file, "r"); - xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", file); + xbt_assert(surf_file_to_parse != nullptr, "Unable to open '%s'\n", file); surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE); surf_parse__switch_to_buffer(surf_input_buffer); surf_parse_lineno = 1; diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index 780d908f19..4b5ec9330c 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -1,5 +1,5 @@ # C examples -foreach(x get_sender host_on_off host_on_off_recv host_on_off_processes trace_integration) +foreach(x cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes trace_integration) add_executable (${x} ${x}/${x}.c) target_link_libraries(${x} simgrid) set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) @@ -9,7 +9,7 @@ foreach(x get_sender host_on_off host_on_off_recv host_on_off_processes trace_in endforeach() # CPP examples -foreach(x task_destroy_cancel) +foreach(x task_destroy_cancel task_listen_from) add_executable (${x} ${x}/${x}.cpp) target_link_libraries(${x} simgrid) set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) @@ -33,6 +33,6 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1-c1s1-c3s2.xml ${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 trace_integration) +foreach(x cloud-sharing 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) endforeach() diff --git a/teshsuite/msg/cloud-sharing/cloud-sharing.c b/teshsuite/msg/cloud-sharing/cloud-sharing.c new file mode 100644 index 0000000000..da63459bf1 --- /dev/null +++ b/teshsuite/msg/cloud-sharing/cloud-sharing.c @@ -0,0 +1,117 @@ +/* Copyright (c) 2007-2015. 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. */ + +#include "simgrid/msg.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); + +static int computation_fun(int argc, char* argv[]) +{ + msg_task_t task = MSG_task_create("Task", 100000000, 0, NULL); + + double clock_sta = MSG_get_clock(); + MSG_task_execute(task); + double clock_end = MSG_get_clock(); + + XBT_INFO("Task took %gs to execute", clock_end - clock_sta); + + MSG_task_destroy(task); + + return 0; +} + +static int master_main(int argc, char* argv[]) +{ + msg_host_t pm0 = MSG_host_by_name("node-0.acme.org"); + msg_host_t pm1 = MSG_host_by_name("node-1.acme.org"); + xbt_assert(pm0, "Host node-0.acme.org does not seem to exist"); + + XBT_INFO("## Test 1 (started): check computation on normal PMs"); + + XBT_INFO("### Put a task on a PM"); + MSG_process_create("compute", computation_fun, NULL, pm0); + MSG_process_sleep(2); + + XBT_INFO("### Put two tasks on a PM"); + MSG_process_create("compute", computation_fun, NULL, pm0); + MSG_process_create("compute", computation_fun, NULL, pm0); + MSG_process_sleep(2); + + XBT_INFO("### Put a task on each PM"); + MSG_process_create("compute", computation_fun, NULL, pm0); + MSG_process_create("compute", computation_fun, NULL, pm1); + MSG_process_sleep(2); + + XBT_INFO("## Test 1 (ended)"); + + XBT_INFO("## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)"); + + XBT_INFO("### Put a VM on a PM, and put a task to the VM"); + msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0"); + MSG_vm_start(vm0); + MSG_process_create("compute", computation_fun, NULL, vm0); + MSG_process_sleep(2); + MSG_vm_destroy(vm0); + + XBT_INFO("## Test 2 (ended)"); + + XBT_INFO( + "## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)"); + + XBT_INFO("### Put a VM on a PM, and put a task to the PM"); + vm0 = MSG_vm_create_core(pm0, "VM0"); + MSG_vm_start(vm0); + MSG_process_create("compute", computation_fun, NULL, pm0); + MSG_process_sleep(2); + MSG_vm_destroy(vm0); + + XBT_INFO("## Test 3 (ended)"); + + XBT_INFO("## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for" + " the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1"); + + XBT_INFO("### Put two VMs on a PM, and put a task to each VM"); + vm0 = MSG_vm_create_core(pm0, "VM0"); + msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1"); + MSG_vm_start(vm0); + MSG_vm_start(vm1); + MSG_process_create("compute", computation_fun, NULL, vm0); + MSG_process_create("compute", computation_fun, NULL, vm1); + MSG_process_sleep(2); + MSG_vm_destroy(vm0); + MSG_vm_destroy(vm1); + + XBT_INFO("### Put a VM on each PM, and put a task to each VM"); + vm0 = MSG_vm_create_core(pm0, "VM0"); + vm1 = MSG_vm_create_core(pm1, "VM1"); + MSG_vm_start(vm0); + MSG_vm_start(vm1); + MSG_process_create("compute", computation_fun, NULL, vm0); + MSG_process_create("compute", computation_fun, NULL, vm1); + MSG_process_sleep(2); + MSG_vm_destroy(vm0); + MSG_vm_destroy(vm1); + XBT_INFO("## Test 4 (ended)"); + + return 0; +} + +int main(int argc, char* argv[]) +{ + /* Get the arguments */ + MSG_init(&argc, argv); + + /* load the platform file */ + const char* platform = "../../platforms/cluster.xml"; + if (argc == 2) + platform = argv[1]; + MSG_create_environment(platform); + + msg_host_t pm0 = MSG_host_by_name("node-0.acme.org"); + xbt_assert(pm0, "Host 'node-0.acme.org' not found"); + MSG_process_create("master", master_main, NULL, pm0); + + return MSG_main() != MSG_OK; +} diff --git a/teshsuite/msg/cloud-sharing/cloud-sharing.tesh b/teshsuite/msg/cloud-sharing/cloud-sharing.tesh new file mode 100644 index 0000000000..beb39ace2a --- /dev/null +++ b/teshsuite/msg/cloud-sharing/cloud-sharing.tesh @@ -0,0 +1,29 @@ +#! ./tesh + +$ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=no_loc ${srcdir:=.}/../../../examples/platforms/cluster.xml +> [node-0.acme.org:master:(1) 0.000000] [msg_test/INFO] ## Test 1 (started): check computation on normal PMs +> [node-0.acme.org:master:(1) 0.000000] [msg_test/INFO] ### Put a task on a PM +> [node-0.acme.org:compute:(2) 0.100000] [msg_test/INFO] Task took 0.1s to execute +> [node-0.acme.org:master:(1) 2.000000] [msg_test/INFO] ### Put two tasks on a PM +> [node-0.acme.org:compute:(4) 2.200000] [msg_test/INFO] Task took 0.2s to execute +> [node-0.acme.org:compute:(3) 2.200000] [msg_test/INFO] Task took 0.2s to execute +> [node-0.acme.org:master:(1) 4.000000] [msg_test/INFO] ### Put a task on each PM +> [node-0.acme.org:compute:(5) 4.100000] [msg_test/INFO] Task took 0.1s to execute +> [node-1.acme.org:compute:(6) 4.100000] [msg_test/INFO] Task took 0.1s to execute +> [node-0.acme.org:master:(1) 6.000000] [msg_test/INFO] ## Test 1 (ended) +> [node-0.acme.org:master:(1) 6.000000] [msg_test/INFO] ## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment) +> [node-0.acme.org:master:(1) 6.000000] [msg_test/INFO] ### Put a VM on a PM, and put a task to the VM +> [VM0:compute:(7) 6.100000] [msg_test/INFO] Task took 0.1s to execute +> [node-0.acme.org:master:(1) 8.000000] [msg_test/INFO] ## Test 2 (ended) +> [node-0.acme.org:master:(1) 8.000000] [msg_test/INFO] ## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment) +> [node-0.acme.org:master:(1) 8.000000] [msg_test/INFO] ### Put a VM on a PM, and put a task to the PM +> [node-0.acme.org:compute:(8) 8.100000] [msg_test/INFO] Task took 0.1s to execute +> [node-0.acme.org:master:(1) 10.000000] [msg_test/INFO] ## Test 3 (ended) +> [node-0.acme.org:master:(1) 10.000000] [msg_test/INFO] ## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1 +> [node-0.acme.org:master:(1) 10.000000] [msg_test/INFO] ### Put two VMs on a PM, and put a task to each VM +> [VM0:compute:(9) 10.200000] [msg_test/INFO] Task took 0.2s to execute +> [VM1:compute:(10) 10.200000] [msg_test/INFO] Task took 0.2s to execute +> [node-0.acme.org:master:(1) 12.000000] [msg_test/INFO] ### Put a VM on each PM, and put a task to each VM +> [VM0:compute:(11) 12.100000] [msg_test/INFO] Task took 0.1s to execute +> [VM1:compute:(12) 12.100000] [msg_test/INFO] Task took 0.1s to execute +> [node-0.acme.org:master:(1) 14.000000] [msg_test/INFO] ## Test 4 (ended) diff --git a/teshsuite/msg/host_on_off_processes/host_on_off_processes.c b/teshsuite/msg/host_on_off_processes/host_on_off_processes.c index 83071fbd5f..a76bd53074 100644 --- a/teshsuite/msg/host_on_off_processes/host_on_off_processes.c +++ b/teshsuite/msg/host_on_off_processes/host_on_off_processes.c @@ -176,7 +176,7 @@ static int test_launcher(int argc, char *argv[]) msg_vm_t vm0; msg_process_t daemon; - vm0 = MSG_vm_create(jupiter, "vm0", 2048, 125, dpRate); + vm0 = MSG_vm_create(jupiter, "vm0", 1, 2048, 125, dpRate); MSG_vm_start(vm0); argvF = xbt_new(char*, 2); diff --git a/teshsuite/msg/task_listen_from/task_listen_from.cpp b/teshsuite/msg/task_listen_from/task_listen_from.cpp new file mode 100644 index 0000000000..128b046d07 --- /dev/null +++ b/teshsuite/msg/task_listen_from/task_listen_from.cpp @@ -0,0 +1,36 @@ +/* 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. */ + +/* This is the test case of GitHub's #121 */ + +#include "simgrid/msg.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); + +static int tester(int argc, char* argv[]) +{ + msg_task_t task = MSG_task_create("name", 0, 10, NULL); + msg_comm_t comm = MSG_task_isend(task, "mailbox"); + + XBT_INFO("MSG_task_listen_from returns() %d (should return my pid, which is %d)", MSG_task_listen_from("mailbox"), + MSG_process_get_PID(MSG_process_self())); + XBT_INFO("MSG_task_listen returns() %d (should return true, i.e. 1)", MSG_task_listen("mailbox")); + + MSG_comm_destroy(comm); + MSG_task_destroy(task); + + return 0; +} + +int main(int argc, char* argv[]) +{ + MSG_init(&argc, argv); + xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]); + MSG_create_environment(argv[1]); + + MSG_process_create("tester", tester, NULL, MSG_get_host_by_name("Tremblay")); + + return MSG_main(); +} diff --git a/teshsuite/msg/task_listen_from/task_listen_from.tesh b/teshsuite/msg/task_listen_from/task_listen_from.tesh new file mode 100644 index 0000000000..32db934eb4 --- /dev/null +++ b/teshsuite/msg/task_listen_from/task_listen_from.tesh @@ -0,0 +1,3 @@ +$ ./task_listen_from ${srcdir:=.}/../../../examples/platforms/small_platform.xml +> [Tremblay:tester:(1) 0.000000] [msg_test/INFO] MSG_task_listen_from returns() 1 (should return my pid, which is 1) +> [Tremblay:tester:(1) 0.000000] [msg_test/INFO] MSG_task_listen returns() 1 (should return true, i.e. 1) diff --git a/teshsuite/simdag/availability/availability.c b/teshsuite/simdag/availability/availability.c index ed79a9327a..73c9e993da 100644 --- a/teshsuite/simdag/availability/availability.c +++ b/teshsuite/simdag/availability/availability.c @@ -60,6 +60,5 @@ int main(int argc, char *argv[]) SD_task_destroy(task); } xbt_dynar_free(&dax); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/basic-link-test/basic-link-test.c b/teshsuite/simdag/basic-link-test/basic-link-test.c index 36971c3fe7..e3a01ade8a 100644 --- a/teshsuite/simdag/basic-link-test/basic-link-test.c +++ b/teshsuite/simdag/basic-link-test/basic-link-test.c @@ -34,6 +34,5 @@ int main(int argc, char **argv) xbt_assert(!strcmp(user_data, (const char*)sg_link_data(links[i])),"User data was corrupted."); } xbt_free(links); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/basic-parsing-test/basic-parsing-test.c b/teshsuite/simdag/basic-parsing-test/basic-parsing-test.c index e8a056c6bf..c2ea385515 100644 --- a/teshsuite/simdag/basic-parsing-test/basic-parsing-test.c +++ b/teshsuite/simdag/basic-parsing-test/basic-parsing-test.c @@ -64,6 +64,5 @@ int main(int argc, char **argv) } xbt_free(hosts); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/basic0/basic0.c b/teshsuite/simdag/basic0/basic0.c index 04c1e09631..0115af360d 100644 --- a/teshsuite/simdag/basic0/basic0.c +++ b/teshsuite/simdag/basic0/basic0.c @@ -54,6 +54,5 @@ int main(int argc, char **argv) XBT_INFO("Simulation time: %f", SD_get_clock()); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/basic1/basic1.c b/teshsuite/simdag/basic1/basic1.c index 318911f5d9..5f0cdfa749 100644 --- a/teshsuite/simdag/basic1/basic1.c +++ b/teshsuite/simdag/basic1/basic1.c @@ -53,6 +53,5 @@ int main(int argc, char **argv) XBT_INFO("Simulation time: %f", SD_get_clock()); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/basic3/basic3.c b/teshsuite/simdag/basic3/basic3.c index ab44e3e9ce..01467e7000 100644 --- a/teshsuite/simdag/basic3/basic3.c +++ b/teshsuite/simdag/basic3/basic3.c @@ -47,6 +47,5 @@ int main(int argc, char **argv) XBT_INFO("Simulation time: %f", SD_get_clock()); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/basic4/basic4.c b/teshsuite/simdag/basic4/basic4.c index c061e6ac01..3d3ea052c3 100644 --- a/teshsuite/simdag/basic4/basic4.c +++ b/teshsuite/simdag/basic4/basic4.c @@ -50,6 +50,5 @@ int main(int argc, char **argv) XBT_INFO("Simulation time: %f", SD_get_clock()); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/basic5/basic5.c b/teshsuite/simdag/basic5/basic5.c index 485cdcb40b..1382e36d7a 100644 --- a/teshsuite/simdag/basic5/basic5.c +++ b/teshsuite/simdag/basic5/basic5.c @@ -53,6 +53,5 @@ int main(int argc, char **argv) XBT_INFO("Simulation time: %f", SD_get_clock()); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/basic6/basic6.c b/teshsuite/simdag/basic6/basic6.c index c9adf72f3c..50886ba52b 100644 --- a/teshsuite/simdag/basic6/basic6.c +++ b/teshsuite/simdag/basic6/basic6.c @@ -46,6 +46,5 @@ int main(int argc, char **argv) XBT_INFO("Simulation time: %f", SD_get_clock()); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/comm-mxn-all2all/comm-mxn-all2all.c b/teshsuite/simdag/comm-mxn-all2all/comm-mxn-all2all.c index 5ba3320eaf..45e8e62849 100644 --- a/teshsuite/simdag/comm-mxn-all2all/comm-mxn-all2all.c +++ b/teshsuite/simdag/comm-mxn-all2all/comm-mxn-all2all.c @@ -40,6 +40,5 @@ int main(int argc, char **argv) SD_task_destroy(task); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/comm-mxn-independent/comm-mxn-independent.c b/teshsuite/simdag/comm-mxn-independent/comm-mxn-independent.c index 07a79ac9aa..7e9e61921d 100644 --- a/teshsuite/simdag/comm-mxn-independent/comm-mxn-independent.c +++ b/teshsuite/simdag/comm-mxn-independent/comm-mxn-independent.c @@ -41,6 +41,5 @@ int main(int argc, char **argv) SD_task_destroy(task); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/comm-mxn-scatter/comm-mxn-scatter.c b/teshsuite/simdag/comm-mxn-scatter/comm-mxn-scatter.c index e55fadfe85..6116df43e7 100644 --- a/teshsuite/simdag/comm-mxn-scatter/comm-mxn-scatter.c +++ b/teshsuite/simdag/comm-mxn-scatter/comm-mxn-scatter.c @@ -42,6 +42,5 @@ int main(int argc, char **argv) SD_task_destroy(task); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/comm-p2p-latency-1/comm-p2p-latency-1.c b/teshsuite/simdag/comm-p2p-latency-1/comm-p2p-latency-1.c index ed3557ac75..e4bce55f33 100644 --- a/teshsuite/simdag/comm-p2p-latency-1/comm-p2p-latency-1.c +++ b/teshsuite/simdag/comm-p2p-latency-1/comm-p2p-latency-1.c @@ -37,6 +37,5 @@ int main(int argc, char **argv) SD_task_destroy(task); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/comm-p2p-latency-2/comm-p2p-latency-2.c b/teshsuite/simdag/comm-p2p-latency-2/comm-p2p-latency-2.c index dd845e12d8..95f3491074 100644 --- a/teshsuite/simdag/comm-p2p-latency-2/comm-p2p-latency-2.c +++ b/teshsuite/simdag/comm-p2p-latency-2/comm-p2p-latency-2.c @@ -46,7 +46,6 @@ int main(int argc, char **argv) SD_task_destroy(task1); SD_task_destroy(task2); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/comm-p2p-latency-3/comm-p2p-latency-3.c b/teshsuite/simdag/comm-p2p-latency-3/comm-p2p-latency-3.c index 74aaca0c5f..abdfb6e15f 100644 --- a/teshsuite/simdag/comm-p2p-latency-3/comm-p2p-latency-3.c +++ b/teshsuite/simdag/comm-p2p-latency-3/comm-p2p-latency-3.c @@ -48,6 +48,5 @@ int main(int argc, char **argv) SD_task_destroy(task1); SD_task_destroy(task2); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/comm-p2p-latency-bound/comm-p2p-latency-bound.c b/teshsuite/simdag/comm-p2p-latency-bound/comm-p2p-latency-bound.c index f29bdd9def..db1fa4ff49 100644 --- a/teshsuite/simdag/comm-p2p-latency-bound/comm-p2p-latency-bound.c +++ b/teshsuite/simdag/comm-p2p-latency-bound/comm-p2p-latency-bound.c @@ -50,6 +50,5 @@ int main(int argc, char **argv) } SD_task_destroy(root); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/comp-only-par/comp-only-par.c b/teshsuite/simdag/comp-only-par/comp-only-par.c index 6ce8ddb9b1..9968151ff2 100644 --- a/teshsuite/simdag/comp-only-par/comp-only-par.c +++ b/teshsuite/simdag/comp-only-par/comp-only-par.c @@ -27,6 +27,5 @@ int main(int argc, char **argv) SD_task_destroy(task); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/comp-only-seq/comp-only-seq.c b/teshsuite/simdag/comp-only-seq/comp-only-seq.c index a0908e21c8..012a960d4e 100644 --- a/teshsuite/simdag/comp-only-seq/comp-only-seq.c +++ b/teshsuite/simdag/comp-only-seq/comp-only-seq.c @@ -30,6 +30,5 @@ int main(int argc, char **argv) SD_task_destroy(task); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c b/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c index c8bf42ad1f..7dd4dd6469 100644 --- a/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c +++ b/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c @@ -47,7 +47,6 @@ int main(int argc, char **argv) printf("%f\n", xbt_os_timer_elapsed(timer) ); xbt_free(hosts); - SD_exit(); return 0; } diff --git a/teshsuite/simdag/evaluate-parse-time/evaluate-parse-time.c b/teshsuite/simdag/evaluate-parse-time/evaluate-parse-time.c index f21cb3a5b9..9bce26c5e3 100644 --- a/teshsuite/simdag/evaluate-parse-time/evaluate-parse-time.c +++ b/teshsuite/simdag/evaluate-parse-time/evaluate-parse-time.c @@ -34,7 +34,6 @@ int main(int argc, char **argv) sleep(atoi(argv[2])); } - SD_exit(); free(timer); return 0; diff --git a/teshsuite/simdag/flatifier/flatifier.cpp b/teshsuite/simdag/flatifier/flatifier.cpp index e434b5bf1d..66d88d9eda 100644 --- a/teshsuite/simdag/flatifier/flatifier.cpp +++ b/teshsuite/simdag/flatifier/flatifier.cpp @@ -202,7 +202,6 @@ int main(int argc, char** argv) dump_platform(); } - SD_exit(); xbt_os_timer_free(parse_time); return 0; diff --git a/teshsuite/simdag/incomplete/incomplete.c b/teshsuite/simdag/incomplete/incomplete.c index 593b93490f..538a3838aa 100644 --- a/teshsuite/simdag/incomplete/incomplete.c +++ b/teshsuite/simdag/incomplete/incomplete.c @@ -59,6 +59,6 @@ int main(int argc, char **argv) XBT_INFO("Simulation time: %f", SD_get_clock()); - SD_exit(); + return 0; } diff --git a/teshsuite/simdag/is-router/is-router.cpp b/teshsuite/simdag/is-router/is-router.cpp index 4a4d891168..523080ccba 100644 --- a/teshsuite/simdag/is-router/is-router.cpp +++ b/teshsuite/simdag/is-router/is-router.cpp @@ -44,6 +44,5 @@ int main(int argc, char **argv) std::printf(" - Seen: \"%s\". Type: %s\n", nc->cname(), nc->isRouter() ? "router" : (nc->isNetZone() ? "netzone" : (nc->isHost() ? "host" : "buggy"))); - SD_exit(); return 0; } diff --git a/tools/cmake/Java.cmake b/tools/cmake/Java.cmake index eb20402562..0e77fab2ec 100644 --- a/tools/cmake/Java.cmake +++ b/tools/cmake/Java.cmake @@ -127,11 +127,47 @@ if(enable_lib_in_jar) COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO} ${JAVA_NATIVE_PATH}/${LIBSIMGRID_SO} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_JAVA_SO} ${JAVA_NATIVE_PATH}/${LIBSIMGRID_JAVA_SO} + ) + +if(WIN32) + add_custom_command( + TARGET simgrid-java_jar POST_BUILD + COMMENT "Add the windows-specific native libs into simgrid.jar..." + DEPENDS simgrid simgrid-java ${JAVALIBS} + # There is no way to disable the dependency of mingw-64 on that lib, unfortunately nor to script cmake -E properly # So let's be brutal and copy it in any case (even on non-windows builds) from the location where chocolatey installs it. # The copy is only expected to work on the appveyor builder, but that's all we need right now # since our users are directed to download that file as nightly build. COMMAND ${CMAKE_COMMAND} -E copy_if_different C:/tools/mingw64/bin/libwinpthread-1.dll ${JAVA_NATIVE_PATH}/libwinpthread-1.dll || true + ) +endif() + +if(APPLE) + add_custom_command( + TARGET simgrid-java_jar POST_BUILD + COMMENT "Add the apple-specific native libs into simgrid.jar..." + DEPENDS simgrid simgrid-java ${JAVALIBS} + + # We need to fix the rpath of the simgrid-java library so that it + # searches the simgrid library in the right location + # + # Since we don't officially install the lib before copying it in + # the jarfile, the lib is searched for where it was built. Given + # how we unpack it, we need to instruct simgrid-java to forget + # about the build path, and search in its current directory + # instead. + # + # This has to be done with the classical Apple tools, as follows: + + COMMAND install_name_tool -change ${CMAKE_BINARY_DIR}/lib/libsimgrid.${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}${CMAKE_SHARED_LIBRARY_SUFFIX} @loader_path/libsimgrid.dylib ${JAVA_NATIVE_PATH}/${LIBSIMGRID_JAVA_SO} + ) +endif() + + add_custom_command( + TARGET simgrid-java_jar POST_BUILD + COMMENT "Packing back the simgrid.jar with the native libs..." + DEPENDS simgrid simgrid-java ${JAVALIBS} COMMAND ${JAVA_ARCHIVE} -uvf ${SIMGRID_JAR} ${JAVA_NATIVE_PATH} diff --git a/tools/cmake/MakeLib.cmake b/tools/cmake/MakeLib.cmake index d7c456a5fd..6f4cf6b299 100644 --- a/tools/cmake/MakeLib.cmake +++ b/tools/cmake/MakeLib.cmake @@ -4,10 +4,13 @@ # See https://cmake.org/Wiki/CMake_RPATH_handling and Java.cmake set(MACOSX_RPATH ON) if(APPLE) + SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # When installed, use system path + set(CMAKE_SKIP_BUILD_RPATH FALSE) # When executing from build tree, take the lib from the build path if exists + set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # When executing from build tree, take the lib from the system path if exists + # add the current location of libsimgrid-java.dynlib as a location for libsimgrid.dynlib # (useful when unpacking the native libraries from the jarfile) - set(CMAKE_INSTALL_RPATH "@loader_path/.") - SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set(CMAKE_INSTALL_RPATH "@loader_path/.;@rpath/.") endif() ############################### diff --git a/tools/git-hooks/clang-format.pre-commit b/tools/git-hooks/clang-format.pre-commit index 9a6678b269..db2e47aad2 100755 --- a/tools/git-hooks/clang-format.pre-commit +++ b/tools/git-hooks/clang-format.pre-commit @@ -149,7 +149,9 @@ do # +++ - timestamp # to both lines working on the same file and having a a/ and b/ prefix. # Else it can not be applied with 'git apply'. - git ${GIT_SUBCOMMAND} --binary ${CLANG_FORMAT} --diff -q "$file" >> "$patch" + git ${GIT_SUBCOMMAND} --binary ${CLANG_FORMAT} --diff -q "$file" \ + | (grep -v "no modified files to format"||true) \ + >> "$patch" #"$CLANG_FORMAT" -style=file "$file" | \ #diff -u "$file" - | \ #sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch" diff --git a/tools/simgrid.supp b/tools/simgrid.supp index e9a7f4fa8f..49ed161781 100644 --- a/tools/simgrid.supp +++ b/tools/simgrid.supp @@ -185,3 +185,27 @@ Memcheck:Addr8 fun:_Ux86_64_setcontext } + +# Java cruft +{ + JavaCruft 1 + Memcheck:Addr4 + ... + fun:_ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread + fun:JVM_DoPrivileged + ... +} +{ + JavaCruft 2 + Memcheck:Cond + ... + fun:_ZN13CompileBroker25invoke_compiler_on_methodEP11CompileTask + ... +} + +{ + Somewhere within the Java conditions and monitors + Memcheck:Cond + fun:MarsagliaXORV + ... +} diff --git a/tools/tesh/tesh.py b/tools/tesh/tesh.py index a7a760a8d6..8f1cb4c022 100755 --- a/tools/tesh/tesh.py +++ b/tools/tesh/tesh.py @@ -353,11 +353,11 @@ class Cmd(object): if self.sort >= 0: # If sorted, truncate the diff output and show the unsorted version difflen = 0; for line in diff: - if difflen<250: + if difflen<50: print(line) difflen += 1 - if difflen > 100: - print("(diff truncated after 250 lines)") + if difflen > 50: + print("(diff truncated after 50 lines)") print("Unsorted observed output:\n") for line in stdcpy: print(line)