From a279c221114b93985c6aa249e71cc4141082b310 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 31 Mar 2014 21:43:02 +0200 Subject: [PATCH] Revert "Remove XBT_INFO call" This commit changes much much more than wanted. In particular, it reverts several changes done in the tree recently. I assume that the merge that occured just before this commit went awfully wrong, actually. That's ok, shit happens, don't worry. Nevertheless, I revert this commit when it's still possible, before the first unrelated commit on top of it. Pierre, please, pick your changes back from the diff, and resubmit them. This reverts commit f9e6853d2c5b7b867211700bc12f0ee57f640b30. --- .gitignore | 1 + buildtools/Cmake/AddTests.cmake | 4 + buildtools/Cmake/DefinePackages.cmake | 7 ++ buildtools/Cmake/MakeExe.cmake | 2 + .../java/reservationSurfPlugin/Receiver.java | 12 +- .../ReservationPlugin.java | 63 ++++------- .../java/reservationSurfPlugin/Sender.java | 48 ++++---- .../reservationSurfPlugin/TestPlugin.java | 6 +- .../reservationSurfPluginDeployment.xml | 4 +- .../reservationSurfPluginPlatform.xml | 6 +- .../reservation_surf_plugin.tesh | 38 +++---- examples/java/surfPlugin/TracePlugin.java | 8 +- examples/msg/mc/bugged1.tesh | 2 +- examples/msg/mc/bugged1_liveness.tesh | 2 +- examples/msg/mc/bugged1_liveness_visited.tesh | 2 +- examples/msg/mc/bugged2.tesh | 2 +- examples/smpi/CMakeLists.txt | 4 + examples/smpi/mc/hostfile_mutual_exclusion | 3 + examples/smpi/mc/mutual_exclusion.c | 72 ++++++++++++ src/bindings/java/surf.i | 48 +++++++- src/bindings/java/surf_swig.cpp | 14 ++- src/bindings/java/surf_swig.hpp | 12 +- src/mc/mc_checkpoint.c | 17 ++- src/mc/mc_dwarf.c | 89 ++++++++------- src/mc/mc_dwarf_expression.c | 9 +- src/mc/mc_global.c | 9 ++ src/mc/mc_private.h | 6 +- src/msg/msg_io.c | 4 +- src/simix/smx_global.c | 7 +- src/simix/smx_io.c | 2 +- src/smpi/smpi_base.c | 13 +-- src/smpi/smpi_bench.c | 9 +- src/smpi/smpi_global.c | 13 ++- src/smpi/smpi_pmpi.c | 93 +-------------- src/surf/cpu_interface.cpp | 10 +- src/surf/cpu_interface.hpp | 50 ++++---- src/surf/network_cm02.cpp | 107 ++++++++++-------- src/surf/network_cm02.hpp | 2 + src/surf/network_constant.cpp | 1 + src/surf/network_interface.cpp | 11 +- src/surf/network_interface.hpp | 64 +++++++---- src/surf/network_ns3.cpp | 11 +- src/surf/network_ns3.hpp | 6 +- src/surf/ns3/ns3_interface.cc | 9 +- src/surf/ns3/ns3_interface.h | 6 +- src/surf/plugins/energy.cpp | 6 +- src/surf/storage_interface.cpp | 10 +- src/surf/storage_interface.hpp | 38 +++---- src/surf/surf_interface.cpp | 6 +- src/surf/workstation_interface.cpp | 10 +- src/surf/workstation_interface.hpp | 76 ++++++------- src/surf/workstation_ptask_L07.cpp | 33 ++++-- src/surf/workstation_ptask_L07.hpp | 2 + src/xbt/mmalloc/mmorecore.c | 4 + teshsuite/bug-17132/CMakeLists.txt | 37 ++++++ teshsuite/bug-17132/README | 8 ++ teshsuite/bug-17132/bug-17132.c | 40 +++++++ teshsuite/bug-17132/bug-17132.tesh | 8 ++ teshsuite/bug-17132/hostfile.txt | 2 + teshsuite/bug-17132/small_platform.xml | 15 +++ teshsuite/simix/stack_overflow.tesh | 7 +- testsuite/mc/dwarf_expression.c | 2 +- 62 files changed, 722 insertions(+), 490 deletions(-) create mode 100644 examples/smpi/mc/hostfile_mutual_exclusion create mode 100644 examples/smpi/mc/mutual_exclusion.c create mode 100644 teshsuite/bug-17132/CMakeLists.txt create mode 100644 teshsuite/bug-17132/README create mode 100644 teshsuite/bug-17132/bug-17132.c create mode 100644 teshsuite/bug-17132/bug-17132.tesh create mode 100644 teshsuite/bug-17132/hostfile.txt create mode 100644 teshsuite/bug-17132/small_platform.xml diff --git a/.gitignore b/.gitignore index 6dc00ee2e1..5b889c15ac 100644 --- a/.gitignore +++ b/.gitignore @@ -254,6 +254,7 @@ examples/smpi/mc/bugged2 src/replay/replay src/testall +teshsuite/bug-17132/bug-17132 teshsuite/smpi/allgather_coll teshsuite/smpi/allgatherv_coll teshsuite/smpi/allreduce_coll diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index 03ad3a8a69..1b7ea2c81c 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -444,6 +444,10 @@ if(NOT enable_memcheck) ADD_TEST(smpi-struct-thread ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/struct.tesh) ADD_TEST(smpi-pt2pt-thread ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pt2pt.tesh) ADD_TEST(smpi-compute-thread ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/compute.tesh) + + # https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165 + ADD_TEST(smpi-bug-17132 ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132 --cd ${CMAKE_BINARY_DIR}/teshsuite/bug-17132 ${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132/bug-17132.tesh) + if (NOT WIN32) ADD_TEST(smpi-shared-thread ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/shared.tesh) endif() diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 2c0e140ae3..013c8fc526 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -505,7 +505,13 @@ set(JSURF_JAVA_GENERATED_SRC ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/NetworkLink.java ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/NetworkAction.java + ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/RoutingEdge.java + + ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/ActionState.java + ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/ResourceState.java + ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/LmmConstraint.java + ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/LmmVariable.java ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/XbtDict.java ) @@ -975,6 +981,7 @@ set(TESHSUITE_CMAKEFILES_TXT teshsuite/msg/CMakeLists.txt teshsuite/msg/storage/CMakeLists.txt teshsuite/msg/trace/CMakeLists.txt + teshsuite/bug-17132/CMakeLists.txt teshsuite/simdag/CMakeLists.txt teshsuite/simdag/availability/CMakeLists.txt teshsuite/simdag/network/CMakeLists.txt diff --git a/buildtools/Cmake/MakeExe.cmake b/buildtools/Cmake/MakeExe.cmake index a5a5819361..b9445e4573 100644 --- a/buildtools/Cmake/MakeExe.cmake +++ b/buildtools/Cmake/MakeExe.cmake @@ -90,6 +90,8 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/network/p2p) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/partask) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms) +add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132) + add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simix) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/smpi) diff --git a/examples/java/reservationSurfPlugin/Receiver.java b/examples/java/reservationSurfPlugin/Receiver.java index cd66bb4502..7097e5bcf2 100644 --- a/examples/java/reservationSurfPlugin/Receiver.java +++ b/examples/java/reservationSurfPlugin/Receiver.java @@ -21,15 +21,11 @@ public class Receiver extends Process { public void main(String[] args) throws MsgException { Msg.info("helloo!"); - double communicationTime=0; - Msg.info("try to get a task"); - - Task task = Task.receive(getHost().getName()); - double timeGot = Msg.getClock(); - - Msg.info("Got at time "+ timeGot); - task.execute(); + Task task; + task = Task.receive(getHost().getName()); + task = Task.receive(getHost().getName()); + task = Task.receive(getHost().getName()); Msg.info("goodbye!"); } diff --git a/examples/java/reservationSurfPlugin/ReservationPlugin.java b/examples/java/reservationSurfPlugin/ReservationPlugin.java index 0bd91aa5d1..8f3b6b72bf 100644 --- a/examples/java/reservationSurfPlugin/ReservationPlugin.java +++ b/examples/java/reservationSurfPlugin/ReservationPlugin.java @@ -7,55 +7,34 @@ import java.util.HashMap; public class ReservationPlugin extends Plugin { public ReservationPlugin() { - activateCpuCreatedCallback(); - activateCpuDestructedCallback(); - activateCpuStateChangedCallback(); - activateCpuActionStateChangedCallback(); - - activateNetworkLinkCreatedCallback(); - activateNetworkLinkDestructedCallback(); - activateNetworkLinkStateChangedCallback(); - activateNetworkActionStateChangedCallback(); - - } - - public void init() { - NetworkLink[] route = Surf.getRoute("Jacquelin", "Boivin"); - Msg.info("RouteLength:"+route.length); - Msg.info("RouteName0:"+route[0].getName()); - Msg.info("RouteName1:"+route[1].getName()); + activateNetworkCommunicateCallback(); } - public void cpuCreatedCallback(Cpu cpu) { - Msg.info("Trace: Cpu created "+cpu.getName()); - } - - public void cpuDestructedCallback(Cpu cpu) { - Msg.info("Trace: Cpu destructed "+cpu.getName()); - } - - public void cpuStateChangedCallback(Cpu cpu){ - Msg.info("Trace: Cpu state changed "+cpu.getName()); - } - - public void cpuActionStateChangedCallback(CpuAction action){ - Msg.info("Trace: CpuAction state changed "+action.getModel().getName()); - } - - public void networkLinkCreatedCallback(NetworkLink link) { - Msg.info("Trace: NetworkLink created "+link.getName()); - } + //HashMap reservations; + double bandwidth = 0; + String src = ""; + String dst = ""; - public void networkLinkDestructedCallback(NetworkLink link) { - Msg.info("Trace: NetworkLink destructed "+link.getName()); + public void limitBandwidthActions(String src, String dst, double bandwidth){ + this.bandwidth = bandwidth; + this.src = src; + this.dst = dst; } - public void networkLinkStateChangedCallback(NetworkLink link){ - Msg.info("Trace: NetworkLink state changed "+link.getName()); + public void updateBandwidthRoute(String src, String dst, double bandwidth){ + NetworkLink[] route = Surf.getRoute(src, dst); + for (int i =0; i - + - + diff --git a/examples/java/reservationSurfPlugin/reservationSurfPluginPlatform.xml b/examples/java/reservationSurfPlugin/reservationSurfPluginPlatform.xml index 2712607497..155dd2d2aa 100644 --- a/examples/java/reservationSurfPlugin/reservationSurfPluginPlatform.xml +++ b/examples/java/reservationSurfPlugin/reservationSurfPluginPlatform.xml @@ -5,9 +5,9 @@ - - - + + + diff --git a/examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh b/examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh index 012094f87a..3d2e4b29b6 100644 --- a/examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh +++ b/examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh @@ -2,26 +2,18 @@ $ java -classpath ${classpath:=.} reservationSurfPlugin/TestPlugin ${srcdir:=.}/reservationSurfPlugin/reservationSurfPluginPlatform.xml ${srcdir:=.}/reservationSurfPlugin/reservationSurfPluginDeployment.xml > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up. -> [0.000000] [jmsg/INFO] Trace: NetworkLink created __loopback__ -> [0.000000] [jmsg/INFO] Trace: NetworkLink state changed __loopback__ -> [0.000000] [jmsg/INFO] Trace: Cpu created Jacquelin -> [0.000000] [jmsg/INFO] Trace: Cpu state changed Jacquelin -> [0.000000] [jmsg/INFO] Trace: Cpu created Boivin -> [0.000000] [jmsg/INFO] Trace: Cpu state changed Boivin -> [0.000000] [jmsg/INFO] Trace: NetworkLink created link -> [0.000000] [jmsg/INFO] Trace: NetworkLink state changed link -> [Jacquelin:surfPlugin.Sender:(1) 0.000000] [jmsg/INFO] helloo! -> [Jacquelin:surfPlugin.Sender:(1) 0.000000] [jmsg/INFO] host count: 1 -> [Jacquelin:surfPlugin.Sender:(1) 0.000000] [jmsg/INFO] sender time: 0.0 -> [Boivin:surfPlugin.Receiver:(2) 0.000000] [jmsg/INFO] helloo! -> [Boivin:surfPlugin.Receiver:(2) 0.000000] [jmsg/INFO] try to get a task -> [1.301001] [jmsg/INFO] Trace: NetworkAction state changed network -> [Boivin:surfPlugin.Receiver:(2) 1.301001] [jmsg/INFO] Got at time 1.3010010824742269 -> [Jacquelin:surfPlugin.Sender:(1) 1.301001] [jmsg/INFO] goodbye! -> [1.301103] [jmsg/INFO] Trace: CpuAction state changed cpu -> [Boivin:surfPlugin.Receiver:(2) 1.301103] [jmsg/INFO] goodbye! -> [1.301103] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... -> [1.301103] [jmsg/INFO] Trace: Cpu destructed Jacquelin -> [1.301103] [jmsg/INFO] Trace: Cpu destructed Boivin -> [1.301103] [jmsg/INFO] Trace: NetworkLink destructed link -> [1.301103] [jmsg/INFO] Trace: NetworkLink destructed __loopback__ +> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.000000] [jmsg/INFO] helloo! +> [Boivin:reservationSurfPlugin.Receiver:(2) 0.000000] [jmsg/INFO] helloo! +> [0.000000] [jmsg/INFO] Trace: Communicate message of size 1.0 with rate -1.0 and bound 1.048576E9 from Jacquelin to Boivin +> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Send duration: 0.026021082474226805 +> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Trace: bandwidth of link0 before 1000000.0 +> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Trace: bandwidth of link0 after 1000.0 +> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Trace: bandwidth of link1 before 1000000.0 +> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Trace: bandwidth of link1 after 1000.0 +> [0.026021] [jmsg/INFO] Trace: Communicate message of size 1.0 with rate -1.0 and bound 1.048576E9 from Jacquelin to Boivin +> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.053124] [jmsg/INFO] Send duration with update bandwidth: 0.027102474226804125 +> [0.053124] [jmsg/INFO] Trace: Communicate message of size 1.0 with rate -1.0 and bound 100.0 from Jacquelin to Boivin +> [Boivin:reservationSurfPlugin.Receiver:(2) 0.089144] [jmsg/INFO] goodbye! +> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.089144] [jmsg/INFO] Send normal duration with limited bandwidth: 0.036019999999999996 +> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.089144] [jmsg/INFO] goodbye! +> [0.089144] [jmsg/INFO] MSG_main finished; Cleaning up the simulation... diff --git a/examples/java/surfPlugin/TracePlugin.java b/examples/java/surfPlugin/TracePlugin.java index 6de18235e8..0d1fec44d2 100644 --- a/examples/java/surfPlugin/TracePlugin.java +++ b/examples/java/surfPlugin/TracePlugin.java @@ -26,11 +26,11 @@ public class TracePlugin extends Plugin { Msg.info("Trace: Cpu destructed "+cpu.getName()); } - public void cpuStateChangedCallback(Cpu cpu){ + public void cpuStateChangedCallback(Cpu cpu, ResourceState old, ResourceState cur){ Msg.info("Trace: Cpu state changed "+cpu.getName()); } - public void cpuActionStateChangedCallback(CpuAction action){ + public void cpuActionStateChangedCallback(CpuAction action, ActionState old, ActionState cur){ Msg.info("Trace: CpuAction state changed "+action.getModel().getName()); } @@ -42,11 +42,11 @@ public class TracePlugin extends Plugin { Msg.info("Trace: NetworkLink destructed "+link.getName()); } - public void networkLinkStateChangedCallback(NetworkLink link){ + public void networkLinkStateChangedCallback(NetworkLink link, ResourceState old, ResourceState cur){ Msg.info("Trace: NetworkLink state changed "+link.getName()); } - public void networkActionStateChangedCallback(NetworkAction action){ + public void networkActionStateChangedCallback(NetworkAction action, ActionState old, ActionState cur){ Msg.info("Trace: NetworkAction state changed "+action.getModel().getName()); } diff --git a/examples/msg/mc/bugged1.tesh b/examples/msg/mc/bugged1.tesh index 504b90e1ad..85cd2ce791 100644 --- a/examples/msg/mc/bugged1.tesh +++ b/examples/msg/mc/bugged1.tesh @@ -2,7 +2,7 @@ ! expect signal SIGABRT ! timeout 20 -$ ${bindir:=.}/bugged1 --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ ${bindir:=.}/bugged1 --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/stack_size:256 > [ 0.000000] (0:@) Configuration change: Set 'model-check' to '1' > [ 0.000000] (0:@) Check a safety property > [ 0.000000] (0:@) Get debug information ... diff --git a/examples/msg/mc/bugged1_liveness.tesh b/examples/msg/mc/bugged1_liveness.tesh index fd34555a56..ff3cd799cc 100644 --- a/examples/msg/mc/bugged1_liveness.tesh +++ b/examples/msg/mc/bugged1_liveness.tesh @@ -2,7 +2,7 @@ ! expect signal SIGABRT ! timeout 20 -$ ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../msg_platform.xml ${srcdir:=.}/deploy_bugged1_liveness.xml --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext +$ ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../msg_platform.xml ${srcdir:=.}/deploy_bugged1_liveness.xml --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=contexts/stack_size:256 > [ 0.000000] (0:@) Configuration change: Set 'model-check' to '1' > [ 0.000000] (0:@) Check the liveness property promela_bugged1_liveness > [ 0.000000] (0:@) Get debug information ... diff --git a/examples/msg/mc/bugged1_liveness_visited.tesh b/examples/msg/mc/bugged1_liveness_visited.tesh index f117bb4b22..4775fdcf55 100644 --- a/examples/msg/mc/bugged1_liveness_visited.tesh +++ b/examples/msg/mc/bugged1_liveness_visited.tesh @@ -2,7 +2,7 @@ ! expect signal SIGABRT ! timeout 90 -$ ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../msg_platform.xml ${srcdir:=.}/deploy_bugged1_liveness_visited.xml --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=model-check/visited:100 +$ ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../msg_platform.xml ${srcdir:=.}/deploy_bugged1_liveness_visited.xml --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=model-check/visited:100 --cfg=contexts/stack_size:256 > [ 0.000000] (0:@) Configuration change: Set 'model-check' to '1' > [ 0.000000] (0:@) Configuration change: Set 'model-check/visited' to '100' > [ 0.000000] (0:@) Check the liveness property promela_bugged1_liveness diff --git a/examples/msg/mc/bugged2.tesh b/examples/msg/mc/bugged2.tesh index 3d65e677e7..d3d7eec5e1 100644 --- a/examples/msg/mc/bugged2.tesh +++ b/examples/msg/mc/bugged2.tesh @@ -2,7 +2,7 @@ ! expect signal SIGABRT ! timeout 20 -$ ${bindir:=.}/bugged2 --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ ${bindir:=.}/bugged2 --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/stack_size:256 > [ 0.000000] (0:@) Configuration change: Set 'model-check' to '1' > [ 0.000000] (0:@) Check a safety property > [ 0.000000] (0:@) Get debug information ... diff --git a/examples/smpi/CMakeLists.txt b/examples/smpi/CMakeLists.txt index 9afad64a60..7420e8457b 100644 --- a/examples/smpi/CMakeLists.txt +++ b/examples/smpi/CMakeLists.txt @@ -25,12 +25,14 @@ if(enable_smpi) add_executable(mc/bugged1_liveness mc/bugged1_liveness.c) add_executable(mc/send_deterministic mc/send_deterministic.c) add_executable(mc/non_deterministic mc/non_deterministic.c) + add_executable(mc/mutual_exclusion mc/mutual_exclusion.c) target_link_libraries(mc/bugged1 simgrid) target_link_libraries(mc/bugged2 simgrid) target_link_libraries(mc/bugged1_liveness simgrid) target_link_libraries(mc/send_deterministic simgrid) target_link_libraries(mc/non_deterministic simgrid) + target_link_libraries(mc/mutual_exclusion simgrid) endif() target_link_libraries(bcbench simgrid) @@ -64,6 +66,7 @@ set(examples_src ${CMAKE_CURRENT_SOURCE_DIR}/mc/bugged1_liveness.c ${CMAKE_CURRENT_SOURCE_DIR}/mc/send_deterministic.c ${CMAKE_CURRENT_SOURCE_DIR}/mc/non_deterministic.c + ${CMAKE_CURRENT_SOURCE_DIR}/mc/mutual_exclusion.c PARENT_SCOPE ) set(bin_files @@ -75,6 +78,7 @@ set(bin_files ${CMAKE_CURRENT_SOURCE_DIR}/mc/hostfile_bugged2 ${CMAKE_CURRENT_SOURCE_DIR}/mc/hostfile_send_deterministic ${CMAKE_CURRENT_SOURCE_DIR}/mc/hostfile_non_deterministic + ${CMAKE_CURRENT_SOURCE_DIR}/mc/hostfile_mutual_exclusion PARENT_SCOPE ) set(txt_files diff --git a/examples/smpi/mc/hostfile_mutual_exclusion b/examples/smpi/mc/hostfile_mutual_exclusion new file mode 100644 index 0000000000..b6d1c07b45 --- /dev/null +++ b/examples/smpi/mc/hostfile_mutual_exclusion @@ -0,0 +1,3 @@ +c-1.me +c-2.me +c-3.me diff --git a/examples/smpi/mc/mutual_exclusion.c b/examples/smpi/mc/mutual_exclusion.c new file mode 100644 index 0000000000..a9170608c6 --- /dev/null +++ b/examples/smpi/mc/mutual_exclusion.c @@ -0,0 +1,72 @@ +#include +#include +#include + +#define GRANT_TAG 0 +#define REQUEST_TAG 1 +#define RELEASE_TAG 2 + +int main(int argc, char **argv){ + + int err, size, rank; + int recv_buff; + MPI_Status status; + int CS_used = 0; + xbt_dynar_t requests = xbt_dynar_new(sizeof(int), NULL); + + /* Initialize MPI */ + err = MPI_Init(&argc, &argv); + if(err != MPI_SUCCESS){ + printf("MPI initialization failed !\n"); + exit(1); + } + + MC_ignore(&(status.count), sizeof(status.count)); + + /* Get number of processes */ + err = MPI_Comm_size(MPI_COMM_WORLD, &size); + /* Get id of this process */ + err = MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + if(rank == 0){ /* Coordinator */ + while(1){ + MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); + if(status.MPI_TAG == REQUEST_TAG){ + if(CS_used){ + printf("CS already used. Queue the request.\n"); + xbt_dynar_push(requests, &recv_buff); + }else{ + printf("CS idle. Grant immediatly.\n"); + MPI_Send(&rank, 1, MPI_INT, recv_buff, GRANT_TAG, MPI_COMM_WORLD); + CS_used = 1; + } + }else{ + if(!xbt_dynar_is_empty(requests)){ + printf("CS release. Grant to queued requests (queue size: %lu)", + xbt_dynar_length(requests)); + xbt_dynar_shift(requests, &recv_buff); + MPI_Send(&rank, 1, MPI_INT, recv_buff, GRANT_TAG, MPI_COMM_WORLD); + CS_used = 1; + }else{ + printf("CS release. Resource now idle.\n"); + CS_used = 0; + } + } + } + }else{ /* Client */ + while(1){ + printf("%d asks the request.\n", rank); + MPI_Send(&rank, 1, MPI_INT, 0, REQUEST_TAG, MPI_COMM_WORLD); + + MPI_Recv(&recv_buff, 1, MPI_INT, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &status); + + printf("%d got the answer. Release it.\n", rank); + MPI_Send(&rank, 1, MPI_INT, 0, RELEASE_TAG, MPI_COMM_WORLD); + + } + } + + MPI_Finalize(); + + return 0; +} diff --git a/src/bindings/java/surf.i b/src/bindings/java/surf.i index d860b98256..91e75dce72 100644 --- a/src/bindings/java/surf.i +++ b/src/bindings/java/surf.i @@ -40,9 +40,14 @@ JAVA_ARRAYSOFCLASSES(NetworkLink); %typemap(out) NetworkLinkDynar { long l = xbt_dynar_length($1); $result = jenv->NewLongArray(l); - NetworkLink **lout = (NetworkLink **)xbt_dynar_to_array($1); - jenv->SetLongArrayRegion($result, 0, l, (const jlong*)lout); - free(lout); + unsigned i; + NetworkLink *link; + jlong *elts = jenv->GetLongArrayElements($result, NULL); + xbt_dynar_foreach($1, i, link) { + elts[i] = (jlong)link; + } + jenv->ReleaseLongArrayElements($result, elts, 0); + xbt_dynar_free(&$1); } /* Allow to subclass Plugin and send java object to C++ code */ @@ -76,11 +81,18 @@ class NetworkLink : public Resource { public: NetworkLink(); ~NetworkLink(); + double getBandwidth(); + void updateBandwidth(double value, double date=surf_get_clock()); + double getLatency(); + void updateLatency(double value, double date=surf_get_clock()); }; class Action { public: Model *getModel(); + lmm_variable *getVariable(); + double getBound(); + void setBound(double bound); }; class CpuAction : public Action { @@ -98,6 +110,12 @@ public: } }; +%nodefaultctor RoutingEdge; +class RoutingEdge { +public: + virtual char *getName()=0; +}; + %rename lmm_constraint LmmConstraint; struct lmm_constraint { %extend { @@ -105,9 +123,33 @@ struct lmm_constraint { } }; +%rename lmm_variable LmmVariable; +struct lmm_variable { +%extend { + double getValue() {return lmm_variable_getvalue($self);} +} +}; + %rename s_xbt_dict XbtDict; struct s_xbt_dict { %extend { char *getValue(char *key) {return (char*)xbt_dict_get_or_null($self, key);} } }; + +%rename e_surf_action_state_t ActionState; +typedef enum { + SURF_ACTION_READY = 0, /**< Ready */ + SURF_ACTION_RUNNING, /**< Running */ + SURF_ACTION_FAILED, /**< Task Failure */ + SURF_ACTION_DONE, /**< Completed */ + SURF_ACTION_TO_FREE, /**< Action to free in next cleanup */ + SURF_ACTION_NOT_IN_THE_SYSTEM + /**< Not in the system anymore. Why did you ask ? */ +} e_surf_action_state_t; + +%rename e_surf_resource_state_t ResourceState; +typedef enum { + SURF_RESOURCE_ON = 1, /**< Up & ready */ + SURF_RESOURCE_OFF = 0 /**< Down & broken */ +} e_surf_resource_state_t; diff --git a/src/bindings/java/surf_swig.cpp b/src/bindings/java/surf_swig.cpp index 32f557f819..88f0ee665d 100644 --- a/src/bindings/java/surf_swig.cpp +++ b/src/bindings/java/surf_swig.cpp @@ -24,7 +24,6 @@ NetworkLinkDynar getRoute(char *srcName, char *dstName) { xbt_die("TOTO"); if (dst==NULL) xbt_die("TOTO"); - printf("src: %s\ndst: %s\n", src->getName(), dst->getName()); xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL); routing_platf->getRouteAndLatency(src, dst, &route, NULL); return route; @@ -39,11 +38,11 @@ void Plugin::activateCpuDestructedCallback(){ } void Plugin::activateCpuStateChangedCallback(){ - surf_callback_connect(cpuStateChangedCallbacks, boost::bind(&Plugin::cpuStateChangedCallback, this, _1)); + surf_callback_connect(cpuStateChangedCallbacks, boost::bind(&Plugin::cpuStateChangedCallback, this, _1, _2, _3)); } void Plugin::activateCpuActionStateChangedCallback(){ - surf_callback_connect(cpuActionStateChangedCallbacks, boost::bind(&Plugin::cpuActionStateChangedCallback, this, _1)); + surf_callback_connect(cpuActionStateChangedCallbacks, boost::bind(&Plugin::cpuActionStateChangedCallback, this, _1, _2, _3)); } @@ -56,11 +55,16 @@ void Plugin::activateNetworkLinkDestructedCallback(){ } void Plugin::activateNetworkLinkStateChangedCallback(){ - surf_callback_connect(networkLinkStateChangedCallbacks, boost::bind(&Plugin::networkLinkStateChangedCallback, this, _1)); + surf_callback_connect(networkLinkStateChangedCallbacks, boost::bind(&Plugin::networkLinkStateChangedCallback, this, _1, _2, _3)); } void Plugin::activateNetworkActionStateChangedCallback(){ - surf_callback_connect(networkActionStateChangedCallbacks, boost::bind(&Plugin::networkActionStateChangedCallback, this, _1)); + surf_callback_connect(networkActionStateChangedCallbacks, boost::bind(&Plugin::networkActionStateChangedCallback, this, _1, _2, _3)); } +void Plugin::activateNetworkCommunicateCallback(){ + surf_callback_connect(networkCommunicateCallbacks, boost::bind(&Plugin::networkCommunicateCallback, this, _1, _2, _3, _4, _5)); +} + + diff --git a/src/bindings/java/surf_swig.hpp b/src/bindings/java/surf_swig.hpp index 1c51c7b6c8..a7e7024ff4 100644 --- a/src/bindings/java/surf_swig.hpp +++ b/src/bindings/java/surf_swig.hpp @@ -25,10 +25,10 @@ public: virtual void cpuDestructedCallback(Cpu *cpu) {} void activateCpuStateChangedCallback(); - virtual void cpuStateChangedCallback(Cpu *cpu) {} + virtual void cpuStateChangedCallback(Cpu *cpu, e_surf_resource_state_t, e_surf_resource_state_t) {} void activateCpuActionStateChangedCallback(); - virtual void cpuActionStateChangedCallback(CpuAction *action) {} + virtual void cpuActionStateChangedCallback(CpuAction *action, e_surf_action_state_t, e_surf_action_state_t) {} void activateNetworkLinkCreatedCallback(); @@ -38,11 +38,11 @@ public: virtual void networkLinkDestructedCallback(NetworkLink *link) {} void activateNetworkLinkStateChangedCallback(); - virtual void networkLinkStateChangedCallback(NetworkLink *link) {} + virtual void networkLinkStateChangedCallback(NetworkLink *link, e_surf_resource_state_t, e_surf_resource_state_t) {} void activateNetworkActionStateChangedCallback(); - virtual void networkActionStateChangedCallback(NetworkAction *action) {} + virtual void networkActionStateChangedCallback(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t cur) {} + void activateNetworkCommunicateCallback(); + virtual void networkCommunicateCallback(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate) {} }; - - diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index cece2e82ad..e482c42aa4 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -323,8 +323,13 @@ static xbt_dynar_t MC_unwind_stack_frames(void *stack_context) { unw_cursor_t c; - int ret; - for(ret = unw_init_local(&c, (unw_context_t *)stack_context); ret >= 0; ret = unw_step(&c)){ + // TODO, check condition check (unw_init_local==0 means end of frame) + if(unw_init_local(&c, (unw_context_t *)stack_context)!=0) { + + xbt_die("Could not initialize stack unwinding"); + + } else while(1) { + mc_stack_frame_t stack_frame = xbt_new(s_mc_stack_frame_t, 1); xbt_dynar_push(result, &stack_frame); @@ -348,11 +353,19 @@ static xbt_dynar_t MC_unwind_stack_frames(void *stack_context) { stack_frame->frame_base = (unw_word_t)mc_find_frame_base(frame, frame->object_info, &c); } else { stack_frame->frame_base = 0; + stack_frame->frame_name = NULL; } /* Stop before context switch with maestro */ if(frame!=NULL && frame->name!=NULL && !strcmp(frame->name, "smx_ctx_sysv_wrapper")) break; + + int ret = ret = unw_step(&c); + if(ret==0) { + xbt_die("Unexpected end of stack."); + } else if(ret<0) { + xbt_die("Error while unwinding stack."); + } } if(xbt_dynar_length(result) == 0){ diff --git a/src/mc/mc_dwarf.c b/src/mc/mc_dwarf.c index 253350064e..b24af22405 100644 --- a/src/mc/mc_dwarf.c +++ b/src/mc/mc_dwarf.c @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include +#define DW_LANG_Objc DW_LANG_ObjC /* fix spelling error in older dwarf.h */ #include #include #include @@ -453,8 +454,8 @@ static void MC_dwarf_fill_member_location(dw_type_t type, dw_type_t member, Dwar if (!dwarf_hasattr_integrate(child, DW_AT_data_member_location)) { if (type->type != DW_TAG_union_type) { xbt_die( - "Missing DW_AT_data_member_location field in DW_TAG_member %s of type <%p>%s", - member->name, type->id, type->name); + "Missing DW_AT_data_member_location field in DW_TAG_member %s of type <%"PRIx64">%s", + member->name, (uint64_t) type->id, type->name); } else { return; } @@ -473,9 +474,9 @@ static void MC_dwarf_fill_member_location(dw_type_t type, dw_type_t member, Dwar size_t len; if (dwarf_getlocation(&attr, &expr, &len)) { xbt_die( - "Could not read location expression DW_AT_data_member_location in DW_TAG_member %s of type <%p>%s", + "Could not read location expression DW_AT_data_member_location in DW_TAG_member %s of type <%"PRIx64">%s", MC_dwarf_attr_integrate_string(child, DW_AT_name), - type->id, type->name); + (uint64_t) type->id, type->name); } if (len==1 && expr[0].atom == DW_OP_plus_uconst) { member->offset = expr[0].number; @@ -491,9 +492,9 @@ static void MC_dwarf_fill_member_location(dw_type_t type, dw_type_t member, Dwar if (!dwarf_formudata(&attr, &offset)) member->offset = offset; else - xbt_die("Cannot get %s location <%p>%s", + xbt_die("Cannot get %s location <%"PRIx64">%s", MC_dwarf_attr_integrate_string(child, DW_AT_name), - type->id, type->name); + (uint64_t) type->id, type->name); break; } case MC_DW_CLASS_LOCLISTPTR: @@ -543,7 +544,7 @@ static void MC_dwarf_add_members(mc_object_info_t info, Dwarf_Die* die, Dwarf_Di member->type = tag; // Global Offset: - member->id = (void *) dwarf_dieoffset(&child); + member->id = dwarf_dieoffset(&child); const char* name = MC_dwarf_attr_integrate_string(&child, DW_AT_name); if(name) @@ -565,7 +566,7 @@ static void MC_dwarf_add_members(mc_object_info_t info, Dwarf_Die* die, Dwarf_Di MC_dwarf_fill_member_location(type, member, &child); if (!member->dw_type_id) { - xbt_die("Missing type for member %s of <%p>%s", member->name, type->id, type->name); + xbt_die("Missing type for member %s of <%"PRIx64">%s", member->name, (uint64_t) type->id, type->name); } xbt_dynar_push(type->members, &member); @@ -584,7 +585,7 @@ static dw_type_t MC_dwarf_die_to_type(mc_object_info_t info, Dwarf_Die* die, Dwa dw_type_t type = xbt_new0(s_dw_type_t, 1); type->type = -1; - type->id = NULL; + type->id = 0; type->name = NULL; type->byte_size = 0; type->element_count = -1; @@ -596,7 +597,7 @@ static dw_type_t MC_dwarf_die_to_type(mc_object_info_t info, Dwarf_Die* die, Dwa type->type = dwarf_tag(die); // Global Offset - type->id = (void *) dwarf_dieoffset(die); + type->id = dwarf_dieoffset(die); const char* prefix = ""; switch (type->type) { @@ -618,8 +619,6 @@ static dw_type_t MC_dwarf_die_to_type(mc_object_info_t info, Dwarf_Die* die, Dwa type->name = namespace ? bprintf("%s%s::%s", prefix, namespace, name) : bprintf("%s%s", prefix, name); } - XBT_DEBUG("Processing type <%p>%s", type->id, type->name); - type->dw_type_id = MC_dwarf_at_type(die); // Computation of the byte_size; @@ -708,14 +707,14 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D size_t len; if (dwarf_getlocation(&attr_location, &expr, &len)) { xbt_die( - "Could not read location expression in DW_AT_location of variable <%p>%s", - (void*) variable->dwarf_offset, variable->name); + "Could not read location expression in DW_AT_location of variable <%"PRIx64">%s", + (uint64_t) variable->dwarf_offset, variable->name); } if (len==1 && expr[0].atom == DW_OP_addr) { variable->global = 1; - Dwarf_Off offset = expr[0].number; - Dwarf_Off base = (Dwarf_Off) MC_object_base_address(info); + uintptr_t offset = (uintptr_t) expr[0].number; + uintptr_t base = (uintptr_t) MC_object_base_address(info); variable->address = (void*) (base + offset); } else { mc_dwarf_location_list_init_from_expression(&variable->locations, len, expr); @@ -729,8 +728,8 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D mc_dwarf_location_list_init(&variable->locations, info, die, &attr_location); break; default: - xbt_die("Unexpected form 0x%x (%i), class 0x%x (%i) list for location in <%p>%s", - form, form, klass, klass, (void*) variable->dwarf_offset, variable->name); + xbt_die("Unexpected form 0x%x (%i), class 0x%x (%i) list for location in <%"PRIx64">%s", + form, form, klass, klass, (uint64_t) variable->dwarf_offset, variable->name); } // Handle start_scope: @@ -746,6 +745,7 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D variable->start_scope = dwarf_formudata(&attr, &value) == 0 ? (size_t) value : 0; break; } + case MC_DW_CLASS_RANGELISTPTR: // TODO default: xbt_die("Unhandled form 0x%x, class 0x%X for DW_AT_start_scope of variable %s", form, klass, name==NULL ? "?" : name); @@ -811,29 +811,40 @@ static void MC_dwarf_handle_scope_die(mc_object_info_t info, Dwarf_Die* die, Dwa // Variables are filled in the (recursive) call of MC_dwarf_handle_children: frame->variables = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp); - frame->low_pc = ((char*) base) + MC_dwarf_attr_integrate_addr(die, DW_AT_low_pc); - // DW_AT_high_pc: - { + // TODO, support DW_AT_ranges + uint64_t low_pc = MC_dwarf_attr_integrate_addr(die, DW_AT_low_pc); + frame->low_pc = low_pc ? ((char*) base) + low_pc : 0; + if(low_pc) { + // DW_AT_high_pc: Dwarf_Attribute attr; - if(dwarf_attr_integrate(die, DW_AT_high_pc, &attr)) { - uint64_t high_pc; - Dwarf_Addr value; - if (dwarf_formaddr(&attr, &value) == 0) - high_pc = (uint64_t) value; - else - high_pc = 0; - - int form = dwarf_whatform(&attr); - int klass = MC_dwarf_form_get_class(form); - if (klass == MC_DW_CLASS_CONSTANT) - frame->high_pc = (void*) ((Dwarf_Off)frame->low_pc + high_pc); - else if(klass == MC_DW_CLASS_ADDRESS) - frame->high_pc = ((char*) base) + high_pc; - else - xbt_die("Unexpected class for DW_AT_high_pc"); - } else { - frame->high_pc = 0; + if(!dwarf_attr_integrate(die, DW_AT_high_pc, &attr)) { + xbt_die("Missing DW_AT_high_pc matching with DW_AT_low_pc"); + } + + Dwarf_Sword offset; + Dwarf_Addr high_pc; + + switch(MC_dwarf_form_get_class(dwarf_whatform(&attr))) { + + // DW_AT_high_pc if an offset from the low_pc: + case MC_DW_CLASS_CONSTANT: + + if (dwarf_formsdata(&attr, &offset) !=0) + xbt_die("Could not read constant"); + frame->high_pc = (void*) ((char*)frame->low_pc + offset); + break; + + // DW_AT_high_pc is a relocatable address: + case MC_DW_CLASS_ADDRESS: + if (dwarf_formaddr(&attr, &high_pc) != 0) + xbt_die("Could not read address"); + frame->high_pc = ((char*) base) + high_pc; + break; + + default: + xbt_die("Unexpected class for DW_AT_high_pc"); + } } diff --git a/src/mc/mc_dwarf_expression.c b/src/mc/mc_dwarf_expression.c index caaf9322ce..c3490916ec 100644 --- a/src/mc/mc_dwarf_expression.c +++ b/src/mc/mc_dwarf_expression.c @@ -92,7 +92,8 @@ int mc_dwarf_execute_expression( return MC_EXPRESSION_E_NO_BASE_ADDRESS; if(state->stack_size==MC_EXPRESSION_STACK_SIZE) return MC_EXPRESSION_E_STACK_OVERFLOW; - error = mc_dwarf_push_value(state, (Dwarf_Off)MC_object_base_address(state->object_info) + op->number); + error = mc_dwarf_push_value(state, + (Dwarf_Off)(uintptr_t)MC_object_base_address(state->object_info) + op->number); break; case DW_OP_const1u: @@ -260,7 +261,7 @@ int mc_dwarf_execute_expression( /** \brief Resolve a location expression * \deprecated Use mc_dwarf_resolve_expression */ -Dwarf_Off mc_dwarf_resolve_location(mc_expression_t expression, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot) { +uintptr_t mc_dwarf_resolve_location(mc_expression_t expression, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot) { s_mc_expression_state_t state; memset(&state, 0, sizeof(s_mc_expression_state_t)); state.frame_base = frame_pointer_address; @@ -273,10 +274,10 @@ Dwarf_Off mc_dwarf_resolve_location(mc_expression_t expression, mc_object_info_t if(state.stack_size==0) xbt_die("No value on the stack"); else - return (Dwarf_Off) state.stack[state.stack_size-1]; + return state.stack[state.stack_size-1]; } -Dwarf_Off mc_dwarf_resolve_locations(mc_location_list_t locations, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot) { +uintptr_t mc_dwarf_resolve_locations(mc_location_list_t locations, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot) { unw_word_t ip; if(c) { diff --git a/src/mc/mc_global.c b/src/mc/mc_global.c index 0457aa97c7..55cf9088ca 100644 --- a/src/mc/mc_global.c +++ b/src/mc/mc_global.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "simgrid/sg_config.h" @@ -799,6 +800,14 @@ static void MC_init_debug_info(void) { mc_libsimgrid_info = MC_find_object_info(maps, libsimgrid_path, 0); mc_object_infos[1] = mc_libsimgrid_info; +#ifdef MADV_MERGEABLE + for(int i=0; i!=mc_object_infos_size; ++i) { + void* start = mc_object_infos[i]->start_rw; + void* end = mc_object_infos[i]->end_rw; + madvise(start, (char*)end - (char*)start, MADV_MERGEABLE); + } +#endif + // Use information of the other objects: MC_post_process_object_info(mc_binary_info); MC_post_process_object_info(mc_libsimgrid_info); diff --git a/src/mc/mc_private.h b/src/mc/mc_private.h index 6b2ae33224..20e4ab832f 100644 --- a/src/mc/mc_private.h +++ b/src/mc/mc_private.h @@ -416,8 +416,8 @@ typedef struct s_mc_location_list { mc_expression_t locations; } s_mc_location_list_t, *mc_location_list_t; -Dwarf_Off mc_dwarf_resolve_location(mc_expression_t expression, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot); -Dwarf_Off mc_dwarf_resolve_locations(mc_location_list_t locations, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot); +uintptr_t mc_dwarf_resolve_location(mc_expression_t expression, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot); +uintptr_t mc_dwarf_resolve_locations(mc_location_list_t locations, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot); void mc_dwarf_expression_clear(mc_expression_t expression); void mc_dwarf_expression_init(mc_expression_t expression, size_t len, Dwarf_Op* ops); @@ -431,7 +431,7 @@ void mc_dwarf_location_list_init(mc_location_list_t target, mc_object_info_t inf struct s_dw_type{ e_dw_type_type type; - void *id; /* Offset in the section (in hexadecimal form) */ + Dwarf_Off id; /* Offset in the section (in hexadecimal form) */ char *name; /* Name of the type */ int byte_size; /* Size in bytes */ int element_count; /* Number of elements for array type */ diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index f632e57e3d..9a8b5c4076 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -326,7 +326,7 @@ msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath) /** * \ingroup msg_file_management * \brief Copy a file to another location on a remote host. - * \param fd : the file to move + * \param file : the file to move * \param host : the remote host where the file has to be copied * \param fullpath : the complete path destination on the remote host * \return If successful, the function returns MSG_OK. Otherwise, it returns @@ -406,7 +406,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa /** * \ingroup msg_file_management * \brief Move a file to another location on a remote host. - * \param fd : the file to move + * \param file : the file to move * \param host : the remote host where the file has to be moved * \param fullpath : the complete path destination on the remote host * \return If successful, the function returns MSG_OK. Otherwise, it returns diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index 7df250c5c1..71a85a4b3d 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -44,7 +44,12 @@ static void _XBT_CALL segvhandler(int signum, siginfo_t *siginfo, void *context) { if (siginfo->si_signo == SIGSEGV && siginfo->si_code == SEGV_ACCERR) { fprintf(stderr, - "Access violation detected. This can result from a stack overflow.\n" + "Access violation detected.\n" + "This can result from a programming error in your code or, although less likely,\n" + "from a bug in SimGrid itself. This can also be the sign of a bug in the OS or\n" + "in third-party libraries. Failing hardware can sometimes generate such errors\n" + "too.\n" + "Finally, if nothing of the above applies, this can result from a stack overflow.\n" "Try to increase stack size with --cfg=contexts/stack_size (current size is %d KiB).\n", smx_context_stack_size / 1024); if (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_debug)) { diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index 4b5b1f28ca..4be4d69fdb 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -112,7 +112,7 @@ smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t si action->io.surf_io = surf_workstation_write(host, fd->surf_file, size); surf_action_set_data(action->io.surf_io, action); - XBT_DEBUG("Create io action %p", action); + XBT_INFO("Create io action %p", action); return action; } diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 6295038a3c..f2085f2041 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -377,14 +377,11 @@ void smpi_mpi_start(MPI_Request request) oldbuf = request->buf; if (!_xbt_replay_is_active() && oldbuf && request->size!=0){ if((smpi_privatize_global_variables) - && ((char*)request->buf >= start_data_exe) - && ((char*)request->buf < start_data_exe + size_data_exe ) - ){ - XBT_WARN("Privatization : We are sending from a zone inside global memory. Switch data segment "); - switch_data_segment(smpi_process_index()); - } - - + && ((char*)request->buf >= start_data_exe) + && ((char*)request->buf < start_data_exe + size_data_exe )){ + XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment "); + switch_data_segment(smpi_process_index()); + } buf = xbt_malloc(request->size); memcpy(buf,oldbuf,request->size); } diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 126d1819d9..fe8f3b4e0e 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -590,11 +590,18 @@ void switch_data_segment(int dest){ if (loaded_page==dest)//no need to switch either return; + + #ifdef HAVE_MMAP + int i; + if(loaded_page==-1){//initial switch, do the copy from the real page here + for (i=0; i< SIMIX_process_count(); i++){ + memcpy(mappings[i],TOPAGE(start_data_exe),size_data_exe); + } + } int current= fds[dest]; XBT_VERB("Switching data frame to the one of process %d", dest); void* tmp = mmap (TOPAGE(start_data_exe), size_data_exe, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, current, 0); - msync(TOPAGE(start_data_exe), size_data_exe, MS_SYNC | MS_INVALIDATE ); if (tmp != TOPAGE(start_data_exe)) xbt_die("Couldn't map the new region"); loaded_page=dest; diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index 60e550f84d..75815c11fe 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -72,6 +72,7 @@ void smpi_process_init(int *argc, char ***argv) #ifdef SMPI_F2C smpi_current_rank = index; #endif + data = smpi_process_remote_data(index); simcall_process_set_data(proc, data); if (*argc > 2) { @@ -85,6 +86,11 @@ void smpi_process_init(int *argc, char ***argv) // set the process attached to the mailbox simcall_rdv_set_receiver(data->mailbox_small, proc); XBT_DEBUG("<%d> New process in the game: %p", index, proc); + + if(smpi_privatize_global_variables){ + switch_data_segment(index); + } + } if (smpi_process_data() == NULL) xbt_die("smpi_process_data() returned NULL. You probably gave a NULL parameter to MPI_Init. Although it's required by MPI-2, this is currently not supported by SMPI."); @@ -93,6 +99,9 @@ void smpi_process_init(int *argc, char ***argv) void smpi_process_destroy(void) { int index = smpi_process_index(); + if(smpi_privatize_global_variables){ + switch_data_segment(index); + } process_data[index]->state = SMPI_FINALIZED; XBT_DEBUG("<%d> Process left the game", index); } @@ -334,7 +343,7 @@ static void smpi_comm_copy_buffer_callback(smx_action_t comm, && ((char*)buff >= start_data_exe) && ((char*)buff < start_data_exe + size_data_exe ) ){ - XBT_WARN("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !"); + XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !"); switch_data_segment(((smpi_process_data_t)SIMIX_process_get_data(comm->comm.src_proc))->index); tmpbuff = (void*)xbt_malloc(buff_size); memcpy(tmpbuff, buff, buff_size); @@ -345,7 +354,7 @@ static void smpi_comm_copy_buffer_callback(smx_action_t comm, && ((char*)comm->comm.dst_buff >= start_data_exe) && ((char*)comm->comm.dst_buff < start_data_exe + size_data_exe ) ){ - XBT_WARN("Privatization : We are copying to a zone inside global memory - Switch data segment"); + XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment"); switch_data_segment(((smpi_process_data_t)SIMIX_process_get_data(comm->comm.dst_proc))->index); } diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index cfd9b5bab9..5b51a9bf89 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -93,14 +93,12 @@ int PMPI_Query_thread(int *provided) { int retval = 0; - smpi_bench_end(); if (provided == NULL) { retval = MPI_ERR_ARG; } else { *provided = MPI_THREAD_MULTIPLE; retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -108,14 +106,12 @@ int PMPI_Is_thread_main(int *flag) { int retval = 0; - smpi_bench_end(); if (flag == NULL) { retval = MPI_ERR_ARG; } else { *flag = smpi_process_index() == 0; retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -151,14 +147,12 @@ int PMPI_Address(void *location, MPI_Aint * address) { int retval = 0; - smpi_bench_end(); if (!address) { retval = MPI_ERR_ARG; } else { *address = (MPI_Aint) location; retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -171,14 +165,12 @@ int PMPI_Type_free(MPI_Datatype * datatype) { int retval = 0; - smpi_bench_end(); if (!datatype) { retval = MPI_ERR_ARG; } else { smpi_datatype_free(datatype); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -186,7 +178,6 @@ int PMPI_Type_size(MPI_Datatype datatype, int *size) { int retval = 0; - smpi_bench_end(); if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (size == NULL) { @@ -195,7 +186,6 @@ int PMPI_Type_size(MPI_Datatype datatype, int *size) *size = (int) smpi_datatype_size(datatype); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -203,7 +193,6 @@ int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent { int retval = 0; - smpi_bench_end(); if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (lb == NULL || extent == NULL) { @@ -211,7 +200,6 @@ int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent } else { retval = smpi_datatype_extent(datatype, lb, extent); } - smpi_bench_begin(); return retval; } @@ -224,7 +212,6 @@ int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent) { int retval = 0; - smpi_bench_end(); if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (extent == NULL) { @@ -233,7 +220,6 @@ int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent) *extent = smpi_datatype_get_extent(datatype); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -241,7 +227,6 @@ int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp) { int retval = 0; - smpi_bench_end(); if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (disp == NULL) { @@ -250,7 +235,6 @@ int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp) *disp = smpi_datatype_lb(datatype); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -258,7 +242,6 @@ int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp) { int retval = 0; - smpi_bench_end(); if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (disp == NULL) { @@ -267,7 +250,6 @@ int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp) *disp = smpi_datatype_ub(datatype); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -275,14 +257,12 @@ int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op) { int retval = 0; - smpi_bench_end(); if (function == NULL || op == NULL) { retval = MPI_ERR_ARG; } else { *op = smpi_op_new(function, commute); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -290,7 +270,6 @@ int PMPI_Op_free(MPI_Op * op) { int retval = 0; - smpi_bench_end(); if (op == NULL) { retval = MPI_ERR_ARG; } else if (*op == MPI_OP_NULL) { @@ -300,7 +279,6 @@ int PMPI_Op_free(MPI_Op * op) *op = MPI_OP_NULL; retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -308,7 +286,6 @@ int PMPI_Group_free(MPI_Group * group) { int retval = 0; - smpi_bench_end(); if (group == NULL) { retval = MPI_ERR_ARG; } else { @@ -316,7 +293,6 @@ int PMPI_Group_free(MPI_Group * group) *group = MPI_GROUP_NULL; retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -324,7 +300,6 @@ int PMPI_Group_size(MPI_Group group, int *size) { int retval = 0; - smpi_bench_end(); if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (size == NULL) { @@ -333,7 +308,6 @@ int PMPI_Group_size(MPI_Group group, int *size) *size = smpi_group_size(group); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -341,7 +315,6 @@ int PMPI_Group_rank(MPI_Group group, int *rank) { int retval = 0; - smpi_bench_end(); if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (rank == NULL) { @@ -350,7 +323,6 @@ int PMPI_Group_rank(MPI_Group group, int *rank) *rank = smpi_group_rank(group, smpi_process_index()); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -358,7 +330,6 @@ int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1, MPI_Group group2, int *ranks2) { int retval, i, index; - smpi_bench_end(); if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else { @@ -372,7 +343,6 @@ int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1, } retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -380,7 +350,6 @@ int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result) { int retval = 0; - smpi_bench_end(); if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (result == NULL) { @@ -389,7 +358,6 @@ int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result) *result = smpi_group_compare(group1, group2); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -398,7 +366,6 @@ int PMPI_Group_union(MPI_Group group1, MPI_Group group2, { int retval, i, proc1, proc2, size, size2; - smpi_bench_end(); if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (newgroup == NULL) { @@ -429,7 +396,6 @@ int PMPI_Group_union(MPI_Group group1, MPI_Group group2, } retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -438,7 +404,6 @@ int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2, { int retval, i, proc1, proc2, size; - smpi_bench_end(); if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (newgroup == NULL) { @@ -468,7 +433,6 @@ int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2, } retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -476,7 +440,6 @@ int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgro { int retval, i, proc1, proc2, size, size2; - smpi_bench_end(); if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (newgroup == NULL) { @@ -504,7 +467,6 @@ int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgro } retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -512,7 +474,6 @@ int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup) { int retval, i, index; - smpi_bench_end(); if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (newgroup == NULL) { @@ -536,7 +497,6 @@ int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup) } retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -544,7 +504,6 @@ int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup) { int retval, i, j, newsize, oldsize, index; - smpi_bench_end(); if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (newgroup == NULL) { @@ -583,7 +542,6 @@ int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup) } retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -592,7 +550,6 @@ int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3], { int retval, i, j, rank, size, index; - smpi_bench_end(); if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (newgroup == NULL) { @@ -641,7 +598,6 @@ int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3], } retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -650,7 +606,6 @@ int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], { int retval, i, rank, newrank,oldrank, size, index, add; - smpi_bench_end(); if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (newgroup == NULL) { @@ -719,15 +674,12 @@ int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } int PMPI_Comm_rank(MPI_Comm comm, int *rank) { int retval = 0; - - smpi_bench_end(); if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (rank == NULL) { @@ -736,15 +688,12 @@ int PMPI_Comm_rank(MPI_Comm comm, int *rank) *rank = smpi_comm_rank(comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } int PMPI_Comm_size(MPI_Comm comm, int *size) { int retval = 0; - - smpi_bench_end(); if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (size == NULL) { @@ -753,7 +702,6 @@ int PMPI_Comm_size(MPI_Comm comm, int *size) *size = smpi_comm_size(comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -761,7 +709,6 @@ int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len) { int retval = 0; - smpi_bench_end(); if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (name == NULL || len == NULL) { @@ -770,7 +717,6 @@ int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len) smpi_comm_get_name(comm, name, len); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -778,7 +724,6 @@ int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group) { int retval = 0; - smpi_bench_end(); if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (group == NULL) { @@ -792,7 +737,6 @@ int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group) smpi_group_use(*group); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -800,7 +744,6 @@ int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result) { int retval = 0; - smpi_bench_end(); if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (result == NULL) { @@ -818,7 +761,6 @@ int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result) } retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -826,7 +768,6 @@ int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm) { int retval = 0; - smpi_bench_end(); if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (newcomm == NULL) { @@ -835,7 +776,6 @@ int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm) *newcomm = smpi_comm_new(smpi_comm_group(comm)); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -843,7 +783,6 @@ int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm) { int retval = 0; - smpi_bench_end(); if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (group == MPI_GROUP_NULL) { @@ -858,7 +797,6 @@ int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm) *newcomm = smpi_comm_new(group); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -866,7 +804,6 @@ int PMPI_Comm_free(MPI_Comm * comm) { int retval = 0; - smpi_bench_end(); if (comm == NULL) { retval = MPI_ERR_ARG; } else if (*comm == MPI_COMM_NULL) { @@ -876,7 +813,6 @@ int PMPI_Comm_free(MPI_Comm * comm) *comm = MPI_COMM_NULL; retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -885,7 +821,6 @@ int PMPI_Comm_disconnect(MPI_Comm * comm) /* TODO: wait until all communication in comm are done */ int retval = 0; - smpi_bench_end(); if (comm == NULL) { retval = MPI_ERR_ARG; } else if (*comm == MPI_COMM_NULL) { @@ -895,15 +830,14 @@ int PMPI_Comm_disconnect(MPI_Comm * comm) *comm = MPI_COMM_NULL; retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out) { int retval = 0; - smpi_bench_end(); + if (comm_out == NULL) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { @@ -913,6 +847,7 @@ int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out) retval = MPI_SUCCESS; } smpi_bench_begin(); + return retval; } @@ -2425,7 +2360,6 @@ int PMPI_Get_processor_name(char *name, int *resultlen) { int retval = MPI_SUCCESS; - smpi_bench_end(); strncpy(name, SIMIX_host_get_name(SIMIX_host_self()), strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ? strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 : @@ -2434,7 +2368,6 @@ int PMPI_Get_processor_name(char *name, int *resultlen) strlen(name) > MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name); - smpi_bench_begin(); return retval; } @@ -2443,7 +2376,6 @@ int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count) int retval = MPI_SUCCESS; size_t size; - smpi_bench_end(); if (status == NULL || count == NULL) { retval = MPI_ERR_ARG; } else if (datatype == MPI_DATATYPE_NULL) { @@ -2458,14 +2390,12 @@ int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count) *count = smpi_mpi_get_count(status, datatype); } } - smpi_bench_begin(); return retval; } int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) { int retval = 0; - smpi_bench_end(); if (old_type == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (count<0){ @@ -2473,21 +2403,18 @@ int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_typ } else { retval = smpi_datatype_contiguous(count, old_type, new_type, 0); } - smpi_bench_begin(); return retval; } int PMPI_Type_commit(MPI_Datatype* datatype) { int retval = 0; - smpi_bench_end(); if (datatype == NULL || *datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else { smpi_datatype_commit(datatype); retval = MPI_SUCCESS; } - smpi_bench_begin(); return retval; } @@ -2495,7 +2422,6 @@ int PMPI_Type_commit(MPI_Datatype* datatype) { int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) { int retval = 0; - smpi_bench_end(); if (old_type == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (count<0 || blocklen<0){ @@ -2503,14 +2429,12 @@ int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, } else { retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type); } - smpi_bench_begin(); return retval; } int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) { int retval = 0; - smpi_bench_end(); if (old_type == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (count<0 || blocklen<0){ @@ -2518,7 +2442,6 @@ int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old } else { retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type); } - smpi_bench_begin(); return retval; } @@ -2529,7 +2452,6 @@ int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datat int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) { int retval = 0; - smpi_bench_end(); if (old_type == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (count<0){ @@ -2537,14 +2459,12 @@ int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_ } else { retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type); } - smpi_bench_begin(); return retval; } int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) { int retval = 0; - smpi_bench_end(); if (old_type == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (count<0){ @@ -2552,14 +2472,12 @@ int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Dataty } else { retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type); } - smpi_bench_begin(); return retval; } int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) { int retval,i; - smpi_bench_end(); if (old_type == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (count<0){ @@ -2570,7 +2488,6 @@ int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type); xbt_free(blocklens); } - smpi_bench_begin(); return retval; } @@ -2578,7 +2495,6 @@ int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) { int retval = 0; - smpi_bench_end(); if (old_type == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (count<0){ @@ -2586,7 +2502,6 @@ int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatyp } else { retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type); } - smpi_bench_begin(); return retval; } @@ -2597,7 +2512,6 @@ int PMPI_Type_create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_ int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) { int retval,i; - smpi_bench_end(); if (old_type == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else if (count<0){ @@ -2608,7 +2522,6 @@ int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indice retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type); xbt_free(blocklens); } - smpi_bench_begin(); return retval; } @@ -2616,13 +2529,11 @@ int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indice int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) { int retval = 0; - smpi_bench_end(); if (count<0){ retval = MPI_ERR_COUNT; } else { retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type); } - smpi_bench_begin(); return retval; } diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 736b29ee87..246f48ff16 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -25,8 +25,8 @@ CpuPtr getActionCpu(CpuActionPtr action) { surf_callback(void, CpuPtr) cpuCreatedCallbacks; surf_callback(void, CpuPtr) cpuDestructedCallbacks; -surf_callback(void, CpuPtr) cpuStateChangedCallbacks; -surf_callback(void, CpuActionPtr) cpuActionStateChangedCallbacks; +surf_callback(void, CpuPtr, e_surf_resource_state_t, e_surf_resource_state_t) cpuStateChangedCallbacks; +surf_callback(void, CpuActionPtr, e_surf_action_state_t, e_surf_action_state_t) cpuActionStateChangedCallbacks; /********* * Model * @@ -203,8 +203,9 @@ int Cpu::getCore() void Cpu::setState(e_surf_resource_state_t state) { + e_surf_resource_state_t old = Resource::getState(); Resource::setState(state); - surf_callback_emit(cpuStateChangedCallbacks, this); + surf_callback_emit(cpuStateChangedCallbacks, this, old, state); } /********** * Action * @@ -309,6 +310,7 @@ void CpuAction::setAffinity(CpuPtr cpu, unsigned long mask) } void CpuAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(cpuActionStateChangedCallbacks, this); + surf_callback_emit(cpuActionStateChangedCallbacks, this, old, state); } diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index c72e0f5a40..7e2203f05c 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -31,28 +31,28 @@ typedef CpuPlugin *CpuPluginPtr; CpuPtr getActionCpu(CpuActionPtr action); /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after Cpu creation * + * @brief Callbacks handler which emit the callbacks after Cpu creation * * @details Callback functions have the following signature: `void(CpuPtr)` */ extern surf_callback(void, CpuPtr) cpuCreatedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after Cpu destruction * + * @brief Callbacks handler which emit the callbacks after Cpu destruction * * @details Callback functions have the following signature: `void(CpuPtr)` */ extern surf_callback(void, CpuPtr) cpuDestructedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after Cpu State changed * - * @details Callback functions have the following signature: `void(CpuActionPtr)` + * @brief Callbacks handler which emit the callbacks after Cpu State changed * + * @details Callback functions have the following signature: `void(CpuActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, CpuPtr) cpuStateChangedCallbacks; +extern surf_callback(void, CpuPtr, e_surf_resource_state_t, e_surf_resource_state_t) cpuStateChangedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after CpuAction State changed * - * @details Callback functions have the following signature: `void(CpuActionPtr)` + * @brief Callbacks handler which emit the callbacks after CpuAction State changed * + * @details Callback functions have the following signature: `void(CpuActionPtr action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -extern surf_callback(void, CpuActionPtr) cpuActionStateChangedCallbacks; +extern surf_callback(void, CpuActionPtr, e_surf_action_state_t, e_surf_action_state_t) cpuActionStateChangedCallbacks; /********* * Model * @@ -66,16 +66,16 @@ class CpuModel : public Model { public: /** * @brief CpuModel constructor - * + * * @param name The name of the model */ CpuModel(const char *name) : Model(name) {}; /** * @brief Create a Cpu - * + * * @param name The name of the Cpu - * + * * @return The created Cpu */ CpuPtr createResource(string name); @@ -105,7 +105,7 @@ public: /** * @brief Cpu constructor - * + * * @param model The CpuModel associated to this Cpu * @param name The name of the Cpu * @param props Dictionary of properties associated to this Cpu @@ -119,7 +119,7 @@ public: /** * @brief Cpu constructor - * + * * @param model The CpuModel associated to this Cpu * @param name The name of the Cpu * @param props Dictionary of properties associated to this Cpu @@ -137,7 +137,7 @@ public: /** * @brief Execute some quantity of computation - * + * * @param size The value of the processing amount (in flop) needed to process * @return The CpuAction corresponding to the processing */ @@ -145,7 +145,7 @@ public: /** * @brief Make a process sleep for duration (in seconds) - * + * * @param duration The number of seconds to sleep * @return The CpuAction corresponding to the sleeping */ @@ -153,7 +153,7 @@ public: /** * @brief Get the number of cores of the current Cpu - * + * * @return The number of cores of the current Cpu */ virtual int getCore(); @@ -161,9 +161,9 @@ public: /** * @brief Get the speed of the current Cpu * @details [TODO] load * m_powerPeak - * + * * @param load [TODO] - * + * * @return The speed of the current Cpu */ virtual double getSpeed(double load); @@ -171,23 +171,23 @@ public: /** * @brief Get the available speed of the current Cpu * @details [TODO] - * + * * @return The available speed of the current Cpu */ virtual double getAvailableSpeed(); /** * @brief Get the current Cpu power peak - * + * * @return The current Cpu power peak */ virtual double getCurrentPowerPeak()=0; virtual double getPowerPeakAt(int pstate_index)=0; - + virtual int getNbPstates()=0; - + virtual void setPowerPeakAt(int pstate_index)=0; void setState(e_surf_resource_state_t state); @@ -220,7 +220,7 @@ public: /** * @brief CpuAction constructor - * + * * @param model The CpuModel associated to this CpuAction * @param cost [TODO] * @param failed [TODO] @@ -230,7 +230,7 @@ public: /** * @brief CpuAction constructor - * + * * @param model The CpuModel associated to this CpuAction * @param cost [TODO] * @param failed [TODO] @@ -242,7 +242,7 @@ public: /** * @brief Set the affinity of the current CpuAction * @details [TODO] - * + * * @param cpu [TODO] * @param mask [TODO] */ diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index b80ddfd255..66e588370d 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -482,6 +482,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, xbt_dynar_free(&route); XBT_OUT(); + surf_callback_emit(networkCommunicateCallbacks, action, src, dst, size, rate); return action; } @@ -530,59 +531,11 @@ void NetworkCm02Link::updateState(tmgr_trace_event_t event_type, /* value, event_type); */ if (event_type == p_power.event) { - double delta = - sg_weight_S_parameter / value - sg_weight_S_parameter / - (p_power.peak * p_power.scale); - lmm_variable_t var = NULL; - lmm_element_t elem = NULL; - NetworkCm02ActionPtr action = NULL; - - p_power.peak = value; - lmm_update_constraint_bound(getModel()->getMaxminSystem(), - getConstraint(), - sg_bandwidth_factor * - (p_power.peak * p_power.scale)); -#ifdef HAVE_TRACING - TRACE_surf_link_set_bandwidth(date, getName(), sg_bandwidth_factor * p_power.peak * p_power.scale); -#endif - if (sg_weight_S_parameter > 0) { - while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) { - action = (NetworkCm02ActionPtr) lmm_variable_id(var); - action->m_weight += delta; - if (!action->isSuspended()) - lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight); - } - } + updateBandwidth(value, date); if (tmgr_trace_event_free(event_type)) p_power.event = NULL; } else if (event_type == p_latEvent) { - double delta = value - m_latCurrent; - lmm_variable_t var = NULL; - lmm_element_t elem = NULL; - NetworkCm02ActionPtr action = NULL; - - m_latCurrent = value; - while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) { - action = (NetworkCm02ActionPtr) lmm_variable_id(var); - action->m_latCurrent += delta; - action->m_weight += delta; - if (action->m_rate < 0) - lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->m_latCurrent)); - else { - lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), - min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent))); - - if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) { - XBT_INFO("Flow is limited BYBANDWIDTH"); - } else { - XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", - action->m_latCurrent); - } - } - if (!action->isSuspended()) - lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight); - - } + updateLatency(value, date); if (tmgr_trace_event_free(event_type)) p_latEvent = NULL; } else if (event_type == p_stateEvent) { @@ -617,6 +570,60 @@ void NetworkCm02Link::updateState(tmgr_trace_event_t event_type, return; } +void NetworkCm02Link::updateBandwidth(double value, double date){ + double delta = sg_weight_S_parameter / value - sg_weight_S_parameter / + (p_power.peak * p_power.scale); + lmm_variable_t var = NULL; + lmm_element_t elem = NULL; + NetworkCm02ActionPtr action = NULL; + + p_power.peak = value; + lmm_update_constraint_bound(getModel()->getMaxminSystem(), + getConstraint(), + sg_bandwidth_factor * + (p_power.peak * p_power.scale)); +#ifdef HAVE_TRACING + TRACE_surf_link_set_bandwidth(date, getName(), sg_bandwidth_factor * p_power.peak * p_power.scale); +#endif + if (sg_weight_S_parameter > 0) { + while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) { + action = (NetworkCm02ActionPtr) lmm_variable_id(var); + action->m_weight += delta; + if (!action->isSuspended()) + lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight); + } + } +} + +void NetworkCm02Link::updateLatency(double value, double date){ + double delta = value - m_latCurrent; + lmm_variable_t var = NULL; + lmm_element_t elem = NULL; + NetworkCm02ActionPtr action = NULL; + + m_latCurrent = value; + while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) { + action = (NetworkCm02ActionPtr) lmm_variable_id(var); + action->m_latCurrent += delta; + action->m_weight += delta; + if (action->m_rate < 0) + lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->m_latCurrent)); + else { + lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), + min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent))); + + if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) { + XBT_INFO("Flow is limited BYBANDWIDTH"); + } else { + XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", + action->m_latCurrent); + } + } + if (!action->isSuspended()) + lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight); + } +} + /********** * Action * **********/ diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index b4d40482d9..c31c1c99b6 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -80,6 +80,8 @@ public: tmgr_trace_t lat_trace, e_surf_link_sharing_policy_t policy); void updateState(tmgr_trace_event_t event_type, double value, double date); + void updateBandwidth(double value, double date=surf_get_clock()); + void updateLatency(double value, double date=surf_get_clock()); }; diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index d9f36dddcf..e813122ade 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -88,6 +88,7 @@ ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr d NetworkConstantActionPtr action = new NetworkConstantAction(this, size, sg_latency_factor); XBT_OUT(); + surf_callback_emit(networkCommunicateCallbacks, action, src, dst, size, rate); return action; } diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 49e4c6d248..39195ef072 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -19,8 +19,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf, surf_callback(void, NetworkLinkPtr) networkLinkCreatedCallbacks; surf_callback(void, NetworkLinkPtr) networkLinkDestructedCallbacks; -surf_callback(void, NetworkLinkPtr) networkLinkStateChangedCallbacks; -surf_callback(void, NetworkActionPtr) networkActionStateChangedCallbacks; +surf_callback(void, NetworkLinkPtr, e_surf_resource_state_t, e_surf_resource_state_t) networkLinkStateChangedCallbacks; +surf_callback(void, NetworkActionPtr, e_surf_action_state_t, e_surf_action_state_t) networkActionStateChangedCallbacks; +surf_callback(void, NetworkActionPtr, RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate) networkCommunicateCallbacks; /********* * Model * @@ -89,8 +90,9 @@ bool NetworkLink::isShared() } void NetworkLink::setState(e_surf_resource_state_t state){ + e_surf_resource_state_t old = Resource::getState(); Resource::setState(state); - surf_callback_emit(networkLinkStateChangedCallbacks, this); + surf_callback_emit(networkLinkStateChangedCallbacks, this, old, state); } /********** @@ -98,8 +100,9 @@ void NetworkLink::setState(e_surf_resource_state_t state){ **********/ void NetworkAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(networkActionStateChangedCallbacks, this); + surf_callback_emit(networkActionStateChangedCallbacks, this, old, state); } #endif /* NETWORK_INTERFACE_CPP_ */ diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 8988357d7c..05792b2117 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -27,28 +27,34 @@ typedef NetworkAction *NetworkActionPtr; *************/ /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after NetworkLink creation * + * @brief Callbacks handler which emit the callbacks after NetworkLink creation * @details Callback functions have the following signature: `void(NetworkLinkPtr)` */ extern surf_callback(void, NetworkLinkPtr) networkLinkCreatedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after NetworkLink destruction * + * @brief Callbacks handler which emit the callbacks after NetworkLink destruction * @details Callback functions have the following signature: `void(NetworkLinkPtr)` */ extern surf_callback(void, NetworkLinkPtr) networkLinkDestructedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after NetworkLink State changed * - * @details Callback functions have the following signature: `void(NetworkLinkActionPtr)` + * @brief Callbacks handler which emit the callbacks after NetworkLink State changed + * @details Callback functions have the following signature: `void(NetworkLinkActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, NetworkLinkPtr) networkLinkStateChangedCallbacks; +extern surf_callback(void, NetworkLinkPtr, e_surf_resource_state_t, e_surf_resource_state_t) networkLinkStateChangedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after NetworkAction State changed * - * @details Callback functions have the following signature: `void(NetworkActionPtr)` + * @brief Callbacks handler which emit the callbacks after NetworkAction State changed + * @details Callback functions have the following signature: `void(NetworkActionPtr action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -extern surf_callback(void, NetworkActionPtr) networkActionStateChangedCallbacks; +extern surf_callback(void, NetworkActionPtr, e_surf_action_state_t, e_surf_action_state_t) networkActionStateChangedCallbacks; + +/** @ingroup SURF_callbacks + * @brief Callbacks handler which emit the callbacks after communication created + * @details Callback functions have the following signature: `void(NetworkActionPtr action, RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate)` + */ +extern surf_callback(void, NetworkActionPtr, RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate) networkCommunicateCallbacks; /********* * Tools * @@ -73,7 +79,7 @@ public: /** * @brief NetworkModel constructor - * + * * @param name The name of the NetworkModel */ NetworkModel(const char *name) : Model(name) { @@ -95,7 +101,7 @@ public: /** * @brief Create a NetworkLink - * + * * @param name The name of the NetworkLink * @param bw_initial The initial bandwidth of the NetworkLink in bytes per second * @param bw_trace The trace associated to the NetworkLink bandwidth [TODO] @@ -123,11 +129,11 @@ public: /** * @brief Create a communication between two [TODO] * @details [TODO] - * + * * @param src The source [TODO] * @param dst The destination [TODO] * @param size The size of the communication in bytes - * @param rate The + * @param rate The * @return The action representing the communication */ virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst, @@ -135,7 +141,7 @@ public: /** * @brief Function pointer to the function to use to solve the lmm_system_t - * + * * @param system The lmm_system_t to solve */ void (*f_networkSolve)(lmm_system_t); @@ -143,7 +149,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param size [description] * @return [description] */ @@ -152,7 +158,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param size [description] * @return [description] */ @@ -161,7 +167,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param rate [description] * @param bound [description] * @param size [description] @@ -182,7 +188,7 @@ class NetworkLink : public Resource { public: /** * @brief NetworkLink constructor - * + * * @param model The CpuModel associated to this NetworkLink * @param name The name of the NetworkLink * @param props Dictionary of properties associated to this NetworkLink @@ -191,7 +197,7 @@ public: /** * @brief NetworkLink constructor - * + * * @param model The CpuModel associated to this NetworkLink * @param name The name of the NetworkLink * @param props Dictionary of properties associated to this NetworkLink @@ -211,29 +217,39 @@ public: /** * @brief Get the bandwidth in bytes per second of current NetworkLink - * + * * @return The bandwith in bytes per second of the current NetworkLink */ virtual double getBandwidth(); + /** + * @brief Update the bandwidth in bytes per second of current NetworkLink + */ + virtual void updateBandwidth(double value, double date=surf_get_clock())=0; + /** * @brief Get the latency in seconds of current NetworkLink - * + * * @return The latency in seconds of the current NetworkLink */ virtual double getLatency(); + /** + * @brief Update the latency in seconds of current NetworkLink + */ + virtual void updateLatency(double value, double date=surf_get_clock())=0; + /** * @brief Check if the NetworkLink is shared * @details [long description] - * + * * @return true if the current NetwokrLink is shared, false otherwise */ virtual bool isShared(); /** * @brief Check if the NetworkLink is used - * + * * @return true if the current NetwokrLink is used, false otherwise */ bool isUsed(); @@ -261,7 +277,7 @@ class NetworkAction : public Action { public: /** * @brief NetworkAction constructor - * + * * @param model The NetworkModel associated to this NetworkAction * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] @@ -271,7 +287,7 @@ public: /** * @brief NetworkAction constructor - * + * * @param model The NetworkModel associated to this NetworkAction * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 4fecb0f530..b133fb89bf 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -331,6 +331,7 @@ ActionPtr NetworkNS3Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, action->p_srcElm = src; action->p_dstElm = dst; #endif + surf_callback_emit(networkCommunicateCallbacks, action, src, dst, size, rate); return (surf_action_t) action; } @@ -427,8 +428,8 @@ void NetworkNS3Model::updateActionsState(double now, double delta) NetworkNS3Link::NetworkNS3Link(NetworkNS3ModelPtr model, const char *name, xbt_dict_t props, double bw_initial, double lat_initial) : NetworkLink(model, name, props) - , p_bdw(bprintf("%f", bw_initial)) , p_lat(bprintf("%f", lat_initial)) + , p_bdw(bprintf("%f", bw_initial)) , m_created(1) { } @@ -440,14 +441,6 @@ NetworkNS3Link::~NetworkNS3Link() void NetworkNS3Link::updateState(tmgr_trace_event_t event_type, double value, double date) { -} -double NetworkNS3Link::getLatency() -{ - -} -double NetworkNS3Link::getBandwidth() -{ - } /********** diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index f5389b80f3..8aab263632 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -61,8 +61,10 @@ public: ~NetworkNS3Link(); void updateState(tmgr_trace_event_t event_type, double value, double date); - double getLatency(); - double getBandwidth(); + double getLatency(){THROW_UNIMPLEMENTED;} + double getBandwidth(){THROW_UNIMPLEMENTED;} + void updateBandwidth(double value, double date=surf_get_clock()){THROW_UNIMPLEMENTED;} + void updateLatency(double value, double date=surf_get_clock()){THROW_UNIMPLEMENTED;} //private: char *p_id; diff --git a/src/surf/ns3/ns3_interface.cc b/src/surf/ns3/ns3_interface.cc index 4c3d591560..900f77b6d7 100644 --- a/src/surf/ns3/ns3_interface.cc +++ b/src/surf/ns3/ns3_interface.cc @@ -122,6 +122,7 @@ int ns3_initialize(const char* TcpProtocol){ } XBT_ERROR("The ns3/TcpModel must be : NewReno or Reno or Tahoe"); + return 0; } void * ns3_add_host(const char * id) @@ -167,7 +168,7 @@ void * ns3_add_router(const char * id) return router; } -void * ns3_add_cluster(char * bw,char * lat,const char *id) +void ns3_add_cluster(char * bw,char * lat,const char *id) { XBT_DEBUG("cluster_id: %s",id); @@ -175,7 +176,7 @@ void * ns3_add_cluster(char * bw,char * lat,const char *id) XBT_DEBUG("Number of %s nodes: %d",id,Cluster_nodes.GetN() - number_of_clusters_nodes); NodeContainer Nodes; - int i; + unsigned int i; for(i = number_of_clusters_nodes; i < Cluster_nodes.GetN() ; i++){ Nodes.Add(Cluster_nodes.Get(i)); @@ -225,7 +226,7 @@ static char* transformIpv4Address (Ipv4Address from){ return bprintf("%s",s.c_str()); } -void * ns3_add_link(int src, e_ns3_network_element_type_t type_src, +void ns3_add_link(int src, e_ns3_network_element_type_t type_src, int dst, e_ns3_network_element_type_t type_dst, char * bw,char * lat) { @@ -273,7 +274,7 @@ void * ns3_add_link(int src, e_ns3_network_element_type_t type_src, } } -void * ns3_end_platform(void) +void ns3_end_platform(void) { XBT_DEBUG("InitializeRoutes"); GlobalRouteManager::BuildGlobalRoutingDatabase(); diff --git a/src/surf/ns3/ns3_interface.h b/src/surf/ns3/ns3_interface.h index db6b1938a3..8aaf466df4 100644 --- a/src/surf/ns3/ns3_interface.h +++ b/src/surf/ns3/ns3_interface.h @@ -40,11 +40,11 @@ XBT_PUBLIC(void *) ns3_add_host(const char * id); XBT_PUBLIC(void *) ns3_add_host_cluster(const char * id); XBT_PUBLIC(void *) ns3_add_router(const char * id); XBT_PUBLIC(void *) ns3_add_AS(const char * id); -XBT_PUBLIC(void *) ns3_add_link(int src, e_ns3_network_element_type_t type_src, +XBT_PUBLIC(void) ns3_add_link(int src, e_ns3_network_element_type_t type_src, int dst, e_ns3_network_element_type_t type_dst, char * bw,char * lat); -XBT_PUBLIC(void *) ns3_end_platform(void); -XBT_PUBLIC(void *) ns3_add_cluster(char * bw,char * lat,const char *id); +XBT_PUBLIC(void) ns3_end_platform(void); +XBT_PUBLIC(void) ns3_add_cluster(char * bw,char * lat,const char *id); SG_END_DECL() diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index 993ac0b7ed..4fd94acf79 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -8,8 +8,8 @@ #include "../cpu_cas01.hpp" /** @addtogroup SURF_plugin_energy - * - * + * + * * BlaBla energy */ @@ -31,7 +31,7 @@ static void energyCpuDestructedCallback(CpuPtr cpu){ surf_energy->erase(cpuIt); } -static void energyCpuActionStateChangedCallback(CpuActionPtr action){ +static void energyCpuActionStateChangedCallback(CpuActionPtr action, e_surf_action_state_t old, e_surf_action_state_t cur){ CpuPtr cpu = getActionCpu(action); CpuEnergyPtr cpu_energy = (*surf_energy)[cpu]; diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index 5e1ef7340f..d1c824d2fb 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -26,8 +26,8 @@ StorageModelPtr surf_storage_model = NULL; surf_callback(void, StoragePtr) storageCreatedCallbacks; surf_callback(void, StoragePtr) storageDestructedCallbacks; -surf_callback(void, StoragePtr) storageStateChangedCallbacks; -surf_callback(void, StorageActionPtr) storageActionStateChangedCallbacks; +surf_callback(void, StoragePtr, e_surf_resource_state_t, e_surf_resource_state_t) storageStateChangedCallbacks; +surf_callback(void, StorageActionPtr, e_surf_action_state_t, e_surf_action_state_t) storageActionStateChangedCallbacks; /********* * Model * @@ -138,8 +138,9 @@ void Storage::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, d void Storage::setState(e_surf_resource_state_t state) { + e_surf_resource_state_t old = Resource::getState(); Resource::setState(state); - surf_callback_emit(storageStateChangedCallbacks, this); + surf_callback_emit(storageStateChangedCallbacks, this, old, state); } xbt_dict_t Storage::getContent() @@ -179,6 +180,7 @@ StorageAction::StorageAction(ModelPtr model, double cost, bool failed, lmm_varia } void StorageAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(storageActionStateChangedCallbacks, this); + surf_callback_emit(storageActionStateChangedCallbacks, this, old, state); } diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index c63d044a69..d0e7df6038 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -48,15 +48,15 @@ extern surf_callback(void, StoragePtr) storageDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Storage State changed * - * @details Callback functions have the following signature: `void(StorageActionPtr)` + * @details Callback functions have the following signature: `void(StorageActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, StoragePtr) storageStateChangedCallbacks; +extern surf_callback(void, StoragePtr, e_surf_resource_state_t, e_surf_resource_state_t) storageStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after StorageAction State changed * - * @details Callback functions have the following signature: `void(StorageActionPtr)` + * @details Callback functions have the following signature: `void(StorageActionPtr action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -extern surf_callback(void, StorageActionPtr) storageActionStateChangedCallbacks; +extern surf_callback(void, StorageActionPtr, e_surf_action_state_t, e_surf_action_state_t) storageActionStateChangedCallbacks; /********* * Model * @@ -79,7 +79,7 @@ public: /** * @brief Create a Storage - * + * * @param id [description] * @param type_id [description] * @param content_name [description] @@ -109,7 +109,7 @@ class Storage : public Resource { public: /** * @brief Storage constructor - * + * * @param model StorageModel associated to this Storage * @param name The name of the Storage * @param props Dictionary of properties associated to this Storage @@ -124,7 +124,7 @@ public: /** * @brief Storage constructor - * + * * @param model StorageModel associated to this Storage * @param name The name of the Storage * @param props Dictionary of properties associated to this Storage @@ -151,14 +151,14 @@ public: /** * @brief Check if the Storage is used - * + * * @return true if the current Storage is used, false otherwise */ bool isUsed(); /** * @brief Update the state of the current Storage - * + * * @param event_type [description] * @param value [description] * @param date [description] @@ -176,17 +176,17 @@ public: /** * @brief Open a file - * + * * @param mount The mount point * @param path The path to the file - * + * * @return The StorageAction corresponding to the opening */ virtual StorageActionPtr open(const char* mount, const char* path)=0; /** * @brief Close a file - * + * * @param fd The file descriptor to close * @return The StorageAction corresponding to the closing */ @@ -195,7 +195,7 @@ public: /** * @brief List directory contents of a path * @details [long description] - * + * * @param path The path to the directory * @return The StorageAction corresponding to the ls action */ @@ -203,7 +203,7 @@ public: /** * @brief Read a file - * + * * @param fd The file descriptor to read * @param size The size in bytes to read * @return The StorageAction corresponding to the reading @@ -212,7 +212,7 @@ public: /** * @brief Write a file - * + * * @param fd The file descriptor to write * @param size The size in bytes to write * @return The StorageAction corresponding to the writing @@ -221,14 +221,14 @@ public: /** * @brief Get the content of the current Storage - * + * * @return A xbt_dict_t with path as keys and size in bytes as values */ virtual xbt_dict_t getContent(); /** * @brief Get the size in bytes of the current Storage - * + * * @return The size in bytes of the current Storage */ virtual sg_size_t getSize(); @@ -269,7 +269,7 @@ public: /** * @brief StorageAction constructor - * + * * @param model The StorageModel associated to this StorageAction * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] @@ -281,7 +281,7 @@ public: /** * @brief StorageAction constructor - * + * * @param model The StorageModel associated to this StorageAction * @param cost The cost of this StorageAction in [TODO] * @param failed [description] diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 6be998b709..56454da3db 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -260,7 +260,7 @@ static const char *disk_drives_letter_table[MAX_DRIVE] = { "Y:\\", "Z:\\" }; -#endif +#endif /* * Returns the initial path. On Windows the initial path is @@ -872,8 +872,8 @@ void Action::setBound(double bound) if (p_variable) lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), bound); - if (getModel()->getUpdateMechanism() == UM_LAZY) - heapRemove(getModel()->getActionHeap()); + if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate()!=surf_get_clock()) + heapRemove(getModel()->getActionHeap()); XBT_OUT(); } diff --git a/src/surf/workstation_interface.cpp b/src/surf/workstation_interface.cpp index b04b7195d8..dae99c941d 100644 --- a/src/surf/workstation_interface.cpp +++ b/src/surf/workstation_interface.cpp @@ -22,8 +22,8 @@ WorkstationModelPtr surf_workstation_model = NULL; surf_callback(void, WorkstationPtr) workstationCreatedCallbacks; surf_callback(void, WorkstationPtr) workstationDestructedCallbacks; -surf_callback(void, WorkstationPtr) workstationStateChangedCallbacks; -surf_callback(void, WorkstationActionPtr) workstationActionStateChangedCallbacks; +surf_callback(void, WorkstationPtr, e_surf_resource_state_t, e_surf_resource_state_t) workstationStateChangedCallbacks; +surf_callback(void, WorkstationActionPtr, e_surf_action_state_t, e_surf_action_state_t) workstationActionStateChangedCallbacks; /********* * Model * @@ -112,8 +112,9 @@ Workstation::~Workstation(){ } void Workstation::setState(e_surf_resource_state_t state){ + e_surf_resource_state_t old = Resource::getState(); Resource::setState(state); - surf_callback_emit(workstationStateChangedCallbacks, this); + surf_callback_emit(workstationStateChangedCallbacks, this, old, state); } int Workstation::getCore(){ @@ -507,6 +508,7 @@ void Workstation::setParams(ws_params_t params) **********/ void WorkstationAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(workstationActionStateChangedCallbacks, this); + surf_callback_emit(workstationActionStateChangedCallbacks, this, old, state); } diff --git a/src/surf/workstation_interface.hpp b/src/surf/workstation_interface.hpp index c472d377c6..799ee13ac9 100644 --- a/src/surf/workstation_interface.hpp +++ b/src/surf/workstation_interface.hpp @@ -43,15 +43,15 @@ extern surf_callback(void, WorkstationPtr) workstationDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Workstation State changed * - * @details Callback functions have the following signature: `void(WorkstationActionPtr)` + * @details Callback functions have the following signature: `void(WorkstationActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, WorkstationPtr) workstationStateChangedCallbacks; +extern surf_callback(void, WorkstationPtr, e_surf_resource_state_t, e_surf_resource_state_t) workstationStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after WorkstationAction State changed * - * @details Callback functions have the following signature: `void(WorkstationActionPtr)` + * @details Callback functions have the following signature: `void(WorkstationActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, WorkstationActionPtr) workstationActionStateChangedCallbacks; +extern surf_callback(void, WorkstationActionPtr, e_surf_action_state_t, e_surf_action_state_t) workstationActionStateChangedCallbacks; /********* * Tools * @@ -67,9 +67,9 @@ extern WorkstationModelPtr surf_workstation_model; */ class WorkstationModel : public Model { public: - /** + /** * @brief WorkstationModel constructor - * + * * @param name the name of the model */ WorkstationModel(const char *name); @@ -89,11 +89,11 @@ public: * @details [long description] */ virtual void adjustWeightOfDummyCpuActions(); - + /** * @brief [brief description] * @details [long description] - * + * * @param workstation_nb [description] * @param workstation_list [description] * @param computation_amount [description] @@ -110,7 +110,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param src [description] * @param dst [description] * @param size [description] @@ -138,7 +138,7 @@ public: /** * @brief Workstation constructor - * + * * @param model WorkstationModel associated to this Workstation * @param name The name of the Workstation * @param props Dictionary of properties associated to this Workstation @@ -151,7 +151,7 @@ public: /** * @brief Workstation constructor - * + * * @param model WorkstationModel associated to this Workstation * @param name The name of the Workstation * @param props Dictionary of properties associated to this Workstation @@ -179,7 +179,7 @@ public: /** * @brief Execute some quantity of computation - * + * * @param size The value of the processing amount (in flop) needed to process * @return The CpuAction corresponding to the processing * @see Cpu @@ -188,7 +188,7 @@ public: /** * @brief Make a process sleep for duration seconds - * + * * @param duration The number of seconds to sleep * @return The CpuAction corresponding to the sleeping * @see Cpu @@ -197,7 +197,7 @@ public: /** * @brief Get the number of cores of the associated Cpu - * + * * @return The number of cores of the associated Cpu * @see Cpu */ @@ -205,7 +205,7 @@ public: /** * @brief Get the speed of the associated Cpu - * + * * @param load [TODO] * @return The speed of the associated Cpu * @see Cpu @@ -215,7 +215,7 @@ public: /** * @brief Get the available speed of the associated Cpu * @details [TODO] - * + * * @return The available speed of the associated Cpu * @see Cpu */ @@ -223,7 +223,7 @@ public: /** * @brief Get the associated Cpu power peak - * + * * @return The associated Cpu power peak * @see Cpu */ @@ -235,7 +235,7 @@ public: /** * @brief Return the storage of corresponding mount point - * + * * @param storage The mount point * @return The corresponding Storage */ @@ -243,7 +243,7 @@ public: /** * @brief Get the xbt_dict_t of mount_point: Storage - * + * * @return The xbt_dict_t of mount_point: Storage */ virtual xbt_dict_t getMountedStorageList(); @@ -257,16 +257,16 @@ public: /** * @brief Open a file - * + * * @param fullpath The full path to the file - * + * * @return The StorageAction corresponding to the opening */ virtual ActionPtr open(const char* fullpath); /** * @brief Close a file - * + * * @param fd The file descriptor to close * @return The StorageAction corresponding to the closing */ @@ -275,7 +275,7 @@ public: /** * @brief Unlink a file * @details [long description] - * + * * @param fd [description] * @return [description] */ @@ -284,7 +284,7 @@ public: /** * @brief List directory contents of a path * @details [long description] - * + * * @param mount [description] * @param path The path to the directory * @return The StorageAction corresponding to the ls action @@ -293,7 +293,7 @@ public: /** * @brief Get the size in bytes of the file - * + * * @param fd The file descriptor to read * @return The size in bytes of the file */ @@ -301,7 +301,7 @@ public: /** * @brief Read a file - * + * * @param fd The file descriptor to read * @param size The size in bytes to read * @return The StorageAction corresponding to the reading @@ -310,7 +310,7 @@ public: /** * @brief Write a file - * + * * @param fd The file descriptor to write * @param size The size in bytes to write * @return The StorageAction corresponding to the writing @@ -325,7 +325,7 @@ public: * - the storage name, * - the storage typeId, * - the storage content type - * + * * @param fd The file descriptor * @return An xbt_dynar_t with the file informations */ @@ -333,15 +333,15 @@ public: /** * @brief Get the current position of the file descriptor - * + * * @param fd The file descriptor * @return The current position of the file descriptor */ virtual sg_size_t fileTell(surf_file_t fd); /** - * @brief Get the available space of the storage at the mount point - * + * @brief Get the available space of the storage at the mount point + * * @param name The mount point * @return The amount of availble space in bytes */ @@ -349,7 +349,7 @@ public: /** * @brief Get the used space of the storage at the mount point - * + * * @param name The mount point * @return The amount of used space in bytes */ @@ -358,7 +358,7 @@ public: /** * @brief Set the position indictator assiociated with the file descriptor to a new position * @details [long description] - * + * * @param fd The file descriptor * @param offset The offset from the origin * @param origin Position used as a reference for the offset @@ -398,7 +398,7 @@ public: /** * @brief Get the list of virtual machines on the current Workstation - * + * * @return The list of VMs */ xbt_dynar_t getVms(); @@ -407,7 +407,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param params [description] */ void getParams(ws_params_t params); @@ -415,7 +415,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param params [description] */ void setParams(ws_params_t params); @@ -433,7 +433,7 @@ class WorkstationAction : public Action { public: /** * @brief WorkstationAction constructor - * + * * @param model The WorkstationModel associated to this WorkstationAction * @param cost The cost of this WorkstationAction in [TODO] * @param failed [description] @@ -443,7 +443,7 @@ public: /** * @brief WorkstationAction constructor - * + * * @param model The WorkstationModel associated to this WorkstationAction * @param cost The cost of this WorkstationAction in [TODO] * @param failed [description] diff --git a/src/surf/workstation_ptask_L07.cpp b/src/surf/workstation_ptask_L07.cpp index f44c1a1834..71d2a57037 100644 --- a/src/surf/workstation_ptask_L07.cpp +++ b/src/surf/workstation_ptask_L07.cpp @@ -502,20 +502,11 @@ void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*d void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){ XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", getName(), this, value, date); if (event_type == p_bwEvent) { - m_bwCurrent = value; - lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_bwCurrent); + updateBandwidth(value, date); if (tmgr_trace_event_free(event_type)) p_bwEvent = NULL; } else if (event_type == p_latEvent) { - lmm_variable_t var = NULL; - WorkstationL07ActionPtr action; - lmm_element_t elem = NULL; - - m_latCurrent = value; - while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, getConstraint(), &elem))) { - action = (WorkstationL07ActionPtr) lmm_variable_id(var); - action->updateBound(); - } + updateLatency(value, date); if (tmgr_trace_event_free(event_type)) p_latEvent = NULL; } else if (event_type == p_stateEvent) { @@ -582,11 +573,31 @@ double LinkL07::getBandwidth() return m_bwCurrent; } +void LinkL07::updateBandwidth(double value, double date) +{ + m_bwCurrent = value; + lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_bwCurrent); +} + double LinkL07::getLatency() { return m_latCurrent; } +void LinkL07::updateLatency(double value, double date) +{ + lmm_variable_t var = NULL; + WorkstationL07ActionPtr action; + lmm_element_t elem = NULL; + + m_latCurrent = value; + while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, getConstraint(), &elem))) { + action = (WorkstationL07ActionPtr) lmm_variable_id(var); + action->updateBound(); + } +} + + bool LinkL07::isShared() { return lmm_constraint_is_shared(getConstraint()); diff --git a/src/surf/workstation_ptask_L07.hpp b/src/surf/workstation_ptask_L07.hpp index 360a851780..9bcac9fe0f 100644 --- a/src/surf/workstation_ptask_L07.hpp +++ b/src/surf/workstation_ptask_L07.hpp @@ -164,6 +164,8 @@ public: double getBandwidth(); double getLatency(); bool isShared(); + void updateBandwidth(double value, double date=surf_get_clock()); + void updateLatency(double value, double date=surf_get_clock()); double m_latCurrent; tmgr_trace_event_t p_latEvent; diff --git a/src/xbt/mmalloc/mmorecore.c b/src/xbt/mmalloc/mmorecore.c index 014b8b81c2..74ed341050 100644 --- a/src/xbt/mmalloc/mmorecore.c +++ b/src/xbt/mmalloc/mmorecore.c @@ -123,6 +123,10 @@ void *mmorecore(struct mdesc *mdp, ssize_t size) abort(); } +#ifdef MADV_MERGEABLE + madvise(mapto, mapbytes, MADV_MERGEABLE); +#endif + if (mdp->top == 0) mdp->base = mdp->breakval = mapto; diff --git a/teshsuite/bug-17132/CMakeLists.txt b/teshsuite/bug-17132/CMakeLists.txt new file mode 100644 index 0000000000..d2d8163401 --- /dev/null +++ b/teshsuite/bug-17132/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 2.6) + +if(enable_smpi) + if(WIN32) + set(CMAKE_C_FLAGS "-include ${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_main.h") + else() + set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc") + endif() + + + set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") + + add_executable(bug-17132 ${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132/bug-17132.c) + target_link_libraries(bug-17132 simgrid) + + set(tesh_files + ${tesh_files} + ${CMAKE_CURRENT_SOURCE_DIR}/bug-17132.tesh + PARENT_SCOPE) + set(xml_files + ${xml_files} + ${CMAKE_CURRENT_SOURCE_DIR}/small_platform.xml + PARENT_SCOPE) + set(teshsuite_src + ${teshsuite_src} + ${CMAKE_CURRENT_SOURCE_DIR}/bug-17132.c + PARENT_SCOPE) + set(bin_files + ${bin_files} + PARENT_SCOPE) + set(txt_files + ${txt_files} + ${CMAKE_CURRENT_SOURCE_DIR}/hostfile.txt + ${CMAKE_CURRENT_SOURCE_DIR}/README + PARENT_SCOPE) + +endif(enable_smpi) diff --git a/teshsuite/bug-17132/README b/teshsuite/bug-17132/README new file mode 100644 index 0000000000..22e35b9bb3 --- /dev/null +++ b/teshsuite/bug-17132/README @@ -0,0 +1,8 @@ +This is the bug #17132 described on gforge [1]. This small SMPI code +triggers an issue in SURF, which is still to be debugged. + +The problem seems to be related to the order of events, as changing it +(with another platform or another message size or a MPI_barrier in +between) fixes the problem. + +[1] https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165 \ No newline at end of file diff --git a/teshsuite/bug-17132/bug-17132.c b/teshsuite/bug-17132/bug-17132.c new file mode 100644 index 0000000000..cecb3e4607 --- /dev/null +++ b/teshsuite/bug-17132/bug-17132.c @@ -0,0 +1,40 @@ +#include "xbt/log.h" +#include +#include + +XBT_LOG_NEW_DEFAULT_CATEGORY(MM_mpi, "Messages for this SMPI test"); + +int main(int argc, char ** argv) +{ + size_t err; + size_t M = 8*1024; + size_t N = 32*1024; + + MPI_Init(&argc, &argv); + + double *a = malloc(sizeof(double) * M); + double *b = malloc(sizeof(double) * N); + + // A broadcast + err = MPI_Bcast(a, M, MPI_DOUBLE, 0, MPI_COMM_WORLD); + if (err != MPI_SUCCESS) { + perror("Error Bcast A\n"); MPI_Finalize(); exit(-1); + } + +// Uncommenting this barrier fixes it! +// MPI_Barrier(MPI_COMM_WORLD); + + // Another broadcast + err = MPI_Bcast(b, N, MPI_DOUBLE, 0, MPI_COMM_WORLD ); + if (err != MPI_SUCCESS) { + perror("Error Bcast B\n"); MPI_Finalize(); exit(-1); + } + + // Commenting out this barrier fixes it!! + MPI_Barrier(MPI_COMM_WORLD); + + MPI_Finalize(); + free(a); + free(b); + return 0; +} diff --git a/teshsuite/bug-17132/bug-17132.tesh b/teshsuite/bug-17132/bug-17132.tesh new file mode 100644 index 0000000000..d167f08b25 --- /dev/null +++ b/teshsuite/bug-17132/bug-17132.tesh @@ -0,0 +1,8 @@ +$ ../../smpi_script/bin/smpirun -np 16 -platform ${srcdir:=.}/small_platform.xml -hostfile ${srcdir:=.}/hostfile.txt ./bug-17132 --cfg=smpi/cpu_threshold:-1 --log=smpi_kernel.thres:warning +> You requested to use 16 processes, but there is only 2 processes in your hostfile... +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9' +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'SMPI' +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP_gamma' to '4194304' +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'smpi/cpu_threshold' to '-1' +> [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s) +> (some sensible output) diff --git a/teshsuite/bug-17132/hostfile.txt b/teshsuite/bug-17132/hostfile.txt new file mode 100644 index 0000000000..994b3e2cfc --- /dev/null +++ b/teshsuite/bug-17132/hostfile.txt @@ -0,0 +1,2 @@ +host1 +host2 diff --git a/teshsuite/bug-17132/small_platform.xml b/teshsuite/bug-17132/small_platform.xml new file mode 100644 index 0000000000..a2b420d810 --- /dev/null +++ b/teshsuite/bug-17132/small_platform.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/teshsuite/simix/stack_overflow.tesh b/teshsuite/simix/stack_overflow.tesh index 2606c83a4b..a0df41eb0f 100644 --- a/teshsuite/simix/stack_overflow.tesh +++ b/teshsuite/simix/stack_overflow.tesh @@ -1,5 +1,10 @@ ! expect signal SIGSEGV $ ./simix/stack_overflow --cfg=contexts/stack_size:96 ${srcdir:=.}/simix/stack_overflow.xml > [Tremblay:master:(0) 0.000000] [test/INFO] Launching our nice bugged recursive function... -> Access violation detected. This can result from a stack overflow. +> Access violation detected. +> This can result from a programming error in your code or, although less likely, +> from a bug in SimGrid itself. This can also be the sign of a bug in the OS or +> in third-party libraries. Failing hardware can sometimes generate such errors +> too. +> Finally, if nothing of the above applies, this can result from a stack overflow. > Try to increase stack size with --cfg=contexts/stack_size (current size is 96 KiB). diff --git a/testsuite/mc/dwarf_expression.c b/testsuite/mc/dwarf_expression.c index 7def465f70..8fa09c5f2e 100644 --- a/testsuite/mc/dwarf_expression.c +++ b/testsuite/mc/dwarf_expression.c @@ -96,7 +96,7 @@ void test_deref(mc_expression_state_t state) { Dwarf_Op ops[60]; ops[0].atom = DW_OP_const8u; - ops[0].number = (Dwarf_Word) &foo; + ops[0].number = (uintptr_t) &foo; ops[1].atom = DW_OP_deref; state->stack_size = 0; -- 2.20.1