Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'smpi-topo'
authorStéphane Castelli <stephane.castelli@loria.fr>
Tue, 22 Apr 2014 14:37:30 +0000 (16:37 +0200)
committerStéphane Castelli <stephane.castelli@loria.fr>
Tue, 22 Apr 2014 14:37:30 +0000 (16:37 +0200)
Conflicts:
src/smpi/smpi_pmpi.c

310 files changed:
.gitignore
CMakeLists.txt
COPYING
ChangeLog
buildtools/Cmake/AddTests.cmake
buildtools/Cmake/CompleteInFiles.cmake
buildtools/Cmake/DefinePackages.cmake
buildtools/Cmake/Distrib.cmake
buildtools/Cmake/Flags.cmake
buildtools/Cmake/GenerateDoc.cmake
buildtools/Cmake/MakeExe.cmake
buildtools/Cmake/MakeJava.cmake
buildtools/Cmake/MakeLib.cmake
buildtools/Cmake/MakeLibWin.cmake
buildtools/Cmake/Modules/FindLibdw.cmake [new file with mode: 0644]
buildtools/Cmake/Modules/FindLibunwind.cmake
buildtools/Cmake/Scripts/java_bundle.sh
buildtools/Cmake/Scripts/tesh.pl
buildtools/Cmake/src/internal_config.h.in
buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c
buildtools/Cmake/test_prog/prog_stacksetup.c
buildtools/jenkins/run.sh
buildtools/pipol/Experimental_bindings.sh
buildtools/pipol/MemCheck.sh
buildtools/pipol/Nightly_memCheck.sh
buildtools/pipol/Nightly_simgrid.sh
buildtools/pipol/rc.debian
buildtools/pipol/rc.fedora
buildtools/pipol/rc.mac
buildtools/pipol/rc.ubuntu
contrib/benchmarking_code_block/Rdhist.R [new file with mode: 0644]
contrib/benchmarking_code_block/Rhist.R
contrib/benchmarking_code_block/Rplot_hist.R [new file with mode: 0644]
contrib/benchmarking_code_block/inject.h
doc/Doxyfile.in
doc/doxygen/install.doc
doc/doxygen/platform.doc
examples/java/reservationSurfPlugin/CMakeLists.txt [new file with mode: 0644]
examples/java/reservationSurfPlugin/Receiver.java [new file with mode: 0644]
examples/java/reservationSurfPlugin/ReservationPlugin.java [new file with mode: 0644]
examples/java/reservationSurfPlugin/Sender.java [new file with mode: 0644]
examples/java/reservationSurfPlugin/TestPlugin.java [new file with mode: 0644]
examples/java/reservationSurfPlugin/reservationSurfPluginDeployment.xml [new file with mode: 0644]
examples/java/reservationSurfPlugin/reservationSurfPluginPlatform.xml [new file with mode: 0644]
examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh [new file with mode: 0644]
examples/java/surfCpuModel/CMakeLists.txt [new file with mode: 0644]
examples/java/surfCpuModel/CpuConstantModel.java [new file with mode: 0644]
examples/java/surfCpuModel/Receiver.java [new file with mode: 0644]
examples/java/surfCpuModel/Sender.java [new file with mode: 0644]
examples/java/surfCpuModel/TestCpuModel.java [new file with mode: 0644]
examples/java/surfCpuModel/surfCpuModelDeployment.xml [new file with mode: 0644]
examples/java/surfCpuModel/surfCpuModelPlatform.xml [new file with mode: 0644]
examples/java/surfCpuModel/surf_cpu_model.tesh [new file with mode: 0644]
examples/java/surfPlugin/CMakeLists.txt [new file with mode: 0644]
examples/java/surfPlugin/Receiver.java [new file with mode: 0644]
examples/java/surfPlugin/Sender.java [new file with mode: 0644]
examples/java/surfPlugin/TestPlugin.java [new file with mode: 0644]
examples/java/surfPlugin/TracePlugin.java [new file with mode: 0644]
examples/java/surfPlugin/surfPluginDeployment.xml [new file with mode: 0644]
examples/java/surfPlugin/surfPluginPlatform.xml [new file with mode: 0644]
examples/java/surfPlugin/surf_plugin.tesh [new file with mode: 0644]
examples/msg/io/file.c
examples/msg/io/file_unlink.c
examples/msg/io/io.tesh
examples/msg/io/storage.c
examples/msg/io/storage.tesh
examples/msg/mc/bugged1.tesh
examples/msg/mc/bugged1_liveness.tesh
examples/msg/mc/bugged1_liveness_visited.tesh
examples/msg/mc/bugged2.tesh
examples/platforms/content/small_content.txt
examples/platforms/content/storage_content.txt
examples/platforms/content/win_storage_content.txt
examples/platforms/storage.xml
examples/simdag/io/io.tesh
examples/smpi/CMakeLists.txt
examples/smpi/energy/energy.tesh
examples/smpi/energy/f77/energy.tesh
examples/smpi/energy/f77/sef.f
examples/smpi/energy/f90/energy.tesh
examples/smpi/energy/f90/sef90.f90
examples/smpi/energy/se.c
examples/smpi/mc/bugged1_liveness.c
examples/smpi/mc/hostfile_mutual_exclusion [new file with mode: 0644]
examples/smpi/mc/hostfile_non_deterministic [new file with mode: 0644]
examples/smpi/mc/hostfile_send_deterministic [new file with mode: 0644]
examples/smpi/mc/mutual_exclusion.c [new file with mode: 0644]
examples/smpi/mc/non_deterministic.c [new file with mode: 0644]
examples/smpi/mc/send_deterministic.c [new file with mode: 0644]
examples/smpi/replay/smpi_replay.tesh
examples/smpi/tracing/smpi_traced.tesh
include/msg/datatypes.h
include/msg/msg.h
include/simdag/simdag.h
include/simgrid/platf.h
include/simgrid/simix.h
include/smpi/mpi.h
include/smpi/smpi.h
include/surf/surf_routing.h
include/xbt/misc.h
include/xbt/mmalloc.h
include/xbt/sysdep.h
include/xbt/xbt_os_thread.h
src/bindings/java/jmsg_file.c
src/bindings/java/jmsg_file.h
src/bindings/java/jmsg_process.c
src/bindings/java/org/simgrid/NativeLib.java [new file with mode: 0644]
src/bindings/java/org/simgrid/msg/Msg.java
src/bindings/java/org/simgrid/msg/NativeLib.java [deleted file]
src/bindings/java/org/simgrid/surf/Action.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/ActionList.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/ActionState.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/Cpu.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/CpuAction.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/CpuModel.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/LmmConstraint.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/LmmVariable.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/Model.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/NetworkAction.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/NetworkLink.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/Plugin.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/Resource.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/ResourceState.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/RoutingEdge.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/Surf.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/SurfJNI.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/TmgrTrace.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/TmgrTraceEvent.java [new file with mode: 0644]
src/bindings/java/org/simgrid/surf/XbtDict.java [new file with mode: 0644]
src/bindings/java/org/simgrid/trace/Trace.java
src/bindings/java/surf.i [new file with mode: 0644]
src/bindings/java/surfJAVA_wrap.cxx [new file with mode: 0644]
src/bindings/java/surfJAVA_wrap.h [new file with mode: 0644]
src/bindings/java/surf_swig.cpp [new file with mode: 0644]
src/bindings/java/surf_swig.hpp [new file with mode: 0644]
src/bindings/java/surfdoc.i [new file with mode: 0644]
src/include/mc/datatypes.h
src/include/mc/mc.h
src/include/surf/maxmin.h
src/include/surf/surf.h
src/include/xbt/win32_ucontext.h [moved from include/xbt/win32_ucontext.h with 100% similarity]
src/mc/mc_checkpoint.c
src/mc/mc_compare.c
src/mc/mc_dpor.c
src/mc/mc_dwarf.c [new file with mode: 0644]
src/mc/mc_dwarf_attrnames.h [new file with mode: 0644]
src/mc/mc_dwarf_expression.c [new file with mode: 0644]
src/mc/mc_dwarf_tagnames.h [new file with mode: 0644]
src/mc/mc_global.c
src/mc/mc_hash.c [new file with mode: 0644]
src/mc/mc_liveness.c
src/mc/mc_member.c [new file with mode: 0644]
src/mc/mc_memory.c
src/mc/mc_private.h
src/mc/mc_request.c
src/mc/mc_set.cpp [new file with mode: 0644]
src/mc/mc_state.c
src/msg/msg_global.c
src/msg/msg_gos.c
src/msg/msg_io.c
src/msg/msg_mailbox.c
src/msg/msg_private.h
src/msg/msg_task.c
src/simdag/sd_workstation.c
src/simgrid/sg_config.c
src/simix/simcalls.in
src/simix/simcalls_generated_args_getter_setter.h
src/simix/simcalls_generated_body.c
src/simix/simcalls_generated_case.c
src/simix/simcalls_generated_enum.h
src/simix/simcalls_generated_res_getter_setter.h
src/simix/simcalls_generated_string.c
src/simix/smx_context.c
src/simix/smx_context_raw.c
src/simix/smx_context_sysv.c
src/simix/smx_context_thread.c
src/simix/smx_global.c
src/simix/smx_io.c
src/simix/smx_io_private.h
src/simix/smx_network.c
src/simix/smx_private.h
src/simix/smx_user.c
src/smpi/private.h
src/smpi/smpi_base.c
src/smpi/smpi_bench.c
src/smpi/smpi_f77.c
src/smpi/smpi_global.c
src/smpi/smpi_mpi_dt.c
src/smpi/smpi_pmpi.c
src/smpi/smpirun.in
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/fair_bottleneck.cpp
src/surf/lagrange.cpp
src/surf/maxmin.cpp
src/surf/network_cm02.cpp
src/surf/network_cm02.hpp
src/surf/network_constant.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_ns3.cpp
src/surf/network_ns3.hpp
src/surf/network_smpi.cpp
src/surf/ns3/ns3_interface.cc
src/surf/ns3/ns3_interface.h
src/surf/plugins/energy.cpp
src/surf/storage_interface.cpp
src/surf/storage_interface.hpp
src/surf/storage_n11.cpp
src/surf/storage_n11.hpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
src/surf/surf_routing_cluster_fat_tree.cpp [new file with mode: 0644]
src/surf/surf_routing_cluster_fat_tree.hpp [new file with mode: 0644]
src/surf/surf_routing_dijkstra.cpp
src/surf/surf_routing_floyd.cpp
src/surf/surf_routing_full.cpp
src/surf/surfxml_parseplatf.c
src/surf/workstation_interface.cpp
src/surf/workstation_interface.hpp
src/surf/workstation_ptask_L07.cpp
src/surf/workstation_ptask_L07.hpp
src/xbt/backtrace_linux.c
src/xbt/log.c
src/xbt/mmalloc/mfree.c
src/xbt/mmalloc/mm.c
src/xbt/mmalloc/mm_diff.c
src/xbt/mmalloc/mm_legacy.c
src/xbt/mmalloc/mm_module.c
src/xbt/mmalloc/mmalloc.c
src/xbt/mmalloc/mmorecore.c
src/xbt/mmalloc/mmprivate.h
src/xbt/mmalloc/mrealloc.c
src/xbt/win32_ucontext.c
src/xbt/xbt_main.c
src/xbt/xbt_os_thread.c
src/xbt/xbt_sha.c
teshsuite/bug-17132/CMakeLists.txt [new file with mode: 0644]
teshsuite/bug-17132/README [new file with mode: 0644]
teshsuite/bug-17132/bug-17132-surf-debug.tesh [new file with mode: 0644]
teshsuite/bug-17132/bug-17132.c [new file with mode: 0644]
teshsuite/bug-17132/bug-17132.tesh [new file with mode: 0644]
teshsuite/bug-17132/hostfile.txt [new file with mode: 0644]
teshsuite/bug-17132/small_platform.xml [new file with mode: 0644]
teshsuite/msg/storage/storage_basic.c
teshsuite/msg/storage/storage_basic.tesh
teshsuite/msg/storage/storage_content_c.txt
teshsuite/msg/storage/storage_content_s1.txt
teshsuite/msg/storage/storage_content_s2.txt
teshsuite/simdag/platforms/CMakeLists.txt
teshsuite/simdag/platforms/bogus_disk_attachment.tesh [new file with mode: 0644]
teshsuite/simdag/platforms/bogus_disk_attachment.xml [new file with mode: 0644]
teshsuite/simdag/platforms/flatifier.c
teshsuite/simdag/platforms/flatifier.tesh
teshsuite/simdag/platforms/one_cluster_multicore.xml [new file with mode: 0644]
teshsuite/simix/CMakeLists.txt
teshsuite/simix/stack_overflow.c [new file with mode: 0644]
teshsuite/simix/stack_overflow.tesh [new file with mode: 0644]
teshsuite/simix/stack_overflow.xml [new file with mode: 0644]
teshsuite/smpi/TI_output.tesh
teshsuite/smpi/allreduce_coll_large.tesh
teshsuite/smpi/bcast.tesh
teshsuite/smpi/hvector.tesh
teshsuite/smpi/indexed.tesh
teshsuite/smpi/mpich3-test/CMakeLists.txt
teshsuite/smpi/mpich3-test/coll/bcastzerotype.c
teshsuite/smpi/mpich3-test/datatype/unusual-noncontigs.c
teshsuite/smpi/mpich3-test/f77/coll/redscatf.f
teshsuite/smpi/mpich3-test/f77/pt2pt/CMakeLists.txt
teshsuite/smpi/mpich3-test/f77/pt2pt/testlist
teshsuite/smpi/mpich3-test/f77/util/mtestf.f
teshsuite/smpi/mpich3-test/f90/coll/redscatf90.f90
teshsuite/smpi/mpich3-test/f90/datatype/indtype.f90
teshsuite/smpi/mpich3-test/f90/datatype/structf.f90
teshsuite/smpi/mpich3-test/f90/pt2pt/CMakeLists.txt
teshsuite/smpi/mpich3-test/f90/pt2pt/allpairf90.f90
teshsuite/smpi/mpich3-test/f90/pt2pt/testlist
teshsuite/smpi/mpich3-test/f90/util/mtestf90.f90
teshsuite/smpi/mpich3-test/util/mtest.c
teshsuite/smpi/mpich3-test/util/mtest_manual.c [new file with mode: 0644]
teshsuite/smpi/pt2pt.tesh
teshsuite/smpi/reduce.tesh
teshsuite/smpi/shared.tesh
teshsuite/smpi/struct.tesh
teshsuite/smpi/vector.tesh
teshsuite/xbt/mmalloc_test.c
testsuite/mc/CMakeLists.txt [new file with mode: 0644]
testsuite/mc/dwarf.c [new file with mode: 0644]
testsuite/mc/dwarf_expression.c [new file with mode: 0644]
testsuite/surf/lmm_usage.c
tools/CMakeLists.txt
tools/check_dist_archive.exclude
tools/generate.sh [new file with mode: 0755]
tools/tesh/README
tools/tesh/background.tesh
tools/tesh/bg-set-signal.tesh
tools/tesh/catch-return.tesh
tools/tesh/catch-signal.tesh
tools/tesh/set-return.tesh
tools/tesh/set-signal.tesh
tools/tesh/setenv.tesh
tools/tesh/tesh.1
tools/tesh/tesh.c

index 6dc00ee..7cb9548 100644 (file)
@@ -12,6 +12,7 @@
 *.plist
 *.trace
 *.class
+\#*
 
 ################################################
 ### Maintainer mode
@@ -254,6 +255,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
@@ -733,6 +735,7 @@ teshsuite/msg/pid
 teshsuite/msg/get_sender
 teshsuite/msg/trace/test_trace_integration
 teshsuite/simix/check_defaults
+teshsuite/simix/stack_overflow
 teshsuite/simdag/availability/availability_test
 teshsuite/simdag/basic0
 teshsuite/simdag/basic1
@@ -797,6 +800,7 @@ examples/java/async/java_async_compiled
 examples/java/bittorrent/java_bittorrent_compiled
 examples/java/chord/java_chord_compiled
 examples/java/cloud/java_cloud_compiled
+examples/java/cloud/migration/java_cloud_migration_compiled
 examples/java/commTime/java_commTime_compiled
 examples/java/io/java_io_compiled
 examples/java/kademlia/java_kademlia_compiled
@@ -810,3 +814,5 @@ examples/java/priority/java_priority_compiled
 examples/java/startKillTime/java_startKillTime_compiled
 examples/java/suspend/java_suspend_compiled
 examples/java/tracing/java_tracing_compiled
+examples/java/reservationSurfPlugin/java_reservation_surf_plugin_compiled
+examples/java/surfPlugin/java_surf_plugin_compiled
index 621f9f6..edd9041 100644 (file)
@@ -4,7 +4,7 @@ if(WIN32)
   SET(CMAKE_RC_COMPILER "windres")
 endif()
 project(SimGrid C)
-if (enable_gtnets OR enable_ns3)
+if (enable_gtnets OR enable_ns3 OR enable_model-checking)
   enable_language(CXX)
 endif()
 
@@ -66,7 +66,7 @@ else()
 endif()
 
 set(SIMGRID_VERSION_STRING
-  "SimGrid version ${release_version}${SIMGRID_VERSION_EXTRA}\\nCopyright (c) ${SIMGRID_VERSION_DATE}. The Simgrid Team.")
+  "SimGrid version ${release_version}${SIMGRID_VERSION_EXTRA}\\nCopyright (c) 2004-${SIMGRID_VERSION_DATE}. The Simgrid Team.")
 
 set(libsimgrid_version "${release_version}")
 set(libsimgrid-java_version "${release_version}")
@@ -99,6 +99,9 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
   endif()
 endif()
 
+exec_program("${CMAKE_LINKER} --version" OUTPUT_VARIABLE "LINKER_VERSION")
+string(REGEX MATCH "[0-9].[0-9]*" LINKER_VERSION "${LINKER_VERSION}")
+
 string(REGEX MATCH "cl.exe" VBC "${CMAKE_C_COMPILER}")
 if(VBC)
   message(FATAL_ERROR "VB is not yet supported by Simgrid.")
diff --git a/COPYING b/COPYING
index 6ff568f..4ff2f05 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -92,7 +92,7 @@ include/xbt/mmalloc.h
 
 In order to use ucontext with windows platform we had those files :
         src/xbt/win32_ucontext.c
-        include/xbt/win32_ucontext.h
+        src/include/xbt/win32_ucontext.h
 
 Their copyright is the following:
 
index 2351083..5abdda7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,10 +31,13 @@ SimGrid (3.11) NOT RELEASED; urgency=low
    - creation of a VM on a PM
    - migration of a VM from a PM to another PM
 
- Simcalls:
- * Simcalls are now generated by a python script
-   - generate files include by simgrid
-   - check that all the functions exists and propose prototypes
+ SIMIX:
+ * Protect context stacks against stack overflow. The number of protected memory
+   pages allocated on the top of each stack (1 by default) can be configured
+   with the new command line option --cfg=contexts/guard_size:<value>.
+ * Simcalls are now generated by a python script that
+   - generates files included by SimGrid
+   - checks that all the functions exist, and proposes prototypes
  * Clean simcalls
    - remove sem_destroy, file_set_data, comm_destroy, vm_set_state,
      host_set_data, host_get_data
@@ -70,7 +73,7 @@ SimGrid (3.11) NOT RELEASED; urgency=low
  * Supernovae build mode is definitively removed. It was used to improve
    inlining and inter-module optimizations. It is nowadays superseded by
    link-time optimizations commonly available in compilers.
- * Update ns3 find lib. NS3 bindings should work again now.
+ * Update ns-3 find lib. Bindings for ns-3 should work again now.
  * Add boost dependency for surf++
 
  -- $date Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
@@ -295,7 +298,7 @@ SimGrid (3.8) stable; urgency=low
  * New option "enable_mallocators" to disable mallocators, for debugging
    purpose ("on" by default).
 
- Simix:
+ SIMIX:
  * Bug fixes around the resource failures: don't let the processes
    survive the host they are running onto.
  * Add an interface to auto-restart processes when the host in which they are
index 21e0cff..e9f0b7a 100644 (file)
@@ -30,10 +30,10 @@ endif()
 
 #some tests may take forever on non futexes systems, using busy_wait with n cores < n workers
 # default to posix for these tests if futexes are not supported
-if(NOT HAVE_FUTEX_H) 
+if(NOT HAVE_FUTEX_H)
 SET(CONTEXTS_SYNCHRO --cfg contexts/synchro:posix)
 endif()
+
 
 INCLUDE(CTest)
 ENABLE_TESTING()
@@ -140,6 +140,7 @@ if(NOT enable_memcheck)
   IF(enable_debug AND NOT enable_memcheck)
     ADD_TEST(tesh-parser-bogus-symmetric     ${TESH_COMMAND} ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms bogus_two_hosts_asymetric.tesh)
     ADD_TEST(tesh-parser-bogus-missing-gw ${TESH_COMMAND} ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms bogus_missing_gateway.tesh)
+    ADD_TEST(tesh-disk-attachment ${TESH_COMMAND} ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms bogus_disk_attachment.tesh)
   ENDIF()
 
   ADD_TEST(tesh-simdag-bypass                   ${TESH_COMMAND} ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms basic_parsing_test_bypass.tesh)
@@ -198,7 +199,7 @@ if(NOT enable_memcheck)
   ADD_TEST(msg-masterslave-vivaldi-thread       ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_vivaldi.tesh)
 
   ADD_TEST(msg-cloud-two-tasks-vm-thread ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/cloud/ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/ --cd ${CMAKE_BINARY_DIR}/examples/msg/cloud/ ${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/two_tasks_vm.tesh)
-  
+
   ADD_TEST(msg-cloud-simple-vm-thread ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/cloud/ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/ --cd ${CMAKE_BINARY_DIR}/examples/msg/cloud/ ${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/simple_vm.tesh)
 
   if(CONTEXT_UCONTEXT)
@@ -443,6 +444,11 @@ 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)
+    ADD_TEST(smpi-bug-17132-surf-debug          ${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-surf-debug.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()
@@ -473,12 +479,30 @@ if(NOT enable_memcheck)
       endif()
     endif()
 
-    ADD_TEST(smpi-energy                        ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/energy.tesh)
+    ADD_TEST(smpi-energy-thread                 ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/energy.tesh)
     if(SMPI_F2C)
-      ADD_TEST(smpi-energy-f77                  ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f77/energy.tesh)
+      ADD_TEST(smpi-energy-f77-thread           ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f77/energy.tesh)
     endif()
     if(SMPI_F90)
-      ADD_TEST(smpi-energy-f90                  ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f90/energy.tesh)
+      ADD_TEST(smpi-energy-f90-thread           ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f90/energy.tesh)
+    endif()
+    if(CONTEXT_UCONTEXT)
+      ADD_TEST(smpi-energy-ucontext             ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/energy.tesh)
+      if(SMPI_F2C)
+        ADD_TEST(smpi-energy-f77-ucontext       ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f77/energy.tesh)
+      endif()
+      if(SMPI_F90)
+        ADD_TEST(smpi-energy-f90-ucontext       ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f90/energy.tesh)
+      endif()
+    endif()
+    if(HAVE_RAWCTX)
+      ADD_TEST(smpi-energy-raw                  ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:raw --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/energy.tesh)
+      if(SMPI_F2C)
+        ADD_TEST(smpi-energy-f77-raw            ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:raw --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f77/energy.tesh)
+      endif()
+      if(SMPI_F90)
+        ADD_TEST(smpi-energy-f90-raw            ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:raw --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/energy --cd ${CMAKE_BINARY_DIR}/examples/smpi/energy ${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f90/energy.tesh)
+      endif()
     endif()
 
     if(HAVE_TRACING)
@@ -551,19 +575,19 @@ if(NOT enable_memcheck)
   # END TESH TESTS
 
   if(enable_smpi_MPICH3_testsuite)
-    ADD_TEST(smpi-mpich3-coll-thread            ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:thread)
-    ADD_TEST(smpi-mpich3-coll-ompi-thread       ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:thread -execarg=--cfg=smpi/coll_selector:ompi -execarg=--cfg=smpi/send_is_detached_thres:0)
-    ADD_TEST(smpi-mpich3-coll-mpich-thread      ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:thread -execarg=--cfg=smpi/coll_selector:mpich)
+    ADD_TEST(smpi-mpich3-coll-thread            ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:thread -execarg=--cfg=smpi/privatize_global_variables:yes)
+    ADD_TEST(smpi-mpich3-coll-ompi-thread       ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:thread -execarg=--cfg=smpi/coll_selector:ompi -execarg=--cfg=smpi/send_is_detached_thres:0 -execarg=--cfg=smpi/privatize_global_variables:yes)
+    ADD_TEST(smpi-mpich3-coll-mpich-thread      ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:thread -execarg=--cfg=smpi/coll_selector:mpich -execarg=--cfg=smpi/privatize_global_variables:yes)
     set_tests_properties(smpi-mpich3-coll-thread smpi-mpich3-coll-ompi-thread smpi-mpich3-coll-mpich-thread PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
     
     ADD_TEST(smpi-mpich3-topo-raw            ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/topo perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/topo -tests=testlist -execarg=--cfg=contexts/factory:raw)
       set_tests_properties(smpi-mpich3-topo-raw PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
     if(CONTEXT_UCONTEXT)
-      ADD_TEST(smpi-mpich3-coll-ompi-ucontext   ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:ucontext -execarg=--cfg=smpi/coll_selector:ompi -execarg=--cfg=smpi/send_is_detached_thres:0)
+      ADD_TEST(smpi-mpich3-coll-ompi-ucontext   ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:ucontext -execarg=--cfg=smpi/coll_selector:ompi -execarg=--cfg=smpi/send_is_detached_thres:0 -execarg=--cfg=smpi/privatize_global_variables:yes)
       set_tests_properties(smpi-mpich3-coll-ompi-ucontext PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
     endif()
     if(HAVE_RAWCTX)
-      ADD_TEST(smpi-mpich3-coll-mpich-raw       ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:raw -execarg=--cfg=smpi/coll_selector:mpich)
+      ADD_TEST(smpi-mpich3-coll-mpich-raw       ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/coll perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/coll -tests=testlist -execarg=--cfg=contexts/factory:raw -execarg=--cfg=smpi/coll_selector:mpich -execarg=--cfg=smpi/privatize_global_variables:yes)
       set_tests_properties(smpi-mpich3-coll-mpich-raw PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
     endif()
 
@@ -578,11 +602,11 @@ if(NOT enable_memcheck)
     endif()
 
     if(SMPI_F2C)
-      ADD_TEST(smpi-mpich3-thread-f77           ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f77/ perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f77/ -tests=testlist -execarg=--cfg=contexts/factory:thread -execarg=--cfg=contexts/stack_size:8000)
+      ADD_TEST(smpi-mpich3-thread-f77           ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f77/ perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f77/ -tests=testlist -execarg=--cfg=contexts/stack_size:8000 -execarg=--cfg=smpi/privatize_global_variables:yes)
       set_tests_properties(smpi-mpich3-thread-f77 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
     endif()
     if(SMPI_F90)
-      ADD_TEST(smpi-mpich3-thread-f90           ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f90/ perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f90/ -tests=testlist -execarg=--cfg=contexts/factory:thread)
+      ADD_TEST(smpi-mpich3-thread-f90           ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f90/ perl ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f90/ -tests=testlist -execarg=--cfg=smpi/privatize_global_variables:yes)
       set_tests_properties(smpi-mpich3-thread-f90 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
     endif()
   endif()
@@ -608,7 +632,10 @@ if(NOT enable_memcheck)
     ADD_TEST(java-mutualExclusion               ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/mutualExclusion/mutualexclusion.tesh)
     ADD_TEST(java-pingPong                      ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/pingPong/pingpong.tesh)
     ADD_TEST(java-priority                      ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/priority/priority.tesh)
+    ADD_TEST(java-reservation-surf-plugin       ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh)
     ADD_TEST(java-startKillTime                 ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/startKillTime/startKillTime.tesh)
+    ADD_TEST(java-surf-cpu-model                ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/surfCpuModel/surf_cpu_model.tesh)
+    ADD_TEST(java-surf-plugin                   ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/surfPlugin/surf_plugin.tesh)
     ADD_TEST(java-suspend                       ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/suspend/suspend.tesh)
     if(HAVE_TRACING)
       ADD_TEST(java-tracing                     ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/tracing/tracingPingPong.tesh)
@@ -628,6 +655,14 @@ if(NOT enable_memcheck)
     ADD_TEST(scala-masterslave                  ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/scala --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/scala ${CMAKE_HOME_DIRECTORY}/examples/scala/masterslave/masterslave.tesh)
   endif()
 
+  ADD_TEST(stack-overflow-thread                ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite --cd ${CMAKE_BINARY_DIR}/teshsuite ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/stack_overflow.tesh)
+  if(CONTEXT_UCONTEXT)
+    ADD_TEST(stack-overflow-ucontext            ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite --cd ${CMAKE_BINARY_DIR}/teshsuite ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/stack_overflow.tesh)
+  endif()
+  if(HAVE_RAWCTX)
+    ADD_TEST(stack-overflow-raw                 ${TESH_COMMAND} ${TESH_OPTION} --cfg contexts/factory:raw --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite --cd ${CMAKE_BINARY_DIR}/teshsuite ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/stack_overflow.tesh)
+  endif()
+
   # examples/msg/mc
   if(HAVE_MC)
     if(CONTEXT_UCONTEXT)
@@ -644,6 +679,23 @@ if(NOT enable_memcheck)
     endif()
   endif()
 
+  ###
+  ### Declare that we know that some tests are broken
+  ###
+  if(release)
+    if(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
+      # These tests are known to fail on Windows and Mac OS X
+      # (the expected error message is not shown).
+      set_tests_properties(stack-overflow-thread PROPERTIES WILL_FAIL true)
+      if(CONTEXT_UCONTEXT)
+        set_tests_properties(stack-overflow-ucontext PROPERTIES WILL_FAIL true)
+      endif()
+      if(HAVE_RAWCTX)
+        set_tests_properties(stack-overflow-raw PROPERTIES WILL_FAIL true)
+      endif()
+    endif()
+  endif()
+
 endif()
 
 ADD_TEST(tesh-simdag-full-links01               ${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms/basic_parsing_test ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms/two_clusters.xml FULL_LINK)
@@ -662,6 +714,11 @@ add_test(test-surf-usage                        ${CMAKE_BINARY_DIR}/testsuite/su
 add_test(test-surf-usage2                       ${CMAKE_BINARY_DIR}/testsuite/surf/surf_usage2 --cfg=path:${CMAKE_HOME_DIRECTORY}/testsuite/surf/ platform.xml)
 add_test(test-surf-trace                        ${CMAKE_BINARY_DIR}/testsuite/surf/trace_usage --cfg=path:${CMAKE_HOME_DIRECTORY}/testsuite/surf/)
 
+if(HAVE_MC)
+  add_test(mc-dwarf                             ${CMAKE_BINARY_DIR}/testsuite/mc/dwarf)
+  add_test(mc-dwarf-expression                  ${CMAKE_BINARY_DIR}/testsuite/mc/dwarf-expression)
+endif()
+
 add_test(testall                                ${CMAKE_BINARY_DIR}/src/testall)
 
 if(enable_auto_install)
index 04a2a3e..8dd7bb8 100644 (file)
@@ -84,6 +84,11 @@ if(enable_java)
   find_package(JNI REQUIRED)
   message("-- [Java] JNI found: ${JNI_FOUND}")
   message("-- [Java] JNI include dirs: ${JNI_INCLUDE_DIRS}")
+  if(enable_maintainer_mode)
+    find_package(SWIG REQUIRED)
+    include(UseSWIG)
+    message("-- [Java] Swig found: ${SWIG_FOUND} (version ${SWIG_VERSION})")
+  endif()
   set(HAVE_Java 1)
 endif()
 if(enable_scala)
@@ -107,6 +112,8 @@ else()
 endif()
 
 # Checks for header libraries functions.
+CHECK_LIBRARY_EXISTS(dl      dlopen                  "" HAVE_DLOPEN_IN_LIBDL)
+CHECK_LIBRARY_EXISTS(execinfo backtrace              "" HAVE_BACKTRACE_IN_LIBEXECINFO)
 CHECK_LIBRARY_EXISTS(pthread pthread_create          "" pthread)
 CHECK_LIBRARY_EXISTS(pthread sem_init                "" HAVE_SEM_INIT_LIB)
 CHECK_LIBRARY_EXISTS(pthread sem_open                "" HAVE_SEM_OPEN_LIB)
@@ -225,11 +232,13 @@ if(enable_model-checking AND HAVE_MMALLOC)
   SET(HAVE_MC 1)
   SET(MMALLOC_WANT_OVERRIDE_LEGACY 1)
   include(FindLibunwind)
+  include(FindLibdw)
 else()
   if(enable_model-checking)
     message(STATUS "Warning: support for model-checking has been disabled because HAVE_MMALLOC is false")
   endif()
   SET(HAVE_MC 0)
+  SET(HAVE_MMALLOC 0)
   SET(MMALLOC_WANT_OVERRIDE_LEGACY 0)
 endif()
 
@@ -249,7 +258,10 @@ CHECK_TYPE_SIZE(void* SIZEOF_VOIDP)
 ### Check for GNU dynamic linker
 CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
 if (HAVE_DLFCN_H)
-    execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_gnu_dynlinker.c -ldl -o test_gnu_ld
+    if(HAVE_DLOPEN_IN_LIBDL)
+      set(DL_LIBRARY "-ldl")
+    endif(HAVE_DLOPEN_IN_LIBDL)
+    execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_gnu_dynlinker.c ${DL_LIBRARY} -o test_gnu_ld
       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
       OUTPUT_VARIABLE HAVE_GNU_LD_compil
     )
@@ -415,14 +427,14 @@ endif()
 # AC_CHECK_MCSC(mcsc=yes, mcsc=no)
 set(mcsc_flags "")
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  set(mcsc_flags "-D_XOPEN_SOURCE")
+  set(mcsc_flags -D_XOPEN_SOURCE)
 endif()
 
 if(WIN32)
   if(ARCH_32_BITS)
-    set(mcsc_flags "-D_XBT_WIN32 -D_I_X86_ -I${CMAKE_HOME_DIRECTORY}/include/xbt -I${CMAKE_HOME_DIRECTORY}/src/xbt")
+    set(mcsc_flags -D_XBT_WIN32 -D_I_X86_ -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt)
   else()
-    set(mcsc_flags "-D_XBT_WIN32 -D_AMD64_ -I${CMAKE_HOME_DIRECTORY}/include/xbt -I${CMAKE_HOME_DIRECTORY}/src/xbt")
+    set(mcsc_flags -D_XBT_WIN32 -D_AMD64_ -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt)
   endif()
 endif()
 
@@ -436,7 +448,7 @@ ELSE()
   file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
   execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c ${mcsc_flags} -o testprog
   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/
-  OUTPUT_VARIABLE COMPILE_mcsc_VAR)
+  OUTPUT_VARIABLE COMPILE_mcsc_VAR ERROR_VARIABLE COMPILE_mcsc_VAR)
 
   if(NOT COMPILE_mcsc_VAR)
     message(STATUS "prog_AC_CHECK_MCSC.c is compilable")
@@ -444,7 +456,7 @@ ELSE()
     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/
     OUTPUT_VARIABLE var_compil)
   else()
-    message(STATUS "prog_AC_CHECK_MCSC.c is not compilable")
+    message(STATUS "prog_AC_CHECK_MCSC.c is not compilable:\n${COMPILE_mcsc_VAR}")
   endif()
   file(REMOVE "${CMAKE_BINARY_DIR}/testprog*")
 
@@ -561,7 +573,7 @@ if(HAVE_MAKECONTEXT OR WIN32)
     else()
       set(makecontext_CPPFLAGS "-DTEST_makecontext -D_AMD64_")
     endif()
-    set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 -I${CMAKE_HOME_DIRECTORY}/include/xbt -I${CMAKE_HOME_DIRECTORY}/src/xbt")
+    set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt")
   endif()
 
   file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
@@ -671,7 +683,7 @@ int main(void)
     )
 
   execute_process(
-  COMMAND ${CMAKE_C_COMPILER} "${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c" 
+  COMMAND ${CMAKE_C_COMPILER} "${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c"
   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
   RESULT_VARIABLE COMPILE_VA_NULL_VAR
   OUTPUT_QUIET
index a89ac22..4ed6294 100644 (file)
@@ -1,7 +1,6 @@
 ### define source packages
 
 set(EXTRA_DIST
-  include/xbt/win32_ucontext.h
   src/bindings/java/MANIFEST.MF.in
   src/include/instr/instr_interface.h
   src/include/mc/datatypes.h
@@ -17,6 +16,7 @@ set(EXTRA_DIST
   src/include/surf/surf_resource_lmm.h
   src/include/surf/surfxml_parse_values.h
   src/include/surf/trace_mgr.h
+  src/include/xbt/win32_ucontext.h
   src/include/xbt/wine_dbghelp.h
   src/include/xbt/xbt_os_time.h
   src/msg/msg_mailbox.h
@@ -124,9 +124,11 @@ set(EXTRA_DIST
   src/xbt/win32_ucontext.c
   tools/tesh/run_context.h
   tools/tesh/tesh.h
+  src/surf/surf_routing_cluster_fat_tree.hpp
   )
 
 set(SMPI_SRC
+  src/surf/surf_routing_cluster_fat_tree.cpp
   src/smpi/instr_smpi.c
   src/smpi/smpi_base.c
   src/smpi/smpi_bench.c
@@ -159,7 +161,7 @@ set(SMPI_SRC
   src/smpi/colls/allgather-smp-simple.c
   src/smpi/colls/allgather-spreading-simple.c
   src/smpi/colls/allgather-ompi-neighborexchange.c
-  src/smpi/colls/allgatherv-GB.c  
+  src/smpi/colls/allgatherv-GB.c
   src/smpi/colls/allgatherv-pair.c
   src/smpi/colls/allgatherv-ring.c
   src/smpi/colls/allgatherv-ompi-neighborexchange.c
@@ -191,10 +193,10 @@ set(SMPI_SRC
   src/smpi/colls/alltoall-ring-light-barrier.c
   src/smpi/colls/alltoall-ring-mpi-barrier.c
   src/smpi/colls/alltoall-ring-one-barrier.c
-  src/smpi/colls/alltoallv-pair.c   
+  src/smpi/colls/alltoallv-pair.c
   src/smpi/colls/alltoallv-pair-light-barrier.c
   src/smpi/colls/alltoallv-pair-mpi-barrier.c
-  src/smpi/colls/alltoallv-pair-one-barrier.c 
+  src/smpi/colls/alltoallv-pair-one-barrier.c
   src/smpi/colls/alltoallv-ring.c
   src/smpi/colls/alltoallv-ring-light-barrier.c
   src/smpi/colls/alltoallv-ring-mpi-barrier.c
@@ -320,7 +322,7 @@ set(SURF_SRC
   src/surf/maxmin.cpp
   src/surf/network_interface.cpp
   src/surf/network_cm02.cpp
-  src/surf/network_smpi.cpp  
+  src/surf/network_smpi.cpp
   src/surf/network_constant.cpp
   src/surf/platf_generator.c
   src/surf/random_mgr.c
@@ -329,7 +331,7 @@ set(SURF_SRC
   src/surf/storage_n11.cpp
   src/surf/surf_interface.cpp
   src/surf/surf_c_bindings.cpp
-  src/surf/surf_routing.cpp  
+  src/surf/surf_routing.cpp
   src/surf/surf_routing_cluster.cpp
   src/surf/surf_routing_cluster_torus.cpp
   src/surf/surf_routing_dijkstra.cpp
@@ -431,6 +433,47 @@ set(BINDINGS_SRC
   src/bindings/lua/simgrid_lua.h
   )
 
+set(JSURF_SWIG_SRC
+  src/bindings/java/surf.i
+)
+
+set(JSURF_SWIG_SRC_EXTRA
+  src/bindings/java/surfdoc.i
+)
+
+set(JSURF_JAVA_C_SRC
+  src/bindings/java/surf_swig.cpp
+  src/bindings/java/surf_swig.hpp
+)
+
+set(JSURF_JAVA_GENERATED_SRC
+  src/bindings/java/org/simgrid/surf/Surf.java
+  src/bindings/java/org/simgrid/surf/SurfJNI.java
+  src/bindings/java/org/simgrid/surf/Plugin.java
+  src/bindings/java/org/simgrid/surf/Model.java
+  src/bindings/java/org/simgrid/surf/CpuModel.java
+  src/bindings/java/org/simgrid/surf/Resource.java
+  src/bindings/java/org/simgrid/surf/Action.java
+  src/bindings/java/org/simgrid/surf/Cpu.java
+  src/bindings/java/org/simgrid/surf/CpuAction.java
+  src/bindings/java/org/simgrid/surf/NetworkLink.java
+  src/bindings/java/org/simgrid/surf/NetworkAction.java
+
+  src/bindings/java/org/simgrid/surf/RoutingEdge.java
+  src/bindings/java/org/simgrid/surf/TmgrTraceEvent.java
+  src/bindings/java/org/simgrid/surf/TmgrTrace.java
+
+  src/bindings/java/org/simgrid/surf/ActionList.java
+
+  #enums
+  src/bindings/java/org/simgrid/surf/ActionState.java
+  src/bindings/java/org/simgrid/surf/ResourceState.java
+
+  src/bindings/java/org/simgrid/surf/LmmConstraint.java
+  src/bindings/java/org/simgrid/surf/LmmVariable.java
+  src/bindings/java/org/simgrid/surf/XbtDict.java
+)
+
 set(JMSG_C_SRC
   src/bindings/java/jmsg.c
   src/bindings/java/jmsg.h
@@ -460,8 +503,16 @@ set(JMSG_C_SRC
   src/bindings/java/smx_context_java.h
 )
 
+set(JSURF_C_SRC
+  src/bindings/java/surfJAVA_wrap.cxx
+  src/bindings/java/surfJAVA_wrap.h
+  ${JSURF_JAVA_C_SRC}
+)
+
 set(JMSG_JAVA_SRC
-  src/bindings/java/org/simgrid/msg/As.java    
+  src/bindings/java/org/simgrid/NativeLib.java
+
+  src/bindings/java/org/simgrid/msg/As.java
   src/bindings/java/org/simgrid/msg/Comm.java
   src/bindings/java/org/simgrid/msg/File.java
   src/bindings/java/org/simgrid/msg/Host.java
@@ -472,7 +523,6 @@ set(JMSG_JAVA_SRC
   src/bindings/java/org/simgrid/msg/MsgException.java
   src/bindings/java/org/simgrid/msg/Mutex.java
   src/bindings/java/org/simgrid/msg/NativeException.java
-  src/bindings/java/org/simgrid/msg/NativeLib.java
   src/bindings/java/org/simgrid/msg/Process.java
   src/bindings/java/org/simgrid/msg/ProcessKilledError.java
   src/bindings/java/org/simgrid/msg/ProcessNotFoundException.java
@@ -483,6 +533,7 @@ set(JMSG_JAVA_SRC
   src/bindings/java/org/simgrid/msg/TimeoutException.java
   src/bindings/java/org/simgrid/msg/TransferFailureException.java
   src/bindings/java/org/simgrid/msg/VM.java
+  ${JSURF_JAVA_GENERATED_SRC}
 )
 
 set(JTRACE_C_SRC
@@ -543,6 +594,11 @@ set(MC_SRC
   src/mc/mc_compare.c
   src/mc/mc_dpor.c
   src/mc/mc_global.c
+  src/mc/mc_dwarf.c
+  src/mc/mc_member.c
+  src/mc/mc_dwarf_attrnames.h
+  src/mc/mc_dwarf_expression.c
+  src/mc/mc_dwarf_tagnames.h
   src/mc/mc_liveness.c
   src/mc/mc_memory.c
   src/mc/mc_private.h
@@ -550,6 +606,8 @@ set(MC_SRC
   src/mc/mc_state.c
   src/mc/memory_map.c
   src/mc/mc_pair.c
+  src/mc/mc_hash.c
+  src/mc/mc_set.cpp
   )
 
 set(headers_to_install
@@ -800,7 +858,7 @@ set(DOC_SOURCES
   doc/msg-tuto-src/platforms/griffon.xml
   doc/msg-tuto-src/platforms/peers.xml
   doc/msg-tuto-src/platforms/platform.xml
-  
+
   CITATION.bib
   )
 
@@ -885,7 +943,10 @@ set(EXAMPLES_CMAKEFILES_TXT
   examples/java/mutualExclusion/CMakeLists.txt
   examples/java/pingPong/CMakeLists.txt
   examples/java/priority/CMakeLists.txt
+  examples/java/reservationSurfPlugin/CMakeLists.txt
   examples/java/startKillTime/CMakeLists.txt
+  examples/java/surfCpuModel/CMakeLists.txt
+  examples/java/surfPlugin/CMakeLists.txt
   examples/java/suspend/CMakeLists.txt
   examples/java/tracing/CMakeLists.txt
   examples/lua/CMakeLists.txt
@@ -942,6 +1003,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
@@ -985,6 +1047,7 @@ set(TOOLS_CMAKEFILES_TXT
 set(TESTSUITE_CMAKEFILES_TXT
   testsuite/surf/CMakeLists.txt
   testsuite/xbt/CMakeLists.txt
+  testsuite/mc/CMakeLists.txt
   )
 
 set(CMAKE_SOURCE_FILES
@@ -1009,6 +1072,7 @@ set(CMAKE_SOURCE_FILES
   buildtools/Cmake/Modules/FindGraphviz.cmake
   buildtools/Cmake/Modules/FindLibSigc++.cmake
   buildtools/Cmake/Modules/FindLibunwind.cmake
+  buildtools/Cmake/Modules/FindLibdw.cmake
   buildtools/Cmake/Modules/FindLua51Simgrid.cmake
   buildtools/Cmake/Modules/FindNS3.cmake
   buildtools/Cmake/Modules/FindRngStream.cmake
index 74b539b..61b8edf 100644 (file)
@@ -69,7 +69,7 @@ add_custom_target(simgrid_update_xml ALL
   )
 
 # libraries
-install(TARGETS simgrid 
+install(TARGETS simgrid
   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
 
 if(enable_lib_static AND NOT WIN32)
@@ -189,6 +189,9 @@ set(source_to_pack
   ${JEDULE_SRC}
   ${JMSG_C_SRC}
   ${JMSG_JAVA_SRC}
+  ${JSURF_SWIG_SRC}
+  ${JSURF_SWIG_SRC_EXTRA}
+  ${JSURF_C_SRC}
   ${LUA_SRC}
   ${MC_SRC}
   ${MSG_SRC}
index 5e959e3..675587b 100644 (file)
@@ -36,7 +36,7 @@ if(enable_compile_optimizations)
       endif()
     else()    
       # On non-windows, 4.6 is enough for that
-      if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
+      if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5" AND LINKER_VERSION STRGREATER "2.22")
         set(optCFLAGS "${optCFLAGS} -flto ")
       endif()
     endif()
index 6d9769e..d4f482c 100644 (file)
@@ -63,7 +63,7 @@ if(DOXYGEN_PATH)
     COMMAND ${DOXYGEN_PATH}/doxygen Doxyfile
     COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_HOME_DIRECTORY}/doc/simgrid_modules.map
     COMMAND ${CMAKE_COMMAND} -E echo "XX Javadoc pass"
-    COMMAND ${JAVADOC_PATH}/javadoc -quiet -d ${CMAKE_HOME_DIRECTORY}/doc/html/javadoc/ ${CMAKE_HOME_DIRECTORY}/src/bindings/java/org/simgrid/msg/*.java
+    COMMAND ${JAVADOC_PATH}/javadoc -quiet -d ${CMAKE_HOME_DIRECTORY}/doc/html/javadoc/ ${CMAKE_HOME_DIRECTORY}/src/bindings/java/org/simgrid/*.java ${CMAKE_HOME_DIRECTORY}/src/bindings/java/org/simgrid/*/*.java
     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc
     )
 
index 72ec2fc..513d72f 100644 (file)
@@ -18,7 +18,10 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/migration)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/mutualExclusion)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/pingPong)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/priority)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/reservationSurfPlugin)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/startKillTime)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/surfCpuModel)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/surfPlugin)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/suspend)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/tracing)
 
@@ -88,6 +91,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)
@@ -117,6 +122,7 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f90/pt2pt)
 
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/xbt)
 
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/testsuite/mc)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/testsuite/surf)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/testsuite/xbt)
 
index f1c43de..4b90414 100644 (file)
@@ -29,13 +29,11 @@ message("-- [Java] simgrid-java includes: ${CHECK_INCLUDES}")
 target_link_libraries(simgrid-java simgrid)
 
 
-
-
 if(WIN32)
   exec_program("java -d32 -version"
                 OUTPUT_VARIABLE IS_32_BITS_JVM)
   STRING( FIND ${IS_32_BITS_JVM} "Error" POSITION )
-  if(${POSITION} GREATER -1) 
+  if(${POSITION} GREATER -1)
     message(FATAL_ERROR "Java JVM needs to be 32 bits to be able to run with Simgrid on Windows for now")
   endif()
 
@@ -65,6 +63,8 @@ set(LIBSIMGRID_SO
   libsimgrid${CMAKE_SHARED_LIBRARY_SUFFIX})
 set(LIBSIMGRID_JAVA_SO
   ${CMAKE_SHARED_LIBRARY_PREFIX}simgrid-java${CMAKE_SHARED_LIBRARY_SUFFIX})
+set(LIBSURF_JAVA_SO
+  ${CMAKE_SHARED_LIBRARY_PREFIX}surf-java${CMAKE_SHARED_LIBRARY_SUFFIX})
 
 ## Don't strip libraries if not in release mode
 ##
@@ -78,15 +78,16 @@ endif()
 ##
 if(CMAKE_VERSION VERSION_LESS "2.8.12")
   set(CMAKE_JAVA_TARGET_OUTPUT_NAME simgrid)
-  add_jar(simgrid-java_pre_jar ${JMSG_JAVA_SRC})
+  add_jar(simgrid-java_pre_jar ${JMSG_JAVA_SRC} ${JSURF_JAVA_GENERATED_SRC})
 else()
-  add_jar(simgrid-java_pre_jar ${JMSG_JAVA_SRC} OUTPUT_NAME simgrid)
+  add_jar(simgrid-java_pre_jar ${JMSG_JAVA_SRC} ${JSURF_JAVA_GENERATED_SRC} OUTPUT_NAME simgrid)
 endif()
 
 set(JAVA_BUNDLE "${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Scripts/java_bundle.sh")
 set(JAVA_BUNDLE_SO_FILES
   ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}
   ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_JAVA_SO}
+  ${CMAKE_BINARY_DIR}/lib/${LIBSURF_JAVA_SO}
   )
 set(JAVA_BUNDLE_TXT_FILES
   ${CMAKE_HOME_DIRECTORY}/COPYING
@@ -111,3 +112,40 @@ add_custom_command(
   COMMAND ${CMAKE_COMMAND} -E touch ${SIMGRID_JAR}_finalized
   )
 add_custom_target(simgrid-java_jar ALL DEPENDS ${SIMGRID_JAR}_finalized)
+
+
+if(enable_maintainer_mode)
+  set(CMAKE_SWIG_FLAGS "-package" "org.simgrid.surf")
+  set(CMAKE_SWIG_OUTDIR "${CMAKE_HOME_DIRECTORY}/src/bindings/java/org/simgrid/surf")
+
+  set_source_files_properties(${JSURF_SWIG_SRC} PROPERTIES CPLUSPLUS 1)
+  include_directories(${JNI_INCLUDE_DIRS})
+  swig_add_module(surf-java java ${JSURF_SWIG_SRC} ${JSURF_JAVA_C_SRC})
+
+  add_custom_command(TARGET surf-java POST_BUILD
+    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/src/bindings/java/surfJAVA_wrap.cxx" "${CMAKE_HOME_DIRECTORY}/src/bindings/java/surfJAVA_wrap.cxx"
+    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/src/bindings/java/surfJAVA_wrap.h" "${CMAKE_HOME_DIRECTORY}/src/bindings/java/surfJAVA_wrap.h"
+  )
+
+  swig_link_libraries(surf-java simgrid)
+else()
+  add_library(surf-java SHARED
+    ${JSURF_C_SRC})
+  target_link_libraries(surf-java simgrid)
+  set_source_files_properties("${CMAKE_HOME_DIRECTORY}/src/bindings/java/surfJAVA_wrap.cxx"
+    PROPERTIES COMPILE_FLAGS "-fPIC -I${JAVA_INCLUDE_PATH} -I${JAVA_INCLUDE_PATH2}"
+  )
+endif()
+
+add_dependencies(simgrid-java surf-java)
+add_dependencies(simgrid-java_pre_jar surf-java)
+
+if(WIN32)
+  set_target_properties(surf-java PROPERTIES
+    LINK_FLAGS "-Wl,--subsystem,windows,--kill-at"
+    PREFIX "")
+  if(PEXPORTS_PATH)
+    add_custom_command(TARGET surf-java POST_BUILD
+      COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/lib/surf-java.dll > ${CMAKE_BINARY_DIR}/lib/surf-java.def)
+  endif(PEXPORTS_PATH)
+endif()
index 1e21137..ef15efa 100644 (file)
@@ -20,7 +20,16 @@ add_dependencies(simgrid maintainer_files)
 
 # Compute the dependencies of SimGrid
 #####################################
-set(SIMGRID_DEP "-lm -lstdc++")
+set(SIMGRID_DEP "-lm")
+
+if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
+    AND NOT ${CMAKE_SYSTEM_VERSION} VERSION_LESS 10.0
+    AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+  # FreeBSD from 10.0 provide a internal C++ stack (unused by gcc)
+  set(SIMGRID_DEP "${SIMGRID_DEP} -lc++")
+else()
+  set(SIMGRID_DEP "${SIMGRID_DEP} -lstdc++")
+endif()
 
 if(pthread)
   if(${CONTEXT_THREADS})
@@ -77,6 +86,9 @@ if(HAVE_MC)
   #   (that includes FindLibunwind.cmake), so simply load it now.
   
   SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind")
+
+  # Same for libdw
+  SET(SIMGRID_DEP "${SIMGRID_DEP} -ldw")
   # This supposes that the host machine is either an AMD or a X86.
   # This is deeply wrong, and should be fixed by manually loading -lunwind-PLAT (FIXME)
   if(PROCESSOR_x86_64)
@@ -87,7 +99,7 @@ if(HAVE_MC)
 endif()
 
 if(MMALLOC_WANT_OVERRIDE_LEGACY AND HAVE_GNU_LD)
-  SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl")
+  SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
 endif()
 
 if(HAVE_NS3)
@@ -104,6 +116,10 @@ if(HAVE_POSIX_GETTIME)
   SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
 endif()
 
+if(HAVE_BACKTRACE_IN_LIBEXECINFO)
+  SET(SIMGRID_DEP "${SIMGRID_DEP} -lexecinfo")
+endif(HAVE_BACKTRACE_IN_LIBEXECINFO)
+
 # Compute the dependencies of SMPI
 ##################################
 if(enable_smpi AND APPLE)
index 3699a3a..49a0833 100644 (file)
@@ -31,11 +31,11 @@ set(SIMGRID_DEP "-lws2_32 -L${PATH_PTHREAD_LIB} -lm -lpthreadGC2")
 
 
 if(ARCH_32_BITS)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -march=i486")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -march=i486")
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -march=i486 -D_I_X86_")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -march=i486 -D_I_X86_")
 else()
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -D_AMD64_")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -D_AMD64_")
   #        message(FATAL_ERROR "Sorry, Simgrid fails with full 64bits for now! Please contact us.")
 endif()
 
diff --git a/buildtools/Cmake/Modules/FindLibdw.cmake b/buildtools/Cmake/Modules/FindLibdw.cmake
new file mode 100644 (file)
index 0000000..9e07a38
--- /dev/null
@@ -0,0 +1,55 @@
+find_library(PATH_LIBDW_LIB
+  NAMES dw
+  HINTS
+  $ENV{SIMGRID_LIBDW_LIBRARY_PATH}
+  $ENV{LD_LIBRARY_PATH}
+  $ENV{LIBDW_LIBRARY_PATH}
+  PATH_SUFFIXES lib/ GnuWin32/lib
+  PATHS
+  /opt
+  /opt/local
+  /opt/csw
+  /sw
+  /usr)
+
+
+find_path(PATH_LIBDW_H "elfutils/libdw.h"
+  HINTS
+  $ENV{SIMGRID_LIBDW_LIBRARY_PATH}
+  $ENV{LD_LIBRARY_PATH}
+  $ENV{LIBDW_LIBRARY_PATH}
+  PATH_SUFFIXES include/ GnuWin32/include
+  PATHS
+  /opt
+  /opt/local
+  /opt/csw
+  /sw
+  /usr)
+
+message(STATUS "Looking for libdw.h")
+if(PATH_LIBDW_H)
+  message(STATUS "Looking for libdw.h - found")
+else()
+  message(STATUS "Looking for libdw.h - not found")
+endif()
+
+message(STATUS "Looking for libdw")
+if(PATH_LIBDW_LIB)
+  message(STATUS "Looking for libdw - found")
+else()
+  message(STATUS "Looking for libdw - not found")
+endif()
+
+if(PATH_LIBDW_LIB AND PATH_LIBDW_H)
+  string(REGEX REPLACE "/libdw.*[.]${LIB_EXE}$" "" PATH_LIBDW_LIB "${PATH_LIBDW_LIB}")
+  string(REGEX REPLACE "/libdw.h"               "" PATH_LIBDW_H   "${PATH_LIBDW_H}")
+
+  include_directories(${PATH_LIBDW_H})
+  link_directories(${PATH_LIBDW_LIB})
+
+else()
+  message(FATAL_ERROR "Please either install the libdw-dev package (or equivalent) or turn off the model-checking option of SimGrid.")
+endif()
+
+mark_as_advanced(PATH_LIBDW_H)
+mark_as_advanced(PATH_LIBDW_LIB)
index 56de1f7..03bbed9 100644 (file)
@@ -66,5 +66,5 @@ else()
   message(FATAL_ERROR "Please either install the libunwind7-dev package (or equivalent) or turn off the model-checking option of SimGrid.")
 endif()
 
-mark_as_advanced(PATH_LIBUNWIND_H)
-mark_as_advanced(PATH_LIBUNWIND_LIB)
\ No newline at end of file
+mark_as_advanced(PATH_LIBDW_H)
+mark_as_advanced(PATH_LIBDW_LIB)
index 1c232b8..c0d51ce 100755 (executable)
@@ -20,7 +20,7 @@ JAVA=$2
 STRIP=$3
 shift 3
 
-JSG_BUNDLE=$("$JAVA" -classpath "$SIMGRID_JAR" org.simgrid.msg.NativeLib)
+JSG_BUNDLE=$("$JAVA" -classpath "$SIMGRID_JAR" org.simgrid.NativeLib)
 
 # sanity check
 case "$JSG_BUNDLE" in
index 451b26a..0b819b1 100755 (executable)
@@ -33,6 +33,7 @@ my $tesh_name;
 my $error=0;
 my $exitcode=0;
 my @bg_cmds;
+my (%environ);
 
 $path =~ s|[^/]*$||;
 push @INC,$path;
@@ -40,6 +41,7 @@ push @INC,$path;
 use Getopt::Long qw(GetOptions);
 use strict;
 use Term::ANSIColor;
+use Text::ParseWords;
 use IPC::Open3;
 use IO::File;
 
@@ -51,13 +53,24 @@ else{
     $ENV{"PRINTF_EXPONENT_DIGITS"} = "2"; 
 }
 
-#Add current directory to path
-$ENV{PATH} = "$ENV{PATH}:.";
-
 ##
 ## Command line option handling
 ##
 
+sub var_subst {
+    my ($text, $name, $value) = @_;
+    if ($value) {
+        $text =~ s/\${$name(?::[=-][^}]*)?}/$value/g;
+        $text =~ s/\$$name(\W|$)/$value$1/g;
+    }
+    else {
+        $text =~ s/\${$name:=([^}]*)}/$1/g;
+        $text =~ s/\${$name}//g;
+        $text =~ s/\$$name(\W|$)/$1/g;
+    }
+    return $text;
+}
+
 # option handling helper subs
 sub cd_cmd {
   my $directory=$_[1];
@@ -89,20 +102,8 @@ sub setenv_cmd {
       die "[Tesh/CRITICAL] Malformed argument to setenv: expected 'name=value' but got '$_[1]'\n";
   }
     
-    if($var =~ /bindir/){
-        print "[Tesh/INFO] setenv $var=$ctn\n";
-        $bindir = $ctn;
-    }
-    else
-    {
-        if($var =~ /srcdir/){
-            $srcdir = $ctn;
-        }
-        else{
-            $ENV{$var} = $ctn;
-            print "[Tesh/INFO] setenv $var=$ctn\n";
-        }
-    }    
+  print "[Tesh/INFO] setenv $var=$ctn\n";
+  $environ{$var} = $ctn;
 }
 
 # Main option parsing sub
@@ -220,25 +221,31 @@ sub exec_cmd {
   }
 
   # cleanup the command line
-  if($OS eq "WIN"){
-        $cmd{'cmd'} =~ s/\${EXEEXT:=}/.exe/g;
-        $cmd{'cmd'} =~ s/\${EXEEXT}/.exe/g;
-        $cmd{'cmd'} =~ s/\$EXEEXT/.exe/g;
-    }
-    else{
-        $cmd{'cmd'} =~ s/\${EXEEXT:=}//g;
-    }
-  $cmd{'cmd'} =~ s/\${bindir:=}/$bindir/g;
-  $cmd{'cmd'} =~ s/\${srcdir:=}/$srcdir/g;
-  $cmd{'cmd'} =~ s/\${bindir:=.}/$bindir/g;
-  $cmd{'cmd'} =~ s/\${srcdir:=.}/$srcdir/g;
-  $cmd{'cmd'} =~ s/\${bindir}/$bindir/g;
-  $cmd{'cmd'} =~ s/\${srcdir}/$srcdir/g;
-# $cmd{'cmd'} =~ s|^\./||g;
-#  $cmd{'cmd'} =~ s|tesh|tesh.pl|g;
-  $cmd{'cmd'} =~ s/\(%i:%P@%h\)/\\\(%i:%P@%h\\\)/g;
+  if($OS eq "WIN") {
+      var_subst($cmd{'cmd'}, "EXEEXT", ".exe");
+  } else {
+      var_subst($cmd{'cmd'}, "EXEEXT", "");
+  }
+
+  # substitute environ variables
+  foreach my $key (keys %environ) {
+      $cmd{'cmd'} = var_subst($cmd{'cmd'}, $key, $environ{$key});
+  }
+  # substitute remaining variables, if any
+  while ($cmd{'cmd'} =~ /\${(\w+)(?::[=-][^}]*)?}/) {
+      $cmd{'cmd'} = var_subst($cmd{'cmd'}, $1, "");
+  }
+  while ($cmd{'cmd'} =~ /\$(\w+)/) {
+      $cmd{'cmd'} = var_subst($cmd{'cmd'}, $1, "");
+  }
+
+  # add cfg options
   $cmd{'cmd'} .= " $opts{'cfg'}" if (defined($opts{'cfg'}) && length($opts{'cfg'}));
 
+  # final cleanup
+  $cmd{'cmd'} =~ s/^\s+//;
+  $cmd{'cmd'} =~ s/\s+$//;
+
   print "[$tesh_name:$cmd{'line'}] $cmd{'cmd'}\n" ;
 
   ###
@@ -248,7 +255,8 @@ sub exec_cmd {
   $cmd{'got'} = IO::File->new_tmpfile;
   $cmd{'got'}->autoflush(1);
   local *E = $cmd{'got'}; 
-  $cmd{'pid'} = open3(\*CHILD_IN,  ">&E",  ">&E", $cmd{'cmd'} );
+  $cmd{'pid'} = open3(\*CHILD_IN,  ">&E",  ">&E",
+                      quotewords('\s+', 0, $cmd{'cmd'}));
 
   # push all provided input to executing child
   map { print CHILD_IN "$_\n"; }  @{$cmd{'in'}};
index bd406de..71b4bb4 100644 (file)
 /* Define to 1 if mmalloc is compiled in. */
 #cmakedefine HAVE_MMALLOC @HAVE_MMALLOC@
 
+/* Define to 1 if mmap is available */
+#cmakedefine HAVE_MMAP @HAVE_MMAP@
+
 /* Define to 1 if you have the `getdtablesize' function. */
 #cmakedefine HAVE_GETDTABLESIZE @HAVE_GETDTABLESIZE@
 
index a20e1bd..1c39b5c 100644 (file)
@@ -8,7 +8,7 @@
 #include <stdlib.h>
 
 #ifdef _XBT_WIN32
-#include "win32_ucontext.h"
+#include "xbt/win32_ucontext.h"
 #include "win32_ucontext.c"
 #else
 #include <ucontext.h>
index 35f08bc..8039927 100644 (file)
@@ -9,7 +9,7 @@
 #endif
 
 #ifdef _XBT_WIN32
-#include "win32_ucontext.h"
+#include "xbt/win32_ucontext.h"
 #include "win32_ucontext.c"
 #endif
 
@@ -24,7 +24,7 @@
 
 #if defined(TEST_makecontext)
 #ifdef _XBT_WIN32
-#include "win32_ucontext.h"
+#include "xbt/win32_ucontext.h"
 #else
 #include <ucontext.h>
 #endif
index 96f8afb..c95277c 100755 (executable)
@@ -12,6 +12,8 @@ die () {
   exit $status
 }
 
+ulimit -c 0
+
 rm -rf $WORKSPACE/build
 
 mkdir $WORKSPACE/build
index 7cb21a9..8e7f0ea 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+ulimit -c 0
+
 if [ -e ./pipol ] ; then
        rm -rf ./pipol/$PIPOL_HOST
        mkdir ./pipol/$PIPOL_HOST
index 3247bbc..c696420 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+ulimit -c 0
+
 if [ -e ./pipol ] ; then
        rm -rf ./pipol/$PIPOL_HOST
        mkdir ./pipol/$PIPOL_HOST
index 00ff108..a1720c6 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+ulimit -c 0
+
 #PIPOL esn amd64_2010-linux-ubuntu-maverick.dd.gz none 02:00 --user --silent
 
 if [ -e ./pipol ] ; then
@@ -45,4 +47,4 @@ ctest -D NightlyStart
 ctest -D NightlyConfigure
 ctest -D NightlyBuild
 ctest -D NightlyMemCheck
-ctest -D NightlySubmit
\ No newline at end of file
+ctest -D NightlySubmit
index a19e890..b556483 100755 (executable)
@@ -42,6 +42,8 @@
 #___________________________________________________________________________________________________
 #MacOS Snow Leopard 10.6____________________________________________________________________________
 
+ulimit -c 0
+
 if [ -e ./pipol ] ; then
         rm -rf ./pipol/$PIPOL_HOST
         mkdir ./pipol/$PIPOL_HOST
index 8a65eff..67e8688 100644 (file)
@@ -4,6 +4,7 @@ sudo aptitude update
 
 sudo aptitude -y install cmake
 sudo aptitude -y install default-jdk
+sudo aptitude -y install swig
 sudo aptitude -y install f2c
 sudo aptitude -y install g++
 sudo aptitude -y install gcc
@@ -21,6 +22,7 @@ which_gcc=`which gcc`         #gcc gcc necessary
 which_gpp=`which g++`          #gcc g++ necessary
 which_make=`which make`                #make necessary
 which_java=`which java`                #java optional
+which_swig=`which swig`                #swig optional
 which_lua=`which lua`          #lua
 which_cmake=`which cmake`      #cmake necessary
 which_unzip=`which unzip`      #unzip for gtnets
@@ -35,6 +37,7 @@ echo $which_cmake
 echo $which_unzip
 echo $which_lua
 echo $which_java
+echo $which_swig
 echo $which_make
 echo $which_gcc
 echo $which_gpp
index 6dcc08b..9c0f818 100644 (file)
@@ -11,6 +11,7 @@ sudo yum -y -q install gcc
 sudo yum -y -q install git-core
 sudo yum -y -q install graphviz-dev graphviz
 sudo yum -y -q install java-1.6.0-openjdk
+sudo yum -y -q install swig
 sudo yum -y -q install libunwind libunwind-devel
 sudo yum -y -q install lua-devel lua
 sudo yum -y -q install make
@@ -24,6 +25,7 @@ which_gcc=`which gcc`         #gcc gcc necessary
 which_gpp=`which g++`          #gcc g++ necessary
 which_make=`which make`                #make necessary
 which_java=`which java`                #java optional
+which_swig=`which swig`                #swig optional
 which_lua=`which lua`          #lua
 which_cmake=`which cmake`      #cmake necessary
 which_unzip=`which unzip`      #unzip for gtnets
@@ -38,6 +40,7 @@ echo $which_cmake
 echo $which_unzip
 echo $which_lua
 echo $which_java
+echo $which_swig
 echo $which_make
 echo $which_gcc
 echo $which_gpp
@@ -48,4 +51,4 @@ echo $which_perl
 echo $which_f2c
 echo $which_gcov
 echo $which_git
-echo "FIN------------------------------------"
\ No newline at end of file
+echo "FIN------------------------------------"
index 9fc740a..7538a6c 100644 (file)
@@ -4,6 +4,7 @@
 #sudo port install gcc46
 #sudo port install graphviz-devel
 #sudo port install lua
+#sudo port install swig
 #sudo port select bf2c
 
 sudo port install ruby19
@@ -16,6 +17,7 @@ which_gcc=`which gcc`         #gcc gcc necessary
 which_gpp=`which g++`          #gcc g++ necessary
 which_make=`which make`                #make necessary
 which_java=`which java`                #java optional
+which_java=`which swig`                #swig optional
 which_lua=`which lua`          #lua
 which_cmake=`which cmake`      #cmake necessary
 which_unzip=`which unzip`      #unzip for gtnets
@@ -30,6 +32,7 @@ echo $which_cmake
 echo $which_unzip
 echo $which_lua
 echo $which_java
+echo $which_swig
 echo $which_make
 echo $which_gcc
 echo $which_gpp
@@ -39,4 +42,4 @@ echo $which_perl
 echo $which_f2c
 echo $which_gcov
 echo $which_git
-echo "FIN------------------------------------"
\ No newline at end of file
+echo "FIN------------------------------------"
index b2b9d25..19658e8 100644 (file)
@@ -4,6 +4,7 @@ sudo apt-get update
 
 sudo apt-get -y -qq install cmake
 sudo apt-get -y -qq install default-jdk
+sudo apt-get -y -qq install swig
 sudo apt-get -y -qq install f2c
 sudo apt-get -y -qq install g++
 sudo apt-get -y -qq install gcc
@@ -33,6 +34,7 @@ which_gcc=`which gcc`         #gcc gcc necessary
 which_gpp=`which g++`          #gcc g++ necessary
 which_make=`which make`                #make necessary
 which_java=`which java`                #java optional
+which_swig=`which swig`                #swig optional
 which_lua=`which lua`          #lua
 which_cmake=`which cmake`      #cmake necessary
 which_unzip=`which unzip`      #unzip for gtnets
@@ -47,6 +49,7 @@ echo $which_cmake
 echo $which_unzip
 echo $which_lua
 echo $which_java
+echo $which_swig
 echo $which_make
 echo $which_gcc
 echo $which_gpp
@@ -57,4 +60,4 @@ echo $which_perl
 echo $which_f2c
 echo $which_gcov
 echo $which_git
-echo "FIN------------------------------------"
\ No newline at end of file
+echo "FIN------------------------------------"
diff --git a/contrib/benchmarking_code_block/Rdhist.R b/contrib/benchmarking_code_block/Rdhist.R
new file mode 100644 (file)
index 0000000..76ff210
--- /dev/null
@@ -0,0 +1,313 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2012 University of Illinois, NCSA.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the
+# University of Illinois/NCSA Open Source License
+# which accompanies this distribution, and is available at
+# http://opensource.ncsa.illinois.edu/license.html
+#-------------------------------------------------------------------------------
+##--------------------------------------------------------------------------------------------------#
+##' Variable-width (dagonally cut) histogram
+##'
+##'
+##' When constructing a histogram, it is common to make all bars the same width.
+##' One could also choose to make them all have the same area.
+##' These two options have complementary strengths and weaknesses; the equal-width histogram oversmooths in regions of high density, and is poor at identifying sharp peaks; the equal-area histogram oversmooths in regions of low density, and so does not identify outliers.
+##' We describe a compromise approach which avoids both of these defects. We regard the histogram as an exploratory device, rather than as an estimate of a density.
+##' @name dhist
+##' @title Diagonally Cut Histogram
+##' @param x is a numeric vector (the data)
+##' @param a is the scaling factor, default is 5 * IQR
+##' @param nbins is the number of bins, default is assigned by the Stuges method
+##' @param rx is the range used for the left of the left-most bin to the right of the right-most bin
+##' @param eps used to set artificial bound on min width / max height of bins as described in Denby and Mallows (2009) on page 24.
+##' @param xlab is label for the x axis
+##' @param plot = TRUE produces the plot, FALSE returns the heights, breaks and counts
+##' @param lab.spikes = TRUE labels the \% of data in the spikes
+##' @return list with two elements, heights of length n and breaks of length n+1 indicating the heights and break points of the histogram bars.
+##' @author Lorraine Denby, Colin Mallows
+##' @references Lorraine Denby, Colin Mallows. Journal of Computational and Graphical Statistics. March 1, 2009, 18(1): 21-31. doi:10.1198/jcgs.2009.0002.
+dhist <- function(x, a=5*iqr(x),
+                nbins=nclass.Sturges(x), rx = range(x,na.rm = TRUE),
+                eps=.15, xlab = "x", plot = TRUE,lab.spikes = TRUE)
+{
+
+  if(is.character(nbins))
+    nbins <- switch(casefold(nbins),
+                    sturges = nclass.Sturges(x),
+                    fd = nclass.FD(x),
+                    scott = nclass.scott(x),
+                    stop("Nclass method not recognized"))
+  else if(is.function(nbins))
+    nbins <- nbins(x)
+
+  x <- sort(x[!is.na(x)])
+  if(a == 0)
+    a <- diff(range(x))/100000000
+  if(a != 0 & a != Inf) {
+    n <- length(x)
+    h <- (rx[2] + a - rx[1])/nbins
+    ybr <- rx[1] + h * (0:nbins)
+    yupper <- x + (a * (1:n))/n
+                                        # upper and lower corners in the ecdf
+    ylower <- yupper - a/n
+                                        #
+    cmtx <- cbind(cut(yupper, breaks = ybr), cut(yupper, breaks =
+                                ybr, left.include = TRUE), cut(ylower, breaks = ybr),
+                  cut(ylower, breaks = ybr, left.include = TRUE))
+    cmtx[1, 3] <- cmtx[1, 4] <- 1
+                                        # to replace NAs when default r is used
+    cmtx[n, 1] <- cmtx[n, 2] <- nbins
+                                        #
+                                        #checksum <- apply(cmtx, 1, sum) %% 4
+    checksum <- (cmtx[, 1] + cmtx[, 2] + cmtx[, 3] + cmtx[, 4]) %%
+    4
+                                        # will be 2 for obs. that straddle two bins
+    straddlers <- (1:n)[checksum == 2]
+                                        # to allow for zero counts
+    if(length(straddlers) > 0) {
+      counts <- table(c(1:nbins, cmtx[ - straddlers, 1]))
+    } else {
+      counts <- table(c(1:nbins, cmtx[, 1]))
+    }
+    counts <- counts - 1
+                                        #
+    if(length(straddlers) > 0) {
+      for(i in straddlers) {
+        binno <- cmtx[i, 1]
+        theta <- ((yupper[i] - ybr[binno]) * n)/a
+        counts[binno - 1] <- counts[binno - 1] + (
+                                                  1 - theta)
+        counts[binno] <- counts[binno] + theta
+      }
+    }
+    xbr <- ybr
+    xbr[-1] <- ybr[-1] - (a * cumsum(counts))/n
+    spike<-eps*diff(rx)/nbins
+    flag.vec<-c(diff(xbr)<spike,F)
+    if ( sum(abs(diff(xbr))<=spike) >1) {
+      xbr.new<-xbr
+      counts.new<-counts
+      diff.xbr<-abs(diff(xbr))
+      amt.spike<-diff.xbr[length(diff.xbr)]
+      for (i in rev(2:length(diff.xbr))) {
+        if (diff.xbr[i-1] <= spike&diff.xbr[i] <= spike &
+            !is.na(diff.xbr[i])) {
+          amt.spike <- amt.spike+diff.xbr[i-1]
+          counts.new[i-1] <- counts.new[i-1]+counts.new[i]
+          xbr.new[i] <- NA
+          counts.new[i] <- NA
+          flag.vec[i-1] <- T
+        }
+        else amt.spike<-diff.xbr[i-1]
+      }
+      flag.vec<-flag.vec[!is.na(xbr.new)]
+      flag.vec<-flag.vec[-length(flag.vec)]
+      counts<-counts.new[!is.na(counts.new)]
+      xbr<-xbr.new[!is.na(xbr.new)]
+
+    }
+    else flag.vec<-flag.vec[-length(flag.vec)]
+    widths <- abs(diff(xbr))
+    ## N.B. argument "widths" in barplot must be xbr
+    heights <- counts/widths
+  }
+  bin.size <- length(x)/nbins
+  cut.pt <- unique(c(min(x) - abs(min(x))/1000,
+                     approx(seq(length(x)), x, (1:(nbins - 1)) * bin.size, rule = 2)$y, max(x)))
+  aa <- hist(x, breaks = cut.pt, plot = FALSE, probability = TRUE)
+  if(a == Inf) {
+    heights <- aa$counts
+    xbr <- aa$breaks
+  }
+  amt.height<-3
+  q75<-quantile(heights,.75)
+  if (sum(flag.vec)!=0) {
+    amt<-max(heights[!flag.vec])
+    ylim.height<-amt*amt.height
+    ind.h<-flag.vec&heights> ylim.height
+    flag.vec[heights<ylim.height*(amt.height-1)/amt.height]<-F
+    heights[ind.h] <- ylim.height
+  }
+  amt.txt<-0
+  end.y<-(-10000)
+  if(plot) {
+    barplot(heights, abs(diff(xbr)), space = 0, density = -1, xlab =
+            xlab, plot = TRUE, xaxt = "n",yaxt='n')
+    at <- pretty(xbr)
+    axis(1, at = at - xbr[1], labels = as.character(at))
+    if (lab.spikes) {
+      if (sum(flag.vec)>=1) {
+        usr<-par('usr')
+        for ( i in seq(length(xbr)-1)) {
+          if (!flag.vec[i]) {
+            amt.txt<-0
+            if (xbr[i]-xbr[1]<end.y) amt.txt<-1
+          }
+          else {
+            amt.txt<-amt.txt+1
+            end.y<-xbr[i]-xbr[1]+3*par('cxy')[1]
+          }
+          if (flag.vec[i]) {
+            txt<-paste(' ',format(round(counts[i]/
+                                        sum(counts)*100)),'%',sep='')
+            par(xpd = TRUE)
+            text(xbr[i+1]-xbr[1],ylim.height-par('cxy')[2]*(amt.txt-1),txt, adj=0)
+          }}
+      }
+      else print('no spikes or more than one spike')
+    }
+    invisible(list(heights = heights, xbr = xbr))
+  }
+  else {
+    return(list(heights = heights, xbr = xbr,counts=counts))
+  }
+}
+#==================================================================================================#
+
+
+#--------------------------------------------------------------------------------------------------#
+##' Calculate interquartile range
+##'
+##' Calculates the 25th and 75th quantiles given a vector x; used in function \link{dhist}.
+##' @name iqr
+##' @title Interquartile range
+##' @param x vector
+##' @return numeric vector of length 2, with the 25th and 75th quantiles of input vector x.
+iqr <- function(x){
+  return(diff(quantile(x, c(0.25, 0.75), na.rm = TRUE)))
+}
+##==================================================================================================#
+
+##--------------------------------------------------------------------------------------------------#
+##' Creates empty ggplot object
+##'
+##' An empty base plot to which layers created by other functions
+##' (\code{\link{plot.data}}, \code{\link{plot.prior.density}},
+##' \code{\link{plot.posterior.density}}) can be added.
+##' @name create.base.plot
+##' @title Create Base Plot
+##' @return empty ggplot object
+##' @export
+##' @author David LeBauer
+create.base.plot <- function() {
+  base.plot <- ggplot()
+  return(base.plot)
+}
+#==================================================================================================#
+
+
+
+
+##--------------------------------------------------------------------------------------------------#
+##' Add data to an existing plot or create a new one from \code{\link{create.base.plot}}
+##'
+##' Used to add raw data or summary statistics to the plot of a distribution.
+##' The height of Y is arbitrary, and can be set to optimize visualization.
+##' If SE estimates are available, tehse wil be plotted
+##' @name plot.data
+##' @title Add data to plot
+##' @param trait.data data to be plotted
+##' @param base.plot a ggplot object (grob),
+##' created by \code{\link{create.base.plot}} if none provided
+##' @param ymax maximum height of y
+##' @seealso \code{\link{create.base.plot}}
+##' @return updated plot object
+##' @author David LeBauer
+##' @export
+##' @examples
+##' \dontrun{plot.data(data.frame(Y = c(1, 2), se = c(1,2)), base.plot = NULL, ymax = 10)}
+plot.data <- function(trait.data, base.plot = NULL, ymax, color = 'black') {
+  if(is.null(base.plot)) base.plot <- create.base.plot()
+  n.pts <- nrow(trait.data)
+  if(n.pts == 1){
+    ymax <- ymax/8
+  } else if (n.pts < 5) {
+    ymax <- ymax / 4
+  } else {
+    ymax <- ymax / 2
+  }
+  y.pts <- seq(0, ymax, length.out = 1 + n.pts)[-1]
+  plot.data <- data.frame(x = trait.data$Y,
+                          y = y.pts,
+                          se = trait.data$se,
+                          control = !trait.data$trt == 1 & trait.data$ghs == 1)
+  new.plot <- base.plot +
+    geom_point(data = plot.data,
+               aes(x = x, y = y,
+               color = control)) +
+                 geom_segment(data = plot.data,
+                              aes(x = x - se, y = y, xend = x + se, yend = y,
+                                  color = control)) +
+                                    scale_color_manual(values = c('black', 'grey')) +
+                                      opts(legend_position = "none")
+  return(new.plot)
+}
+##==================================================================================================#
+
+
+#--------------------------------------------------------------------------------------------------#
+##' Add borders to .. content for \description{} (no empty lines) ..
+##'
+##' Has ggplot2 display only specified borders, e.g. ("L"-shaped) borders, rather than a rectangle or no border. Note that the order can be significant; for example, if you specify the L border option and then a theme, the theme settings will override the border option, so you need to specify the theme (if any) before the border option, as above.
+##' @name theme_border
+##' @title Theme border for plot
+##' @param type
+##' @param colour
+##' @param size
+##' @param linetype
+##' @return adds borders to ggplot as a side effect
+##' @author Rudolf Cardinal
+##' @author \url{ggplot2 google group}{https://groups.google.com/forum/?fromgroups#!topic/ggplot2/-ZjRE2OL8lE}
+##' @examples
+##' \dontrun{
+##' df = data.frame( x=c(1,2,3), y=c(4,5,6) )
+##' ggplot(data=df, aes(x=x, y=y)) + geom_point() + theme_bw() +
+##' opts(panel.border = theme_border(c("bottom","left")) )
+##' ggplot(data=df, aes(x=x, y=y)) + geom_point() + theme_bw() +
+##' opts(panel.border = theme_border(c("b","l")) )
+##' }
+theme_border <- function(type = c("left", "right", "bottom", "top",
+                           "none"), colour = "black", size = 1, linetype = 1) {
+  type <- match.arg(type, several.ok=TRUE)
+  structure(
+            function(x = 0, y = 0, width = 1, height = 1, ...) {
+              xlist <- c()
+              ylist <- c()
+              idlist <- c()
+              if ("bottom" %in% type) { # bottom
+                xlist <- append(xlist, c(x, x+width))
+                ylist <- append(ylist, c(y, y))
+                idlist <- append(idlist, c(1,1))
+              }
+              if ("top" %in% type) { # top
+                xlist <- append(xlist, c(x, x+width))
+                ylist <- append(ylist, c(y+height, y+height))
+                idlist <- append(idlist, c(2,2))
+              }
+              if ("left" %in% type) { # left
+                xlist <- append(xlist, c(x, x))
+                ylist <- append(ylist, c(y, y+height))
+                idlist <- append(idlist, c(3,3))
+              }
+              if ("right" %in% type) { # right
+                xlist <- append(xlist, c(x+width, x+width))
+                ylist <- append(ylist, c(y, y+height))
+                idlist <- append(idlist, c(4,4))
+              }
+              polylineGrob(
+                           x=xlist, y=ylist, id=idlist, ..., default.units = "npc",
+                           gp=gpar(lwd=size, col=colour, lty=linetype),
+                           )
+            },
+            class = "theme",
+            type = "box",
+            call = match.call()
+            )
+}
+#==================================================================================================#
+
+
+####################################################################################################
+### EOF. End of R script file.                         
+####################################################################################################
index 92fe61b..991060e 100644 (file)
@@ -3,15 +3,55 @@
 # Can be called from the bash script with the following code:
 # export R_INPUT=$inputfile
 # export R_OUTPUT=$outputfile
+# export R_TYPE=$hist_type
+
 # R CMD BATCH $this_script.R
+#or
+# Rscript $this_script.R
 
 # Use functions from bench.h to benchmark execution time of the desired block,
 # then Rhist.R script to read all timings and produce histograms
 # and finally inject.h to inject values instead of executing block
 
+# This is a small function to help merging empty nbins for dhist histograms
+merge_empty_bins <- function (h)
+{
+  i<-1
+  j<-1
+  counts2<--1
+  breaks2<-h$breaks[1]
+
+  if (length(h$counts)>1)
+    for(i in 1:(length(h$counts)-1))
+      {
+        if(h$counts[i]!=0 || h$counts[i+1]!=0)
+          {
+            counts2[j]<-h$counts[i]
+            breaks2[j+1]<-h$breaks[i+1];
+            j<-j+1
+          }
+      }
   
+  counts2[j]<-h$counts[length(h$counts)]
+  breaks2[j+1]<-h$breaks[length(h$breaks)]
+
+  h$counts<-counts2
+  h$breaks<-breaks2
+
+  return (h)
+}
+
+# Main
+source("analysis/hist_script/Rdhist.R")
+
 inputfile<-Sys.getenv("R_INPUT")
 outputfile<-Sys.getenv("R_OUTPUT")
+type<-Sys.getenv("R_TYPE")
+
+if (!(type %in% c("mean","default","sturges","scott")))
+  {
+    stop("Wrong histogram type")
+  }
 
 df<-read.table(inputfile,header=F)
 df<-df[,c(1,4)]
@@ -21,17 +61,49 @@ attach(df)
 for(i in unique(NAME))
 {
   vector1<-df[NAME==i,2]
-  h<-hist(vector1)
-  
+
+  if (length(vector1)==1)
+    {
+      #If there is only one element
+      h<-hist(vector1) # Just for R compatibility reasons
+      h$breaks<-c(vector1,vector1)
+      h$counts<-1
+    }
+  else
+    {
+      if (type=="mean")
+        {
+          #Mean value only
+          h<-hist(vector1) # Just for R compatibility reasons
+          h$breaks<-c(mean(vector1),mean(vector1))
+          h$counts<-length(vector1)
+        }
+      else
+        if (type=="default")
+          #Standard HISTOGRAM:
+          h<-hist(vector1)
+        else
+          {
+            #Dhist:
+            h<-dhist(vector1,nbins=type, plot = FALSE, lab.spikes = FALSE, a=5*iqr(vector1), eps=0.15)
+            h$breaks<-h$xbr
+            h$count<-as.vector(h$counts)
+            h$counts<-h$count
+            h<-merge_empty_bins(h)
+          }
+    }
+    
   cat(i, file = outputfile, sep = "\t", append = TRUE)
-  cat("  ", file = outputfile, sep = "\t", append = TRUE)
-  cat(sprintf("%.8f", mean(vector1)), file =outputfile, sep = "\t ", append = TRUE)
+  cat("\t", file = outputfile,  append = TRUE)
+  cat(sum(h$counts), file =outputfile, sep = "\t", append = TRUE)
+  cat("\t", file = outputfile,  append = TRUE)
+  cat(sprintf("%.8f", mean(vector1)), file =outputfile, sep = "\t", append = TRUE)
   cat("\t", file = outputfile,  append = TRUE)
   cat(length(h$breaks), file = outputfile, append = TRUE)
   cat("\t", file = outputfile,  append = TRUE)
-  cat(sprintf("%.8f", h$breaks), file = outputfile, sep = " \t", append = TRUE)
+  cat(sprintf("%.8f", h$breaks), file = outputfile, sep = "\t", append = TRUE)
   cat("\t", file = outputfile,  append = TRUE)
   h$density = h$counts/sum(h$counts)
-  cat(sprintf("%.14f", h$density), file = outputfile, sep = " \t", append = TRUE)
+  cat(sprintf("%.8f", h$density), file = outputfile, sep = "\t", append = TRUE)
   cat("\n", file = outputfile,  append = TRUE)
 }
diff --git a/contrib/benchmarking_code_block/Rplot_hist.R b/contrib/benchmarking_code_block/Rplot_hist.R
new file mode 100644 (file)
index 0000000..1f7487a
--- /dev/null
@@ -0,0 +1,72 @@
+# R script showing .pdf file with plots of all injection histograms for a certain file
+
+# Can be called from the command line with:
+# Rscript $this_script.R inputfile
+
+# Necessary libraries
+library(plyr)
+library(ggplot2)
+library(data.table)
+library(grid)
+
+# Functions for arranging multiple plots
+vp.layout <- function(x, y) viewport(layout.pos.row=x, layout.pos.col=y)
+arrange_ggplot2 <- function(list, nrow=NULL, ncol=NULL, as.table=FALSE) {
+n <- length(list)
+if(is.null(nrow) & is.null(ncol)) { nrow = floor(n/2) ; ncol = ceiling(n/nrow)}
+if(is.null(nrow)) { nrow = ceiling(n/ncol)}
+if(is.null(ncol)) { ncol = ceiling(n/nrow)}
+## NOTE see n2mfrow in grDevices for possible alternative
+grid.newpage()
+pushViewport(viewport(layout=grid.layout(nrow,ncol) ) )
+ii.p <- 1
+for(ii.row in seq(1, nrow)){
+ii.table.row <- ii.row
+if(as.table) {ii.table.row <- nrow - ii.table.row + 1}
+for(ii.col in seq(1, ncol)){
+ii.table <- ii.p
+if(ii.p > n) break
+print(list[[ii.table]], vp=vp.layout(ii.table.row, ii.col))
+ii.p <- ii.p + 1
+}
+}
+}
+
+### Main
+
+# Reading command line argument with the input file path
+args <- commandArgs(trailingOnly = TRUE)
+fp  <- file(args[1], open = "r")
+
+plots<-list()
+i<-1
+
+# Reading histograms one by one, line by line
+while (length(oneLine <- readLines(fp, n = 1, warn = FALSE)) > 0)
+{ myVector <- (strsplit(oneLine, "\t")) 
+  
+  dfl <- ldply (myVector, data.frame)
+
+  name<-as.character(dfl[1,])
+  nbins<-as.numeric(as.character(dfl[4,]))
+  allbreaks<-as.numeric(as.character(dfl[5:(5+nbins-1),]))
+  
+  dh<-data.frame(Name=as.character(dfl[1,]), Total=as.numeric(as.character(dfl[2,])), Mean=as.numeric(as.character(dfl[3,])), Nbins=as.numeric(as.character(dfl[4,])))
+  dh<-cbind(dh,Bstart=allbreaks[-length(allbreaks)])
+  dh<-cbind(dh,Bend=allbreaks[-1])
+  dh<-cbind(dh,Density=as.numeric(as.character(dfl[(5+nbins):(5+nbins*2-2),])))
+
+  # Plotting single histogram, if it only has one value then use geom_bar
+  if (nbins > 2)
+    plots[[i]]<-ggplot(data=data.frame(dh), aes(xmin=Bstart, xmax=Bend, ymin=0, ymax=Density)) + geom_rect(aes(fill=Density)) + theme_bw() + scale_x_continuous("Time [s]", allbreaks) + labs(title=name, y=element_text("Density %"))
+  else
+    plots[[i]]<-ggplot(data=data.frame(dh), aes(factor(Bstart))) + geom_bar(aes(fill=Density)) + theme_bw() + labs(title=name, y=element_text("Density %"), x=element_text("Time [s]"))
+
+  i<-i+1
+}
+
+# Printing all plots together in a table
+arrange_ggplot2(plots, as.table=TRUE)
+
+# End
+write("Done producing a histogram plot. Open Rplots.pdf located in this folder to see the results", stdout())
index f4d9fa2..57e2c82 100644 (file)
 #include "xbt/dict.h"
 #include "xbt/sysdep.h"
 
-#define MAX_LINE_INJ 1000
+#define MAX_LINE_INJ 10000
 
 /*
  * Histogram entry for each measured block
  * Each entry is guarded inside xbt dictionary which is read from the file */
 typedef struct xbt_hist {
        int n;
+       int counts;
        double mean;
        double *breaks;
        double *percentage;
@@ -68,7 +69,7 @@ static inline void xbt_inject_init(char *inputfile)
                printf("Error input file is empty!");//Skipping first row
        while (fgets(line, 200, fpInput) != NULL)
        {
-               key = strtok(line, " \t");
+               key = strtok(line, "\t");
 
                data = xbt_dict_get_or_null(mydict, key);
                if (data)
@@ -77,15 +78,16 @@ static inline void xbt_inject_init(char *inputfile)
                data = (xbt_hist_t *) xbt_new(xbt_hist_t, 1);
 
                data->block_id = key;
-               data->mean = atof(strtok(NULL, " \t"));
-               data->n = atoi(strtok(NULL, " \t"));
+               data->counts = atoi(strtok(NULL, "\t"));
+               data->mean = atof(strtok(NULL, "\t"));
+               data->n = atoi(strtok(NULL, "\t"));
 
                data->breaks = (double*) malloc(sizeof(double) * data->n);
                data->percentage = (double*) malloc(sizeof(double) * (data->n - 1));
                for (i = 0; i < data->n; i++)
-                       data->breaks[i] = atof(strtok(NULL, " \t"));
+                       data->breaks[i] = atof(strtok(NULL, "\t"));
                for (i = 0; i < (data->n - 1); i++)
-                       data->percentage[i] = atof(strtok(NULL, " \t"));
+                       data->percentage[i] = atof(strtok(NULL, "\t"));
 
                xbt_dict_set(mydict, key, data, NULL);
        }
@@ -103,7 +105,10 @@ static inline void inject_init_starpu(char *inputfile, xbt_dict_t *dict, RngStre
        mydict = *dict;
        FILE* fpInput = fopen(inputfile, "r");
        if (fpInput == NULL)
+       {
                printf("Error while opening the inputfile");
+               return;
+       }
 
        fseek(fpInput, 0, 0);
 
@@ -113,12 +118,15 @@ static inline void inject_init_starpu(char *inputfile, xbt_dict_t *dict, RngStre
        xbt_hist_t* data;
 
        if (fgets(line, MAX_LINE_INJ, fpInput) == NULL)
+       {
                printf("Error input file is empty!");//Skipping first row
+               return;
+       }
 
 
        while (fgets(line, MAX_LINE_INJ, fpInput) != NULL)
        {
-               key = strtok(line, " \t");
+               key = strtok(line, "\t");
 
                data = xbt_dict_get_or_null(mydict, key);
                if (data)
@@ -126,16 +134,17 @@ static inline void inject_init_starpu(char *inputfile, xbt_dict_t *dict, RngStre
 
                data = (xbt_hist_t *) xbt_new(xbt_hist_t, 1);
                data->block_id = key;
-               data->mean = atof(strtok(NULL, " \t"));
-               data->n = atoi(strtok(NULL, " \t"));
+               data->counts = atoi(strtok(NULL, "\t"));
+               data->mean = atof(strtok(NULL, "\t"));
+               data->n = atoi(strtok(NULL, "\t"));
                data->breaks = (double*) malloc(sizeof(double) * data->n);
                data->percentage = (double*) malloc(sizeof(double) * (data->n - 1));
 
                for (i = 0; i < data->n; i++)
-                       data->breaks[i] = atof(strtok(NULL, " \t"));
+                       data->breaks[i] = atof(strtok(NULL, "\t"));
                        for (i = 0; i < (data->n - 1); i++)
                        {
-                               data->percentage[i] = atof(strtok(NULL, " \t"));
+                               data->percentage[i] = atof(strtok(NULL, "\t"));
                        }
 
                xbt_dict_set(mydict, key, data, NULL);
index 7453925..9976bac 100644 (file)
@@ -1580,7 +1580,11 @@ INCLUDE_FILE_PATTERNS  =
 
 PREDEFINED             = DOXYGEN \
                          DOXYGEN_SKIP_IT \
-                         XBT_PUBLIC= \
+                         XBT_PUBLIC(type)="extern type" \
+                         XBT_EXPORT_NO_IMPORT(type)=type \
+                         XBT_IMPORT_NO_EXPORT(type)=type \
+                         XBT_PUBLIC_DATA(type)="extern type" \
+                         XBT_PUBLIC_CLASS=class \
                          XBT_INLINE= \
                          HAVE_TRACING \
                          MSG_USE_DEPRECATED
index 63aebcf..b557898 100644 (file)
@@ -130,7 +130,7 @@ Note that compile-time options are very different from @ref options
 
 The default configuration should be ok for most usages, but if you
 need to change something, there is several ways to do so. First, you
-can use environment variable. For example, you can change the used
+can use environment variables. For example, you can change the used
 compilers by issuing these commands before launching cmake:
 
 @verbatim
@@ -138,6 +138,9 @@ export CC=gcc-4.4
 export CXX=g++-4.4
 @endverbatim
 
+Note that other variables are available, such as CFLAGS and CXXFLAGS to add
+options for respectively the C compiler and the C++ compiler.
+
 Another way to do so is to use the -D argument of cmake as follows.
 Note that the terminating dot is mandatory (see @ref
 install_cmake_outsrc to understand its meaning).
index e06e223..a4902d6 100644 (file)
@@ -361,6 +361,20 @@ unset.
     availability. Similar to <b>hosts</b> attribute. 
 \li <b>state_file</b>: Allow you to use a file as input for states.
     Similar to <b>hosts</b> attribute. 
+\li <b>loopback_bw </b>: bandwidth for loopback (if any). See <b>link</b>
+    section for syntax/details. If both loopback_* attributes are omitted,
+    no loopback link is created and all intra-node communication will 
+    use the main network link of the node. Loopback link is a <b>FATPIPE</b>.
+\li <b>loopback_lat </b>: latency for loopback (if any). See <b>link</b>
+    section for syntax/details. See loopback_bw for more info.
+\li <b>topology </b>: network topology to use. For now SimGrid supports FLAT 
+     (default, with or without backbone, as described before) or 
+     <a href="http://en.wikipedia.org/wiki/Torus_interconnect">TORUS
+     </a> attributes for this tag.
+\li <b>topo_parameters </b>: specific parameters to pass for the topology 
+     defined in the topology tag. For torus networks, comma-separated list of 
+    the number of nodes in each dimension of the torus.
+
 
 the router name is defined as the resulting String in the following
 java line of code: 
diff --git a/examples/java/reservationSurfPlugin/CMakeLists.txt b/examples/java/reservationSurfPlugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bef5627
--- /dev/null
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 2.6)
+
+set(example java_reservation_surf_plugin)
+set(sources
+   ${CMAKE_CURRENT_SOURCE_DIR}/TestPlugin.java
+   ${CMAKE_CURRENT_SOURCE_DIR}/ReservationPlugin.java
+   ${CMAKE_CURRENT_SOURCE_DIR}/Sender.java
+   ${CMAKE_CURRENT_SOURCE_DIR}/Receiver.java
+  )
+
+if(enable_java)
+  add_custom_command(
+    COMMENT "Building ${example}..."
+    OUTPUT ${example}_compiled
+    DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
+    COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR}
+                             -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources}
+    COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled
+    COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled
+  )
+  add_custom_target(${example} ALL DEPENDS ${example}_compiled)
+endif()
+
+set(tesh_files
+  ${tesh_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/reservation_surf_plugin.tesh
+  PARENT_SCOPE
+  )
+set(xml_files
+  ${xml_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/reservationSurfPluginPlatform.xml
+  ${CMAKE_CURRENT_SOURCE_DIR}/reservationSurfPluginDeployment.xml
+  PARENT_SCOPE
+  )
+set(examples_src
+  ${examples_src}
+  ${sources}
+  PARENT_SCOPE
+  )
+set(bin_files
+  ${bin_files}
+  PARENT_SCOPE
+  )
+set(txt_files
+  ${txt_files}
+  PARENT_SCOPE
+  )
diff --git a/examples/java/reservationSurfPlugin/Receiver.java b/examples/java/reservationSurfPlugin/Receiver.java
new file mode 100644 (file)
index 0000000..7097e5b
--- /dev/null
@@ -0,0 +1,32 @@
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package reservationSurfPlugin;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+
+public class Receiver extends Process {
+   public Receiver(Host host, String name, String[]args) {
+               super(host,name,args);
+   }
+   final double commSizeLat = 1;
+   final double commSizeBw = 100000000;
+
+   public void main(String[] args) throws MsgException {
+
+      Msg.info("helloo!");
+
+      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
new file mode 100644 (file)
index 0000000..8cf24b7
--- /dev/null
@@ -0,0 +1,46 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package reservationSurfPlugin;
+
+import org.simgrid.surf.*;
+import org.simgrid.msg.Msg;
+import java.util.HashMap;
+
+public class ReservationPlugin extends Plugin {
+
+  public ReservationPlugin() {
+    activateNetworkCommunicateCallback();
+  }
+
+  //HashMap<String,Reservation> reservations;
+  double bandwidth = 0;
+  String src = "";
+  String dst = "";
+
+  public void limitBandwidthActions(String src, String dst, double bandwidth){
+    this.bandwidth = bandwidth;
+    this.src = src;
+    this.dst = dst;
+  }
+
+  public void updateBandwidthRoute(String src, String dst, double bandwidth){
+    NetworkLink[] route = Surf.getRoute(src, dst);
+    for (int i =0; i<route.length; i++){
+      Msg.info("Trace: bandwidth of "+route[i].getName()+" before "+route[i].getBandwidth());
+      route[i].updateBandwidth(bandwidth);//getName();
+      Msg.info("Trace: bandwidth of "+route[i].getName()+" after "+route[i].getBandwidth());
+    }
+  }
+
+  public void networkCommunicateCallback(NetworkAction action, RoutingEdge src, RoutingEdge dst, double size, double rate){
+    if (src.getName().equals(this.src) && dst.getName().equals(this.dst)) {
+      action.setBound(this.bandwidth);
+    }
+    Msg.info("Trace: Communicate message of size "+size+" with rate "+rate+" and bound "+action.getBound()+" from "+src.getName()+" to "+dst.getName());
+  }
+
+}
diff --git a/examples/java/reservationSurfPlugin/Sender.java b/examples/java/reservationSurfPlugin/Sender.java
new file mode 100644 (file)
index 0000000..5f6ca38
--- /dev/null
@@ -0,0 +1,53 @@
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package reservationSurfPlugin;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.Task;
+
+public class Sender extends Process {
+       public Sender(Host host, String name, String[] args) {
+               super(host,name,args);
+       }
+    private final double commSizeLat = 1;
+    final double commSizeBw = 100000000;
+
+    public void main(String[] args) throws MsgException {
+
+       Msg.info("helloo!");
+
+       String receiverName = args[0];
+       double oldTime, curTime;
+       double computeDuration = 10000;
+       Task task;
+
+       oldTime = Msg.getClock();
+            task = new Task("no name",computeDuration,commSizeLat);
+            task.send(receiverName);
+       curTime = Msg.getClock();
+       Msg.info("Send duration: " + (curTime - oldTime));
+
+       TestPlugin.tp.updateBandwidthRoute("Jacquelin", "Boivin", 10E2);
+       oldTime = curTime;
+       task = new Task("no name",computeDuration,commSizeLat);
+       task.send(receiverName);
+       curTime = Msg.getClock();
+       Msg.info("Send duration with update bandwidth: " + (curTime - oldTime));
+
+       TestPlugin.tp.limitBandwidthActions("Jacquelin", "Boivin", 10E1);
+       oldTime = curTime;
+       task = new Task("no name",computeDuration,commSizeLat);
+       task.send(receiverName);
+       curTime = Msg.getClock();
+       Msg.info("Send normal duration with limited bandwidth: " + (curTime - oldTime));
+
+       Msg.info("goodbye!");
+    }
+}
diff --git a/examples/java/reservationSurfPlugin/TestPlugin.java b/examples/java/reservationSurfPlugin/TestPlugin.java
new file mode 100644 (file)
index 0000000..64e0a6c
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package reservationSurfPlugin;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.NativeException;
+import org.simgrid.surf.Surf;
+import org.simgrid.surf.Cpu;
+
+public class TestPlugin {
+
+  /* This only contains the launcher. If you do nothing more than than you can run
+  *   java simgrid.msg.Msg
+  * which also contains such a launcher
+  */
+  public static ReservationPlugin tp = new ReservationPlugin();
+
+  public static void main(String[] args) throws NativeException {
+    /* initialize the MSG simulation. Must be done before anything else (even logging). */
+    Msg.init(args);
+    if(args.length < 2) {
+      Msg.info("Usage   : TestPlugin platform_file deployment_file");
+      Msg.info("example : TestPlugin ping_pong_platform.xml ping_pong_deployment.xml");
+      System.exit(1);
+    }
+
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
+
+
+
+    // getName());
+    /*  execute the simulation. */
+    Msg.run();
+  }
+}
diff --git a/examples/java/reservationSurfPlugin/reservationSurfPluginDeployment.xml b/examples/java/reservationSurfPlugin/reservationSurfPluginDeployment.xml
new file mode 100644 (file)
index 0000000..c238e1e
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+  <process host="Jacquelin" function="reservationSurfPlugin.Sender">
+      <argument value="Boivin"/>
+  </process>
+<process host="Boivin" function="reservationSurfPlugin.Receiver"/>
+</platform>
diff --git a/examples/java/reservationSurfPlugin/reservationSurfPluginPlatform.xml b/examples/java/reservationSurfPlugin/reservationSurfPluginPlatform.xml
new file mode 100644 (file)
index 0000000..155dd2d
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version='1.0'?>
+ <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+ <platform version="3">
+ <AS  id="AS0"  routing="Full">
+   <host id="Jacquelin" power="137.333Mf"/>
+   <host id="Boivin" power="98.095Mf"/>
+   <host id="TeX" power="68.667Mf"/>
+   <link id="link0" bandwidth="1MBps" latency="1ms"/>
+   <link id="link1" bandwidth="1MBps" latency="1ms"/>
+   <link id="link2" bandwidth="1MBps" latency="1ms"/>
+   <route src="Jacquelin" dst="Boivin">
+     <link_ctn id="link0"/>
+     <link_ctn id="link1"/>
+   </route>
+   <route src="Jacquelin" dst="TeX">
+     <link_ctn id="link0"/>
+     <link_ctn id="link2"/>
+   </route>
+
+ </AS>
+ </platform>
diff --git a/examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh b/examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh
new file mode 100644 (file)
index 0000000..3d2e4b2
--- /dev/null
@@ -0,0 +1,19 @@
+#! tesh
+
+$ 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.
+> [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/surfCpuModel/CMakeLists.txt b/examples/java/surfCpuModel/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2af5240
--- /dev/null
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 2.6)
+
+set(example java_surf_cpu_model)
+set(sources
+   ${CMAKE_CURRENT_SOURCE_DIR}/TestCpuModel.java
+   ${CMAKE_CURRENT_SOURCE_DIR}/CpuConstantModel.java
+   ${CMAKE_CURRENT_SOURCE_DIR}/Sender.java
+   ${CMAKE_CURRENT_SOURCE_DIR}/Receiver.java
+  )
+
+if(enable_java)
+  add_custom_command(
+    COMMENT "Building ${example}..."
+    OUTPUT ${example}_compiled
+    DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
+    COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR}
+                             -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources}
+    COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled
+    COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled
+  )
+  add_custom_target(${example} ALL DEPENDS ${example}_compiled)
+endif()
+
+set(tesh_files
+  ${tesh_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/surf_cpu_model.tesh
+  PARENT_SCOPE
+  )
+set(xml_files
+  ${xml_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/surfCpuModelPlatform.xml
+  ${CMAKE_CURRENT_SOURCE_DIR}/surfCpuModelDeployment.xml
+  PARENT_SCOPE
+  )
+set(examples_src
+  ${examples_src}
+  ${sources}
+  PARENT_SCOPE
+  )
+set(bin_files
+  ${bin_files}
+  PARENT_SCOPE
+  )
+set(txt_files
+  ${txt_files}
+  PARENT_SCOPE
+  )
diff --git a/examples/java/surfCpuModel/CpuConstantModel.java b/examples/java/surfCpuModel/CpuConstantModel.java
new file mode 100644 (file)
index 0000000..7f7d418
--- /dev/null
@@ -0,0 +1,117 @@
+package surfCpuModel;
+
+import org.simgrid.surf.*;
+import org.simgrid.msg.Msg;
+import java.util.List;
+import java.util.ArrayList;
+
+public class CpuConstantModel extends CpuModel {
+
+  private List<CpuConstant> cpus = new ArrayList<CpuConstant>();
+
+  public CpuConstantModel() {
+    super("Cpu Constant");
+    Msg.info("Initialize Cpu Constant Model");
+  }
+
+  public Cpu createResource(String name, double[] power_peak, int pstate, double power_scale, TmgrTrace power_trace, int core, ResourceState state_initial, TmgrTrace state_trace, XbtDict cpu_properties) {
+    Msg.info("New Cpu("+name+", "+power_peak[pstate]+", "+power_scale+")");
+
+    CpuConstant res = new CpuConstant(this, name, cpu_properties, core, power_peak[pstate], power_scale);
+    cpus.add(res);
+    Surf.setCpu(name, res);
+    return res;
+  }
+
+  public double shareResources(double now) {
+    double res = -1;
+    for (int i=0; i<cpus.size();i++){
+      double tmp = cpus.get(i).share(now);
+      if (tmp!=-1 && (res==-1 || tmp<res))
+        res = tmp;
+    }
+    Msg.info("ShareResources at time "+res);
+    return res;
+  }
+
+  public void updateActionsState(double now, double delta) {
+    Action[] actions = getRunningActionSet().getArray();
+    Msg.info("UpdateActionState of "+actions.length+" actions");
+    for (int i=0; i<actions.length; i++) {
+      CpuConstantAction action = (CpuConstantAction)actions[i];
+      action.update(delta);
+      if (!action.sleeping()) {
+        Msg.info("action remains "+action.getRemains()+" after delta of "+delta);
+        if (action.getRemains()==0.0){
+          action.setState(ActionState.SURF_ACTION_DONE);
+          Msg.info("action DONE");
+        }
+      }
+    }
+  }
+
+  public void addTraces() {
+  }
+
+public class CpuConstant extends Cpu {
+  private List<CpuConstantAction> actions = new ArrayList<CpuConstantAction>();
+
+  public CpuConstant(CpuConstantModel model, String name, XbtDict props,
+                     int core, double powerPeak, double powerScale) {
+    super(model, name, props, core, powerPeak, powerScale);
+  }
+
+  public void remove(CpuConstantAction action){
+    actions.remove(action);
+  }
+
+  public CpuAction execute(double size) {
+    CpuConstantAction res = new CpuConstantAction(getModel(), size, false, false, this);
+    Msg.info("Execute action of size "+size+" sleeping "+res.sleeping());
+    actions.add(res);
+    return res;
+  }
+
+  public CpuAction sleep(double duration) {
+    CpuConstantAction res = new CpuConstantAction(getModel(), duration, false, true, this);
+    Msg.info("Sleep action of duration "+duration+" sleeping "+res.sleeping());
+    return res;
+  }
+
+  public double share(double now){
+    double res = -1;
+    for (int i=0; i<actions.size();i++){
+      double tmp = actions.get(i).getRemains()/getCurrentPowerPeak();
+      Msg.info("Share action with new time "+tmp);
+      if (res==-1 || tmp<res)
+        res = tmp;
+    }
+    return res;
+  }
+
+  public ResourceState getState(){
+    return ResourceState.SURF_RESOURCE_ON;
+  }
+}
+
+public class CpuConstantAction extends CpuAction {
+  boolean sleep;
+  CpuConstant cpu;
+  public CpuConstantAction(Model model, double cost, boolean failed, boolean sleep, CpuConstant cpu) {
+    super(model, cost, failed);
+    this.sleep = sleep;
+    this.cpu = cpu;
+  }
+
+  public void update(double delta){
+    updateRemains(delta*cpu.getCurrentPowerPeak());
+  }
+  public synchronized void delete() {
+    cpu.remove(this);
+    super.delete();
+  }
+
+  public boolean sleeping() {return sleep;}
+  public void setPriority(double priority) {}
+}
+}
diff --git a/examples/java/surfCpuModel/Receiver.java b/examples/java/surfCpuModel/Receiver.java
new file mode 100644 (file)
index 0000000..41779a5
--- /dev/null
@@ -0,0 +1,31 @@
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package surfCpuModel;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+
+public class Receiver extends Process {
+   public Receiver(Host host, String name, String[]args) {
+               super(host,name,args);
+   }
+   final double commSizeLat = 1;
+   final double commSizeBw = 100000000;
+
+   public void main(String[] args) throws MsgException {
+
+      Msg.info("helloo!");
+
+      Task task;
+      task = Task.receive(getHost().getName());
+      task.execute();
+
+      Msg.info("goodbye!");
+    }
+}
diff --git a/examples/java/surfCpuModel/Sender.java b/examples/java/surfCpuModel/Sender.java
new file mode 100644 (file)
index 0000000..908dac4
--- /dev/null
@@ -0,0 +1,39 @@
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package surfCpuModel;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.Task;
+
+public class Sender extends Process {
+       public Sender(Host host, String name, String[] args) {
+               super(host,name,args);
+       }
+    private final double commSizeLat = 1;
+    final double commSizeBw = 100000000;
+
+    public void main(String[] args) throws MsgException {
+
+       Msg.info("helloo!");
+
+       String receiverName = args[0];
+       double oldTime, curTime;
+       double computeDuration = 10E8;
+       Task task;
+
+       oldTime = Msg.getClock();
+            task = new Task("no name",computeDuration,commSizeLat);
+            task.send(receiverName);
+       curTime = Msg.getClock();
+       Msg.info("Send duration: " + (curTime - oldTime));
+
+       Msg.info("goodbye!");
+    }
+}
diff --git a/examples/java/surfCpuModel/TestCpuModel.java b/examples/java/surfCpuModel/TestCpuModel.java
new file mode 100644 (file)
index 0000000..5dc900f
--- /dev/null
@@ -0,0 +1,43 @@
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package surfCpuModel;
+
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.NativeException;
+import org.simgrid.surf.Surf;
+import org.simgrid.surf.Cpu;
+import org.simgrid.surf.CpuModel;
+
+public class TestCpuModel {
+
+  /* This only contains the launcher. If you do nothing more than than you can run
+  *   java simgrid.msg.Msg
+  * which also contains such a launcher
+  */
+
+  public static void main(String[] args) throws NativeException {
+    /* initialize the MSG simulation. Must be done before anything else (even logging). */
+    CpuConstantModel cm = new CpuConstantModel();
+    Surf.setCpuModel(cm);
+
+    Msg.init(args);
+
+    if(args.length < 2) {
+      Msg.info("Usage   : TestPlugin platform_file deployment_file");
+      Msg.info("example : TestPlugin ping_pong_platform.xml ping_pong_deployment.xml");
+      System.exit(1);
+    }
+
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
+    Msg.info("Cpu Loaded: "+Surf.getCpuModel().getName());
+
+    /*  execute the simulation. */
+    Msg.run();
+  }
+}
diff --git a/examples/java/surfCpuModel/surfCpuModelDeployment.xml b/examples/java/surfCpuModel/surfCpuModelDeployment.xml
new file mode 100644 (file)
index 0000000..0cb8e3b
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+  <process host="Jacquelin" function="surfCpuModel.Sender">
+      <argument value="Boivin"/>
+  </process>
+<process host="Boivin" function="surfCpuModel.Receiver"/>
+</platform>
diff --git a/examples/java/surfCpuModel/surfCpuModelPlatform.xml b/examples/java/surfCpuModel/surfCpuModelPlatform.xml
new file mode 100644 (file)
index 0000000..155dd2d
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version='1.0'?>
+ <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+ <platform version="3">
+ <AS  id="AS0"  routing="Full">
+   <host id="Jacquelin" power="137.333Mf"/>
+   <host id="Boivin" power="98.095Mf"/>
+   <host id="TeX" power="68.667Mf"/>
+   <link id="link0" bandwidth="1MBps" latency="1ms"/>
+   <link id="link1" bandwidth="1MBps" latency="1ms"/>
+   <link id="link2" bandwidth="1MBps" latency="1ms"/>
+   <route src="Jacquelin" dst="Boivin">
+     <link_ctn id="link0"/>
+     <link_ctn id="link1"/>
+   </route>
+   <route src="Jacquelin" dst="TeX">
+     <link_ctn id="link0"/>
+     <link_ctn id="link2"/>
+   </route>
+
+ </AS>
+ </platform>
diff --git a/examples/java/surfCpuModel/surf_cpu_model.tesh b/examples/java/surfCpuModel/surf_cpu_model.tesh
new file mode 100644 (file)
index 0000000..00a34ed
--- /dev/null
@@ -0,0 +1,33 @@
+#! tesh
+
+$ java -classpath ${classpath:=.} surfCpuModel/TestCpuModel ${srcdir:=.}/surfCpuModel/surfCpuModelPlatform.xml ${srcdir:=.}/surfCpuModel/surfCpuModelDeployment.xml --cfg=workstation/model:compound
+> [0.000000] [jmsg/INFO] Initialize Cpu Constant Model
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'workstation/model' to 'compound'
+> [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up.
+> [0.000000] [jmsg/INFO] New Cpu(Jacquelin, 1.37333E8, 1.0)
+> [0.000000] [jmsg/INFO] New Cpu(Boivin, 9.8095E7, 1.0)
+> [0.000000] [jmsg/INFO] New Cpu(TeX, 6.8667E7, 1.0)
+> [0.000000] [jmsg/INFO] UpdateActionState of 0 actions
+> [0.000000] [jmsg/INFO] Cpu Loaded: Cpu Constant
+> [Jacquelin:surfCpuModel.Sender:(1) 0.000000] [jmsg/INFO] helloo!
+> [Boivin:surfCpuModel.Receiver:(2) 0.000000] [jmsg/INFO] helloo!
+> [0.000000] [jmsg/INFO] Sleep action of duration -1.0 sleeping true
+> [0.000000] [jmsg/INFO] Sleep action of duration -1.0 sleeping true
+> [0.000000] [jmsg/INFO] ShareResources at time -1.0
+> [0.000000] [jmsg/INFO] ShareResources at time -1.0
+> [0.026020] [jmsg/INFO] UpdateActionState of 2 actions
+> [0.026020] [jmsg/INFO] ShareResources at time -1.0
+> [0.026020] [jmsg/INFO] ShareResources at time -1.0
+> [0.026021] [jmsg/INFO] UpdateActionState of 2 actions
+> [Jacquelin:surfCpuModel.Sender:(1) 0.026021] [jmsg/INFO] Send duration: 0.026021030927835052
+> [Jacquelin:surfCpuModel.Sender:(1) 0.026021] [jmsg/INFO] goodbye!
+> [0.026021] [jmsg/INFO] Execute action of size 1.0E9 sleeping false
+> [0.026021] [jmsg/INFO] Share action with new time 10.194199500484224
+> [0.026021] [jmsg/INFO] ShareResources at time 10.194199500484224
+> [0.026021] [jmsg/INFO] Share action with new time 10.194199500484224
+> [0.026021] [jmsg/INFO] ShareResources at time 10.194199500484224
+> [10.220221] [jmsg/INFO] UpdateActionState of 1 actions
+> [10.220221] [jmsg/INFO] action remains 0.0 after delta of 10.194199500484224
+> [10.220221] [jmsg/INFO] action DONE
+> [Boivin:surfCpuModel.Receiver:(2) 10.220221] [jmsg/INFO] goodbye!
+> [10.220221] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
diff --git a/examples/java/surfPlugin/CMakeLists.txt b/examples/java/surfPlugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2773890
--- /dev/null
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 2.6)
+
+set(example java_surf_plugin)
+set(sources
+   ${CMAKE_CURRENT_SOURCE_DIR}/TestPlugin.java
+   ${CMAKE_CURRENT_SOURCE_DIR}/TracePlugin.java
+   ${CMAKE_CURRENT_SOURCE_DIR}/Sender.java
+   ${CMAKE_CURRENT_SOURCE_DIR}/Receiver.java
+  )
+
+if(enable_java)
+  add_custom_command(
+    COMMENT "Building ${example}..."
+    OUTPUT ${example}_compiled
+    DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
+    COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR}
+                             -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources}
+    COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled
+    COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled
+  )
+  add_custom_target(${example} ALL DEPENDS ${example}_compiled)
+endif()
+
+set(tesh_files
+  ${tesh_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/surf_plugin.tesh
+  PARENT_SCOPE
+  )
+set(xml_files
+  ${xml_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/surfPluginPlatform.xml
+  ${CMAKE_CURRENT_SOURCE_DIR}/surfPluginDeployment.xml  
+  PARENT_SCOPE
+  )
+set(examples_src
+  ${examples_src}
+  ${sources}
+  PARENT_SCOPE
+  )
+set(bin_files
+  ${bin_files}
+  PARENT_SCOPE
+  )
+set(txt_files
+  ${txt_files}
+  PARENT_SCOPE
+  )
diff --git a/examples/java/surfPlugin/Receiver.java b/examples/java/surfPlugin/Receiver.java
new file mode 100644 (file)
index 0000000..8d8158f
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package surfPlugin;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+
+public class Receiver extends Process {
+   public Receiver(Host host, String name, String[]args) {
+               super(host,name,args);
+   } 
+   final double commSizeLat = 1;
+   final double commSizeBw = 100000000;
+    
+   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();
+       
+      Msg.info("goodbye!");
+    }
+}
diff --git a/examples/java/surfPlugin/Sender.java b/examples/java/surfPlugin/Sender.java
new file mode 100644 (file)
index 0000000..2f4a382
--- /dev/null
@@ -0,0 +1,55 @@
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package surfPlugin;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.Task;
+
+public class Sender extends Process {
+       public Sender(Host host, String name, String[] args) {
+               super(host,name,args);
+       }
+    private final double commSizeLat = 1;
+    final double commSizeBw = 100000000;
+   
+    public void main(String[] args) throws MsgException {
+       
+       Msg.info("helloo!");
+        
+       int hostCount = args.length;
+        
+       Msg.info("host count: " + hostCount);
+       String mailboxes[] = new String[hostCount]; 
+       double time;
+       double computeDuration = 10000;
+       Task task;
+        
+       for(int pos = 0; pos < args.length ; pos++) {
+         try {
+            mailboxes[pos] = Host.getByName(args[pos]).getName();
+         } catch (HostNotFoundException e) {
+            Msg.info("Invalid deployment file: " + e.toString());           
+            System.exit(1);
+         }
+        }
+        
+        for (int pos = 0; pos < hostCount; pos++) { 
+          time = Msg.getClock(); 
+            
+          Msg.info("sender time: " + time);
+          
+          task = new Task("no name",computeDuration,commSizeLat);
+            
+          task.send(mailboxes[pos]);
+        } 
+        
+        Msg.info("goodbye!");
+    }
+}
diff --git a/examples/java/surfPlugin/TestPlugin.java b/examples/java/surfPlugin/TestPlugin.java
new file mode 100644 (file)
index 0000000..a4b334c
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package surfPlugin;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.NativeException;
+import org.simgrid.surf.Surf;
+import org.simgrid.surf.Cpu;
+
+public class TestPlugin {
+
+  /* This only contains the launcher. If you do nothing more than than you can run
+  *   java simgrid.msg.Msg
+  * which also contains such a launcher
+  */
+  static TracePlugin tp = new TracePlugin();
+
+  public static void main(String[] args) throws NativeException {
+    /* initialize the MSG simulation. Must be done before anything else (even logging). */
+    Msg.init(args);
+    if(args.length < 2) {
+      Msg.info("Usage   : TestPlugin platform_file deployment_file");
+      Msg.info("example : TestPlugin ping_pong_platform.xml ping_pong_deployment.xml");
+      System.exit(1);
+    }
+
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
+    /*  execute the simulation. */
+    Msg.run();
+  }
+}
diff --git a/examples/java/surfPlugin/TracePlugin.java b/examples/java/surfPlugin/TracePlugin.java
new file mode 100644 (file)
index 0000000..ac1d677
--- /dev/null
@@ -0,0 +1,59 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package surfPlugin;
+
+import org.simgrid.surf.*;
+import org.simgrid.msg.Msg;
+import java.util.HashMap;
+
+public class TracePlugin extends Plugin {
+
+  public TracePlugin() {
+    activateCpuCreatedCallback();
+    activateCpuDestructedCallback();
+    activateCpuStateChangedCallback();
+    activateCpuActionStateChangedCallback();
+
+    activateNetworkLinkCreatedCallback();
+    activateNetworkLinkDestructedCallback();
+    activateNetworkLinkStateChangedCallback();
+    activateNetworkActionStateChangedCallback();
+  }
+
+  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, ResourceState old, ResourceState cur){
+    Msg.info("Trace: Cpu state changed "+cpu.getName());
+  }
+
+  public void cpuActionStateChangedCallback(CpuAction action, ActionState old, ActionState cur){
+    Msg.info("Trace: CpuAction state changed "+action.getModel().getName());
+  }
+
+  public void networkLinkCreatedCallback(NetworkLink link) {
+    Msg.info("Trace: NetworkLink created "+link.getName());
+  }
+
+  public void networkLinkDestructedCallback(NetworkLink link) {
+    Msg.info("Trace: NetworkLink destructed "+link.getName());
+  }
+
+  public void networkLinkStateChangedCallback(NetworkLink link, ResourceState old, ResourceState cur){
+    Msg.info("Trace: NetworkLink state changed "+link.getName());
+  }
+
+  public void networkActionStateChangedCallback(NetworkAction action, ActionState old, ActionState cur){
+    Msg.info("Trace: NetworkAction state changed "+action.getModel().getName());
+  }
+
+}
diff --git a/examples/java/surfPlugin/surfPluginDeployment.xml b/examples/java/surfPlugin/surfPluginDeployment.xml
new file mode 100644 (file)
index 0000000..9101480
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+  <process host="Jacquelin" function="surfPlugin.Sender">
+      <argument value="Boivin"/>
+  </process>
+<process host="Boivin" function="surfPlugin.Receiver"/>
+</platform>
diff --git a/examples/java/surfPlugin/surfPluginPlatform.xml b/examples/java/surfPlugin/surfPluginPlatform.xml
new file mode 100644 (file)
index 0000000..be9a6e1
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version='1.0'?>
+ <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+ <platform version="3">
+ <AS  id="AS0"  routing="Full">
+   <host id="Jacquelin" power="137.333Mf"/>
+   <host id="Boivin" power="98.095Mf"/>
+   <link id="link" bandwidth="1MBps" latency="100ms"/>
+   <route src="Jacquelin" dst="Boivin">
+     <link_ctn id="link"/>
+   </route>
+ </AS>
+ </platform>
diff --git a/examples/java/surfPlugin/surf_plugin.tesh b/examples/java/surfPlugin/surf_plugin.tesh
new file mode 100644 (file)
index 0000000..a369378
--- /dev/null
@@ -0,0 +1,27 @@
+#! tesh
+
+$ java -classpath ${classpath:=.} surfPlugin/TestPlugin ${srcdir:=.}/surfPlugin/surfPluginPlatform.xml ${srcdir:=.}/surfPlugin/surfPluginDeployment.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__
index c86a7d0..6d7b635 100644 (file)
  * - <b>io/file.c</b> Example with the disk resource
  */
 
-#define FILENAME1 "./doc/simgrid/examples/platforms/g5k.xml"
-#define FILENAME2 ".\\Windows\\setupact.log"
-#define FILENAME3 "./doc/simgrid/examples/platforms/g5k_cabinets.xml"
-#define FILENAME4 "./doc/simgrid/examples/platforms/nancy.xml"
+#define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
+#define FILENAME2 "c:\\Windows\\setupact.log"
+#define FILENAME3 "/home/doc/simgrid/examples/platforms/g5k_cabinets.xml"
+#define FILENAME4 "/home/doc/simgrid/examples/platforms/nancy.xml"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -33,39 +33,73 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(io_file,
 int host(int argc, char *argv[])
 {
   msg_file_t file = NULL;
-  char* mount = xbt_strdup("/home");
   sg_size_t read,write;
+  msg_storage_t st;
+  const char* st_name;
 
   if(!strcmp(MSG_process_get_name(MSG_process_self()),"0")){
-    file = MSG_file_open(mount,FILENAME1, NULL);
+    file = MSG_file_open(FILENAME1, NULL);
     MSG_file_dump(file);
+    st_name = "Disk4";
   } else if(!strcmp(MSG_process_get_name(MSG_process_self()),"1")) {
-    free(mount);
-    mount = xbt_strdup("/windows");
-    file = MSG_file_open(mount,FILENAME2, NULL);
+    file = MSG_file_open(FILENAME2, NULL);
+    st_name = "Disk2";
   } else if(!strcmp(MSG_process_get_name(MSG_process_self()),"2")){
-    file = MSG_file_open(mount,FILENAME3, NULL);
-  } else if(!strcmp(MSG_process_get_name(MSG_process_self()),"3"))
-    file = MSG_file_open(mount,FILENAME4, NULL);
+    file = MSG_file_open(FILENAME3, NULL);
+    st_name = "Disk3";
+  } else if(!strcmp(MSG_process_get_name(MSG_process_self()),"3")){
+    file = MSG_file_open(FILENAME4, NULL);
+    st_name = "Disk1";
+  }
   else xbt_die("FILENAME NOT DEFINED %s",MSG_process_get_name(MSG_process_self()));
 
   const char* filename = MSG_file_get_name(file);
   XBT_INFO("\tOpen file '%s'",filename);
+  st = MSG_storage_get_by_name(st_name);
+
+  XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
+            filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
+
+  /* Try to read for 10MB */
+  read = MSG_file_read(file, 10000000);
+  XBT_INFO("\tHave read %llu from '%s'",read,filename);
+
+  /* Write 100KB in file from the current position, i.e, end of file or 10MB */
+  write = MSG_file_write(file, 100000);
+  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu",write,filename,
+           MSG_file_get_size(file));
+
 
-  read = MSG_file_read(file, 10000000);     // Read for 10MB
-  XBT_INFO("\tHave read    %llu on %s",read,filename);
+  XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
+            filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
 
-  write = MSG_file_write(file, 100000);  // Write for 100KB
-  XBT_INFO("\tHave written %llu on %s",write,filename);
+  /* rewind to the beginning of the file */
+  XBT_INFO("\tComing back to the beginning of the stream for file '%s'",
+           filename);
+  MSG_file_seek(file, 0, SEEK_SET);
 
-  read = MSG_file_read(file, 110000);     // Read for 110KB
-  XBT_INFO("\tHave read    %llu on %s (of size %llu)",read,filename,
+  /* Try to read 110KB */
+  read = MSG_file_read(file, 110000);
+  XBT_INFO("\tHave read %llu from '%s' (of size %llu)",read,filename,
       MSG_file_get_size(file));
 
+  /* rewind once again to the beginning of the file */
+  XBT_INFO("\tComing back to the beginning of the stream for file '%s'",
+           filename);
+  MSG_file_seek(file, 0, SEEK_SET);
+
+  /* Write 110KB in file from the current position, i.e, end of file or 10MB */
+  write = MSG_file_write(file, 110000);
+  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write,filename,
+      MSG_file_get_size(file));
+
+  XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
+            filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
+
   XBT_INFO("\tClose file '%s'",filename);
   MSG_file_close(file);
 
-  free(mount);
+
   return 0;
 }
 
index 599caef..04e7bdd 100644 (file)
@@ -15,7 +15,7 @@
  * - <b>io/file.c</b> Example with the disk resource
  */
 
-#define FILENAME1 "./doc/simgrid/examples/platforms/g5k.xml"
+#define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -30,12 +30,11 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(io_file,
 int host(int argc, char *argv[])
 {
   msg_file_t file = NULL;
-  char* mount = xbt_strdup("/home");
   sg_size_t write;
 
   // First open
   XBT_INFO("\tOpen file '%s'",FILENAME1);
-  file = MSG_file_open(mount,FILENAME1, NULL);
+  file = MSG_file_open(FILENAME1, NULL);
 
   // Unlink the file
   XBT_INFO("\tUnlink file '%s'",MSG_file_get_name(file));
@@ -43,7 +42,7 @@ int host(int argc, char *argv[])
 
   // Re Open the file wich is in fact created
   XBT_INFO("\tOpen file '%s'",FILENAME1);
-  file = MSG_file_open(mount,FILENAME1, NULL);
+  file = MSG_file_open(FILENAME1, NULL);
 
   // Write into the new file
   write = MSG_file_write(file,100000);  // Write for 100Ko
@@ -53,37 +52,6 @@ int host(int argc, char *argv[])
   XBT_INFO("\tClose file '%s'",MSG_file_get_name(file));
   MSG_file_close(file);
 
-  xbt_dict_t dict_ls;
-  char* key;
-  surf_stat_t data = NULL;
-  xbt_dict_cursor_t cursor = NULL;
-
-  dict_ls = MSG_file_ls(mount,"./");
-  XBT_INFO(" ");XBT_INFO("ls ./");
-  xbt_dict_foreach(dict_ls,cursor,key,data){
-    if(data) XBT_INFO("FILE : %s",key);
-    else     XBT_INFO("DIR  : %s",key);
-  }
-  xbt_dict_free(&dict_ls);
-
-  dict_ls = MSG_file_ls(mount,"./doc/simgrid/examples/platforms/");
-  XBT_INFO(" ");XBT_INFO("ls ./doc/simgrid/examples/platforms/");
-  xbt_dict_foreach(dict_ls,cursor,key,data){
-    if(data) XBT_INFO("FILE : %s",key);
-    else     XBT_INFO("DIR  : %s",key);
-  }
-  xbt_dict_free(&dict_ls);
-
-  dict_ls = MSG_file_ls(mount,"./doc/simgrid/examples/msg/");
-  XBT_INFO(" ");XBT_INFO("ls ./doc/simgrid/examples/msg/");
-  xbt_dict_foreach(dict_ls,cursor,key,data){
-    if(data) XBT_INFO("FILE : %s",key);
-    else     XBT_INFO("DIR  : %s",key);
-  }
-  xbt_dict_free(&dict_ls);
-
-  free(mount);
-
   return 0;
 }
 
index e612c10..4afb302 100644 (file)
@@ -2,56 +2,64 @@
 
 $ ${bindir:=.}/io/file ${srcdir:=.}/examples/platforms/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (0:@) Number of host '4'
-> [  0.000000] (2:1@alice)     Open file '.\Windows\setupact.log'
-> [  0.000000] (3:2@carl)      Open file './doc/simgrid/examples/platforms/g5k_cabinets.xml'
-> [  0.000000] (4:3@bob)       Open file './doc/simgrid/examples/platforms/nancy.xml'
+> [  0.000000] (2:1@alice)     Open file 'c:\Windows\setupact.log'
+> [  0.000000] (3:2@carl)      Open file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
+> [  0.000000] (4:3@bob)       Open file '/home/doc/simgrid/examples/platforms/nancy.xml'
 > [  0.000000] (1:0@denise) File Descriptor information:
->              Full name: './doc/simgrid/examples/platforms/g5k.xml'
+>              Full path: '/home/doc/simgrid/examples/platforms/g5k.xml'
 >              Size: 17028
 >              Mount point: '/home'
 >              Storage Id: 'Disk4'
 >              Storage Type: 'single_SSD'
 >              Content Type: 'txt_unix'
-> [  0.000000] (1:0@denise)    Open file './doc/simgrid/examples/platforms/g5k.xml'
-> [  0.000040] (4:3@bob)       Have read    4028 on ./doc/simgrid/examples/platforms/nancy.xml
-> [  0.000085] (1:0@denise)    Have read    17028 on ./doc/simgrid/examples/platforms/g5k.xml
-> [  0.000226] (3:2@carl)      Have read    22645 on ./doc/simgrid/examples/platforms/g5k_cabinets.xml
-> [  0.000508] (2:1@alice)     Have read    101663 on .\Windows\setupact.log
-> [  0.001752] (1:0@denise)    Have written 100000 on ./doc/simgrid/examples/platforms/g5k.xml
-> [  0.002175] (2:1@alice)     Have written 100000 on .\Windows\setupact.log
-> [  0.002439] (1:0@denise)    Have read    110000 on ./doc/simgrid/examples/platforms/g5k.xml (of size 117026)
-> [  0.002439] (1:0@denise)    Close file './doc/simgrid/examples/platforms/g5k.xml'
-> [  0.002862] (2:1@alice)     Have read    110000 on .\Windows\setupact.log (of size 201662)
-> [  0.002862] (2:1@alice)     Close file '.\Windows\setupact.log'
-> [  0.003374] (4:3@bob)       Have written 100000 on ./doc/simgrid/examples/platforms/nancy.xml
-> [  0.003560] (3:2@carl)      Have written 100000 on ./doc/simgrid/examples/platforms/g5k_cabinets.xml
-> [  0.004529] (4:3@bob)       Have read    104023 on ./doc/simgrid/examples/platforms/nancy.xml (of size 104023)
-> [  0.004529] (4:3@bob)       Close file './doc/simgrid/examples/platforms/nancy.xml'
-> [  0.004782] (3:2@carl)      Have read    110000 on ./doc/simgrid/examples/platforms/g5k_cabinets.xml (of size 122641)
-> [  0.004782] (3:2@carl)      Close file './doc/simgrid/examples/platforms/g5k_cabinets.xml'
-> [  0.004782] (0:@) Simulation time 0.00478201
+> [  0.000000] (1:0@denise)    Open file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.000000] (2:1@alice)     Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391537133 / 536870912000
+> [  0.000000] (3:2@carl)      Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 36946053 / 536870912000
+> [  0.000000] (4:3@bob)       Capacity of the storage element '/home/doc/simgrid/examples/platforms/nancy.xml' is stored on: 36946053 / 536870912000
+> [  0.000000] (1:0@denise)    Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13221994 / 536870912000
+> [  0.000040] (4:3@bob)       Have read 4028 from '/home/doc/simgrid/examples/platforms/nancy.xml'
+> [  0.000085] (1:0@denise)    Have read 17028 from '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.000226] (3:2@carl)      Have read 22645 from '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
+> [  0.000508] (2:1@alice)     Have read 101663 from 'c:\Windows\setupact.log'
+> [  0.001752] (1:0@denise)    Have written 100000 in '/home/doc/simgrid/examples/platforms/g5k.xml'. Size now is: 117028
+> [  0.001752] (1:0@denise)    Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13321994 / 536870912000
+> [  0.001752] (1:0@denise)    Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.002175] (2:1@alice)     Have written 100000 in 'c:\Windows\setupact.log'. Size now is: 201663
+> [  0.002175] (2:1@alice)     Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391637133 / 536870912000
+> [  0.002175] (2:1@alice)     Coming back to the beginning of the stream for file 'c:\Windows\setupact.log'
+> [  0.002439] (1:0@denise)    Have read 110000 from '/home/doc/simgrid/examples/platforms/g5k.xml' (of size 117028)
+> [  0.002439] (1:0@denise)    Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.002862] (2:1@alice)     Have read 110000 from 'c:\Windows\setupact.log' (of size 201663)
+> [  0.002862] (2:1@alice)     Coming back to the beginning of the stream for file 'c:\Windows\setupact.log'
+> [  0.003374] (4:3@bob)       Have written 100000 in '/home/doc/simgrid/examples/platforms/nancy.xml'. Size now is: 104028
+> [  0.003374] (4:3@bob)       Capacity of the storage element '/home/doc/simgrid/examples/platforms/nancy.xml' is stored on: 37046053 / 536870912000
+> [  0.003374] (4:3@bob)       Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/nancy.xml'
+> [  0.003560] (3:2@carl)      Have written 100000 in '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'. Size now is: 122645
+> [  0.003560] (3:2@carl)      Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 37046053 / 536870912000
+> [  0.003560] (3:2@carl)      Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
+> [  0.004529] (4:3@bob)       Have read 104028 from '/home/doc/simgrid/examples/platforms/nancy.xml' (of size 104028)
+> [  0.004529] (4:3@bob)       Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/nancy.xml'
+> [  0.004782] (3:2@carl)      Have read 110000 from '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' (of size 122645)
+> [  0.004782] (3:2@carl)      Coming back to the beginning of the stream for file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
+> [  0.006106] (1:0@denise)    Have written 110000 in '/home/doc/simgrid/examples/platforms/g5k.xml'. Size now is: 110000
+> [  0.006106] (1:0@denise)    Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13314966 / 536870912000
+> [  0.006106] (1:0@denise)    Close file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.006529] (2:1@alice)     Have written 110000 in 'c:\Windows\setupact.log'. Size now is: 110000
+> [  0.006529] (2:1@alice)     Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391545470 / 536870912000
+> [  0.006529] (2:1@alice)     Close file 'c:\Windows\setupact.log'
+> [  0.011863] (4:3@bob)       Have written 110000 in '/home/doc/simgrid/examples/platforms/nancy.xml'. Size now is: 110000
+> [  0.011863] (4:3@bob)       Capacity of the storage element '/home/doc/simgrid/examples/platforms/nancy.xml' is stored on: 37052025 / 536870912000
+> [  0.011863] (4:3@bob)       Close file '/home/doc/simgrid/examples/platforms/nancy.xml'
+> [  0.012115] (3:2@carl)      Have written 110000 in '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'. Size now is: 110000
+> [  0.012115] (3:2@carl)      Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 37033408 / 536870912000
+> [  0.012115] (3:2@carl)      Close file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
+> [  0.012115] (0:@) Simulation time 0.0121153
 
 $ ${bindir:=.}/io/file_unlink ${srcdir:=.}/examples/platforms/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (0:@) Number of host '4'
-> [  0.000000] (1:0@denise)    Open file './doc/simgrid/examples/platforms/g5k.xml'
-> [  0.000000] (1:0@denise)    Unlink file './doc/simgrid/examples/platforms/g5k.xml'
-> [  0.000000] (1:0@denise)    Open file './doc/simgrid/examples/platforms/g5k.xml'
-> [  0.001667] (1:0@denise)    Have written 100000 on ./doc/simgrid/examples/platforms/g5k.xml
-> [  0.001667] (1:0@denise)    Close file './doc/simgrid/examples/platforms/g5k.xml'
-> [  0.001667] (1:0@denise)  
-> [  0.001667] (1:0@denise) ls ./
-> [  0.001667] (1:0@denise) DIR  : include
-> [  0.001667] (1:0@denise) DIR  : lib
-> [  0.001667] (1:0@denise) DIR  : bin
-> [  0.001667] (1:0@denise) DIR  : doc
-> [  0.001667] (1:0@denise)  
-> [  0.001667] (1:0@denise) ls ./doc/simgrid/examples/platforms/
-> [  0.001667] (1:0@denise) FILE : g5k.xml
-> [  0.001667] (1:0@denise)  
-> [  0.001667] (1:0@denise) ls ./doc/simgrid/examples/msg/
-> [  0.001667] (1:0@denise) DIR  : alias
-> [  0.001667] (1:0@denise) DIR  : trace
-> [  0.001667] (1:0@denise) FILE : README
-> [  0.001667] (1:0@denise) DIR  : parallel_task
-> [  0.001667] (1:0@denise) DIR  : icomms
-> [  0.001667] (0:@) Simulation time 0.00166667
\ No newline at end of file
+> [  0.000000] (1:0@denise)    Open file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.000000] (1:0@denise)    Unlink file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.000000] (1:0@denise)    Open file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.001667] (1:0@denise)    Have written 100000 on /home/doc/simgrid/examples/platforms/g5k.xml
+> [  0.001667] (1:0@denise)    Close file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.001667] (0:@) Simulation time 0.00166667
index 9f2a266..05f14d1 100644 (file)
@@ -33,7 +33,7 @@ static int host(int argc, char *argv[]){
   xbt_dict_cursor_t cursor = NULL;
   char* mount_name;
   char* storage_name;
-  msg_storage_t storage;
+  msg_storage_t storage = NULL;
 
   // Retrieve all mount points of current host
   xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self());
@@ -44,8 +44,8 @@ static int host(int argc, char *argv[]){
     storage = MSG_storage_get_by_name(storage_name);
 
     // Retrieve disk's information
-    sg_size_t free_size = MSG_storage_get_free_size(mount_name);
-    sg_size_t used_size = MSG_storage_get_used_size(mount_name);
+    sg_size_t free_size = MSG_storage_get_free_size(storage);
+    sg_size_t used_size = MSG_storage_get_used_size(storage);
     sg_size_t size = MSG_storage_get_size(storage);
 
     XBT_INFO("Total size: %llu bytes", size);
@@ -56,25 +56,24 @@ static int host(int argc, char *argv[]){
 
 
   // Create a 200,000 bytes file named './tmp/data.txt' on /sd1
-
-  char* mount = xbt_strdup("/home");
-  char* file_name = xbt_strdup("./tmp/data.txt");
+  char* file_name = xbt_strdup("/home/tmp/data.txt");
   msg_file_t file = NULL;
   sg_size_t write, read, file_size;
 
   // Open an non-existing file amounts to create it!
-  file = MSG_file_open(mount, file_name, NULL);
+  file = MSG_file_open(file_name, NULL);
   write = MSG_file_write(file, 200000);  // Write 200,000 bytes
   XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, file_name);
   MSG_file_dump(file);
 
   // check that sizes have changed
-  XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size("/home"));
-  XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size("/home"));
+  XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size(storage));
+  XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage));
 
 
   // Now retrieve the size of created file and read it completely
   file_size = MSG_file_get_size(file);
+  MSG_file_seek(file, 0, SEEK_SET);
   read = MSG_file_read(file, file_size);
   XBT_INFO("Read %llu bytes on %s", read, file_name);
 
@@ -83,16 +82,15 @@ static int host(int argc, char *argv[]){
   XBT_INFO("Write %llu bytes on %s", write, file_name);
   MSG_file_dump(file);
 
-  MSG_file_close(file);
-  free(mount);
-  free(file_name);
-
   storage_name = xbt_strdup("Disk4");
   storage = MSG_storage_get_by_name(storage_name);
 
   // Now rename file from ./tmp/data.txt to ./tmp/simgrid.readme
-  XBT_INFO("*** Renaming './tmp/data.txt' into './tmp/simgrid.readme'");
-  MSG_storage_file_rename(storage, "./tmp/data.txt", "./tmp/simgrid.readme");
+  XBT_INFO("*** Move '/tmp/data.txt' into '/tmp/simgrid.readme'");
+  MSG_file_move(file, "/home/tmp/simgrid.readme");
+
+  MSG_file_close(file);
+  free(file_name);
 
   // Now attach some user data to disk1
   XBT_INFO("*** Get/set data for storage element: %s ***",storage_name);
index 3cd10b5..f3512c0 100644 (file)
 #! ./tesh
 
-$ ${bindir:=.}/io/storage ${srcdir:=.}/examples/platforms/storage.xml "--log=root.fmt:[%8.6r]%e(%i@%h)%e%m%n"
-> [0.000000] (1@denise) *** Storage info on denise ***
-> [0.000000] (1@denise) Storage name: Disk4, mount name: /home
-> [0.000000] (1@denise) Total size: 536870912000 bytes
-> [0.000000] (1@denise) Free size: 536857690006 bytes
-> [0.000000] (1@denise) Used size: 13221994 bytes
-> [0.000000] (1@denise) Storage name: Disk2, mount name: /windows
-> [0.000000] (1@denise) Total size: 536870912000 bytes
-> [0.000000] (1@denise) Free size: 534479374867 bytes
-> [0.000000] (1@denise) Used size: 2391537133 bytes
-> [0.003333] (1@denise) Create a 200000 bytes file named './tmp/data.txt' on /sd1
-> [0.003333] (1@denise) File Descriptor information:
->              Full name: './tmp/data.txt'
+$ ${bindir:=.}/io/storage ${srcdir:=.}/examples/platforms/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:(null)@denise) *** Storage info on denise ***
+> [  0.000000] (1:(null)@denise) Storage name: Disk2, mount name: c:
+> [  0.000000] (1:(null)@denise) Total size: 536870912000 bytes
+> [  0.000000] (1:(null)@denise) Free size: 534479374867 bytes
+> [  0.000000] (1:(null)@denise) Used size: 2391537133 bytes
+> [  0.000000] (1:(null)@denise) Storage name: Disk4, mount name: /home
+> [  0.000000] (1:(null)@denise) Total size: 536870912000 bytes
+> [  0.000000] (1:(null)@denise) Free size: 536857690006 bytes
+> [  0.000000] (1:(null)@denise) Used size: 13221994 bytes
+> [  0.003333] (1:(null)@denise) Create a 200000 bytes file named '/home/tmp/data.txt' on /sd1
+> [  0.003333] (1:(null)@denise) File Descriptor information:
+>              Full path: '/home/tmp/data.txt'
 >              Size: 200000
 >              Mount point: '/home'
 >              Storage Id: 'Disk4'
 >              Storage Type: 'single_SSD'
 >              Content Type: 'txt_unix'
-> [0.003333] (1@denise) Free size: 536857490006 bytes
-> [0.003333] (1@denise) Used size: 13421994 bytes
-> [0.004583] (1@denise) Read 200000 bytes on ./tmp/data.txt
-> [0.007917] (1@denise) Write 100000 bytes on ./tmp/data.txt
-> [0.007917] (1@denise) File Descriptor information:
->              Full name: './tmp/data.txt'
+> [  0.003333] (1:(null)@denise) Free size: 536857490006 bytes
+> [  0.003333] (1:(null)@denise) Used size: 13421994 bytes
+> [  0.004583] (1:(null)@denise) Read 200000 bytes on /home/tmp/data.txt
+> [  0.007917] (1:(null)@denise) Write 100000 bytes on /home/tmp/data.txt
+> [  0.007917] (1:(null)@denise) File Descriptor information:
+>              Full path: '/home/tmp/data.txt'
 >              Size: 300000
 >              Mount point: '/home'
 >              Storage Id: 'Disk4'
 >              Storage Type: 'single_SSD'
 >              Content Type: 'txt_unix'
-> [0.007917] (1@denise) *** Renaming './tmp/data.txt' into './tmp/simgrid.readme'
-> [0.007917] (1@denise) *** Get/set data for storage element: Disk4 ***
-> [0.007917] (1@denise) Get data: '(null)'
-> [0.007917] (1@denise) Set and get data: 'Some user data'
-> [0.007917] (1@denise) *** Dump content of denise ***
-> [0.007917] (1@denise) Print the content of mount point: /home
-> [0.007917] (1@denise) ./doc/simgrid/examples/platforms/g5k.xml size: 17028 bytes
-> [0.007917] (1@denise) ./include/surf/simgrid_dtd.h size: 23583 bytes
-> [0.007917] (1@denise) ./bin/smpicc size: 918 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/mc_bugged2.c size: 1387 bytes
-> [0.007917] (1@denise) ./include/simdag/simdag.h size: 10325 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/sys/README size: 1461 bytes
-> [0.007917] (1@denise) ./tmp/simgrid.readme size: 300000 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/common/randdp.c size: 1441 bytes
-> [0.007917] (1@denise) ./include/msg/datatypes.h size: 4635 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/EP/randlc.c size: 3300 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml size: 654 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/msg/icomms/small_platform.xml size: 972 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/msg/trace/test9.xml size: 598 bytes
-> [0.007917] (1@denise) ./include/simix/simix.h size: 13003 bytes
-> [0.007917] (1@denise) ./include/mc/modelchecker.h size: 96 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/msg/README size: 4805 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/README size: 1857 bytes
-> [0.007917] (1@denise) ./include/instr/instr.h size: 5750 bytes
-> [0.007917] (1@denise) ./doc/simgrid/html/group__XBT__str.html size: 36192 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/EP/README size: 347 bytes
-> [0.007917] (1@denise) ./bin/tesh size: 356434 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/DT/README size: 999 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/FT/README size: 276 bytes
-> [0.007917] (1@denise) ./lib/libsimgrid.so.3.6.2 size: 12710497 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/xbt/sem_basic.c size: 1970 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c size: 6217 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/SP/README size: 926 bytes
-> [0.007917] (1@denise) ./include/xbt/fifo.h size: 3626 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/MPI_dummy/README size: 2406 bytes
-> [0.007917] (1@denise) ./doc/simgrid/examples/smpi/NAS/MG/README size: 5465 bytes
-> [0.007917] (1@denise) ./include/smpi/mpif.h size: 4826 bytes
-> [0.007917] (1@denise) Print the content of mount point: /windows
-> [0.007917] (1@denise) .\Windows\dcmdev64.exe size: 93288 bytes
-> [0.007917] (1@denise) .\Windows\WLXPGSS.SCR size: 322048 bytes
-> [0.007917] (1@denise) .\Windows\twain_32.dll size: 50176 bytes
-> [0.007917] (1@denise) .\Windows\bootstat.dat size: 67584 bytes
-> [0.007917] (1@denise) .\Windows\avastSS.scr size: 41664 bytes
-> [0.007917] (1@denise) .\Windows\font1.sii size: 4907 bytes
-> [0.007917] (1@denise) .\Windows\write.exe size: 10752 bytes
-> [0.007917] (1@denise) .\Windows\font2.sii size: 8698 bytes
-> [0.007917] (1@denise) .\Windows\DtcInstall.log size: 1955 bytes
-> [0.007917] (1@denise) .\Windows\vmgcoinstall.log size: 1585 bytes
-> [0.007917] (1@denise) .\Windows\_isusr32.dll size: 180320 bytes
-> [0.007917] (1@denise) .\Windows\winhlp32.exe size: 10752 bytes
-> [0.007917] (1@denise) .\Windows\setuperr.log size: 0 bytes
-> [0.007917] (1@denise) .\Windows\system.ini size: 219 bytes
-> [0.007917] (1@denise) .\Windows\hapint.exe size: 382056 bytes
-> [0.007917] (1@denise) .\Windows\Professional.xml size: 31881 bytes
-> [0.007917] (1@denise) .\Windows\setupact.log size: 101663 bytes
-> [0.007917] (1@denise) .\Windows\notepad.exe size: 243712 bytes
-> [0.007917] (1@denise) .\Windows\explorer.exe size: 2380944 bytes
-> [0.007917] (1@denise) .\Windows\bfsvc.exe size: 75264 bytes
-> [0.007917] (1@denise) .\Windows\WMSysPr9.prx size: 316640 bytes
-> [0.007917] (1@denise) .\Windows\PFRO.log size: 6770 bytes
-> [0.007917] (1@denise) .\Windows\csup.txt size: 12 bytes
-> [0.007917] (1@denise) .\Windows\win.ini size: 92 bytes
-> [0.007917] (1@denise) .\Windows\mib.bin size: 43131 bytes
-> [0.007917] (1@denise) .\Windows\Starter.xml size: 31537 bytes
-> [0.007917] (1@denise) .\Windows\CoreSingleLanguage.xml size: 31497 bytes
-> [0.007917] (1@denise) .\Windows\regedit.exe size: 159232 bytes
-> [0.007917] (1@denise) .\Windows\dchcfg64.exe size: 335464 bytes
-> [0.007917] (1@denise) .\Windows\HelpPane.exe size: 883712 bytes
-> [0.007917] (1@denise) .\Windows\WindowsUpdate.log size: 1518934 bytes
-> [0.007917] (1@denise) .\Windows\hh.exe size: 17408 bytes
-> [0.007917] (1@denise) .\Windows\DPINST.LOG size: 18944 bytes
-> [0.007917] (1@denise) .\Windows\DirectX.log size: 10486 bytes
-> [0.007917] (1@denise) .\Windows\splwow64.exe size: 126464 bytes
-> [0.007917] (1@denise) .\Windows\MEMORY.DMP size: 2384027342 bytes
-> [0.007917] (0@) Simulated time: 0.00791667
+> [  0.007917] (1:(null)@denise) *** Move '/tmp/data.txt' into '/tmp/simgrid.readme'
+> [  0.007917] (1:(null)@denise) *** Get/set data for storage element: Disk4 ***
+> [  0.007917] (1:(null)@denise) Get data: '(null)'
+> [  0.007917] (1:(null)@denise) Set and get data: 'Some user data'
+> [  0.007917] (1:(null)@denise) *** Dump content of denise ***
+> [  0.007917] (1:(null)@denise) Print the content of mount point: c:
+> [  0.007917] (1:(null)@denise) \Windows\win.ini size: 92 bytes
+> [  0.007917] (1:(null)@denise) \Windows\mib.bin size: 43131 bytes
+> [  0.007917] (1:(null)@denise) \Windows\DtcInstall.log size: 1955 bytes
+> [  0.007917] (1:(null)@denise) \Windows\vmgcoinstall.log size: 1585 bytes
+> [  0.007917] (1:(null)@denise) \Windows\Starter.xml size: 31537 bytes
+> [  0.007917] (1:(null)@denise) \Windows\_isusr32.dll size: 180320 bytes
+> [  0.007917] (1:(null)@denise) \Windows\winhlp32.exe size: 10752 bytes
+> [  0.007917] (1:(null)@denise) \Windows\setuperr.log size: 0 bytes
+> [  0.007917] (1:(null)@denise) \Windows\system.ini size: 219 bytes
+> [  0.007917] (1:(null)@denise) \Windows\hapint.exe size: 382056 bytes
+> [  0.007917] (1:(null)@denise) \Windows\Professional.xml size: 31881 bytes
+> [  0.007917] (1:(null)@denise) \Windows\regedit.exe size: 159232 bytes
+> [  0.007917] (1:(null)@denise) \Windows\setupact.log size: 101663 bytes
+> [  0.007917] (1:(null)@denise) \Windows\WindowsUpdate.log size: 1518934 bytes
+> [  0.007917] (1:(null)@denise) \Windows\explorer.exe size: 2380944 bytes
+> [  0.007917] (1:(null)@denise) \Windows\DirectX.log size: 10486 bytes
+> [  0.007917] (1:(null)@denise) \Windows\WMSysPr9.prx size: 316640 bytes
+> [  0.007917] (1:(null)@denise) \Windows\PFRO.log size: 6770 bytes
+> [  0.007917] (1:(null)@denise) \Windows\csup.txt size: 12 bytes
+> [  0.007917] (1:(null)@denise) \Windows\WLXPGSS.SCR size: 322048 bytes
+> [  0.007917] (1:(null)@denise) \Windows\avastSS.scr size: 41664 bytes
+> [  0.007917] (1:(null)@denise) \Windows\font1.sii size: 4907 bytes
+> [  0.007917] (1:(null)@denise) \Windows\write.exe size: 10752 bytes
+> [  0.007917] (1:(null)@denise) \Windows\font2.sii size: 8698 bytes
+> [  0.007917] (1:(null)@denise) \Windows\CoreSingleLanguage.xml size: 31497 bytes
+> [  0.007917] (1:(null)@denise) \Windows\dchcfg64.exe size: 335464 bytes
+> [  0.007917] (1:(null)@denise) \Windows\notepad.exe size: 243712 bytes
+> [  0.007917] (1:(null)@denise) \Windows\HelpPane.exe size: 883712 bytes
+> [  0.007917] (1:(null)@denise) \Windows\hh.exe size: 17408 bytes
+> [  0.007917] (1:(null)@denise) \Windows\DPINST.LOG size: 18944 bytes
+> [  0.007917] (1:(null)@denise) \Windows\bfsvc.exe size: 75264 bytes
+> [  0.007917] (1:(null)@denise) \Windows\splwow64.exe size: 126464 bytes
+> [  0.007917] (1:(null)@denise) \Windows\MEMORY.DMP size: 2384027342 bytes
+> [  0.007917] (1:(null)@denise) \Windows\dcmdev64.exe size: 93288 bytes
+> [  0.007917] (1:(null)@denise) \Windows\twain_32.dll size: 50176 bytes
+> [  0.007917] (1:(null)@denise) \Windows\bootstat.dat size: 67584 bytes
+> [  0.007917] (1:(null)@denise) Print the content of mount point: /home
+> [  0.007917] (1:(null)@denise) /include/simix/simix.h size: 13003 bytes
+> [  0.007917] (1:(null)@denise) /include/mc/modelchecker.h size: 96 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/msg/README size: 4805 bytes
+> [  0.007917] (1:(null)@denise) /include/instr/instr.h size: 5750 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/mc_bugged2.c size: 1387 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/html/group__XBT__str.html size: 36192 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/EP/README size: 347 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/DT/README size: 999 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/FT/README size: 276 bytes
+> [  0.007917] (1:(null)@denise) /lib/libsimgrid.so.3.6.2 size: 12710497 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/sys/README size: 1461 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c size: 6217 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/SP/README size: 926 bytes
+> [  0.007917] (1:(null)@denise) /tmp/simgrid.readme size: 300000 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml size: 654 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/msg/icomms/small_platform.xml size: 972 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/MG/README size: 5465 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/msg/trace/test9.xml size: 598 bytes
+> [  0.007917] (1:(null)@denise) /include/smpi/mpif.h size: 4826 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/README size: 1857 bytes
+> [  0.007917] (1:(null)@denise) /bin/tesh size: 356434 bytes
+> [  0.007917] (1:(null)@denise) /include/simdag/simdag.h size: 10325 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/xbt/sem_basic.c size: 1970 bytes
+> [  0.007917] (1:(null)@denise) /include/xbt/fifo.h size: 3626 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/common/randdp.c size: 1441 bytes
+> [  0.007917] (1:(null)@denise) /include/msg/datatypes.h size: 4635 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/EP/randlc.c size: 3300 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/smpi/NAS/MPI_dummy/README size: 2406 bytes
+> [  0.007917] (1:(null)@denise) /doc/simgrid/examples/platforms/g5k.xml size: 17028 bytes
+> [  0.007917] (1:(null)@denise) /include/surf/simgrid_dtd.h size: 23583 bytes
+> [  0.007917] (1:(null)@denise) /bin/smpicc size: 918 bytes
+> [  0.007917] (0:@) Simulated time: 0.00791667
index 464633f..85cd2ce 100644 (file)
@@ -2,9 +2,11 @@
 
 ! 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 ...
+> [  0.000000] (0:@) Get debug information done !
 > [  0.000000] (2:client@HostB) Sent!
 > [  0.000000] (3:client@HostC) Sent!
 > [  0.000000] (1:server@HostA) OK
@@ -22,16 +24,16 @@ $ ${bindir:=.}/bugged1 --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%
 > [  0.000000] (1:server@HostA) *** PROPERTY NOT VALID ***
 > [  0.000000] (1:server@HostA) **************************
 > [  0.000000] (1:server@HostA) Counter-example execution trace:
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (1:server@HostA) [(2)HostB (client)] iSend(src=(2)HostB (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(2)HostB (client)-> (1)HostA (server)]) (62)
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (1:server@HostA) [(2)HostB (client)] Wait(comm=(verbose only) [(2)HostB (client)-> (1)HostA (server)]) (62)
-> [  0.000000] (1:server@HostA) [(4)HostD (client)] iSend(src=(4)HostD (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(4)HostD (client)-> (1)HostA (server)]) (62)
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (1:server@HostA) [(3)HostC (client)] iSend(src=(3)HostC (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(3)HostC (client)-> (1)HostA (server)]) (62)
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(2)HostB (client)] iSend(src=(2)HostB (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(2)HostB (client)-> (1)HostA (server)])
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(2)HostB (client)] Wait(comm=(verbose only) [(2)HostB (client)-> (1)HostA (server)])
+> [  0.000000] (1:server@HostA) [(4)HostD (client)] iSend(src=(4)HostD (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(4)HostD (client)-> (1)HostA (server)])
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(3)HostC (client)] iSend(src=(3)HostC (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(3)HostC (client)-> (1)HostA (server)])
 > [  0.000000] (1:server@HostA) Expanded states = 22
 > [  0.000000] (1:server@HostA) Visited states = 56
 > [  0.000000] (1:server@HostA) Executed transitions = 52
index 37652b8..ff3cd79 100644 (file)
@@ -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 ...
@@ -20,26 +20,26 @@ $ ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../msg_platform.xml ${srcdir:=.}/de
 > [  0.000000] (0:@) |             ACCEPTANCE CYCLE            |
 > [  0.000000] (0:@) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 > [  0.000000] (0:@) Counter-example that violates formula :
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(3)Fafard (client)] iSend(src=(3)Fafard (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(3)Fafard (client)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(3)Fafard (client)] iRecv(dst=(3)Fafard (client), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (3)Fafard (client)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(3)Fafard (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (3)Fafard (client)]) (62)
-> [  0.000000] (0:@) [(3)Fafard (client)] iSend(src=(3)Fafard (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(3)Fafard (client)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(3)Fafard (client)] iSend(src=(3)Fafard (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)]) (62)
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(3)Fafard (client)] iSend(src=(3)Fafard (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(3)Fafard (client)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(3)Fafard (client)] iRecv(dst=(3)Fafard (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (3)Fafard (client)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(3)Fafard (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (3)Fafard (client)])
+> [  0.000000] (0:@) [(3)Fafard (client)] iSend(src=(3)Fafard (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(3)Fafard (client)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(3)Fafard (client)] iSend(src=(3)Fafard (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)])
 > [  0.000000] (0:@) Expanded pairs = 21
 > [  0.000000] (0:@) Visited pairs = 21
 > [  0.000000] (0:@) Executed transitions = 20
index f8042cb..4775fdc 100644 (file)
@@ -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
@@ -78,56 +78,56 @@ $ ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../msg_platform.xml ${srcdir:=.}/de
 > [  0.000000] (0:@) |             ACCEPTANCE CYCLE            |
 > [  0.000000] (0:@) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 > [  0.000000] (0:@) Counter-example that violates formula :
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(3)Fafard (client)] iSend(src=(3)Fafard (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(3)Fafard (client)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)]) (62)
-> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)]) (62)
-> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only)) (54)
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(3)Fafard (client)] iSend(src=(3)Fafard (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(3)Fafard (client)] Wait(comm=(verbose only) [(3)Fafard (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iSend(src=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(2)Boivin (client)-> (1)Tremblay (coordinator)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iRecv(dst=(2)Boivin (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)])
+> [  0.000000] (0:@) [(1)Tremblay (coordinator)] iRecv(dst=(1)Tremblay (coordinator), buff=(verbose only), size=(verbose only))
+> [  0.000000] (0:@) [(2)Boivin (client)] Wait(comm=(verbose only) [(1)Tremblay (coordinator)-> (2)Boivin (client)])
+> [  0.000000] (0:@) [(2)Boivin (client)] iSend(src=(2)Boivin (client), buff=(verbose only), size=(verbose only))
 > [  0.000000] (0:@) Expanded pairs = 57
 > [  0.000000] (0:@) Visited pairs = 208
 > [  0.000000] (0:@) Executed transitions = 207
index 2fe18e9..d3d7eec 100644 (file)
@@ -2,9 +2,11 @@
 
 ! 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 ...
+> [  0.000000] (0:@) Get debug information done !
 > [  0.000000] (2:client@HostB) Send 1!
 > [  0.000000] (3:client@HostC) Send 2!
 > [  0.000000] (1:server@HostA) Received 1
@@ -887,13 +889,13 @@ $ ${bindir:=.}/bugged2 --cfg=model-check:1 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%
 > [  0.000000] (1:server@HostA) *** PROPERTY NOT VALID ***
 > [  0.000000] (1:server@HostA) **************************
 > [  0.000000] (1:server@HostA) Counter-example execution trace:
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (1:server@HostA) [(3)HostC (client)] iSend(src=(3)HostC (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(3)HostC (client)-> (1)HostA (server)]) (62)
-> [  0.000000] (1:server@HostA) [(3)HostC (client)] Wait(comm=(verbose only) [(3)HostC (client)-> (1)HostA (server)]) (62)
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only)) (56)
-> [  0.000000] (1:server@HostA) [(3)HostC (client)] iSend(src=(3)HostC (client), buff=(verbose only), size=(verbose only)) (54)
-> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(3)HostC (client)-> (1)HostA (server)]) (62)
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(3)HostC (client)] iSend(src=(3)HostC (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(3)HostC (client)-> (1)HostA (server)])
+> [  0.000000] (1:server@HostA) [(3)HostC (client)] Wait(comm=(verbose only) [(3)HostC (client)-> (1)HostA (server)])
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] iRecv(dst=(1)HostA (server), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(3)HostC (client)] iSend(src=(3)HostC (client), buff=(verbose only), size=(verbose only))
+> [  0.000000] (1:server@HostA) [(1)HostA (server)] Wait(comm=(verbose only) [(3)HostC (client)-> (1)HostA (server)])
 > [  0.000000] (1:server@HostA) Expanded states = 461
 > [  0.000000] (1:server@HostA) Visited states = 2271
 > [  0.000000] (1:server@HostA) Executed transitions = 2117
index 41bab56..80d00dd 100644 (file)
@@ -1,30 +1,30 @@
-./doc/simgrid/examples/platforms/g5k.xml  17028
-./doc/simgrid/examples/smpi/mc_bugged2.c  1387
-./doc/simgrid/examples/smpi/NAS/README  1857
-./doc/simgrid/examples/smpi/NAS/MPI_dummy/README 2406
-./doc/simgrid/examples/smpi/NAS/common/randdp.c 1441
-./doc/simgrid/examples/smpi/NAS/sys/README  1461
-./doc/simgrid/examples/smpi/NAS/SP/README  926
-./doc/simgrid/examples/smpi/NAS/FT/README  276
-./doc/simgrid/examples/smpi/NAS/DT/README  999
-./doc/simgrid/examples/smpi/NAS/EP/README  347
-./doc/simgrid/examples/smpi/NAS/EP/randlc.c  3300
-./doc/simgrid/examples/smpi/NAS/MG/README  5465
-./doc/simgrid/examples/xbt/sem_basic.c  1970
-./doc/simgrid/examples/msg/README  4805
-./doc/simgrid/examples/msg/icomms/small_platform.xml 972
-./doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml  654
-./doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c  6217
-./doc/simgrid/examples/msg/trace/test9.xml  598
-./doc/simgrid/html/group__XBT__str.html  36192
-./include/smpi/mpif.h  4826
-./include/xbt/fifo.h  3626
-./include/msg/datatypes.h 4635
-./include/mc/modelchecker.h  96
-./include/surf/simgrid_dtd.h  23583
-./include/instr/instr.h  5750
-./include/simdag/simdag.h  10325
-./include/simix/simix.h  13003
-./lib/libsimgrid.so.3.6.2  12710497
-./bin/smpicc  918
-./bin/tesh  356434
\ No newline at end of file
+/doc/simgrid/examples/platforms/g5k.xml  17028
+/doc/simgrid/examples/smpi/mc_bugged2.c  1387
+/doc/simgrid/examples/smpi/NAS/README  1857
+/doc/simgrid/examples/smpi/NAS/MPI_dummy/README 2406
+/doc/simgrid/examples/smpi/NAS/common/randdp.c 1441
+/doc/simgrid/examples/smpi/NAS/sys/README  1461
+/doc/simgrid/examples/smpi/NAS/SP/README  926
+/doc/simgrid/examples/smpi/NAS/FT/README  276
+/doc/simgrid/examples/smpi/NAS/DT/README  999
+/doc/simgrid/examples/smpi/NAS/EP/README  347
+/doc/simgrid/examples/smpi/NAS/EP/randlc.c  3300
+/doc/simgrid/examples/smpi/NAS/MG/README  5465
+/doc/simgrid/examples/xbt/sem_basic.c  1970
+/doc/simgrid/examples/msg/README  4805
+/doc/simgrid/examples/msg/icomms/small_platform.xml 972
+/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml  654
+/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c  6217
+/doc/simgrid/examples/msg/trace/test9.xml  598
+/doc/simgrid/html/group__XBT__str.html  36192
+/include/smpi/mpif.h  4826
+/include/xbt/fifo.h  3626
+/include/msg/datatypes.h 4635
+/include/mc/modelchecker.h  96
+/include/surf/simgrid_dtd.h  23583
+/include/instr/instr.h  5750
+/include/simdag/simdag.h  10325
+/include/simix/simix.h  13003
+/lib/libsimgrid.so.3.6.2  12710497
+/bin/smpicc  918
+/bin/tesh  356434
\ No newline at end of file
index b115c53..8e39931 100644 (file)
-./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx  71
-./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml  1262
-./doc/simgrid/examples/cxx/autoDestination/Main.cxx  148
-./doc/simgrid/examples/cxx/autoDestination/Slave.cxx  870
-./doc/simgrid/examples/cxx/autoDestination/BasicTask.cxx  65
-./doc/simgrid/examples/cxx/autoDestination/Master.cxx  1891
-./doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml  2133932
-./doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx  1137
-./doc/simgrid/explicitDestination/FinalizeTask.cxx 71
-./doc/simgrid/examples/cxx/basic/Main.cxx  148
-./doc/simgrid/examples/cxx/basic/Slave.cxx  693
-./doc/simgrid/examples/cxx/basic/BasicTask.cxx  65
-./doc/simgrid/examples/cxx/basic/basic_platform.xml  2133932  
-./doc/simgrid/examples/cxx/basic/Master.cxx  2148
-./doc/simgrid/examples/cxx/basic/basic_deployment.xml 1188
-./doc/simgrid/examples/cxx/basic/Forwarder.cxx  1244
-./doc/simgrid/examples/cxx/explicitDestination/FinalizeTask.cxx  71
-./doc/simgrid/examples/cxx/explicitDestination/Main.cxx  148
-./doc/simgrid/examples/cxx/explicitDestination/explicitDestination_platform.xml  2133932
-./doc/simgrid/examples/cxx/explicitDestination/Slave.cxx  913
-./doc/simgrid/examples/cxx/explicitDestination/BasicTask.cxx  65
-./doc/simgrid/examples/cxx/explicitDestination/explicitDestination_deployment.xml  1188
-./doc/simgrid/examples/cxx/explicitDestination/Master.cxx  1896
-./doc/simgrid/examples/cxx/explicitDestination/Forwarder.cxx  1181
-./doc/simgrid/examples/cxx/ping_pong/Main.cxx  149
-./doc/simgrid/examples/cxx/ping_pong/Sender.cxx 1073
-./doc/simgrid/examples/cxx/ping_pong/ping_pong_deployment.xml  275
-./doc/simgrid/examples/cxx/ping_pong/ping_pong_platform.xml  4718
-./doc/simgrid/examples/cxx/ping_pong/Receiver.cxx 957
-./doc/simgrid/examples/cxx/ping_pong/PingPongTask.cxx 71
-./doc/simgrid/examples/cxx/comm_time/FinalizeTask.cxx 71
-./doc/simgrid/examples/cxx/comm_time/Main.cxx  146
-./doc/simgrid/examples/cxx/comm_time/CommTimeTask.cxx 71
-./doc/simgrid/examples/cxx/comm_time/Slave.cxx  889
-./doc/simgrid/examples/cxx/comm_time/comm_time_platform.xml  2133932
-./doc/simgrid/examples/cxx/comm_time/Master.cxx  1730
-./doc/simgrid/examples/cxx/comm_time/comm_time_deployment.xml  1884
-./doc/simgrid/examples/cxx/suspend/Main.cxx  150
-./doc/simgrid/examples/cxx/suspend/suspend_platform.xml  2133932
-./doc/simgrid/examples/cxx/suspend/suspend_deployment.xml  187
-./doc/simgrid/examples/cxx/suspend/DreamMaster.cxx 826
-./doc/simgrid/examples/cxx/suspend/LazyGuy.cxx  429
-./doc/simgrid/examples/smpi/mc_bugged2.c  1387
-./doc/simgrid/examples/smpi/scatter.c  3496
-./doc/simgrid/examples/smpi/mc_bugged1.c  1411
-./doc/simgrid/examples/smpi/get_processor_name.c  649
-./doc/simgrid/examples/smpi/NAS/README  1857
-./doc/simgrid/examples/smpi/NAS/EP-sampling/README  347
-./doc/simgrid/examples/smpi/NAS/EP-sampling/randlc.c  3300
-./doc/simgrid/examples/smpi/NAS/EP-sampling/ep.c  13723
-./doc/simgrid/examples/smpi/NAS/EP-trace/README  347
-./doc/simgrid/examples/smpi/NAS/EP-trace/randlc.c  3300
-./doc/simgrid/examples/smpi/NAS/EP-trace/ep-trace.c  13850
-./doc/simgrid/examples/smpi/NAS/config/NAS.samples/README  394
-./doc/simgrid/examples/smpi/NAS/IS-trace/is-trace.c 38276
-./doc/simgrid/examples/smpi/NAS/DT-trace/README 999
-./doc/simgrid/examples/smpi/NAS/DT-trace/DGraph.c 5451
-./doc/simgrid/examples/smpi/NAS/DT-trace/dt.c  23031
-./doc/simgrid/examples/smpi/NAS/IS/is.c  38077
-./doc/simgrid/examples/smpi/NAS/MPI_dummy/README 2406
-./doc/simgrid/examples/smpi/NAS/MPI_dummy/mpi_dummy.c 5660
-./doc/simgrid/examples/smpi/NAS/MPI_dummy/wtime_sgi64.c  1700
-./doc/simgrid/examples/smpi/NAS/MPI_dummy/wtime.c 228
-./doc/simgrid/examples/smpi/NAS/common/randdp.c 1441
-./doc/simgrid/examples/smpi/NAS/common/c_timers.c 1159
-./doc/simgrid/examples/smpi/NAS/common/c_print_results.c  3086
-./doc/simgrid/examples/smpi/NAS/sys/README  1461
-./doc/simgrid/examples/smpi/NAS/sys/setparams.c 38805
-./doc/simgrid/examples/smpi/NAS/SP/README  926
-./doc/simgrid/examples/smpi/NAS/FT/README  276
-./doc/simgrid/examples/smpi/NAS/DT/README  999
-./doc/simgrid/examples/smpi/NAS/DT/DGraph.c  5451
-./doc/simgrid/examples/smpi/NAS/DT/dt.c  22620
-./doc/simgrid/examples/smpi/NAS/EP/README  347
-./doc/simgrid/examples/smpi/NAS/EP/randlc.c  3300
-./doc/simgrid/examples/smpi/NAS/EP/ep.c  13688
-./doc/simgrid/examples/smpi/NAS/DT-folding/README 999
-./doc/simgrid/examples/smpi/NAS/DT-folding/DGraph.c 5451
-./doc/simgrid/examples/smpi/NAS/DT-folding/dt.c 22704
-./doc/simgrid/examples/smpi/NAS/MG/README  5465
-./doc/simgrid/examples/smpi/bcast.c  983
-./doc/simgrid/examples/smpi/compute2.c  628
-./doc/simgrid/examples/smpi/sendrecv.c  1652
-./doc/simgrid/examples/smpi/allreduce.c  2135
-./doc/simgrid/examples/smpi/mvmul.c  7069
-./doc/simgrid/examples/smpi/alltoallv.c  4441
-./doc/simgrid/examples/smpi/smpi_traced.c  8529
-./doc/simgrid/examples/smpi/compute3.c  816
-./doc/simgrid/examples/smpi/reduce.c  3545
-./doc/simgrid/examples/smpi/bcbench.c  2466
-./doc/simgrid/examples/smpi/ttest01.c  1273
-./doc/simgrid/examples/smpi/compute.c  622
-./doc/simgrid/examples/smpi/barrier.c  766
-./doc/simgrid/examples/smpi/alltoall_basic.c  1453
-./doc/simgrid/examples/smpi/pingpong.c  2286
-./doc/simgrid/examples/smpi/alltoall2.c  2799
-./doc/simgrid/examples/smpi/split.c  705
-./doc/simgrid/examples/xbt/sem_basic.c  1970
-./doc/simgrid/examples/xbt/sem_sched.c  7207
-./doc/simgrid/examples/msg/small_platform.xml  4582
-./doc/simgrid/examples/msg/README  4805
-./doc/simgrid/examples/msg/properties/deployment_properties.xml  272
-./doc/simgrid/examples/msg/properties/msg_prop.c 3853
-./doc/simgrid/examples/msg/ns3/3links-p.xml  856
-./doc/simgrid/examples/msg/ns3/dogbone-d.xml  582
-./doc/simgrid/examples/msg/ns3/Two_clusters.xml 1817
-./doc/simgrid/examples/msg/ns3/3links-d.xml  927
-./doc/simgrid/examples/msg/ns3/3links-d-timer.xml 1280
-./doc/simgrid/examples/msg/ns3/ns3.c  5177
-./doc/simgrid/examples/msg/ns3/Two_clusters-d.xml 369
-./doc/simgrid/examples/msg/ns3/One_cluster-d.xml 367
-./doc/simgrid/examples/msg/ns3/dogbone-p.xml  1497
-./doc/simgrid/examples/msg/ns3/3hosts_2links_p.xml 566
-./doc/simgrid/examples/msg/ns3/3hosts_2links_d.xml 352
-./doc/simgrid/examples/msg/ns3/One_cluster.xml  658
-./doc/simgrid/examples/msg/migration/migration.c 2922
-./doc/simgrid/examples/msg/small_platform_with_failures.xml  4746
-./doc/simgrid/examples/msg/icomms/small_platform.xml 972
-./doc/simgrid/examples/msg/icomms/deployment_peer.xml 678
-./doc/simgrid/examples/msg/icomms/deployment_peer05.xml  891
-./doc/simgrid/examples/msg/icomms/deployment_peer02.xml  855
-./doc/simgrid/examples/msg/icomms/peer2.c  4276
-./doc/simgrid/examples/msg/icomms/deployment_peer03.xml  851
-./doc/simgrid/examples/msg/icomms/deployment_peer04.xml  852
-./doc/simgrid/examples/msg/icomms/peer.c  5102
-./doc/simgrid/examples/msg/icomms/deployment_peer01.xml  855
-./doc/simgrid/examples/msg/icomms/peer3.c  5258
-./doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml  654
-./doc/simgrid/examples/msg/parallel_task/test_ptask.c 5423
-./doc/simgrid/examples/msg/parallel_task/test_ptask_platform.xml  2380
-./doc/simgrid/examples/msg/parallel_task/parallel_task.c  2708
-./doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c  6217
-./doc/simgrid/examples/msg/trace/test9.xml  598
-./doc/simgrid/examples/msg/trace/test3.xml  372
-./doc/simgrid/examples/msg/trace/test_trace_integration.xml  206
-./doc/simgrid/examples/msg/trace/test2.xml  370
-./doc/simgrid/examples/msg/trace/test7.xml  501
-./doc/simgrid/examples/msg/trace/test11.xml  683
-./doc/simgrid/examples/msg/trace/test4.xml  371
-./doc/simgrid/examples/msg/trace/test10.xml  598
-./doc/simgrid/examples/msg/trace/test6.xml  372
-./doc/simgrid/examples/msg/trace/test8.xml  498
-./doc/simgrid/examples/msg/trace/test5.xml  371
-./doc/simgrid/examples/msg/trace/test_trace_integration.c  1960
-./doc/simgrid/examples/msg/trace/test1.xml  366
-./doc/simgrid/examples/msg/parallel_contexts/pcontexts_platform.xml  1002
-./doc/simgrid/examples/msg/parallel_contexts/deployment_pcontexts2_4.xml 467
-./doc/simgrid/examples/msg/parallel_contexts/pcontexts2.c  2236
-./doc/simgrid/examples/msg/parallel_contexts/deployment_pcontexts_2.xml 242
-./doc/simgrid/examples/msg/parallel_contexts/deployment_pcontexts_4.xml 353
-./doc/simgrid/examples/msg/parallel_contexts/pcontexts.c  1752
-./doc/simgrid/examples/msg/tracing/deployment.xml 800
-./doc/simgrid/examples/msg/tracing/ms.c  4374
-./doc/simgrid/examples/msg/tracing/platform.xml 3930
-./doc/simgrid/examples/msg/tracing/tasks.c  3594
-./doc/simgrid/examples/msg/tracing/procmig-deploy.xml 223
-./doc/simgrid/examples/msg/tracing/procmig.c  3282
-./doc/simgrid/examples/msg/tracing/categories.c 3358
-./doc/simgrid/examples/msg/sendrecv/README  689
-./doc/simgrid/examples/msg/sendrecv/deployment_sendrecv.xml  321
-./doc/simgrid/examples/msg/sendrecv/sendrecv.c  5098
-./doc/simgrid/examples/msg/sendrecv/platform_sendrecv.xml  528
-./doc/simgrid/examples/msg/gtnets/onelink-p.xml 439
-./doc/simgrid/examples/msg/gtnets/fullduplex-p.xml 575
-./doc/simgrid/examples/msg/gtnets/dogbone-d.xml 576
-./doc/simgrid/examples/msg/gtnets/waxman-d.xml  46642
-./doc/simgrid/examples/msg/gtnets/waxman-p.xml 4964600  
-./doc/simgrid/examples/msg/gtnets/fullduplex-d.xml 1029
-./doc/simgrid/examples/msg/gtnets/onelink-d.xml 356
-./doc/simgrid/examples/msg/gtnets/gtnets.c  6172
-./doc/simgrid/examples/msg/gtnets/dogbone-p.xml 1482
-./doc/simgrid/examples/msg/pmm/msg_pmm.c  9688
-./doc/simgrid/examples/msg/pmm/pmm_9_deploy.xml 786
-./doc/simgrid/examples/msg/mc/bugged1.c  1378
-./doc/simgrid/examples/msg/mc/deploy_bugged3.xml 377
-./doc/simgrid/examples/msg/mc/deploy_mutex.xml  925
-./doc/simgrid/examples/msg/mc/platform.xml  876
-./doc/simgrid/examples/msg/mc/deploy_bugged2.xml 377
-./doc/simgrid/examples/msg/mc/random_test.c  563
-./doc/simgrid/examples/msg/mc/deploy_bugged1.xml 459
-./doc/simgrid/examples/msg/mc/bugged3.c  1827
-./doc/simgrid/examples/msg/mc/deploy_random_test.xml 468
-./doc/simgrid/examples/msg/mc/bugged2.c  1957
-./doc/simgrid/examples/msg/mc/centralized_mutex.c 3375
-./doc/simgrid/examples/msg/token_ring/two_clusters.xml 1007
-./doc/simgrid/examples/msg/token_ring/ring_call.c 4205
-./doc/simgrid/examples/msg/token_ring/two_peers.xml 556
-./doc/simgrid/examples/msg/msg_platform.xml 2261806  
-./doc/simgrid/examples/msg/priority/deployment_priority.xml  406
-./doc/simgrid/examples/msg/priority/priority.c  2394
-./doc/simgrid/examples/msg/actions/actions.c  19339
-./doc/simgrid/examples/msg/actions/deployment.xml 249
-./doc/simgrid/examples/msg/actions/NAS_LU_S_4/platform_flat.xml  6805
-./doc/simgrid/examples/msg/actions/NAS_LU_S_4/platform.xml  387
-./doc/simgrid/examples/msg/actions/NAS_LU_S_4/deploy_MPI_4.xml  605
-./doc/simgrid/examples/msg/actions/sim.0.bordereau.lu.b.8/toto.xml  1066
-./doc/simgrid/examples/msg/actions/sim.0.bordereau.lu.b.8/titi.xml  1066
-./doc/simgrid/examples/msg/actions/deployment_split.xml  525
-./doc/simgrid/examples/msg/actions/homogeneous_3_hosts.xml  906
-./doc/simgrid/examples/msg/actions/bcast_deployment.xml  224
-./doc/simgrid/examples/msg/actions/actions_deployment_split.xml  501
-./doc/simgrid/examples/msg/masterslave/masterslave_bypass.c  9082
-./doc/simgrid/examples/msg/masterslave/deployment_masterslave_mailbox.xml 990
-./doc/simgrid/examples/msg/masterslave/masterslave_cluster.c  6773
-./doc/simgrid/examples/msg/masterslave/masterslave_console.c  3952
-./doc/simgrid/examples/msg/masterslave/platform_clusters.xml  930
-./doc/simgrid/examples/msg/masterslave/deployment_masterslave_mailbox_multicore.xml  1078
-./doc/simgrid/examples/msg/masterslave/masterslave_failure.c  7120
-./doc/simgrid/examples/msg/masterslave/deployment_masterslave_vivaldi.xml 4170
-./doc/simgrid/examples/msg/masterslave/deployment_masterslave_forwarder.xml 1382
-./doc/simgrid/examples/msg/masterslave/masterslave_forwarder.c  6438
-./doc/simgrid/examples/msg/masterslave/platform_script.lua  2535
-./doc/simgrid/examples/msg/masterslave/deployment_masterslave.xml  998
-./doc/simgrid/examples/msg/masterslave/jumbo_deployment.xml  6805
-./doc/simgrid/examples/msg/masterslave/jumbo_deployment_masterslave_mailbox.xml  878
-./doc/simgrid/examples/msg/masterslave/masterslave_mailbox.c  4118
-./doc/simgrid/examples/msg/suspend/suspend.c  2692
-./doc/simgrid/examples/msg/suspend/deployment_suspend.xml  183
-./doc/simgrid/examples/msg/small_platform_with_routers.xml  5295
-./doc/simgrid/examples/msg/chord/chord90.xml  13992
-./doc/simgrid/examples/msg/chord/chord.xml  2236
-./doc/simgrid/examples/msg/chord/chord10k.xml 1624671  
-./doc/simgrid/examples/msg/chord/chord.c  28995
-./doc/simgrid/examples/lua/multi_matrix/quicksort_platform.xml  4628
-./doc/simgrid/examples/lua/multi_matrix/mult_matrix.lua  227
-./doc/simgrid/examples/lua/multi_matrix/receiver.lua 1199
-./doc/simgrid/examples/lua/multi_matrix/quicksort_deployment.xml  524
-./doc/simgrid/examples/lua/multi_matrix/sender.lua 748
-./doc/simgrid/examples/lua/mult_matrix.lua  2196
-./doc/simgrid/examples/lua/README  1416
-./doc/simgrid/examples/lua/deploy.xml  879
-./doc/simgrid/examples/lua/splaySim/master.lua  1125
-./doc/simgrid/examples/lua/splaySim/slave.lua  729
-./doc/simgrid/examples/lua/splaySim/splay_platform.lua 1950
-./doc/simgrid/examples/lua/splaySim/splay_ctrl.lua 304
-./doc/simgrid/examples/lua/splaySim/splay_deploy_masterslave.lua  487
-./doc/simgrid/examples/lua/tracing/master.lua  1390
-./doc/simgrid/examples/lua/tracing/slave.lua  713
-./doc/simgrid/examples/lua/tracing/master_slave_trace.lua  491
-./doc/simgrid/examples/lua/SimSplay/sim_splay.lua 2298
-./doc/simgrid/examples/lua/SimSplay/splay_school.lua 402
-./doc/simgrid/examples/lua/SimSplay/chord.lua  1906
-./doc/simgrid/examples/lua/SimSplay/platform_script.lua  1706
-./doc/simgrid/examples/lua/console/master.lua  1125
-./doc/simgrid/examples/lua/console/deploy.lua  480
-./doc/simgrid/examples/lua/console/slave.lua  730
-./doc/simgrid/examples/lua/console/platform.lua 2424
-./doc/simgrid/examples/lua/console/master_slave_bypass.lua  158
-./doc/simgrid/examples/lua/masterslave/master.lua 1125
-./doc/simgrid/examples/lua/masterslave/slave.lua 730
-./doc/simgrid/examples/lua/masterslave/platform.lua 2424
-./doc/simgrid/examples/lua/masterslave/master_slave.lua  378
-./doc/simgrid/examples/simdag/properties/sd_prop.c 3012
-./doc/simgrid/examples/simdag/dax/Strassen.xml  9663
-./doc/simgrid/examples/simdag/dax/Montage_25.xml 23087
-./doc/simgrid/examples/simdag/dax/Sipht_30.xml 267014   
-./doc/simgrid/examples/simdag/dax/dax_test.c  4346
-./doc/simgrid/examples/simdag/dax/Montage_50.xml 48868
-./doc/simgrid/examples/simdag/dax/Inspiral_30.xml 28774
-./doc/simgrid/examples/simdag/dax/sagittaire.xml 289
-./doc/simgrid/examples/simdag/scheduling/minmin_test.c 11328
-./doc/simgrid/examples/simdag/scheduling/Montage_25.xml  23087
-./doc/simgrid/examples/simdag/scheduling/simulacrum_7_hosts.xml  5670
-./doc/simgrid/examples/simdag/sd_seq_access.c  4153
-./doc/simgrid/examples/simdag/sd_test_console.c 6976
-./doc/simgrid/examples/simdag/metaxml/sd_meta.c 2207
-./doc/simgrid/examples/simdag/2clusters.xml  14326
-./doc/simgrid/examples/simdag/sd_test2.c  7538
-./doc/simgrid/examples/simdag/platform_script.lua 1864
-./doc/simgrid/examples/simdag/simdag_trace.c  4354
-./doc/simgrid/examples/simdag/sd_test.c  6964
-./doc/simgrid/examples/simdag/dot/dot_test2.c  1622
-./doc/simgrid/examples/simdag/dot/simulate_dot.c 3590
-./doc/simgrid/examples/simdag/dot/dot_test.c  4002
-./doc/simgrid/examples/platforms/g5k.xml  17028
-./doc/simgrid/examples/platforms/One_cluster_no_backbone.xml  482
-./doc/simgrid/examples/platforms/g5k_cabinets.xml 22645
-./doc/simgrid/examples/platforms/nancy.xml  4028
-./doc/simgrid/examples/platforms/lcg_sept2004_grid.xml 15970
-./doc/simgrid/examples/platforms/Two_clusters.xml 930
-./doc/simgrid/examples/platforms/vivaldi.xml  3274
-./doc/simgrid/examples/platforms/gridpp_grid_2004.xml 6096
-./doc/simgrid/examples/platforms/griffon.xml  1879
-./doc/simgrid/examples/platforms/median_harvard.xml 28125
-./doc/simgrid/examples/platforms/prop.xml  1273
-./doc/simgrid/examples/platforms/One_cluster.xml 661
-./doc/simgrid/examples/platforms/gdx.xml  2323
-./doc/simgrid/examples/platforms/multicore_machine.xml 222
-./doc/simgrid/html/group__XBT__str.html  36192
-./doc/simgrid/html/group__XBT__cfg__decl.html  14505
-./doc/simgrid/html/bug.html 2130
-./doc/simgrid/html/group__MSG__C.html  10658
-./doc/simgrid/html/structs__xbt__strbuff__t.html 2512
-./doc/simgrid/html/MSG_ex_master_slave_lua_bypass.html 4803
-./doc/simgrid/html/simgrid_modules2.png  11932
-./doc/simgrid/html/classsimgrid_1_1msg_1_1Msg.html 1519
-./doc/simgrid/html/group__SURF__actions.html  13562
-./doc/simgrid/html/publis_intra.html  435
-./doc/simgrid/html/simgrid_logo_small.png  8326
-./doc/simgrid/html/group__SURF__resources.html  4203
-./doc/simgrid/html/structsurf__cpu__model__extension__public.html  2751
-./doc/simgrid/html/tabs.css 1095
-./doc/simgrid/html/group__XBT__set.html  6991
-./doc/simgrid/html/group__XBT__set__curs.html  9653
-./doc/simgrid/html/structxbt__ex__t.html  10014
-./doc/simgrid/html/pages.html 5794
-./doc/simgrid/html/MSG_ex_master_slave_scrip_lua.html 30160
-./doc/simgrid/html/group__XBT__API.html  6276
-./doc/simgrid/html/classsimgrid_1_1msg_1_1MsgException.html  1519
-./doc/simgrid/html/todo.html 3202
-./doc/simgrid/html/nav_f.png 159
-./doc/simgrid/html/group__XBT__queue.html  23050
-./doc/simgrid/html/group__XBT__fifo__cons.html  9876
-./doc/simgrid/html/structsurf__model.html  17707
-./doc/simgrid/html/MSG_ex_asynchronous_communications.html  43212
-./doc/simgrid/html/Paje_MSG_screenshot_thn.jpg  30326
-./doc/simgrid/html/structsurf__network__model__extension__public.html  2783
-./doc/simgrid/html/structsurf__model__description.html 2621
-./doc/simgrid/html/group__m__host__management.html 19042
-./doc/simgrid/html/group__XBT__fifo__perl.html  14045
-./doc/simgrid/html/modules.html  12734
-./doc/simgrid/html/annotated.html  7707
-./doc/simgrid/html/group__XBT__fifo.html  6191
-./doc/simgrid/html/group__XBT__parmap.html  3765
-./doc/simgrid/html/tracing.html  58483
-./doc/simgrid/html/structs__surf__metric__t.html 2523
-./doc/simgrid/html/classsimgrid_1_1msg_1_1Task.html 1519
-./doc/simgrid/html/group__XBT__swag.html  5923
-./doc/simgrid/html/functions_vars.html  11436
-./doc/simgrid/html/group__XBT__swag__type.html  8194
-./doc/simgrid/html/win_install_02.png  60084
-./doc/simgrid/html/simgrid_modules.png  8309
-./doc/simgrid/html/group__XBT__error.html  8348
-./doc/simgrid/html/group__XBT__dynar__cons.html 15743
-./doc/simgrid/html/simgrid_logo.png  21536
-./doc/simgrid/html/group__XBT__fifo__misc.html  7717
-./doc/simgrid/html/group__XBT__context.html  3460
-./doc/simgrid/html/group__m__channel__management.html 8963
-./doc/simgrid/html/structm__task.html  4188
-./doc/simgrid/html/group__XBT__swag__curs.html  8561
-./doc/simgrid/html/group__XBT__log.html  60965
-./doc/simgrid/html/open.png 118
-./doc/simgrid/html/group__msg__simulation.html  9008
-./doc/simgrid/html/group__XBT__dynar__cursor.html 11976
-./doc/simgrid/html/group__XBT__log__cats.html  5102
-./doc/simgrid/html/win_install_03.png  55802
-./doc/simgrid/html/poster_thumbnail.png  3249
-./doc/simgrid/html/group__m__datatypes__management__details.html  7557
-./doc/simgrid/html/group__XBT__set__basic.html  24314
-./doc/simgrid/html/win_install_01.png  61053
-./doc/simgrid/html/closed.png 126
-./doc/simgrid/html/group__XBT__adt.html  6958
-./doc/simgrid/html/index.html 9659
-./doc/simgrid/html/group__SD__link__management.html 17867
-./doc/simgrid/html/group__MSG__JAVA.html  5443
-./doc/simgrid/html/group__SURF__simulation.html 10385
-./doc/simgrid/html/structm__host.html  4188
-./doc/simgrid/html/group__XBT__dynar__array.html 22436
-./doc/simgrid/html/simgrid.css 386
-./doc/simgrid/html/group__SD__task__dependency__management.html  15389
-./doc/simgrid/html/group__XBT__grounding.html  7225
-./doc/simgrid/html/pls.html 11863
-./doc/simgrid/html/group__XBT__dynar__ctn.html  12693
-./doc/simgrid/html/functions.html  11564
-./doc/simgrid/html/group__XBT__dynar__speed.html 9616
-./doc/simgrid/html/installSimgrid.html  24837
-./doc/simgrid/html/triva-graph_configuration.png 59769
-./doc/simgrid/html/triva-graph_visualization.png 55335
-./doc/simgrid/html/MSG_ex_master_slave.html  51294
-./doc/simgrid/html/doxygen.png 3942
-./doc/simgrid/html/group__XBT__mallocator__cons.html 10757
-./doc/simgrid/html/group__API__index.html 125324   
-./doc/simgrid/html/group__XBT__dict__cons.html  9746
-./doc/simgrid/html/group__XBT__swag__func.html  19885
-./doc/simgrid/html/group__SimGrid__API.html  4674
-./doc/simgrid/html/group__XBT__dynar__misc.html 9591
-./doc/simgrid/html/structxbt__set__elm__.html  5121
-./doc/simgrid/html/group__XBT__cfg__get.html  19320
-./doc/simgrid/html/bindings.html  23685
-./doc/simgrid/html/group__XBT__dict.html  6916
-./doc/simgrid/html/use.html 3904
-./doc/simgrid/html/group__XBT__dict__basic.html 20935
-./doc/simgrid/html/group__XBT__graph.html  23682
-./doc/simgrid/html/group__XBT__mallocator.html  6444
-./doc/simgrid/html/structsurf__workstation__model__extension__public.html 11076
-./doc/simgrid/html/publis.html 435
-./doc/simgrid/html/group__XBT__misc.html  4663
-./doc/simgrid/html/simdag.html 226
-./doc/simgrid/html/Paje_MSG_screenshot.jpg 340759   
-./doc/simgrid/html/group__msg__gos__functions.html 65293
-./doc/simgrid/html/classsimgrid_1_1msg_1_1Host.html 1519
-./doc/simgrid/html/publis_extern.html  435
-./doc/simgrid/html/group__MSG__LUA.html  5094
-./doc/simgrid/html/group__XBT__dynar.html  14081
-./doc/simgrid/html/structs__model__type.html  2480
-./doc/simgrid/html/group__XBT__synchro.html  19296
-./doc/simgrid/html/bc_s.png 677
-./doc/simgrid/html/classes.html  6934
-./doc/simgrid/html/group__XBT__fifo__direct.html 29778
-./doc/simgrid/html/group__XBT__cfg__use.html  37757
-./doc/simgrid/html/group__XBT__mallocator__objects.html  9306
-./doc/simgrid/html/classsimgrid_1_1msg_1_1Process.html 1519
-./doc/simgrid/html/group__XBT__dict__multi.html 18525
-./doc/simgrid/html/group__m__datatypes__management.html  16459
-./doc/simgrid/html/tab_b.png 178
-./doc/simgrid/html/group__SD__simulation.html  45009
-./doc/simgrid/html/group__msg__easier__life.html 50885
-./doc/simgrid/html/group__m__task__management.html 35307
-./doc/simgrid/html/tab_a.png 140
-./doc/simgrid/html/group__XBT__config.html  16354
-./doc/simgrid/html/options.html  7629
-./doc/simgrid/html/group__XBT__dict__nnul.html  18891
-./doc/simgrid/html/win_install_04.png  52033
-./doc/simgrid/html/structsurf__action.html  8353
-./doc/simgrid/html/group__XBT__ex.html  32537
-./doc/simgrid/html/group__SURF__API.html  6659
-./doc/simgrid/html/doxygen.css 12350
-./doc/simgrid/html/group__XBT__set__cons.html  7965
-./doc/simgrid/html/group__SURF__build__api.html 7821
-./doc/simgrid/html/group__m__process__management.html 47169
-./doc/simgrid/html/group__XBT__dict__curs.html  19747
-./doc/simgrid/html/group__SD__datatypes__management.html  20816
-./doc/simgrid/html/group__SD__API.html  8379
-./doc/simgrid/html/group__SMPI__API.html  4776
-./doc/simgrid/html/group__XBT__dynar__perl.html 12131
-./doc/simgrid/html/group__XBT__cfg__register.html 15874
-./doc/simgrid/html/publis_core.html  435
-./doc/simgrid/html/group__SD__workstation__management.html  46397
-./doc/simgrid/html/MSG_ex_master_slave_lua.html 4794
-./doc/simgrid/html/group__MSG__API.html  6026
-./doc/simgrid/html/msg.html 227
-./doc/simgrid/html/group__SD__task__management.html 60347
-./doc/simgrid/html/group__XBT__syscall.html  10095
-./doc/simgrid/html/group__XBT__heap.html  18482
-./doc/simgrid/html/structsurf__action__state.html 7301
-./doc/simgrid/html/tab_s.png 189
-./doc/simgrid/html/tab_h.png 192
-./doc/simgrid/html/nav_h.png  97  
-./include/smpi/mpif.h  4826
-./include/smpi/smpif.h  1139
-./include/smpi/mpi.h  510
-./include/smpi/smpi_cocci.h 3187
-./include/smpi/smpi.h  24101
-./include/xbt/fifo.h  3626
-./include/xbt/dict.h  7459
-./include/xbt/str.h  2111
-./include/xbt/log.h  25433
-./include/xbt/misc.h  8031
-./include/xbt/synchro_core.h 4477
-./include/xbt/mmalloc.h 1976
-./include/xbt/replay_trace_reader.h  917
-./include/xbt/function_types.h  1111
-./include/xbt/strbuff.h  1281
-./include/xbt/virtu.h  684
-./include/xbt/asserts.h  1871
-./include/xbt/ex.h  23255
-./include/xbt/graph.h  5668
-./include/xbt/graphxml.h  5474
-./include/xbt/queue.h  2252
-./include/xbt/matrix.h  3027
-./include/xbt/setset.h  2422
-./include/xbt/time.h  743
-./include/xbt/lib.h  2014
-./include/xbt/hash.h  1064
-./include/xbt/set.h  4383
-./include/xbt/config.h  9224
-./include/xbt/sysdep.h  4941
-./include/xbt/swag.h  5352
-./include/xbt/graphxml_parse.h  1926
-./include/xbt/peer.h  870
-./include/xbt/module.h  648
-./include/xbt/cunit.h  5523
-./include/xbt/parmap.h  1166
-./include/xbt/mallocator.h  2296
-./include/xbt/dynar.h  9553
-./include/xbt/heap.h  1444
-./include/xbt.h  876
-./include/msg/datatypes.h 4635
-./include/msg/msg.h  12038
-./include/simgrid_config.h 3641
-./include/mc/modelchecker.h  96
-./include/surf/simgrid_dtd.h  23583
-./include/surf/surf_routing.h  1167
-./include/surf/surfxml_parse.h  5343
-./include/instr/instr.h  5750
-./include/simdag/simdag.h  10325
-./include/simdag/datatypes.h  3715
-./include/simix/simix.h  13003
-./include/simix/datatypes.h  3346
-./include/simix/context.h  4040
-./lib/libsimgrid.so.3.6.2  12710497
-./bin/smpicc  918
-./bin/smpirun  7292
-./bin/smpif2c  1990
-./bin/simgrid_update_xml  5018
-./bin/graphicator  66986
-./bin/simgrid-colorizer  2993
-./bin/smpiff  820
-./bin/tesh  356434
+/doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx  71
+/doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml  1262
+/doc/simgrid/examples/cxx/autoDestination/Main.cxx  148
+/doc/simgrid/examples/cxx/autoDestination/Slave.cxx  870
+/doc/simgrid/examples/cxx/autoDestination/BasicTask.cxx  65
+/doc/simgrid/examples/cxx/autoDestination/Master.cxx  1891
+/doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml  2133932
+/doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx  1137
+/doc/simgrid/explicitDestination/FinalizeTask.cxx 71
+/doc/simgrid/examples/cxx/basic/Main.cxx  148
+/doc/simgrid/examples/cxx/basic/Slave.cxx  693
+/doc/simgrid/examples/cxx/basic/BasicTask.cxx  65
+/doc/simgrid/examples/cxx/basic/basic_platform.xml  2133932  
+/doc/simgrid/examples/cxx/basic/Master.cxx  2148
+/doc/simgrid/examples/cxx/basic/basic_deployment.xml 1188
+/doc/simgrid/examples/cxx/basic/Forwarder.cxx  1244
+/doc/simgrid/examples/cxx/explicitDestination/FinalizeTask.cxx  71
+/doc/simgrid/examples/cxx/explicitDestination/Main.cxx  148
+/doc/simgrid/examples/cxx/explicitDestination/explicitDestination_platform.xml  2133932
+/doc/simgrid/examples/cxx/explicitDestination/Slave.cxx  913
+/doc/simgrid/examples/cxx/explicitDestination/BasicTask.cxx  65
+/doc/simgrid/examples/cxx/explicitDestination/explicitDestination_deployment.xml  1188
+/doc/simgrid/examples/cxx/explicitDestination/Master.cxx  1896
+/doc/simgrid/examples/cxx/explicitDestination/Forwarder.cxx  1181
+/doc/simgrid/examples/cxx/ping_pong/Main.cxx  149
+/doc/simgrid/examples/cxx/ping_pong/Sender.cxx 1073
+/doc/simgrid/examples/cxx/ping_pong/ping_pong_deployment.xml  275
+/doc/simgrid/examples/cxx/ping_pong/ping_pong_platform.xml  4718
+/doc/simgrid/examples/cxx/ping_pong/Receiver.cxx 957
+/doc/simgrid/examples/cxx/ping_pong/PingPongTask.cxx 71
+/doc/simgrid/examples/cxx/comm_time/FinalizeTask.cxx 71
+/doc/simgrid/examples/cxx/comm_time/Main.cxx  146
+/doc/simgrid/examples/cxx/comm_time/CommTimeTask.cxx 71
+/doc/simgrid/examples/cxx/comm_time/Slave.cxx  889
+/doc/simgrid/examples/cxx/comm_time/comm_time_platform.xml  2133932
+/doc/simgrid/examples/cxx/comm_time/Master.cxx  1730
+/doc/simgrid/examples/cxx/comm_time/comm_time_deployment.xml  1884
+/doc/simgrid/examples/cxx/suspend/Main.cxx  150
+/doc/simgrid/examples/cxx/suspend/suspend_platform.xml  2133932
+/doc/simgrid/examples/cxx/suspend/suspend_deployment.xml  187
+/doc/simgrid/examples/cxx/suspend/DreamMaster.cxx 826
+/doc/simgrid/examples/cxx/suspend/LazyGuy.cxx  429
+/doc/simgrid/examples/smpi/mc_bugged2.c  1387
+/doc/simgrid/examples/smpi/scatter.c  3496
+/doc/simgrid/examples/smpi/mc_bugged1.c  1411
+/doc/simgrid/examples/smpi/get_processor_name.c  649
+/doc/simgrid/examples/smpi/NAS/README  1857
+/doc/simgrid/examples/smpi/NAS/EP-sampling/README  347
+/doc/simgrid/examples/smpi/NAS/EP-sampling/randlc.c  3300
+/doc/simgrid/examples/smpi/NAS/EP-sampling/ep.c  13723
+/doc/simgrid/examples/smpi/NAS/EP-trace/README  347
+/doc/simgrid/examples/smpi/NAS/EP-trace/randlc.c  3300
+/doc/simgrid/examples/smpi/NAS/EP-trace/ep-trace.c  13850
+/doc/simgrid/examples/smpi/NAS/config/NAS.samples/README  394
+/doc/simgrid/examples/smpi/NAS/IS-trace/is-trace.c 38276
+/doc/simgrid/examples/smpi/NAS/DT-trace/README 999
+/doc/simgrid/examples/smpi/NAS/DT-trace/DGraph.c 5451
+/doc/simgrid/examples/smpi/NAS/DT-trace/dt.c  23031
+/doc/simgrid/examples/smpi/NAS/IS/is.c  38077
+/doc/simgrid/examples/smpi/NAS/MPI_dummy/README 2406
+/doc/simgrid/examples/smpi/NAS/MPI_dummy/mpi_dummy.c 5660
+/doc/simgrid/examples/smpi/NAS/MPI_dummy/wtime_sgi64.c  1700
+/doc/simgrid/examples/smpi/NAS/MPI_dummy/wtime.c 228
+/doc/simgrid/examples/smpi/NAS/common/randdp.c 1441
+/doc/simgrid/examples/smpi/NAS/common/c_timers.c 1159
+/doc/simgrid/examples/smpi/NAS/common/c_print_results.c  3086
+/doc/simgrid/examples/smpi/NAS/sys/README  1461
+/doc/simgrid/examples/smpi/NAS/sys/setparams.c 38805
+/doc/simgrid/examples/smpi/NAS/SP/README  926
+/doc/simgrid/examples/smpi/NAS/FT/README  276
+/doc/simgrid/examples/smpi/NAS/DT/README  999
+/doc/simgrid/examples/smpi/NAS/DT/DGraph.c  5451
+/doc/simgrid/examples/smpi/NAS/DT/dt.c  22620
+/doc/simgrid/examples/smpi/NAS/EP/README  347
+/doc/simgrid/examples/smpi/NAS/EP/randlc.c  3300
+/doc/simgrid/examples/smpi/NAS/EP/ep.c  13688
+/doc/simgrid/examples/smpi/NAS/DT-folding/README 999
+/doc/simgrid/examples/smpi/NAS/DT-folding/DGraph.c 5451
+/doc/simgrid/examples/smpi/NAS/DT-folding/dt.c 22704
+/doc/simgrid/examples/smpi/NAS/MG/README  5465
+/doc/simgrid/examples/smpi/bcast.c  983
+/doc/simgrid/examples/smpi/compute2.c  628
+/doc/simgrid/examples/smpi/sendrecv.c  1652
+/doc/simgrid/examples/smpi/allreduce.c  2135
+/doc/simgrid/examples/smpi/mvmul.c  7069
+/doc/simgrid/examples/smpi/alltoallv.c  4441
+/doc/simgrid/examples/smpi/smpi_traced.c  8529
+/doc/simgrid/examples/smpi/compute3.c  816
+/doc/simgrid/examples/smpi/reduce.c  3545
+/doc/simgrid/examples/smpi/bcbench.c  2466
+/doc/simgrid/examples/smpi/ttest01.c  1273
+/doc/simgrid/examples/smpi/compute.c  622
+/doc/simgrid/examples/smpi/barrier.c  766
+/doc/simgrid/examples/smpi/alltoall_basic.c  1453
+/doc/simgrid/examples/smpi/pingpong.c  2286
+/doc/simgrid/examples/smpi/alltoall2.c  2799
+/doc/simgrid/examples/smpi/split.c  705
+/doc/simgrid/examples/xbt/sem_basic.c  1970
+/doc/simgrid/examples/xbt/sem_sched.c  7207
+/doc/simgrid/examples/msg/small_platform.xml  4582
+/doc/simgrid/examples/msg/README  4805
+/doc/simgrid/examples/msg/properties/deployment_properties.xml  272
+/doc/simgrid/examples/msg/properties/msg_prop.c 3853
+/doc/simgrid/examples/msg/ns3/3links-p.xml  856
+/doc/simgrid/examples/msg/ns3/dogbone-d.xml  582
+/doc/simgrid/examples/msg/ns3/Two_clusters.xml 1817
+/doc/simgrid/examples/msg/ns3/3links-d.xml  927
+/doc/simgrid/examples/msg/ns3/3links-d-timer.xml 1280
+/doc/simgrid/examples/msg/ns3/ns3.c  5177
+/doc/simgrid/examples/msg/ns3/Two_clusters-d.xml 369
+/doc/simgrid/examples/msg/ns3/One_cluster-d.xml 367
+/doc/simgrid/examples/msg/ns3/dogbone-p.xml  1497
+/doc/simgrid/examples/msg/ns3/3hosts_2links_p.xml 566
+/doc/simgrid/examples/msg/ns3/3hosts_2links_d.xml 352
+/doc/simgrid/examples/msg/ns3/One_cluster.xml  658
+/doc/simgrid/examples/msg/migration/migration.c 2922
+/doc/simgrid/examples/msg/small_platform_with_failures.xml  4746
+/doc/simgrid/examples/msg/icomms/small_platform.xml 972
+/doc/simgrid/examples/msg/icomms/deployment_peer.xml 678
+/doc/simgrid/examples/msg/icomms/deployment_peer05.xml  891
+/doc/simgrid/examples/msg/icomms/deployment_peer02.xml  855
+/doc/simgrid/examples/msg/icomms/peer2.c  4276
+/doc/simgrid/examples/msg/icomms/deployment_peer03.xml  851
+/doc/simgrid/examples/msg/icomms/deployment_peer04.xml  852
+/doc/simgrid/examples/msg/icomms/peer.c  5102
+/doc/simgrid/examples/msg/icomms/deployment_peer01.xml  855
+/doc/simgrid/examples/msg/icomms/peer3.c  5258
+/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml  654
+/doc/simgrid/examples/msg/parallel_task/test_ptask.c 5423
+/doc/simgrid/examples/msg/parallel_task/test_ptask_platform.xml  2380
+/doc/simgrid/examples/msg/parallel_task/parallel_task.c  2708
+/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c  6217
+/doc/simgrid/examples/msg/trace/test9.xml  598
+/doc/simgrid/examples/msg/trace/test3.xml  372
+/doc/simgrid/examples/msg/trace/test_trace_integration.xml  206
+/doc/simgrid/examples/msg/trace/test2.xml  370
+/doc/simgrid/examples/msg/trace/test7.xml  501
+/doc/simgrid/examples/msg/trace/test11.xml  683
+/doc/simgrid/examples/msg/trace/test4.xml  371
+/doc/simgrid/examples/msg/trace/test10.xml  598
+/doc/simgrid/examples/msg/trace/test6.xml  372
+/doc/simgrid/examples/msg/trace/test8.xml  498
+/doc/simgrid/examples/msg/trace/test5.xml  371
+/doc/simgrid/examples/msg/trace/test_trace_integration.c  1960
+/doc/simgrid/examples/msg/trace/test1.xml  366
+/doc/simgrid/examples/msg/parallel_contexts/pcontexts_platform.xml  1002
+/doc/simgrid/examples/msg/parallel_contexts/deployment_pcontexts2_4.xml 467
+/doc/simgrid/examples/msg/parallel_contexts/pcontexts2.c  2236
+/doc/simgrid/examples/msg/parallel_contexts/deployment_pcontexts_2.xml 242
+/doc/simgrid/examples/msg/parallel_contexts/deployment_pcontexts_4.xml 353
+/doc/simgrid/examples/msg/parallel_contexts/pcontexts.c  1752
+/doc/simgrid/examples/msg/tracing/deployment.xml 800
+/doc/simgrid/examples/msg/tracing/ms.c  4374
+/doc/simgrid/examples/msg/tracing/platform.xml 3930
+/doc/simgrid/examples/msg/tracing/tasks.c  3594
+/doc/simgrid/examples/msg/tracing/procmig-deploy.xml 223
+/doc/simgrid/examples/msg/tracing/procmig.c  3282
+/doc/simgrid/examples/msg/tracing/categories.c 3358
+/doc/simgrid/examples/msg/sendrecv/README  689
+/doc/simgrid/examples/msg/sendrecv/deployment_sendrecv.xml  321
+/doc/simgrid/examples/msg/sendrecv/sendrecv.c  5098
+/doc/simgrid/examples/msg/sendrecv/platform_sendrecv.xml  528
+/doc/simgrid/examples/msg/gtnets/onelink-p.xml 439
+/doc/simgrid/examples/msg/gtnets/fullduplex-p.xml 575
+/doc/simgrid/examples/msg/gtnets/dogbone-d.xml 576
+/doc/simgrid/examples/msg/gtnets/waxman-d.xml  46642
+/doc/simgrid/examples/msg/gtnets/waxman-p.xml 4964600  
+/doc/simgrid/examples/msg/gtnets/fullduplex-d.xml 1029
+/doc/simgrid/examples/msg/gtnets/onelink-d.xml 356
+/doc/simgrid/examples/msg/gtnets/gtnets.c  6172
+/doc/simgrid/examples/msg/gtnets/dogbone-p.xml 1482
+/doc/simgrid/examples/msg/pmm/msg_pmm.c  9688
+/doc/simgrid/examples/msg/pmm/pmm_9_deploy.xml 786
+/doc/simgrid/examples/msg/mc/bugged1.c  1378
+/doc/simgrid/examples/msg/mc/deploy_bugged3.xml 377
+/doc/simgrid/examples/msg/mc/deploy_mutex.xml  925
+/doc/simgrid/examples/msg/mc/platform.xml  876
+/doc/simgrid/examples/msg/mc/deploy_bugged2.xml 377
+/doc/simgrid/examples/msg/mc/random_test.c  563
+/doc/simgrid/examples/msg/mc/deploy_bugged1.xml 459
+/doc/simgrid/examples/msg/mc/bugged3.c  1827
+/doc/simgrid/examples/msg/mc/deploy_random_test.xml 468
+/doc/simgrid/examples/msg/mc/bugged2.c  1957
+/doc/simgrid/examples/msg/mc/centralized_mutex.c 3375
+/doc/simgrid/examples/msg/token_ring/two_clusters.xml 1007
+/doc/simgrid/examples/msg/token_ring/ring_call.c 4205
+/doc/simgrid/examples/msg/token_ring/two_peers.xml 556
+/doc/simgrid/examples/msg/msg_platform.xml 2261806  
+/doc/simgrid/examples/msg/priority/deployment_priority.xml  406
+/doc/simgrid/examples/msg/priority/priority.c  2394
+/doc/simgrid/examples/msg/actions/actions.c  19339
+/doc/simgrid/examples/msg/actions/deployment.xml 249
+/doc/simgrid/examples/msg/actions/NAS_LU_S_4/platform_flat.xml  6805
+/doc/simgrid/examples/msg/actions/NAS_LU_S_4/platform.xml  387
+/doc/simgrid/examples/msg/actions/NAS_LU_S_4/deploy_MPI_4.xml  605
+/doc/simgrid/examples/msg/actions/sim.0.bordereau.lu.b.8/toto.xml  1066
+/doc/simgrid/examples/msg/actions/sim.0.bordereau.lu.b.8/titi.xml  1066
+/doc/simgrid/examples/msg/actions/deployment_split.xml  525
+/doc/simgrid/examples/msg/actions/homogeneous_3_hosts.xml  906
+/doc/simgrid/examples/msg/actions/bcast_deployment.xml  224
+/doc/simgrid/examples/msg/actions/actions_deployment_split.xml  501
+/doc/simgrid/examples/msg/masterslave/masterslave_bypass.c  9082
+/doc/simgrid/examples/msg/masterslave/deployment_masterslave_mailbox.xml 990
+/doc/simgrid/examples/msg/masterslave/masterslave_cluster.c  6773
+/doc/simgrid/examples/msg/masterslave/masterslave_console.c  3952
+/doc/simgrid/examples/msg/masterslave/platform_clusters.xml  930
+/doc/simgrid/examples/msg/masterslave/deployment_masterslave_mailbox_multicore.xml  1078
+/doc/simgrid/examples/msg/masterslave/masterslave_failure.c  7120
+/doc/simgrid/examples/msg/masterslave/deployment_masterslave_vivaldi.xml 4170
+/doc/simgrid/examples/msg/masterslave/deployment_masterslave_forwarder.xml 1382
+/doc/simgrid/examples/msg/masterslave/masterslave_forwarder.c  6438
+/doc/simgrid/examples/msg/masterslave/platform_script.lua  2535
+/doc/simgrid/examples/msg/masterslave/deployment_masterslave.xml  998
+/doc/simgrid/examples/msg/masterslave/jumbo_deployment.xml  6805
+/doc/simgrid/examples/msg/masterslave/jumbo_deployment_masterslave_mailbox.xml  878
+/doc/simgrid/examples/msg/masterslave/masterslave_mailbox.c  4118
+/doc/simgrid/examples/msg/suspend/suspend.c  2692
+/doc/simgrid/examples/msg/suspend/deployment_suspend.xml  183
+/doc/simgrid/examples/msg/small_platform_with_routers.xml  5295
+/doc/simgrid/examples/msg/chord/chord90.xml  13992
+/doc/simgrid/examples/msg/chord/chord.xml  2236
+/doc/simgrid/examples/msg/chord/chord10k.xml 1624671  
+/doc/simgrid/examples/msg/chord/chord.c  28995
+/doc/simgrid/examples/lua/multi_matrix/quicksort_platform.xml  4628
+/doc/simgrid/examples/lua/multi_matrix/mult_matrix.lua  227
+/doc/simgrid/examples/lua/multi_matrix/receiver.lua 1199
+/doc/simgrid/examples/lua/multi_matrix/quicksort_deployment.xml  524
+/doc/simgrid/examples/lua/multi_matrix/sender.lua 748
+/doc/simgrid/examples/lua/mult_matrix.lua  2196
+/doc/simgrid/examples/lua/README  1416
+/doc/simgrid/examples/lua/deploy.xml  879
+/doc/simgrid/examples/lua/splaySim/master.lua  1125
+/doc/simgrid/examples/lua/splaySim/slave.lua  729
+/doc/simgrid/examples/lua/splaySim/splay_platform.lua 1950
+/doc/simgrid/examples/lua/splaySim/splay_ctrl.lua 304
+/doc/simgrid/examples/lua/splaySim/splay_deploy_masterslave.lua  487
+/doc/simgrid/examples/lua/tracing/master.lua  1390
+/doc/simgrid/examples/lua/tracing/slave.lua  713
+/doc/simgrid/examples/lua/tracing/master_slave_trace.lua  491
+/doc/simgrid/examples/lua/SimSplay/sim_splay.lua 2298
+/doc/simgrid/examples/lua/SimSplay/splay_school.lua 402
+/doc/simgrid/examples/lua/SimSplay/chord.lua  1906
+/doc/simgrid/examples/lua/SimSplay/platform_script.lua  1706
+/doc/simgrid/examples/lua/console/master.lua  1125
+/doc/simgrid/examples/lua/console/deploy.lua  480
+/doc/simgrid/examples/lua/console/slave.lua  730
+/doc/simgrid/examples/lua/console/platform.lua 2424
+/doc/simgrid/examples/lua/console/master_slave_bypass.lua  158
+/doc/simgrid/examples/lua/masterslave/master.lua 1125
+/doc/simgrid/examples/lua/masterslave/slave.lua 730
+/doc/simgrid/examples/lua/masterslave/platform.lua 2424
+/doc/simgrid/examples/lua/masterslave/master_slave.lua  378
+/doc/simgrid/examples/simdag/properties/sd_prop.c 3012
+/doc/simgrid/examples/simdag/dax/Strassen.xml  9663
+/doc/simgrid/examples/simdag/dax/Montage_25.xml 23087
+/doc/simgrid/examples/simdag/dax/Sipht_30.xml 267014   
+/doc/simgrid/examples/simdag/dax/dax_test.c  4346
+/doc/simgrid/examples/simdag/dax/Montage_50.xml 48868
+/doc/simgrid/examples/simdag/dax/Inspiral_30.xml 28774
+/doc/simgrid/examples/simdag/dax/sagittaire.xml 289
+/doc/simgrid/examples/simdag/scheduling/minmin_test.c 11328
+/doc/simgrid/examples/simdag/scheduling/Montage_25.xml  23087
+/doc/simgrid/examples/simdag/scheduling/simulacrum_7_hosts.xml  5670
+/doc/simgrid/examples/simdag/sd_seq_access.c  4153
+/doc/simgrid/examples/simdag/sd_test_console.c 6976
+/doc/simgrid/examples/simdag/metaxml/sd_meta.c 2207
+/doc/simgrid/examples/simdag/2clusters.xml  14326
+/doc/simgrid/examples/simdag/sd_test2.c  7538
+/doc/simgrid/examples/simdag/platform_script.lua 1864
+/doc/simgrid/examples/simdag/simdag_trace.c  4354
+/doc/simgrid/examples/simdag/sd_test.c  6964
+/doc/simgrid/examples/simdag/dot/dot_test2.c  1622
+/doc/simgrid/examples/simdag/dot/simulate_dot.c 3590
+/doc/simgrid/examples/simdag/dot/dot_test.c  4002
+/doc/simgrid/examples/platforms/g5k.xml  17028
+/doc/simgrid/examples/platforms/One_cluster_no_backbone.xml  482
+/doc/simgrid/examples/platforms/g5k_cabinets.xml 22645
+/doc/simgrid/examples/platforms/nancy.xml  4028
+/doc/simgrid/examples/platforms/lcg_sept2004_grid.xml 15970
+/doc/simgrid/examples/platforms/Two_clusters.xml 930
+/doc/simgrid/examples/platforms/vivaldi.xml  3274
+/doc/simgrid/examples/platforms/gridpp_grid_2004.xml 6096
+/doc/simgrid/examples/platforms/griffon.xml  1879
+/doc/simgrid/examples/platforms/median_harvard.xml 28125
+/doc/simgrid/examples/platforms/prop.xml  1273
+/doc/simgrid/examples/platforms/One_cluster.xml 661
+/doc/simgrid/examples/platforms/gdx.xml  2323
+/doc/simgrid/examples/platforms/multicore_machine.xml 222
+/doc/simgrid/html/group__XBT__str.html  36192
+/doc/simgrid/html/group__XBT__cfg__decl.html  14505
+/doc/simgrid/html/bug.html 2130
+/doc/simgrid/html/group__MSG__C.html  10658
+/doc/simgrid/html/structs__xbt__strbuff__t.html 2512
+/doc/simgrid/html/MSG_ex_master_slave_lua_bypass.html 4803
+/doc/simgrid/html/simgrid_modules2.png  11932
+/doc/simgrid/html/classsimgrid_1_1msg_1_1Msg.html 1519
+/doc/simgrid/html/group__SURF__actions.html  13562
+/doc/simgrid/html/publis_intra.html  435
+/doc/simgrid/html/simgrid_logo_small.png  8326
+/doc/simgrid/html/group__SURF__resources.html  4203
+/doc/simgrid/html/structsurf__cpu__model__extension__public.html  2751
+/doc/simgrid/html/tabs.css 1095
+/doc/simgrid/html/group__XBT__set.html  6991
+/doc/simgrid/html/group__XBT__set__curs.html  9653
+/doc/simgrid/html/structxbt__ex__t.html  10014
+/doc/simgrid/html/pages.html 5794
+/doc/simgrid/html/MSG_ex_master_slave_scrip_lua.html 30160
+/doc/simgrid/html/group__XBT__API.html  6276
+/doc/simgrid/html/classsimgrid_1_1msg_1_1MsgException.html  1519
+/doc/simgrid/html/todo.html 3202
+/doc/simgrid/html/nav_f.png 159
+/doc/simgrid/html/group__XBT__queue.html  23050
+/doc/simgrid/html/group__XBT__fifo__cons.html  9876
+/doc/simgrid/html/structsurf__model.html  17707
+/doc/simgrid/html/MSG_ex_asynchronous_communications.html  43212
+/doc/simgrid/html/Paje_MSG_screenshot_thn.jpg  30326
+/doc/simgrid/html/structsurf__network__model__extension__public.html  2783
+/doc/simgrid/html/structsurf__model__description.html 2621
+/doc/simgrid/html/group__m__host__management.html 19042
+/doc/simgrid/html/group__XBT__fifo__perl.html  14045
+/doc/simgrid/html/modules.html  12734
+/doc/simgrid/html/annotated.html  7707
+/doc/simgrid/html/group__XBT__fifo.html  6191
+/doc/simgrid/html/group__XBT__parmap.html  3765
+/doc/simgrid/html/tracing.html  58483
+/doc/simgrid/html/structs__surf__metric__t.html 2523
+/doc/simgrid/html/classsimgrid_1_1msg_1_1Task.html 1519
+/doc/simgrid/html/group__XBT__swag.html  5923
+/doc/simgrid/html/functions_vars.html  11436
+/doc/simgrid/html/group__XBT__swag__type.html  8194
+/doc/simgrid/html/win_install_02.png  60084
+/doc/simgrid/html/simgrid_modules.png  8309
+/doc/simgrid/html/group__XBT__error.html  8348
+/doc/simgrid/html/group__XBT__dynar__cons.html 15743
+/doc/simgrid/html/simgrid_logo.png  21536
+/doc/simgrid/html/group__XBT__fifo__misc.html  7717
+/doc/simgrid/html/group__XBT__context.html  3460
+/doc/simgrid/html/group__m__channel__management.html 8963
+/doc/simgrid/html/structm__task.html  4188
+/doc/simgrid/html/group__XBT__swag__curs.html  8561
+/doc/simgrid/html/group__XBT__log.html  60965
+/doc/simgrid/html/open.png 118
+/doc/simgrid/html/group__msg__simulation.html  9008
+/doc/simgrid/html/group__XBT__dynar__cursor.html 11976
+/doc/simgrid/html/group__XBT__log__cats.html  5102
+/doc/simgrid/html/win_install_03.png  55802
+/doc/simgrid/html/poster_thumbnail.png  3249
+/doc/simgrid/html/group__m__datatypes__management__details.html  7557
+/doc/simgrid/html/group__XBT__set__basic.html  24314
+/doc/simgrid/html/win_install_01.png  61053
+/doc/simgrid/html/closed.png 126
+/doc/simgrid/html/group__XBT__adt.html  6958
+/doc/simgrid/html/index.html 9659
+/doc/simgrid/html/group__SD__link__management.html 17867
+/doc/simgrid/html/group__MSG__JAVA.html  5443
+/doc/simgrid/html/group__SURF__simulation.html 10385
+/doc/simgrid/html/structm__host.html  4188
+/doc/simgrid/html/group__XBT__dynar__array.html 22436
+/doc/simgrid/html/simgrid.css 386
+/doc/simgrid/html/group__SD__task__dependency__management.html  15389
+/doc/simgrid/html/group__XBT__grounding.html  7225
+/doc/simgrid/html/pls.html 11863
+/doc/simgrid/html/group__XBT__dynar__ctn.html  12693
+/doc/simgrid/html/functions.html  11564
+/doc/simgrid/html/group__XBT__dynar__speed.html 9616
+/doc/simgrid/html/installSimgrid.html  24837
+/doc/simgrid/html/triva-graph_configuration.png 59769
+/doc/simgrid/html/triva-graph_visualization.png 55335
+/doc/simgrid/html/MSG_ex_master_slave.html  51294
+/doc/simgrid/html/doxygen.png 3942
+/doc/simgrid/html/group__XBT__mallocator__cons.html 10757
+/doc/simgrid/html/group__API__index.html 125324   
+/doc/simgrid/html/group__XBT__dict__cons.html  9746
+/doc/simgrid/html/group__XBT__swag__func.html  19885
+/doc/simgrid/html/group__SimGrid__API.html  4674
+/doc/simgrid/html/group__XBT__dynar__misc.html 9591
+/doc/simgrid/html/structxbt__set__elm__.html  5121
+/doc/simgrid/html/group__XBT__cfg__get.html  19320
+/doc/simgrid/html/bindings.html  23685
+/doc/simgrid/html/group__XBT__dict.html  6916
+/doc/simgrid/html/use.html 3904
+/doc/simgrid/html/group__XBT__dict__basic.html 20935
+/doc/simgrid/html/group__XBT__graph.html  23682
+/doc/simgrid/html/group__XBT__mallocator.html  6444
+/doc/simgrid/html/structsurf__workstation__model__extension__public.html 11076
+/doc/simgrid/html/publis.html 435
+/doc/simgrid/html/group__XBT__misc.html  4663
+/doc/simgrid/html/simdag.html 226
+/doc/simgrid/html/Paje_MSG_screenshot.jpg 340759   
+/doc/simgrid/html/group__msg__gos__functions.html 65293
+/doc/simgrid/html/classsimgrid_1_1msg_1_1Host.html 1519
+/doc/simgrid/html/publis_extern.html  435
+/doc/simgrid/html/group__MSG__LUA.html  5094
+/doc/simgrid/html/group__XBT__dynar.html  14081
+/doc/simgrid/html/structs__model__type.html  2480
+/doc/simgrid/html/group__XBT__synchro.html  19296
+/doc/simgrid/html/bc_s.png 677
+/doc/simgrid/html/classes.html  6934
+/doc/simgrid/html/group__XBT__fifo__direct.html 29778
+/doc/simgrid/html/group__XBT__cfg__use.html  37757
+/doc/simgrid/html/group__XBT__mallocator__objects.html  9306
+/doc/simgrid/html/classsimgrid_1_1msg_1_1Process.html 1519
+/doc/simgrid/html/group__XBT__dict__multi.html 18525
+/doc/simgrid/html/group__m__datatypes__management.html  16459
+/doc/simgrid/html/tab_b.png 178
+/doc/simgrid/html/group__SD__simulation.html  45009
+/doc/simgrid/html/group__msg__easier__life.html 50885
+/doc/simgrid/html/group__m__task__management.html 35307
+/doc/simgrid/html/tab_a.png 140
+/doc/simgrid/html/group__XBT__config.html  16354
+/doc/simgrid/html/options.html  7629
+/doc/simgrid/html/group__XBT__dict__nnul.html  18891
+/doc/simgrid/html/win_install_04.png  52033
+/doc/simgrid/html/structsurf__action.html  8353
+/doc/simgrid/html/group__XBT__ex.html  32537
+/doc/simgrid/html/group__SURF__API.html  6659
+/doc/simgrid/html/doxygen.css 12350
+/doc/simgrid/html/group__XBT__set__cons.html  7965
+/doc/simgrid/html/group__SURF__build__api.html 7821
+/doc/simgrid/html/group__m__process__management.html 47169
+/doc/simgrid/html/group__XBT__dict__curs.html  19747
+/doc/simgrid/html/group__SD__datatypes__management.html  20816
+/doc/simgrid/html/group__SD__API.html  8379
+/doc/simgrid/html/group__SMPI__API.html  4776
+/doc/simgrid/html/group__XBT__dynar__perl.html 12131
+/doc/simgrid/html/group__XBT__cfg__register.html 15874
+/doc/simgrid/html/publis_core.html  435
+/doc/simgrid/html/group__SD__workstation__management.html  46397
+/doc/simgrid/html/MSG_ex_master_slave_lua.html 4794
+/doc/simgrid/html/group__MSG__API.html  6026
+/doc/simgrid/html/msg.html 227
+/doc/simgrid/html/group__SD__task__management.html 60347
+/doc/simgrid/html/group__XBT__syscall.html  10095
+/doc/simgrid/html/group__XBT__heap.html  18482
+/doc/simgrid/html/structsurf__action__state.html 7301
+/doc/simgrid/html/tab_s.png 189
+/doc/simgrid/html/tab_h.png 192
+/doc/simgrid/html/nav_h.png  97  
+/include/smpi/mpif.h  4826
+/include/smpi/smpif.h  1139
+/include/smpi/mpi.h  510
+/include/smpi/smpi_cocci.h 3187
+/include/smpi/smpi.h  24101
+/include/xbt/fifo.h  3626
+/include/xbt/dict.h  7459
+/include/xbt/str.h  2111
+/include/xbt/log.h  25433
+/include/xbt/misc.h  8031
+/include/xbt/synchro_core.h 4477
+/include/xbt/mmalloc.h 1976
+/include/xbt/replay_trace_reader.h  917
+/include/xbt/function_types.h  1111
+/include/xbt/strbuff.h  1281
+/include/xbt/virtu.h  684
+/include/xbt/asserts.h  1871
+/include/xbt/ex.h  23255
+/include/xbt/graph.h  5668
+/include/xbt/graphxml.h  5474
+/include/xbt/queue.h  2252
+/include/xbt/matrix.h  3027
+/include/xbt/setset.h  2422
+/include/xbt/time.h  743
+/include/xbt/lib.h  2014
+/include/xbt/hash.h  1064
+/include/xbt/set.h  4383
+/include/xbt/config.h  9224
+/include/xbt/sysdep.h  4941
+/include/xbt/swag.h  5352
+/include/xbt/graphxml_parse.h  1926
+/include/xbt/peer.h  870
+/include/xbt/module.h  648
+/include/xbt/cunit.h  5523
+/include/xbt/parmap.h  1166
+/include/xbt/mallocator.h  2296
+/include/xbt/dynar.h  9553
+/include/xbt/heap.h  1444
+/include/xbt.h  876
+/include/msg/datatypes.h 4635
+/include/msg/msg.h  12038
+/include/simgrid_config.h 3641
+/include/mc/modelchecker.h  96
+/include/surf/simgrid_dtd.h  23583
+/include/surf/surf_routing.h  1167
+/include/surf/surfxml_parse.h  5343
+/include/instr/instr.h  5750
+/include/simdag/simdag.h  10325
+/include/simdag/datatypes.h  3715
+/include/simix/simix.h  13003
+/include/simix/datatypes.h  3346
+/include/simix/context.h  4040
+/lib/libsimgrid.so.3.6.2  12710497
+/bin/smpicc  918
+/bin/smpirun  7292
+/bin/smpif2c  1990
+/bin/simgrid_update_xml  5018
+/bin/graphicator  66986
+/bin/simgrid-colorizer  2993
+/bin/smpiff  820
+/bin/tesh  356434
index cf109af..48972ca 100644 (file)
@@ -1,36 +1,36 @@
-.\Windows\avastSS.scr 41664\r
-.\Windows\bfsvc.exe 75264\r
-.\Windows\bootstat.dat 67584\r
-.\Windows\CoreSingleLanguage.xml 31497\r
-.\Windows\csup.txt 12\r
-.\Windows\dchcfg64.exe 335464\r
-.\Windows\dcmdev64.exe 93288\r
-.\Windows\DirectX.log 10486\r
-.\Windows\DPINST.LOG 18944\r
-.\Windows\DtcInstall.log 1955\r
-.\Windows\explorer.exe 2380944\r
-.\Windows\font1.sii 4907\r
-.\Windows\font2.sii 8698\r
-.\Windows\hapint.exe 382056\r
-.\Windows\HelpPane.exe 883712\r
-.\Windows\hh.exe 17408\r
-.\Windows\MEMORY.DMP 2384027342\r
-.\Windows\mib.bin 43131\r
-.\Windows\notepad.exe 243712\r
-.\Windows\PFRO.log 6770\r
-.\Windows\Professional.xml 31881\r
-.\Windows\regedit.exe 159232\r
-.\Windows\setupact.log 101663\r
-.\Windows\setuperr.log 0\r
-.\Windows\splwow64.exe 126464\r
-.\Windows\Starter.xml 31537\r
-.\Windows\system.ini 219\r
-.\Windows\twain_32.dll 50176\r
-.\Windows\vmgcoinstall.log 1585\r
-.\Windows\win.ini 92\r
-.\Windows\WindowsUpdate.log 1518934\r
-.\Windows\winhlp32.exe 10752\r
-.\Windows\WLXPGSS.SCR 322048\r
-.\Windows\WMSysPr9.prx 316640\r
-.\Windows\write.exe 10752\r
-.\Windows\_isusr32.dll 180320
\ No newline at end of file
+\Windows\avastSS.scr 41664\r
+\Windows\bfsvc.exe 75264\r
+\Windows\bootstat.dat 67584\r
+\Windows\CoreSingleLanguage.xml 31497\r
+\Windows\csup.txt 12\r
+\Windows\dchcfg64.exe 335464\r
+\Windows\dcmdev64.exe 93288\r
+\Windows\DirectX.log 10486\r
+\Windows\DPINST.LOG 18944\r
+\Windows\DtcInstall.log 1955\r
+\Windows\explorer.exe 2380944\r
+\Windows\font1.sii 4907\r
+\Windows\font2.sii 8698\r
+\Windows\hapint.exe 382056\r
+\Windows\HelpPane.exe 883712\r
+\Windows\hh.exe 17408\r
+\Windows\MEMORY.DMP 2384027342\r
+\Windows\mib.bin 43131\r
+\Windows\notepad.exe 243712\r
+\Windows\PFRO.log 6770\r
+\Windows\Professional.xml 31881\r
+\Windows\regedit.exe 159232\r
+\Windows\setupact.log 101663\r
+\Windows\setuperr.log 0\r
+\Windows\splwow64.exe 126464\r
+\Windows\Starter.xml 31537\r
+\Windows\system.ini 219\r
+\Windows\twain_32.dll 50176\r
+\Windows\vmgcoinstall.log 1585\r
+\Windows\win.ini 92\r
+\Windows\WindowsUpdate.log 1518934\r
+\Windows\winhlp32.exe 10752\r
+\Windows\WLXPGSS.SCR 322048\r
+\Windows\WMSysPr9.prx 316640\r
+\Windows\write.exe 10752\r
+\Windows\_isusr32.dll 180320
\ No newline at end of file
index 7ad5b02..988e40b 100644 (file)
@@ -37,7 +37,7 @@
     </host>
 
     <host id="alice" power="1Gf">
-      <mount storageId="Disk2" name="/windows"/>
+      <mount storageId="Disk2" name="c:"/>
     </host>
 
     <host id="carl" power="1Gf">
@@ -45,7 +45,7 @@
     </host>
 
     <host id="denise" power="1Gf">
-      <mount storageId="Disk2" name="/windows"/>       
+      <mount storageId="Disk2" name="c:"/>     
       <mount storageId="Disk4" name="/home"/>  
     </host>
 
index 928bd2e..2f2ceed 100644 (file)
@@ -1,8 +1,8 @@
 #! ./tesh
 
 $ ${bindir:=.}/io/sd_io ${srcdir:=.}/examples/platforms/storage.xml 
+> [0.000000] [sd_io/INFO] Workstation 'denise' mounts 'c:'
 > [0.000000] [sd_io/INFO] Workstation 'denise' mounts '/home'
-> [0.000000] [sd_io/INFO] Workstation 'denise' mounts '/windows'
-> [0.000000] [sd_io/INFO] Workstation 'alice' mounts '/windows'
+> [0.000000] [sd_io/INFO] Workstation 'alice' mounts 'c:'
 > [0.000000] [sd_io/INFO] Workstation 'carl' mounts '/home'
 > [0.000000] [sd_io/INFO] Workstation 'bob' mounts '/home'
index 154b3d5..7420e84 100644 (file)
@@ -23,10 +23,16 @@ if(enable_smpi)
     add_executable(mc/bugged1 mc/bugged1.c)
     add_executable(mc/bugged2 mc/bugged2.c)
     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)
@@ -58,6 +64,9 @@ set(examples_src
   ${CMAKE_CURRENT_SOURCE_DIR}/mc/bugged2.c
   ${CMAKE_CURRENT_SOURCE_DIR}/mc/bugged1.c
   ${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
@@ -67,6 +76,9 @@ set(bin_files
   ${CMAKE_CURRENT_SOURCE_DIR}/mc/hostfile_bugged1_liveness
   ${CMAKE_CURRENT_SOURCE_DIR}/mc/hostfile_bugged1
   ${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
index c77fdd9..f8b74fd 100644 (file)
@@ -1,6 +1,7 @@
 p Test smpi bindings for dvfs functions (C example)
 $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile  -platform ${srcdir:=.}/platform.xml --cfg=smpi/cpu_threshold:-1 ${bindir:=.}/se --cfg=plugin:Energy --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
index c23f3f8..9173c49 100644 (file)
@@ -2,6 +2,7 @@ p Test smpi bindings for dvfs functions (Fortran 77 example)
 ! output sort 1
 $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile  -platform ${srcdir:=.}/platform.xml --cfg=smpi/cpu_threshold:-1 ${bindir:=.}/f77/sef --cfg=plugin:Energy --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
index 51a6ea2..a4c4644 100644 (file)
       double precision p, t, e
 
       call MPI_Init(ierr)
+      if (ierr .ne. MPI_SUCCESS) then
+         print *, 'MPI_Init failed:', ierr
+         stop 1
+      endif
       call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
+      if (ierr .ne. MPI_SUCCESS) then
+         print *, 'MPI_Comm_rank failed:', ierr
+         call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
+         stop 1
+      endif
 
       pstates = smpi_get_host_nb_pstates()
 
       end do
 
       call MPI_Finalize(ierr)
+      if (ierr .ne. MPI_SUCCESS) then
+         print *, 'MPI_Finalize failed:', ierr
+         call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
+         stop 1
+      endif
 
       end program main
index c39d8bd..799dffd 100644 (file)
@@ -2,6 +2,7 @@ p Test smpi bindings for dvfs functions (Fortran 90 example)
 ! output sort 1
 $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile  -platform ${srcdir:=.}/platform.xml --cfg=smpi/cpu_threshold:-1 ${bindir:=.}/f90/sef90 --cfg=plugin:Energy  --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
index f1db81a..833bf73 100644 (file)
@@ -13,7 +13,16 @@ program main
   double precision p, t, e
 
   call MPI_Init(ierr)
+  if (ierr .ne. MPI_SUCCESS) then
+     print *, 'MPI_Init failed:', ierr
+     stop 1
+  endif
   call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
+  if (ierr .ne. MPI_SUCCESS) then
+     print *, 'MPI_Comm_rank failed:', ierr
+     call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
+     stop 1
+  endif
 
   pstates = smpi_get_host_nb_pstates()
 
@@ -40,5 +49,10 @@ program main
   end do
 
   call MPI_Finalize(ierr)
+  if (ierr .ne. MPI_SUCCESS) then
+     print *, 'MPI_Finalize failed:', ierr
+     call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
+     stop 1
+  endif
 
 end program main
index ba969e5..2c4571a 100644 (file)
@@ -16,13 +16,20 @@ int main(int argc, char *argv[])
   char buf[1024];
   char *s;
   size_t sz, x;
+  int err;
 
-  if (MPI_Init(&argc, &argv) != MPI_SUCCESS) {
-    fprintf(stderr, "MPI initialization failed!\n");
+  err = MPI_Init(&argc, &argv);
+  if (err != MPI_SUCCESS) {
+    fprintf(stderr, "MPI_init failed: %d\n", err);
     exit(EXIT_FAILURE);
   }
 
-  MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
+  err = MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
+  if (err != MPI_SUCCESS) {
+    fprintf(stderr, "MPI_Comm_rank failed: %d", err);
+    MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
+    exit(EXIT_FAILURE);
+  }
 
   pstates = smpi_get_host_nb_pstates();
 
@@ -59,5 +66,12 @@ int main(int argc, char *argv[])
             MPI_Wtime(), rank, smpi_get_host_consumed_energy());
   }
 
-  return MPI_Finalize();
+  err = MPI_Finalize();
+  if (err != MPI_SUCCESS) {
+    fprintf(stderr, "MPI_Finalize failed: %d\n", err);
+    MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
+    exit(EXIT_FAILURE);
+  }
+
+  return EXIT_SUCCESS;
 }
index cc784eb..7305370 100644 (file)
@@ -10,6 +10,9 @@
 /* LTL property checked : G(r->F(cs)); (r=request of CS, cs=CS ok)            */
 /******************************************************************************/
 
+/* Run :
+  /usr/bin/time -f "clock:%e user:%U sys:%S swapped:%W exitval:%x max:%Mk" "$@" ../../../smpi_script/bin/smpirun -hostfile hostfile_bugged1_liveness -platform ../../platforms/cluster.xml --cfg=model-check:1 --cfg=contexts/factory:ucontext --cfg=model-check/reduction:none --cfg=model-check/property:promela_bugged1_liveness --cfg=smpi/send_is_detached_thres:0 --cfg=contexts/stack_size:128 --cfg=model-check/visited:100000 --cfg=model-check/max_depth:100000 ./bugged1_liveness */
+
 #include <stdio.h>
 #include <mpi.h>
 #include <simgrid/modelchecker.h>
@@ -62,7 +65,7 @@ int main(int argc, char **argv){
           printf("CS already used.\n");
           xbt_dynar_push(requests, &recv_buff);
         }else{
-          if(recv_buff != 1){
+          if(recv_buff != size - 1){
             printf("CS idle. Grant immediatly.\n");
             MPI_Send(&rank, 1, MPI_INT, recv_buff, GRANT_TAG, MPI_COMM_WORLD);
             CS_used = 1;
@@ -72,7 +75,7 @@ int main(int argc, char **argv){
         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);
-          if(recv_buff != 1){
+          if(recv_buff != size - 1){
             MPI_Send(&rank, 1, MPI_INT, recv_buff, GRANT_TAG, MPI_COMM_WORLD);
             CS_used = 1;
           }else{
@@ -89,18 +92,18 @@ int main(int argc, char **argv){
     while(1){
       printf("%d asks the request.\n", rank);
       MPI_Send(&rank, 1, MPI_INT, 0, REQUEST_TAG, MPI_COMM_WORLD);
-      if(rank == 1){
+      if(rank == size - 1){
         r = 1;
         cs = 0;
       }
       MPI_Recv(&recv_buff, 1, MPI_INT, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
-      if(status.MPI_TAG == GRANT_TAG && rank == 1){
+      if(status.MPI_TAG == GRANT_TAG && rank == size - 1){
         cs = 1;
         r = 0;
       }
       printf("%d got the answer. Release it.\n", rank);
       MPI_Send(&rank, 1, MPI_INT, 0, RELEASE_TAG, MPI_COMM_WORLD);
-      if(rank == 1){
+      if(rank == size - 1){
         r = 0;
         cs = 0;
       }
diff --git a/examples/smpi/mc/hostfile_mutual_exclusion b/examples/smpi/mc/hostfile_mutual_exclusion
new file mode 100644 (file)
index 0000000..b6d1c07
--- /dev/null
@@ -0,0 +1,3 @@
+c-1.me
+c-2.me
+c-3.me
diff --git a/examples/smpi/mc/hostfile_non_deterministic b/examples/smpi/mc/hostfile_non_deterministic
new file mode 100644 (file)
index 0000000..b6d1c07
--- /dev/null
@@ -0,0 +1,3 @@
+c-1.me
+c-2.me
+c-3.me
diff --git a/examples/smpi/mc/hostfile_send_deterministic b/examples/smpi/mc/hostfile_send_deterministic
new file mode 100644 (file)
index 0000000..b6d1c07
--- /dev/null
@@ -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 (file)
index 0000000..8c7ab75
--- /dev/null
@@ -0,0 +1,78 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <stdio.h>
+#include <mpi.h>
+#include <simgrid/modelchecker.h>
+
+#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/examples/smpi/mc/non_deterministic.c b/examples/smpi/mc/non_deterministic.c
new file mode 100644 (file)
index 0000000..b5fbcc0
--- /dev/null
@@ -0,0 +1,54 @@
+/* ../../../smpi_script/bin/smpirun -hostfile hostfile_send_deterministic -platform ../../platforms/cluster.xml -np 3 --cfg=model-check:1 --cfg=smpi/send_is_detached_thres:0 gdb\ --args\ ./send_deterministic */
+
+/* Copyright (c) 2009-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <stdio.h>
+#include <mpi.h>
+#include <simgrid/modelchecker.h>
+
+
+int main(int argc, char **argv)
+{
+  int recv_buff, err, size, rank, i;
+  MPI_Status status;
+
+  /* Initialize MPI */
+  err = MPI_Init(&argc, &argv);
+  if (err != MPI_SUCCESS) {
+    printf("MPI initialization failed!\n");
+    exit(1);
+  }
+
+  err = MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get nr of tasks */
+  err = MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
+  if (size < 2) {
+    printf("run this program with at least 2 processes \n");
+    MPI_Finalize();
+    exit(0);
+  }
+
+  if (rank == 0) {
+    printf("MPI_ISend / MPI_IRecv Test \n");
+
+    for(i=0; i < size - 1; i++){
+      MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
+      printf("Message received from %d\n", recv_buff);
+      MPI_Send(&recv_buff, 1, MPI_INT, status.MPI_SOURCE, 42, MPI_COMM_WORLD);
+      // printf("Sent %d to rank %d\n", status.MPI_SOURCE);
+    }
+
+  }else{
+    MPI_Send(&rank, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
+    printf("Sent %d to rank 0\n", rank);
+    MPI_Recv(&recv_buff, 1, MPI_INT, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
+    printf("Message received from %d\n", recv_buff);
+  }
+
+  MPI_Finalize();
+
+  return 0;
+}
diff --git a/examples/smpi/mc/send_deterministic.c b/examples/smpi/mc/send_deterministic.c
new file mode 100644 (file)
index 0000000..fe42106
--- /dev/null
@@ -0,0 +1,50 @@
+/* ../../../smpi_script/bin/smpirun -hostfile hostfile_send_deterministic -platform ../../platforms/cluster.xml -np 3 --cfg=model-check:1 --cfg=smpi/send_is_detached_thres:0 gdb\ --args\ ./send_deterministic */
+
+/* Copyright (c) 2009-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <stdio.h>
+#include <mpi.h>
+#include <simgrid/modelchecker.h>
+
+
+int main(int argc, char **argv)
+{
+  int recv_buff, err, size, rank, i;
+  MPI_Status status;
+
+  /* Initialize MPI */
+  err = MPI_Init(&argc, &argv);
+  if (err != MPI_SUCCESS) {
+    printf("MPI initialization failed!\n");
+    exit(1);
+  }
+
+  err = MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get nr of tasks */
+  err = MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
+  if (size < 2) {
+    printf("run this program with at least 2 processes \n");
+    MPI_Finalize();
+    exit(0);
+  }
+
+  if (rank == 0) {
+    printf("MPI_ISend / MPI_IRecv Test \n");
+
+    for(i=0; i < size - 1; i++){
+      MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
+      printf("Message received from %d\n", recv_buff);
+    }
+
+  }else{
+    MPI_Send(&rank, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
+    printf("Sent %d to rank 0\n", rank);
+  }
+
+  MPI_Finalize();
+
+  return 0;
+}
index 4cbef48..048b46c 100644 (file)
@@ -10,6 +10,7 @@ $ mkfile replay/one_trace
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/cpu_threshold:-1 -np 3 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay replay/one_trace --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
@@ -40,6 +41,7 @@ $ mkfile replay/one_trace
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=no_loc  --cfg=tracing:yes --cfg=tracing/smpi:yes --cfg=tracing/smpi/computing:yes --cfg=smpi/cpu_threshold:-1 -np 3 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay replay/one_trace --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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 'tracing' to 'yes'
@@ -232,6 +234,7 @@ $ mkfile ./split_traces_tesh
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/cpu_threshold:-1 -np 2 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay ./split_traces_tesh --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
@@ -255,6 +258,7 @@ $ mkfile replay/one_trace
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/cpu_threshold:-1 -np 3 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay replay/one_trace --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
@@ -278,6 +282,7 @@ $ mkfile replay/one_trace
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/cpu_threshold:-1 -np 3 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay replay/one_trace --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
@@ -306,6 +311,7 @@ $ mkfile replay/one_trace
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/cpu_threshold:-1 -np 3 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay replay/one_trace --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
@@ -327,6 +333,7 @@ $ mkfile replay/one_trace
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/cpu_threshold:-1 -np 3 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay replay/one_trace --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
@@ -345,6 +352,7 @@ $ mkfile replay/one_trace
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/cpu_threshold:-1 -np 3 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay replay/one_trace --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
@@ -363,6 +371,7 @@ $ mkfile replay/one_trace
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/cpu_threshold:-1 -np 3 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay replay/one_trace --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
@@ -381,6 +390,7 @@ $ mkfile replay/one_trace
 
 $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/cpu_threshold:-1 -np 3 -platform ${srcdir:=.}/replay/replay_platform.xml -hostfile ${srcdir:=.}/hostfile ./smpi_replay replay/one_trace --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
index a12e36f..70a45c4 100644 (file)
@@ -10,6 +10,7 @@ $ ../../smpi_script/bin/smpirun -trace -trace-resource -trace-file smpi_traced.t
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
@@ -22,6 +23,7 @@ $ ../../smpi_script/bin/smpirun -trace -trace-resource -trace-file smpi_traced.t
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
@@ -29,6 +31,7 @@ $ ../../smpi_script/bin/smpirun -trace -trace-resource -trace-file smpi_traced.t
 p Testing without trace parameters
 $ ../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../msg/tracing/platform.xml -np 3 ./smpi_traced_simple --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
@@ -40,6 +43,7 @@ $ ../../smpi_script/bin/smpirun -trace -trace-grouped -trace-file smpi_traced.tr
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi/group' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
@@ -54,6 +58,7 @@ $ ../../smpi_script/bin/smpirun -trace -trace-resource -trace-viva -trace-file s
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/categorized' to 'smpi_cat.plist'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/uncategorized' to 'smpi_uncat.plist'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
@@ -63,6 +68,7 @@ $ ../../smpi_script/bin/smpirun -trace -trace-resource -trace-viva -trace-file s
 p Testing with parameters but without activating them with the safe switch (-trace)
 $ ../../smpi_script/bin/smpirun -trace-resource -trace-viva -trace-file smpi_traced.trace -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../msg/tracing/platform.xml -np 3 ./smpi_traced_simple --log=smpi_kernel.thres:warning
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
index bd2ced1..760a2d8 100644 (file)
@@ -110,7 +110,7 @@ extern int MSG_FILE_LEVEL;
 typedef struct simdata_file *simdata_file_t;
 
 typedef struct msg_file_priv  {
-  char *fullname;
+  char *fullpath;
   sg_size_t size;
   char* mount_point;
   char* storageId;
@@ -138,7 +138,7 @@ typedef xbt_dictelm_t msg_storage_t;
 typedef s_xbt_dictelm_t s_msg_storage_t;
 
 typedef struct msg_storage_priv  {
-  const char *host;
+  const char *hostname;
   void *data;
 } s_msg_storage_priv_t, *msg_storage_priv_t;
 
index e3e5bee..14da996 100644 (file)
@@ -83,25 +83,26 @@ XBT_PUBLIC(xbt_dynar_t) MSG_environment_as_get_hosts(msg_as_t as);
 /************************** File handling ***********************************/
 XBT_PUBLIC(sg_size_t) MSG_file_read(msg_file_t fd, sg_size_t size);
 XBT_PUBLIC(sg_size_t) MSG_file_write(msg_file_t fd, sg_size_t size);
-XBT_PUBLIC(msg_file_t) MSG_file_open(const char* mount, const char* path,
-                                     void* data);
+XBT_PUBLIC(msg_file_t) MSG_file_open(const char* fullpath, void* data);
 XBT_PUBLIC(void*) MSG_file_get_data(msg_file_t fd);
 XBT_PUBLIC(msg_error_t) MSG_file_set_data(msg_file_t fd, void * data);
 XBT_PUBLIC(int) MSG_file_close(msg_file_t fd);
 XBT_PUBLIC(sg_size_t) MSG_file_get_size(msg_file_t fd);
 XBT_PUBLIC(void) MSG_file_dump(msg_file_t fd);
-XBT_PUBLIC(int) MSG_file_unlink(msg_file_t fd);
-XBT_PUBLIC(xbt_dict_t) MSG_file_ls(const char *mount, const char *path);
+XBT_PUBLIC(msg_error_t) MSG_file_unlink(msg_file_t fd);
 XBT_PUBLIC(msg_error_t) MSG_file_seek(msg_file_t fd, sg_size_t offset, int origin);
 XBT_PUBLIC(sg_size_t) MSG_file_tell (msg_file_t fd);
 XBT_PUBLIC(void) __MSG_file_get_info(msg_file_t fd);
 XBT_PUBLIC(void) __MSG_file_priv_free(msg_file_priv_t priv);
 XBT_PUBLIC(const char *) MSG_file_get_name(msg_file_t storage);
+XBT_PUBLIC(msg_error_t) MSG_file_move(msg_file_t fd, const char* fullpath);
+XBT_PUBLIC(msg_error_t) MSG_file_rcopy(msg_file_t fd, msg_host_t host, const char* fullpath);
+XBT_PUBLIC(msg_error_t) MSG_file_rmove(msg_file_t fd, msg_host_t host, const char* fullpath);
 /************************** Storage handling ***********************************/
 XBT_PUBLIC(msg_host_t) MSG_get_storage_by_name(const char *name);
 XBT_PUBLIC(const char *) MSG_storage_get_name(msg_storage_t storage);
-XBT_PUBLIC(sg_size_t) MSG_storage_get_free_size(const char* name);
-XBT_PUBLIC(sg_size_t) MSG_storage_get_used_size(const char* name);
+XBT_PUBLIC(sg_size_t) MSG_storage_get_free_size(msg_storage_t storage);
+XBT_PUBLIC(sg_size_t) MSG_storage_get_used_size(msg_storage_t storage);
 XBT_PUBLIC(msg_storage_t) MSG_storage_get_by_name(const char *name);
 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage);
 XBT_PUBLIC(void) MSG_storage_set_property_value(msg_storage_t storage, const char *name, char *value,void_f_pvoid_t free_ctn);
@@ -111,7 +112,6 @@ XBT_PUBLIC(void *) MSG_storage_get_data(msg_storage_t storage);
 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage);
 XBT_PUBLIC(sg_size_t) MSG_storage_get_size(msg_storage_t storage);
 XBT_PUBLIC(msg_error_t) MSG_storage_file_move(msg_file_t fd, msg_host_t dest, char* mount, char* fullname);
-XBT_PUBLIC(msg_error_t) MSG_storage_file_rename(msg_storage_t storage, const char* src,  const char* dest);
 XBT_PUBLIC(const char *) MSG_storage_get_host(msg_storage_t storage);
 /************************** AS Router handling ************************************/
 XBT_PUBLIC(const char *) MSG_as_router_get_property_value(const char* asr, const char *name);
index eee8f60..31ed69d 100644 (file)
@@ -83,6 +83,7 @@ XBT_PUBLIC(int) SD_route_get_size(SD_workstation_t src,
 XBT_PUBLIC(double) SD_workstation_get_power(SD_workstation_t workstation);
 XBT_PUBLIC(double) SD_workstation_get_available_power(SD_workstation_t
                                                       workstation);
+XBT_PUBLIC(int) SD_workstation_get_cores(SD_workstation_t workstation);
 XBT_PUBLIC(e_SD_workstation_access_mode_t)
     SD_workstation_get_access_mode(SD_workstation_t workstation);
 XBT_PUBLIC(void) SD_workstation_set_access_mode(SD_workstation_t
index 4031d13..4399096 100644 (file)
@@ -45,6 +45,7 @@ typedef enum {
 } e_surf_process_on_failure_t;
 
 typedef enum {
+  SURF_CLUSTER_FAT_TREE=2,
   SURF_CLUSTER_FLAT = 1,
   SURF_CLUSTER_TORUS = 0
 } e_surf_cluster_topology_t;
@@ -331,6 +332,7 @@ typedef struct s_sg_platf_gpu_cbarg {
 
 #define SG_PLATF_GPU_INITIALIZER {NULL}
 
+
 /* ***************************************** */
 
 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
index da13e26..8a32204 100644 (file)
@@ -168,6 +168,8 @@ XBT_PUBLIC(smx_ctx_factory_initializer_t) smx_factory_initializer_to_use;
 extern char* smx_context_factory_name;
 extern int smx_context_stack_size;
 extern int smx_context_stack_size_was_set;
+extern int smx_context_guard_size;
+extern int smx_context_guard_size_was_set;
 
 /* *********************** */
 /* Context type definition */
@@ -486,19 +488,19 @@ XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
 /*****************************   File   **********************************/
 XBT_PUBLIC(void *) simcall_file_get_data(smx_file_t fd);
 XBT_PUBLIC(void) simcall_file_set_data(smx_file_t fd, void *data);
-XBT_PUBLIC(sg_size_t) simcall_file_read(smx_file_t fd, sg_size_t size);
-XBT_PUBLIC(sg_size_t) simcall_file_write(smx_file_t fd, sg_size_t size);
-XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path);
-XBT_PUBLIC(int) simcall_file_close(smx_file_t fd);
+XBT_PUBLIC(sg_size_t) simcall_file_read(smx_file_t fd, sg_size_t size, smx_host_t host);
+XBT_PUBLIC(sg_size_t) simcall_file_write(smx_file_t fd, sg_size_t size, smx_host_t host);
+XBT_PUBLIC(smx_file_t) simcall_file_open(const char* fullpath, smx_host_t host);
+XBT_PUBLIC(int) simcall_file_close(smx_file_t fd, smx_host_t host);
 XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd);
-XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path);
 XBT_PUBLIC(sg_size_t) simcall_file_get_size(smx_file_t fd);
 XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd);
 XBT_PUBLIC(sg_size_t) simcall_file_tell(smx_file_t fd);
 XBT_PUBLIC(int) simcall_file_seek(smx_file_t fd, sg_size_t offset, int origin);
+XBT_PUBLIC(int) simcall_file_move(smx_file_t fd, const char* fullpath);
 /*****************************   Storage   **********************************/
-XBT_PUBLIC(sg_size_t) simcall_storage_get_free_size (const char* name);
-XBT_PUBLIC(sg_size_t) simcall_storage_get_used_size (const char* name);
+XBT_PUBLIC(sg_size_t) simcall_storage_get_free_size (smx_storage_t storage);
+XBT_PUBLIC(sg_size_t) simcall_storage_get_used_size (smx_storage_t storage);
 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
 XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage);
 XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data);
@@ -506,7 +508,6 @@ XBT_PUBLIC(xbt_dict_t) SIMIX_storage_get_content(smx_storage_t storage);
 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_content(smx_storage_t storage);
 XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_storage_t storage);
 XBT_PUBLIC(sg_size_t) SIMIX_storage_get_size(smx_storage_t storage);
-XBT_PUBLIC(void) simcall_storage_file_rename(smx_storage_t storage, const char* src,  const char* dest);
 XBT_PUBLIC(const char*) SIMIX_storage_get_host(smx_storage_t storage);
 /************************** AS router   **********************************/
 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
index 2830983..4224e7f 100644 (file)
 #include <xbt/sysdep.h>
 #include <xbt/log.h>
 #include <xbt/asserts.h>
+#include <simgrid/modelchecker.h>
+
+#ifdef HAVE_MC
+#undef assert
+#define assert(x) MC_assert(x)
+#endif
 
 #endif
index 49c20d4..b91aece 100644 (file)
@@ -102,6 +102,11 @@ SG_BEGIN_DECL()
 #define MPI_INTEGER8 MPI_DATATYPE_NULL
 #define MPI_COMPLEX MPI_DATATYPE_NULL
 #define MPI_DOUBLE_COMPLEX MPI_DATATYPE_NULL
+#define MPI_2DOUBLE_PRECISION MPI_DATATYPE_NULL
+#define MPI_REAL MPI_DATATYPE_NULL
+#define MPI_LOGICAL MPI_DATATYPE_NULL
+#define MPI_DOUBLE_PRECISION MPI_DATATYPE_NULL
+#define MPI_INTEGER MPI_DATATYPE_NULL
 
 #define MPI_DISTRIBUTE_BLOCK 0
 #define MPI_DISTRIBUTE_NONE 1
index a7a5a50..95984aa 100644 (file)
@@ -8,7 +8,7 @@
 #define _SURF_SURF_ROUTING_H
 
 #include "xbt/lib.h"
-#include "simgrid/platf_interface.h"
+#include "simgrid/platf.h"
 
 SG_BEGIN_DECL()
 
index 43fb347..3be8fc1 100644 (file)
 #  define XBT_EXPORT_NO_IMPORT(type)  __declspec(dllexport) type
 #  define XBT_IMPORT_NO_EXPORT(type)  type
 #  define XBT_PUBLIC_DATA(type)       extern __declspec(dllexport) type
+#  define XBT_PUBLIC_CLASS            class __declspec(dllexport)
+
 
 /* Pack everything up statically */
 #elif defined(DLL_STATIC)
 #  define XBT_EXPORT_NO_IMPORT(type)  type
 #  define XBT_IMPORT_NO_EXPORT(type)  type
 #  define XBT_PUBLIC_DATA(type)       extern type
+#  define XBT_PUBLIC_CLASS            class
+
 
 /* Link against the DLL */
 #elif (defined(_XBT_WIN32) && !defined(DLL_EXPORT) && !defined(DLL_STATIC))
 #  define XBT_EXPORT_NO_IMPORT(type)  type
 #  define XBT_IMPORT_NO_EXPORT(type)  __declspec(dllimport) type
 #  define XBT_PUBLIC_DATA(type)       extern __declspec(dllimport) type
+#  define XBT_PUBLIC_CLASS            class __declspec(dllimport)
+
 
 /* UNIX build */
 #else
 #  define XBT_EXPORT_NO_IMPORT(type)  type
 #  define XBT_IMPORT_NO_EXPORT(type)  type
 #  define XBT_PUBLIC_DATA(type)       extern type
+#  define XBT_PUBLIC_CLASS            class
+
 #endif
 
 #if !defined (max) && !defined(__cplusplus)
 
 SG_BEGIN_DECL()
 
+/** Cache the size of a memory page for the current system. */
+XBT_PUBLIC_DATA(int) xbt_pagesize;
+
 XBT_PUBLIC(const char *) xbt_procname(void);
 
 #define XBT_BACKTRACE_SIZE 10   /* FIXME: better place? Do document */
index d583884..353249e 100644 (file)
@@ -1,15 +1,18 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-   This file was then part of the GNU C Library. */
-
 /* Copyright (c) 2010-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+   This file was then part of the GNU C Library. */
+
 #ifndef MMALLOC_H
 #define MMALLOC_H 1
 
+#include <simgrid_config.h>
+#ifdef HAVE_MMALLOC
+
 #ifdef HAVE_STDDEF_H
 #  include <stddef.h>
 #else
@@ -37,6 +40,7 @@ void *mmalloc_no_memset(xbt_mheap_t mdp, size_t size);
 
 /* Re-allocate the previously allocated block in void*, making the new block
    SIZE bytes long.  */
+
 XBT_PUBLIC( void ) *mrealloc(xbt_mheap_t md, void *ptr, size_t size);
 
 /* Free a block allocated by `mmalloc', `mrealloc' or `mcalloc'.  */
@@ -55,14 +59,18 @@ XBT_PUBLIC( xbt_mheap_t ) mmalloc_get_default_md(void);
 void mmalloc_set_current_heap(xbt_mheap_t new_heap);
 xbt_mheap_t mmalloc_get_current_heap(void);
 
-int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_types, xbt_dict_t other_types);
+struct s_mc_snapshot;
+
+typedef struct s_dw_type *dw_type_t;
+
+int mmalloc_compare_heap(struct s_mc_snapshot* snapshot1, struct s_mc_snapshot* snapshot2, xbt_mheap_t heap1, xbt_mheap_t heap2);
 int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2);
 int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t to_ignore1, xbt_dynar_t to_ignore2);
-int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t all_types, xbt_dict_t other_types, char *type, int pointer_level);
+int compare_heap_area(void *area1, void* area2, struct s_mc_snapshot* snapshot1, struct s_mc_snapshot* snapshot2, xbt_dynar_t previous, dw_type_t type, int pointer_level);
 void reset_heap_information(void);
-int get_pointed_area_size(void *area, int heap);
 
 size_t mmalloc_get_bytes_used(xbt_mheap_t);
 ssize_t mmalloc_get_busy_size(xbt_mheap_t, void *ptr);
 
+#endif
 #endif                          /* MMALLOC_H */
index 390ef24..4b901a3 100644 (file)
@@ -31,17 +31,7 @@ SG_BEGIN_DECL()
  * @{
  */
 /** @brief Kill the program in silence */
-#ifdef COVERAGE
-/* Call __gcov_flush on abort when compiling with coverage options. */
-#define xbt_abort()                             \
-  do {                                          \
-    extern void __gcov_flush(void);             \
-    __gcov_flush();                             \
-    abort();                                    \
-  } while (0)
-#else
-#define xbt_abort() abort()
-#endif
+XBT_PUBLIC(void) xbt_abort(void) _XBT_GNUC_NORETURN;
 
 /**
  * @brief Kill the program with an error message
index eede122..655c882 100644 (file)
@@ -68,6 +68,7 @@ XBT_PUBLIC(void) xbt_os_thread_yield(void);
 XBT_PUBLIC(void) xbt_os_thread_cancel(xbt_os_thread_t thread);
 XBT_PUBLIC(void *) xbt_os_thread_getparam(void);
 XBT_PUBLIC(void) xbt_os_thread_setstacksize(int stack_size);
+XBT_PUBLIC(void) xbt_os_thread_setguardsize(int guard_size);
 
   /** \brief Thread mutex data type (opaque structure) */
 typedef struct xbt_os_mutex_ *xbt_os_mutex_t;
index f8adbda..1210a74 100644 (file)
@@ -26,15 +26,13 @@ Java_org_simgrid_msg_File_nativeInit(JNIEnv *env, jclass cls) {
   xbt_assert((jfile_field_bind != NULL), "Can't find \"bind\" field in File class.");
 }
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jstorage, jobject jpath) {
-  const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
+Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jpath) {
   const char *path = (*env)->GetStringUTFChars(env, jpath, 0);
   msg_file_t file;
 
-  file = MSG_file_open(storage, path, NULL);
+  file = MSG_file_open(path, NULL);
   jfile_bind(env, jfile, file);
 
-  (*env)->ReleaseStringUTFChars(env, jstorage, storage);
   (*env)->ReleaseStringUTFChars(env, jpath, path);
 }
 JNIEXPORT jlong JNICALL
index 05dc575..e2c0352 100644 (file)
@@ -28,7 +28,7 @@ Java_org_simgrid_msg_File_nativeInit(JNIEnv*, jclass);
  * Signature   (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
  */
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_File_open(JNIEnv*, jobject, jobject, jobject);
+Java_org_simgrid_msg_File_open(JNIEnv*, jobject, jobject);
 /**
  * Class                       org_simgrid_msg_File
  * Method                      read
index ed259b7..7bb72ea 100644 (file)
@@ -405,12 +405,5 @@ Java_org_simgrid_msg_Process_setKillTime (JNIEnv *env , jobject jprocess, jdoubl
 
 JNIEXPORT jint JNICALL
 Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls) {
-       /* The next test on SimGrid version is to ensure that this still compiles with SG 3.8 while the C function were added in SG 3.9 only.
-        * This kind of pimple becomes mandatory when you get so slow to release the java version that it begins evolving further after the C release date.
-        */
-#if SIMGRID_VERSION >= 30900
   return (jint) MSG_process_get_number();
-#else
-  return (jint) -1;
-#endif
 }
diff --git a/src/bindings/java/org/simgrid/NativeLib.java b/src/bindings/java/org/simgrid/NativeLib.java
new file mode 100644 (file)
index 0000000..18e593a
--- /dev/null
@@ -0,0 +1,119 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+package org.simgrid;
+
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.File;
+
+public final class NativeLib {
+
+    public static String getPath() {
+        String prefix = "NATIVE";
+        String os = System.getProperty("os.name");
+        String arch = System.getProperty("os.arch");
+
+        if (arch.matches("^i[3-6]86$"))
+            arch = "x86";
+        else if (arch.equalsIgnoreCase("amd64"))
+            arch = "x86_64";
+
+        if (os.toLowerCase().startsWith("win")){
+            os = "Windows";
+            arch = "x86";
+        }else if (os.contains("OS X"))
+            os = "Darwin";
+
+        os = os.replace(' ', '_');
+        arch = arch.replace(' ', '_');
+
+        return prefix + "/" + os + "/" + arch + "/";
+    }
+    public static void nativeInit(String name) {
+        try {
+            /* prefer the version on disk, if existing */
+            System.loadLibrary(name);
+        } catch (UnsatisfiedLinkError e) {
+            /* If not found, unpack the one bundled into the jar file and use it */
+            loadLib(name);
+        }
+    }
+
+    private static void loadLib (String name) {
+        String Path = NativeLib.getPath();
+
+        String filename=name;
+        InputStream in = NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+               
+        if (in == null) {
+           filename = "lib"+name+".so";
+            in = NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+        } 
+       if (in == null) {
+           filename = name+".dll";
+           in =  NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+       }  
+       if (in == null) {
+           filename = "lib"+name+".dll";
+           in =  NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+       }  
+       if (in == null) {
+           filename = "lib"+name+".dylib";
+           in =  NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+       }  
+       if (in == null) {
+           throw new RuntimeException("Cannot find library "+name+" in path "+Path+". Sorry, but this jar does not seem to be usable on your machine.");
+       }
+       try {
+           // We must write the lib onto the disk before loading it -- stupid operating systems
+           File fileOut = new File(filename);
+           fileOut = File.createTempFile(name+"-", ".tmp");
+           // don't leak the file on disk, but remove it on JVM shutdown
+           Runtime.getRuntime().addShutdownHook(new Thread(new FileCleaner(fileOut.getAbsolutePath())));
+           OutputStream out = new FileOutputStream(fileOut);
+                       
+           /* copy the library in position */  
+           byte[] buffer = new byte[4096]; 
+           int bytes_read; 
+           while ((bytes_read = in.read(buffer)) != -1)     // Read until EOF
+                   out.write(buffer, 0, bytes_read); 
+                     
+           /* close all file descriptors, and load that shit */
+           in.close();
+           out.close();
+           System.load(fileOut.getAbsolutePath());
+
+       } catch (Exception e) {
+           System.err.println("Cannot load the bindings to the "+name+" library: ");
+           e.printStackTrace();
+           System.err.println("This jar file does not seem to fit your system, sorry");
+           System.exit(1);
+       }
+    }
+    
+       /* A hackish mechanism used to remove the file containing our library when the JVM shuts down */
+       private static class FileCleaner implements Runnable {
+               private String target;
+               public FileCleaner(String name) {
+                       target = name;
+               }
+        public void run() {
+            try {
+                new File(target).delete();
+            } catch(Exception e) {
+                System.out.println("Unable to clean temporary file "+target+" during shutdown.");
+                e.printStackTrace();
+            }
+        }    
+       }
+
+
+    public static void main(String[] args) {
+        System.out.println(getPath());
+    }
+}
index 108c7b5..ec212a7 100644 (file)
@@ -7,6 +7,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package org.simgrid.msg;
+import org.simgrid.NativeLib;
 
 import java.io.FileOutputStream;
 import java.io.InputStream;
@@ -17,98 +18,19 @@ import java.io.File;
 public final class Msg {
        /* Statically load the library which contains all native functions used in here */
        static private boolean isNativeInited = false;
-       public static void nativeInit() {
-               if (isNativeInited)
-                       return;
-               try {
-                       /* prefer the version on disk, if existing */
-                       System.loadLibrary("simgrid-java");
-               } catch (UnsatisfiedLinkError e) {
-                       /* If not found, unpack the one bundled into the jar file and use it */
-                       loadLib("simgrid");
-                       loadLib("simgrid-java");
-               }
+        public static void nativeInit() {
+                if (isNativeInited)
+                      return;
+                NativeLib.nativeInit("simgrid");
+                NativeLib.nativeInit("simgrid-java");      
                isNativeInited = true;
+
        }
+
        static {
-               nativeInit();
+                nativeInit();
        }
-       private static void loadLib (String name) {
-               String Path = NativeLib.getPath();
-
-               String filename=name;
-               InputStream in = Msg.class.getClassLoader().getResourceAsStream(Path+filename);
-               
-               if (in == null) {
-                       filename = "lib"+name+".so";
-                       in = Msg.class.getClassLoader().getResourceAsStream(Path+filename);
-               } 
-               if (in == null) {
-                       filename = name+".dll";
-                       in = Msg.class.getClassLoader().getResourceAsStream(Path+filename);
-               }  
-               if (in == null) {
-                       filename = "lib"+name+".dll";
-                       in = Msg.class.getClassLoader().getResourceAsStream(Path+filename);
-               }  
-               if (in == null) {
-                       filename = "lib"+name+".dylib";
-                       in = Msg.class.getClassLoader().getResourceAsStream(Path+filename);
-               }  
-               if (in == null) {
-                       throw new RuntimeException("Cannot find library "+name+" in path "+Path+". Sorry, but this jar does not seem to be usable on your machine.");
-               }
-// Caching the file on disk: desactivated because it could fool the users              
-//             if (new File(filename).isFile()) {
-//                     // file was already unpacked -- use it directly
-//                     System.load(new File(".").getAbsolutePath()+File.separator+filename);
-//                     return;
-//             }
-               try {
-                       // We must write the lib onto the disk before loading it -- stupid operating systems
-                       File fileOut = new File(filename);
-//                     if (!new File(".").canWrite()) {
-//                             System.out.println("Cannot write in ."+File.separator+filename+"; unpacking the library into a temporary file instead");
-                               fileOut = File.createTempFile("simgrid-", ".tmp");
-                               // don't leak the file on disk, but remove it on JVM shutdown
-                               Runtime.getRuntime().addShutdownHook(new Thread(new FileCleaner(fileOut.getAbsolutePath())));
-//                     }
-//                     System.out.println("Unpacking SimGrid native library to " + fileOut.getAbsolutePath());
-                       OutputStream out = new FileOutputStream(fileOut);
-                       
-                       /* copy the library in position */  
-                       byte[] buffer = new byte[4096]; 
-                       int bytes_read; 
-                       while ((bytes_read = in.read(buffer)) != -1)     // Read until EOF
-                               out.write(buffer, 0, bytes_read); 
-                     
-                       /* close all file descriptors, and load that shit */
-                       in.close();
-                       out.close();
-                       System.load(fileOut.getAbsolutePath());
-               } catch (Exception e) {
-                       System.err.println("Cannot load the bindings to the simgrid library: ");
-                       e.printStackTrace();
-                       System.err.println("This jar file does not seem to fit your system, sorry");
-                       System.exit(1);
-               }
-       }               
-       /* A hackish mechanism used to remove the file containing our library when the JVM shuts down */
-       private static class FileCleaner implements Runnable {
-               private String target;
-               public FileCleaner(String name) {
-                       target = name;
-               }
-        public void run() {
-            try {
-                new File(target).delete();
-            } catch(Exception e) {
-                System.out.println("Unable to clean temporary file "+target+" during shutdown.");
-                e.printStackTrace();
-            }
-        }    
-       }
-
+        
     /** Retrieve the simulation time
      * @return The simulation time.
      */
diff --git a/src/bindings/java/org/simgrid/msg/NativeLib.java b/src/bindings/java/org/simgrid/msg/NativeLib.java
deleted file mode 100644 (file)
index 151fb95..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.simgrid.msg;
-
-public final class NativeLib {
-    public static String getPath() {
-        String prefix = "NATIVE";
-        String os = System.getProperty("os.name");
-        String arch = System.getProperty("os.arch");
-
-        if (os.toLowerCase().startsWith("^win"))
-            os = "Windows";
-        else if (os.contains("OS X"))
-            os = "Darwin";
-
-        if (arch.matches("^i[3-6]86$"))
-            arch = "x86";
-        else if (arch.equalsIgnoreCase("amd64"))
-            arch = "x86_64";
-
-        os = os.replace(' ', '_');
-        arch = arch.replace(' ', '_');
-
-        return prefix + "/" + os + "/" + arch + "/";
-    }
-
-    public static void main(String[] args) {
-        System.out.println(getPath());
-    }
-}
diff --git a/src/bindings/java/org/simgrid/surf/Action.java b/src/bindings/java/org/simgrid/surf/Action.java
new file mode 100644 (file)
index 0000000..d81b2ba
--- /dev/null
@@ -0,0 +1,151 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+/**
+  * An action created by a Resource (e.g., a communication, an execution)
+  * @see Model
+  * @see Resource
+  */
+public class Action {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected Action(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(Action obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_Action(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  protected static long[] cArrayUnwrap(Action[] arrayWrapper) {
+      long[] cArray = new long[arrayWrapper.length];
+      for (int i=0; i<arrayWrapper.length; i++)
+        cArray[i] = Action.getCPtr(arrayWrapper[i]);
+      return cArray;
+  }
+
+  protected static Action[] cArrayWrap(long[] cArray, boolean cMemoryOwn) {
+    Action[] arrayWrapper = new Action[cArray.length];
+    for (int i=0; i<cArray.length; i++)
+      arrayWrapper[i] = new Action(cArray[i], cMemoryOwn);
+    return arrayWrapper;
+  }
+
+  
+  /**
+    * Action constructor
+    * @param model The model associated
+    * @param cost The cost of the action (e.g., flops, bytes)
+    * @param failed If the action has failed
+    */
+  public Action(Model model, double cost, boolean failed) {
+    this(SurfJNI.new_Action(Model.getCPtr(model), model, cost, failed), true);
+  }
+
+  
+  /**
+    * @return The model associated
+    */
+  public Model getModel() {
+    long cPtr = SurfJNI.Action_getModel(swigCPtr, this);
+    return (cPtr == 0) ? null : new Model(cPtr, false);
+  }
+
+  
+  /**
+    * @return The variable associatied (if using LMM)
+    */
+  public LmmVariable getVariable() {
+    long cPtr = SurfJNI.Action_getVariable(swigCPtr, this);
+    return (cPtr == 0) ? null : new LmmVariable(cPtr, false);
+  }
+
+  
+  /**
+    * @return The state of the action
+    */
+  public ActionState getState() {
+    return ActionState.swigToEnum(SurfJNI.Action_getState(swigCPtr, this));
+  }
+
+  
+  /**
+    * @return True if suspended
+    */
+  public boolean isSuspended() {
+    return SurfJNI.Action_isSuspended(swigCPtr, this);
+  }
+
+  
+  /**
+    * @return TODO
+    */
+  public double getBound() {
+    return SurfJNI.Action_getBound(swigCPtr, this);
+  }
+
+  
+  /**
+    * @param TODO
+    */
+  public void setBound(double bound) {
+    SurfJNI.Action_setBound(swigCPtr, this, bound);
+  }
+
+  
+  /**
+    * Update remaining amount of cost to do
+    * @param delta Difference of time since last call to this function
+    */
+  public void updateRemains(double delta) {
+    SurfJNI.Action_updateRemains(swigCPtr, this, delta);
+  }
+
+  
+  /**
+    * @return The remaining amount of cost to do
+    */
+  public double getRemains() {
+    return SurfJNI.Action_getRemains(swigCPtr, this);
+  }
+
+  
+  /**
+    * @param The new priority of the action
+    */
+  public void setPriority(double priority) {
+    SurfJNI.Action_setPriority(swigCPtr, this, priority);
+  }
+
+  
+  /**
+    * @param The new state
+    */
+  public void setState(ActionState state) {
+    SurfJNI.Action_setState(swigCPtr, this, state.swigValue());
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/ActionList.java b/src/bindings/java/org/simgrid/surf/ActionList.java
new file mode 100644 (file)
index 0000000..5a9493c
--- /dev/null
@@ -0,0 +1,51 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public class ActionList {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected ActionList(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(ActionList obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_ActionList(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  public Action[] getArray() {
+  long[] cArray = SurfJNI.ActionList_getArray(swigCPtr, this);
+  Action[] arrayWrapper = new Action[cArray.length];
+  for (int i=0; i<cArray.length; i++)
+    arrayWrapper[i] = (Action) Surf.getAction(cArray[i]);
+  return arrayWrapper;
+  //   return Action.cArrayWrap(SurfJNI.ActionList_getArray(swigCPtr, this), false);
+}
+
+  public ActionList() {
+    this(SurfJNI.new_ActionList(), true);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/ActionState.java b/src/bindings/java/org/simgrid/surf/ActionState.java
new file mode 100644 (file)
index 0000000..094dd49
--- /dev/null
@@ -0,0 +1,58 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public final class ActionState {
+  public final static ActionState SURF_ACTION_READY = new ActionState("SURF_ACTION_READY", SurfJNI.SURF_ACTION_READY_get());
+  public final static ActionState SURF_ACTION_RUNNING = new ActionState("SURF_ACTION_RUNNING");
+  public final static ActionState SURF_ACTION_FAILED = new ActionState("SURF_ACTION_FAILED");
+  public final static ActionState SURF_ACTION_DONE = new ActionState("SURF_ACTION_DONE");
+  public final static ActionState SURF_ACTION_TO_FREE = new ActionState("SURF_ACTION_TO_FREE");
+  public final static ActionState SURF_ACTION_NOT_IN_THE_SYSTEM = new ActionState("SURF_ACTION_NOT_IN_THE_SYSTEM");
+
+  public final int swigValue() {
+    return swigValue;
+  }
+
+  public String toString() {
+    return swigName;
+  }
+
+  public static ActionState swigToEnum(int swigValue) {
+    if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
+      return swigValues[swigValue];
+    for (int i = 0; i < swigValues.length; i++)
+      if (swigValues[i].swigValue == swigValue)
+        return swigValues[i];
+    throw new IllegalArgumentException("No enum " + ActionState.class + " with value " + swigValue);
+  }
+
+  private ActionState(String swigName) {
+    this.swigName = swigName;
+    this.swigValue = swigNext++;
+  }
+
+  private ActionState(String swigName, int swigValue) {
+    this.swigName = swigName;
+    this.swigValue = swigValue;
+    swigNext = swigValue+1;
+  }
+
+  private ActionState(String swigName, ActionState swigEnum) {
+    this.swigName = swigName;
+    this.swigValue = swigEnum.swigValue;
+    swigNext = this.swigValue+1;
+  }
+
+  private static ActionState[] swigValues = { SURF_ACTION_READY, SURF_ACTION_RUNNING, SURF_ACTION_FAILED, SURF_ACTION_DONE, SURF_ACTION_TO_FREE, SURF_ACTION_NOT_IN_THE_SYSTEM };
+  private static int swigNext = 0;
+  private final int swigValue;
+  private final String swigName;
+}
+
diff --git a/src/bindings/java/org/simgrid/surf/Cpu.java b/src/bindings/java/org/simgrid/surf/Cpu.java
new file mode 100644 (file)
index 0000000..82ce3e2
--- /dev/null
@@ -0,0 +1,177 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+/**
+  * A generic resource for the cpu component
+  * @see CpuModel
+  * @see CpuAction
+  */
+public class Cpu extends Resource {
+  private long swigCPtr;
+
+  protected Cpu(long cPtr, boolean cMemoryOwn) {
+    super(SurfJNI.Cpu_SWIGUpcast(cPtr), cMemoryOwn);
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(Cpu obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_Cpu(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+    super.delete();
+  }
+
+  protected void swigDirectorDisconnect() {
+    swigCMemOwn = false;
+    delete();
+  }
+
+  public void swigReleaseOwnership() {
+    swigCMemOwn = false;
+    SurfJNI.Cpu_change_ownership(this, swigCPtr, false);
+  }
+
+  public void swigTakeOwnership() {
+    swigCMemOwn = true;
+    SurfJNI.Cpu_change_ownership(this, swigCPtr, true);
+  }
+
+  
+  /**
+    * A cpu constructor (using LMM)
+    * @param model
+    * @param name
+    * @param properties
+    * @param constraint
+    * @param core
+    * @param powerPeak
+    * @param powerScale
+    */
+  public Cpu(Model model, String name, XbtDict props, LmmConstraint constraint, int core, double powerPeak, double powerScale) {
+    this(SurfJNI.new_Cpu__SWIG_0(Model.getCPtr(model), model, name, XbtDict.getCPtr(props), props, LmmConstraint.getCPtr(constraint), constraint, core, powerPeak, powerScale), true);
+    SurfJNI.Cpu_director_connect(this, swigCPtr, swigCMemOwn, true);
+  }
+
+  
+  /**
+    * A cpu constructor
+    * @param model
+    * @param name
+    * @param properties
+    * @param core
+    * @param powerPeak
+    * @param powerScale
+    */
+  public Cpu(Model model, String name, XbtDict props, int core, double powerPeak, double powerScale) {
+    this(SurfJNI.new_Cpu__SWIG_1(Model.getCPtr(model), model, name, XbtDict.getCPtr(props), props, core, powerPeak, powerScale), true);
+    SurfJNI.Cpu_director_connect(this, swigCPtr, swigCMemOwn, true);
+  }
+
+  
+  /**
+    * @return The current power peak
+    */
+  public double getCurrentPowerPeak() {
+    return (getClass() == Cpu.class) ? SurfJNI.Cpu_getCurrentPowerPeak(swigCPtr, this) : SurfJNI.Cpu_getCurrentPowerPeakSwigExplicitCpu(swigCPtr, this);
+  }
+
+  
+  /**
+    * Execute some quantity of computation
+    * @param size The processing amount (in flop) needed to process
+    * @return A cpu action representing code execution
+    */
+  public CpuAction execute(double size) {
+  long cPtr = SurfJNI.Cpu_execute(swigCPtr, this, size);
+  return (CpuAction)Surf.getCpuDirector(cPtr);
+}
+
+  
+  /**
+    * Make a process sleep for duration
+    * @param duration The number of seconds to sleep
+    * @return A cpu action representing sleeping
+    */
+  public CpuAction sleep(double duration) {
+  long cPtr = SurfJNI.Cpu_sleep(swigCPtr, this, duration);
+  return (CpuAction)Surf.getCpuDirector(cPtr);
+}
+
+  
+  /**
+    * @return The number of cores on the cpu
+    */
+  public int getCore() {
+    return (getClass() == Cpu.class) ? SurfJNI.Cpu_getCore(swigCPtr, this) : SurfJNI.Cpu_getCoreSwigExplicitCpu(swigCPtr, this);
+  }
+
+  
+  /**
+    * TODO
+    * @param load
+    */
+  public double getSpeed(double load) {
+    return (getClass() == Cpu.class) ? SurfJNI.Cpu_getSpeed(swigCPtr, this, load) : SurfJNI.Cpu_getSpeedSwigExplicitCpu(swigCPtr, this, load);
+  }
+
+  
+  /**
+    * TODO
+    */
+  public double getAvailableSpeed() {
+    return (getClass() == Cpu.class) ? SurfJNI.Cpu_getAvailableSpeed(swigCPtr, this) : SurfJNI.Cpu_getAvailableSpeedSwigExplicitCpu(swigCPtr, this);
+  }
+
+  
+  /**
+    * @param pstate_index index of power peak to get
+    * @return Power peak at index
+    */
+  public double getPowerPeakAt(int pstate_index) {
+    return SurfJNI.Cpu_getPowerPeakAt(swigCPtr, this, pstate_index);
+  }
+
+  
+  /**
+    * @return Number of power peak
+    */
+  public int getNbPstates() {
+    return SurfJNI.Cpu_getNbPstates(swigCPtr, this);
+  }
+
+  
+  /**
+    * @param  index of power peak to set
+    */
+  public void setPowerPeakAt(int pstate_index) {
+    SurfJNI.Cpu_setPowerPeakAt(swigCPtr, this, pstate_index);
+  }
+
+  
+  /**
+    * @param The new state of the cpu
+    */
+  public void setState(ResourceState state) {
+    SurfJNI.Cpu_setState(swigCPtr, this, state.swigValue());
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/CpuAction.java b/src/bindings/java/org/simgrid/surf/CpuAction.java
new file mode 100644 (file)
index 0000000..50f0fd6
--- /dev/null
@@ -0,0 +1,79 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+/**
+  * An cpu action created by a Cpu
+  * @see CpuModel
+  * @see Cpu
+  */
+public class CpuAction extends Action {
+  private long swigCPtr;
+
+  protected CpuAction(long cPtr, boolean cMemoryOwn) {
+    super(SurfJNI.CpuAction_SWIGUpcast(cPtr), cMemoryOwn);
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(CpuAction obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_CpuAction(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+    super.delete();
+  }
+
+  protected void swigDirectorDisconnect() {
+    swigCMemOwn = false;
+    delete();
+  }
+
+  public void swigReleaseOwnership() {
+    swigCMemOwn = false;
+    SurfJNI.CpuAction_change_ownership(this, swigCPtr, false);
+  }
+
+  public void swigTakeOwnership() {
+    swigCMemOwn = true;
+    SurfJNI.CpuAction_change_ownership(this, swigCPtr, true);
+  }
+
+  
+  /**
+    * CpuAction constructor
+    * @param model The model associated
+    * @param cost The cost of the action (e.g., flops, bytes)
+    * @param failed If the action has failed
+    */
+  public CpuAction(Model model, double cost, boolean failed) {
+    this(SurfJNI.new_CpuAction(Model.getCPtr(model), model, cost, failed), true);
+    SurfJNI.CpuAction_director_connect(this, swigCPtr, swigCMemOwn, true);
+  }
+
+  
+  /**
+    * @return The associated cpu
+    */
+  public Cpu getCpu() {
+  long cPtr = SurfJNI.CpuAction_getCpu(swigCPtr, this);
+  return (Cpu)Surf.getCpuDirector(cPtr);
+}
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/CpuModel.java b/src/bindings/java/org/simgrid/surf/CpuModel.java
new file mode 100644 (file)
index 0000000..466308a
--- /dev/null
@@ -0,0 +1,93 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+/**
+  * The generic model for the Cpu component
+  * @see Cpu
+  * @see CpuAction
+  */
+public class CpuModel extends Model {
+  private long swigCPtr;
+
+  protected CpuModel(long cPtr, boolean cMemoryOwn) {
+    super(SurfJNI.CpuModel_SWIGUpcast(cPtr), cMemoryOwn);
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(CpuModel obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_CpuModel(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+    super.delete();
+  }
+
+  protected void swigDirectorDisconnect() {
+    swigCMemOwn = false;
+    delete();
+  }
+
+  public void swigReleaseOwnership() {
+    swigCMemOwn = false;
+    SurfJNI.CpuModel_change_ownership(this, swigCPtr, false);
+  }
+
+  public void swigTakeOwnership() {
+    swigCMemOwn = true;
+    SurfJNI.CpuModel_change_ownership(this, swigCPtr, true);
+  }
+
+  
+  /**
+    * CpuModel constructon
+    * @param name The name of the cpumodel
+    */
+  public CpuModel(String name) {
+    this(SurfJNI.new_CpuModel(name), true);
+    SurfJNI.CpuModel_director_connect(this, swigCPtr, swigCMemOwn, true);
+  }
+
+  
+  /**
+    * Create a new Cpu
+    *
+    * @param name
+    * @param power_peak
+    * @param pstate
+    * @param power_scale
+    * @param power_trace
+    * @param core
+    * @param state_initial
+    * @param state_trace
+    * @param cpu_properties
+    * @return The new Cpu
+    * @see Cpu
+    */
+  public Cpu createResource(String name, double[] power_peak, int pstate, double power_scale, TmgrTrace power_trace, int core, ResourceState state_initial, TmgrTrace state_trace, XbtDict cpu_properties) {
+  long cPtr = SurfJNI.CpuModel_createResource(swigCPtr, this, name, power_peak, pstate, power_scale, TmgrTrace.getCPtr(power_trace), power_trace, core, state_initial.swigValue(), TmgrTrace.getCPtr(state_trace), state_trace, XbtDict.getCPtr(cpu_properties), cpu_properties);
+  return (Cpu)Surf.getCpuDirector(cPtr);
+}
+
+  public void addTraces() {
+    SurfJNI.CpuModel_addTraces(swigCPtr, this);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/LmmConstraint.java b/src/bindings/java/org/simgrid/surf/LmmConstraint.java
new file mode 100644 (file)
index 0000000..775c379
--- /dev/null
@@ -0,0 +1,46 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public class LmmConstraint {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected LmmConstraint(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(LmmConstraint obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_LmmConstraint(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  public double getUsage() {
+    return SurfJNI.LmmConstraint_getUsage(swigCPtr, this);
+  }
+
+  public LmmConstraint() {
+    this(SurfJNI.new_LmmConstraint(), true);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/LmmVariable.java b/src/bindings/java/org/simgrid/surf/LmmVariable.java
new file mode 100644 (file)
index 0000000..7e9e372
--- /dev/null
@@ -0,0 +1,46 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public class LmmVariable {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected LmmVariable(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(LmmVariable obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_LmmVariable(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  public double getValue() {
+    return SurfJNI.LmmVariable_getValue(swigCPtr, this);
+  }
+
+  public LmmVariable() {
+    this(SurfJNI.new_LmmVariable(), true);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/Model.java b/src/bindings/java/org/simgrid/surf/Model.java
new file mode 100644 (file)
index 0000000..f1caaa3
--- /dev/null
@@ -0,0 +1,110 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+/**
+  * A component (e.g., Cpu, Network, Storage, ...) is composed of three classes:
+  * <ul>
+  *  <li> Model: It handle the interactions between resoucses and actions</li>
+  *  <li> Resource: A resource used by the model (e.g., a cpu, a network link)</li>
+  *  <li> Action: An action generated by the resources (e.g., execution, communication)</li>
+  * </ul>
+  * @see Resource
+  * @see Action
+  */
+public class Model {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected Model(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(Model obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_Model(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  
+  /**
+    * Model constructor
+    * @param name The name of the model
+    */
+  public Model(String name) {
+    this(SurfJNI.new_Model(name), true);
+  }
+
+  
+  /**
+    * @return The name of the model
+    */
+  public String getName() {
+    return SurfJNI.Model_getName(swigCPtr, this);
+  }
+
+  
+  /**
+    * Share the resources between the actions
+    * @param now the current time
+    * @return the date of the next action of the model will finish
+    */
+  public double shareResources(double now) {
+    return SurfJNI.Model_shareResources(swigCPtr, this, now);
+  }
+
+  public double shareResourcesLazy(double now) {
+    return SurfJNI.Model_shareResourcesLazy(swigCPtr, this, now);
+  }
+
+  public double shareResourcesFull(double now) {
+    return SurfJNI.Model_shareResourcesFull(swigCPtr, this, now);
+  }
+
+  
+  /**
+    * Update time of actions and eventually their states
+    * @param now the new current time
+    * @param delta the delta between previous and new current time
+    */
+  public void updateActionsState(double now, double delta) {
+    SurfJNI.Model_updateActionsState(swigCPtr, this, now, delta);
+  }
+
+  public void updateActionsStateLazy(double now, double delta) {
+    SurfJNI.Model_updateActionsStateLazy(swigCPtr, this, now, delta);
+  }
+
+  public void updateActionsStateFull(double now, double delta) {
+    SurfJNI.Model_updateActionsStateFull(swigCPtr, this, now, delta);
+  }
+
+  
+  /**
+    * Get the List of running Actions
+    */
+  public ActionList getRunningActionSet() {
+    long cPtr = SurfJNI.Model_getRunningActionSet(swigCPtr, this);
+    return (cPtr == 0) ? null : new ActionList(cPtr, false);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/NetworkAction.java b/src/bindings/java/org/simgrid/surf/NetworkAction.java
new file mode 100644 (file)
index 0000000..c1b758d
--- /dev/null
@@ -0,0 +1,50 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+/**
+  * An network action created by network model
+  * @see NetworkLink
+  */
+public class NetworkAction extends Action {
+  private long swigCPtr;
+
+  protected NetworkAction(long cPtr, boolean cMemoryOwn) {
+    super(SurfJNI.NetworkAction_SWIGUpcast(cPtr), cMemoryOwn);
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(NetworkAction obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_NetworkAction(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+    super.delete();
+  }
+
+  
+  /**
+    * @return The latency of the action
+    */
+  public double getLatency() {
+    return SurfJNI.NetworkAction_getLatency(swigCPtr, this);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/NetworkLink.java b/src/bindings/java/org/simgrid/surf/NetworkLink.java
new file mode 100644 (file)
index 0000000..a787a8b
--- /dev/null
@@ -0,0 +1,107 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+/**
+ * A generic resource for the network component
+ */
+public class NetworkLink extends Resource {
+  private long swigCPtr;
+
+  protected NetworkLink(long cPtr, boolean cMemoryOwn) {
+    super(SurfJNI.NetworkLink_SWIGUpcast(cPtr), cMemoryOwn);
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(NetworkLink obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_NetworkLink(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+    super.delete();
+  }
+
+  protected static long[] cArrayUnwrap(NetworkLink[] arrayWrapper) {
+      long[] cArray = new long[arrayWrapper.length];
+      for (int i=0; i<arrayWrapper.length; i++)
+        cArray[i] = NetworkLink.getCPtr(arrayWrapper[i]);
+      return cArray;
+  }
+
+  protected static NetworkLink[] cArrayWrap(long[] cArray, boolean cMemoryOwn) {
+    NetworkLink[] arrayWrapper = new NetworkLink[cArray.length];
+    for (int i=0; i<cArray.length; i++)
+      arrayWrapper[i] = new NetworkLink(cArray[i], cMemoryOwn);
+    return arrayWrapper;
+  }
+
+  
+  /**
+    * @return The bandwidth of the link
+    */
+  public double getBandwidth() {
+    return SurfJNI.NetworkLink_getBandwidth(swigCPtr, this);
+  }
+
+  
+  /**
+    * @param value The new bandwidth
+    * @param date When to change the bandwidth
+    */
+  public void updateBandwidth(double value, double date) {
+    SurfJNI.NetworkLink_updateBandwidth__SWIG_0(swigCPtr, this, value, date);
+  }
+
+  
+  /**
+    * @param value The new bandwidth
+    * @param date When to change the bandwidth
+    */
+  public void updateBandwidth(double value) {
+    SurfJNI.NetworkLink_updateBandwidth__SWIG_1(swigCPtr, this, value);
+  }
+
+  
+  /**
+    * @return The latency of the link
+    */
+  public double getLatency() {
+    return SurfJNI.NetworkLink_getLatency(swigCPtr, this);
+  }
+
+  
+  /**
+    * @param value The new latency
+    * @param date When to change the latency
+    */
+  public void updateLatency(double value, double date) {
+    SurfJNI.NetworkLink_updateLatency__SWIG_0(swigCPtr, this, value, date);
+  }
+
+  
+  /**
+    * @param value The new latency
+    * @param date When to change the latency
+    */
+  public void updateLatency(double value) {
+    SurfJNI.NetworkLink_updateLatency__SWIG_1(swigCPtr, this, value);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/Plugin.java b/src/bindings/java/org/simgrid/surf/Plugin.java
new file mode 100644 (file)
index 0000000..c3d5f5c
--- /dev/null
@@ -0,0 +1,130 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public class Plugin {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected Plugin(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(Plugin obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_Plugin(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  protected void swigDirectorDisconnect() {
+    swigCMemOwn = false;
+    delete();
+  }
+
+  public void swigReleaseOwnership() {
+    swigCMemOwn = false;
+    SurfJNI.Plugin_change_ownership(this, swigCPtr, false);
+  }
+
+  public void swigTakeOwnership() {
+    swigCMemOwn = true;
+    SurfJNI.Plugin_change_ownership(this, swigCPtr, true);
+  }
+
+  public void activateCpuCreatedCallback() {
+    SurfJNI.Plugin_activateCpuCreatedCallback(swigCPtr, this);
+  }
+
+  public void cpuCreatedCallback(Cpu cpu) {
+    if (getClass() == Plugin.class) SurfJNI.Plugin_cpuCreatedCallback(swigCPtr, this, Cpu.getCPtr(cpu), cpu); else SurfJNI.Plugin_cpuCreatedCallbackSwigExplicitPlugin(swigCPtr, this, Cpu.getCPtr(cpu), cpu);
+  }
+
+  public void activateCpuDestructedCallback() {
+    SurfJNI.Plugin_activateCpuDestructedCallback(swigCPtr, this);
+  }
+
+  public void cpuDestructedCallback(Cpu cpu) {
+    if (getClass() == Plugin.class) SurfJNI.Plugin_cpuDestructedCallback(swigCPtr, this, Cpu.getCPtr(cpu), cpu); else SurfJNI.Plugin_cpuDestructedCallbackSwigExplicitPlugin(swigCPtr, this, Cpu.getCPtr(cpu), cpu);
+  }
+
+  public void activateCpuStateChangedCallback() {
+    SurfJNI.Plugin_activateCpuStateChangedCallback(swigCPtr, this);
+  }
+
+  public void cpuStateChangedCallback(Cpu cpu, ResourceState arg1, ResourceState arg2) {
+    if (getClass() == Plugin.class) SurfJNI.Plugin_cpuStateChangedCallback(swigCPtr, this, Cpu.getCPtr(cpu), cpu, arg1.swigValue(), arg2.swigValue()); else SurfJNI.Plugin_cpuStateChangedCallbackSwigExplicitPlugin(swigCPtr, this, Cpu.getCPtr(cpu), cpu, arg1.swigValue(), arg2.swigValue());
+  }
+
+  public void activateCpuActionStateChangedCallback() {
+    SurfJNI.Plugin_activateCpuActionStateChangedCallback(swigCPtr, this);
+  }
+
+  public void cpuActionStateChangedCallback(CpuAction action, ActionState arg1, ActionState arg2) {
+    if (getClass() == Plugin.class) SurfJNI.Plugin_cpuActionStateChangedCallback(swigCPtr, this, CpuAction.getCPtr(action), action, arg1.swigValue(), arg2.swigValue()); else SurfJNI.Plugin_cpuActionStateChangedCallbackSwigExplicitPlugin(swigCPtr, this, CpuAction.getCPtr(action), action, arg1.swigValue(), arg2.swigValue());
+  }
+
+  public void activateNetworkLinkCreatedCallback() {
+    SurfJNI.Plugin_activateNetworkLinkCreatedCallback(swigCPtr, this);
+  }
+
+  public void networkLinkCreatedCallback(NetworkLink link) {
+    if (getClass() == Plugin.class) SurfJNI.Plugin_networkLinkCreatedCallback(swigCPtr, this, NetworkLink.getCPtr(link), link); else SurfJNI.Plugin_networkLinkCreatedCallbackSwigExplicitPlugin(swigCPtr, this, NetworkLink.getCPtr(link), link);
+  }
+
+  public void activateNetworkLinkDestructedCallback() {
+    SurfJNI.Plugin_activateNetworkLinkDestructedCallback(swigCPtr, this);
+  }
+
+  public void networkLinkDestructedCallback(NetworkLink link) {
+    if (getClass() == Plugin.class) SurfJNI.Plugin_networkLinkDestructedCallback(swigCPtr, this, NetworkLink.getCPtr(link), link); else SurfJNI.Plugin_networkLinkDestructedCallbackSwigExplicitPlugin(swigCPtr, this, NetworkLink.getCPtr(link), link);
+  }
+
+  public void activateNetworkLinkStateChangedCallback() {
+    SurfJNI.Plugin_activateNetworkLinkStateChangedCallback(swigCPtr, this);
+  }
+
+  public void networkLinkStateChangedCallback(NetworkLink link, ResourceState arg1, ResourceState arg2) {
+    if (getClass() == Plugin.class) SurfJNI.Plugin_networkLinkStateChangedCallback(swigCPtr, this, NetworkLink.getCPtr(link), link, arg1.swigValue(), arg2.swigValue()); else SurfJNI.Plugin_networkLinkStateChangedCallbackSwigExplicitPlugin(swigCPtr, this, NetworkLink.getCPtr(link), link, arg1.swigValue(), arg2.swigValue());
+  }
+
+  public void activateNetworkActionStateChangedCallback() {
+    SurfJNI.Plugin_activateNetworkActionStateChangedCallback(swigCPtr, this);
+  }
+
+  public void networkActionStateChangedCallback(NetworkAction action, ActionState old, ActionState cur) {
+    if (getClass() == Plugin.class) SurfJNI.Plugin_networkActionStateChangedCallback(swigCPtr, this, NetworkAction.getCPtr(action), action, old.swigValue(), cur.swigValue()); else SurfJNI.Plugin_networkActionStateChangedCallbackSwigExplicitPlugin(swigCPtr, this, NetworkAction.getCPtr(action), action, old.swigValue(), cur.swigValue());
+  }
+
+  public void activateNetworkCommunicateCallback() {
+    SurfJNI.Plugin_activateNetworkCommunicateCallback(swigCPtr, this);
+  }
+
+  public void networkCommunicateCallback(NetworkAction action, RoutingEdge src, RoutingEdge dst, double size, double rate) {
+    if (getClass() == Plugin.class) SurfJNI.Plugin_networkCommunicateCallback(swigCPtr, this, NetworkAction.getCPtr(action), action, RoutingEdge.getCPtr(src), src, RoutingEdge.getCPtr(dst), dst, size, rate); else SurfJNI.Plugin_networkCommunicateCallbackSwigExplicitPlugin(swigCPtr, this, NetworkAction.getCPtr(action), action, RoutingEdge.getCPtr(src), src, RoutingEdge.getCPtr(dst), dst, size, rate);
+  }
+
+  public Plugin() {
+    this(SurfJNI.new_Plugin(), true);
+    SurfJNI.Plugin_director_connect(this, swigCPtr, swigCMemOwn, true);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/Resource.java b/src/bindings/java/org/simgrid/surf/Resource.java
new file mode 100644 (file)
index 0000000..4091eb5
--- /dev/null
@@ -0,0 +1,106 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+/**
+  * A resource used by a model (e.g., a cpu, a network link)
+  * @see Model
+  * @see Action
+  */
+public class Resource {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected Resource(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(Resource obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_Resource(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  
+  /**
+    * @return The name of the resource
+    */
+  public String getName() {
+    return SurfJNI.Resource_getName(swigCPtr, this);
+  }
+
+  
+  /**
+    * @return True if the Resource is used
+    */
+  public boolean isUsed() {
+    return SurfJNI.Resource_isUsed(swigCPtr, this);
+  }
+
+  
+  /**
+    * @return The model associated to this Resource
+    */
+  public Model getModel() {
+    long cPtr = SurfJNI.Resource_getModel(swigCPtr, this);
+    return (cPtr == 0) ? null : new Model(cPtr, false);
+  }
+
+  
+  /**
+    * @return The state of the resource
+    * @see ResourceState
+    */
+  public ResourceState getState() {
+    return ResourceState.swigToEnum(SurfJNI.Resource_getState(swigCPtr, this));
+  }
+
+  
+  /**
+    * @return The constraint associatied (if using LMM)
+    */
+  public LmmConstraint getConstraint() {
+    long cPtr = SurfJNI.Resource_getConstraint(swigCPtr, this);
+    return (cPtr == 0) ? null : new LmmConstraint(cPtr, false);
+  }
+
+  
+  /**
+    * @return The XbtDict of properties associated to this Resource
+    */
+  public XbtDict getProperties() {
+    long cPtr = SurfJNI.Resource_getProperties(swigCPtr, this);
+    return (cPtr == 0) ? null : new XbtDict(cPtr, false);
+  }
+
+  
+  /**
+    * Update the state of the Resource
+    * @param event_type
+    * @param value
+    * @param date
+    */
+  public void updateState(TmgrTraceEvent event_type, double value, double date) {
+    SurfJNI.Resource_updateState(swigCPtr, this, TmgrTraceEvent.getCPtr(event_type), event_type, value, date);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/ResourceState.java b/src/bindings/java/org/simgrid/surf/ResourceState.java
new file mode 100644 (file)
index 0000000..8303734
--- /dev/null
@@ -0,0 +1,54 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public final class ResourceState {
+  public final static ResourceState SURF_RESOURCE_ON = new ResourceState("SURF_RESOURCE_ON", SurfJNI.SURF_RESOURCE_ON_get());
+  public final static ResourceState SURF_RESOURCE_OFF = new ResourceState("SURF_RESOURCE_OFF", SurfJNI.SURF_RESOURCE_OFF_get());
+
+  public final int swigValue() {
+    return swigValue;
+  }
+
+  public String toString() {
+    return swigName;
+  }
+
+  public static ResourceState swigToEnum(int swigValue) {
+    if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
+      return swigValues[swigValue];
+    for (int i = 0; i < swigValues.length; i++)
+      if (swigValues[i].swigValue == swigValue)
+        return swigValues[i];
+    throw new IllegalArgumentException("No enum " + ResourceState.class + " with value " + swigValue);
+  }
+
+  private ResourceState(String swigName) {
+    this.swigName = swigName;
+    this.swigValue = swigNext++;
+  }
+
+  private ResourceState(String swigName, int swigValue) {
+    this.swigName = swigName;
+    this.swigValue = swigValue;
+    swigNext = swigValue+1;
+  }
+
+  private ResourceState(String swigName, ResourceState swigEnum) {
+    this.swigName = swigName;
+    this.swigValue = swigEnum.swigValue;
+    swigNext = this.swigValue+1;
+  }
+
+  private static ResourceState[] swigValues = { SURF_RESOURCE_ON, SURF_RESOURCE_OFF };
+  private static int swigNext = 0;
+  private final int swigValue;
+  private final String swigName;
+}
+
diff --git a/src/bindings/java/org/simgrid/surf/RoutingEdge.java b/src/bindings/java/org/simgrid/surf/RoutingEdge.java
new file mode 100644 (file)
index 0000000..36b117a
--- /dev/null
@@ -0,0 +1,42 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public class RoutingEdge {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected RoutingEdge(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(RoutingEdge obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_RoutingEdge(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  public String getName() {
+    return SurfJNI.RoutingEdge_getName(swigCPtr, this);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/Surf.java b/src/bindings/java/org/simgrid/surf/Surf.java
new file mode 100644 (file)
index 0000000..b4ef317
--- /dev/null
@@ -0,0 +1,57 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public class Surf {
+  public static Object getAction(long jarg1) {
+    return SurfJNI.getAction(jarg1);
+  }
+
+  public static Object getCpuModelDirector(long jarg1) {
+    return SurfJNI.getCpuModelDirector(jarg1);
+  }
+
+  public static Object getCpuDirector(long jarg1) {
+    return SurfJNI.getCpuDirector(jarg1);
+  }
+
+  public static Object getCpuActionDirector(long jarg1) {
+    return SurfJNI.getCpuActionDirector(jarg1);
+  }
+
+  
+  /**
+    * @return The current simulated time
+    */
+  public static double getClock() {
+    return SurfJNI.getClock();
+  }
+
+  public static void clean() {
+    SurfJNI.clean();
+  }
+
+  public static CpuModel getCpuModel() {
+  long cPtr = SurfJNI.getCpuModel();
+  return (CpuModel)Surf.getCpuModelDirector(cPtr);
+}
+
+  public static void setCpuModel(CpuModel cpuModel) {
+    SurfJNI.setCpuModel(CpuModel.getCPtr(cpuModel), cpuModel);
+  }
+
+  public static void setCpu(String name, Cpu cpu) {
+    SurfJNI.setCpu(name, Cpu.getCPtr(cpu), cpu);
+  }
+
+  public static NetworkLink[] getRoute(String srcName, String dstName) {
+     return NetworkLink.cArrayWrap(SurfJNI.getRoute(srcName, dstName), false);
+}
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/SurfJNI.java b/src/bindings/java/org/simgrid/surf/SurfJNI.java
new file mode 100644 (file)
index 0000000..040ca88
--- /dev/null
@@ -0,0 +1,267 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+import org.simgrid.NativeLib;
+
+public class SurfJNI {
+
+  static {
+    NativeLib.nativeInit("surf-java");
+    Runtime.getRuntime().addShutdownHook(
+      new Thread() {
+        public void run() {
+          Thread.currentThread().setName( "Destroyer" );
+          Surf.clean();
+        }
+      }
+    );
+  }
+
+  public final static native long[] ActionList_getArray(long jarg1, ActionList jarg1_);
+  public final static native long new_ActionList();
+  public final static native void delete_ActionList(long jarg1);
+  public final static native Object getAction(long jarg1);
+  public final static native Object getCpuModelDirector(long jarg1);
+  public final static native Object getCpuDirector(long jarg1);
+  public final static native Object getCpuActionDirector(long jarg1);
+  public final static native double getClock();
+  public final static native void clean();
+  public final static native long getCpuModel();
+  public final static native void setCpuModel(long jarg1, CpuModel jarg1_);
+  public final static native void setCpu(String jarg1, long jarg2, Cpu jarg2_);
+  public final static native long[] getRoute(String jarg1, String jarg2);
+  public final static native void delete_Plugin(long jarg1);
+  public final static native void Plugin_activateCpuCreatedCallback(long jarg1, Plugin jarg1_);
+  public final static native void Plugin_cpuCreatedCallback(long jarg1, Plugin jarg1_, long jarg2, Cpu jarg2_);
+  public final static native void Plugin_cpuCreatedCallbackSwigExplicitPlugin(long jarg1, Plugin jarg1_, long jarg2, Cpu jarg2_);
+  public final static native void Plugin_activateCpuDestructedCallback(long jarg1, Plugin jarg1_);
+  public final static native void Plugin_cpuDestructedCallback(long jarg1, Plugin jarg1_, long jarg2, Cpu jarg2_);
+  public final static native void Plugin_cpuDestructedCallbackSwigExplicitPlugin(long jarg1, Plugin jarg1_, long jarg2, Cpu jarg2_);
+  public final static native void Plugin_activateCpuStateChangedCallback(long jarg1, Plugin jarg1_);
+  public final static native void Plugin_cpuStateChangedCallback(long jarg1, Plugin jarg1_, long jarg2, Cpu jarg2_, int jarg3, int jarg4);
+  public final static native void Plugin_cpuStateChangedCallbackSwigExplicitPlugin(long jarg1, Plugin jarg1_, long jarg2, Cpu jarg2_, int jarg3, int jarg4);
+  public final static native void Plugin_activateCpuActionStateChangedCallback(long jarg1, Plugin jarg1_);
+  public final static native void Plugin_cpuActionStateChangedCallback(long jarg1, Plugin jarg1_, long jarg2, CpuAction jarg2_, int jarg3, int jarg4);
+  public final static native void Plugin_cpuActionStateChangedCallbackSwigExplicitPlugin(long jarg1, Plugin jarg1_, long jarg2, CpuAction jarg2_, int jarg3, int jarg4);
+  public final static native void Plugin_activateNetworkLinkCreatedCallback(long jarg1, Plugin jarg1_);
+  public final static native void Plugin_networkLinkCreatedCallback(long jarg1, Plugin jarg1_, long jarg2, NetworkLink jarg2_);
+  public final static native void Plugin_networkLinkCreatedCallbackSwigExplicitPlugin(long jarg1, Plugin jarg1_, long jarg2, NetworkLink jarg2_);
+  public final static native void Plugin_activateNetworkLinkDestructedCallback(long jarg1, Plugin jarg1_);
+  public final static native void Plugin_networkLinkDestructedCallback(long jarg1, Plugin jarg1_, long jarg2, NetworkLink jarg2_);
+  public final static native void Plugin_networkLinkDestructedCallbackSwigExplicitPlugin(long jarg1, Plugin jarg1_, long jarg2, NetworkLink jarg2_);
+  public final static native void Plugin_activateNetworkLinkStateChangedCallback(long jarg1, Plugin jarg1_);
+  public final static native void Plugin_networkLinkStateChangedCallback(long jarg1, Plugin jarg1_, long jarg2, NetworkLink jarg2_, int jarg3, int jarg4);
+  public final static native void Plugin_networkLinkStateChangedCallbackSwigExplicitPlugin(long jarg1, Plugin jarg1_, long jarg2, NetworkLink jarg2_, int jarg3, int jarg4);
+  public final static native void Plugin_activateNetworkActionStateChangedCallback(long jarg1, Plugin jarg1_);
+  public final static native void Plugin_networkActionStateChangedCallback(long jarg1, Plugin jarg1_, long jarg2, NetworkAction jarg2_, int jarg3, int jarg4);
+  public final static native void Plugin_networkActionStateChangedCallbackSwigExplicitPlugin(long jarg1, Plugin jarg1_, long jarg2, NetworkAction jarg2_, int jarg3, int jarg4);
+  public final static native void Plugin_activateNetworkCommunicateCallback(long jarg1, Plugin jarg1_);
+  public final static native void Plugin_networkCommunicateCallback(long jarg1, Plugin jarg1_, long jarg2, NetworkAction jarg2_, long jarg3, RoutingEdge jarg3_, long jarg4, RoutingEdge jarg4_, double jarg5, double jarg6);
+  public final static native void Plugin_networkCommunicateCallbackSwigExplicitPlugin(long jarg1, Plugin jarg1_, long jarg2, NetworkAction jarg2_, long jarg3, RoutingEdge jarg3_, long jarg4, RoutingEdge jarg4_, double jarg5, double jarg6);
+  public final static native long new_Plugin();
+  public final static native void Plugin_director_connect(Plugin obj, long cptr, boolean mem_own, boolean weak_global);
+  public final static native void Plugin_change_ownership(Plugin obj, long cptr, boolean take_or_release);
+  public final static native void delete_TmgrTrace(long jarg1);
+  public final static native long TmgrTraceEvent_getIdx(long jarg1, TmgrTraceEvent jarg1_);
+  public final static native void delete_TmgrTraceEvent(long jarg1);
+  public final static native long new_Model(String jarg1);
+  public final static native String Model_getName(long jarg1, Model jarg1_);
+  public final static native double Model_shareResources(long jarg1, Model jarg1_, double jarg2);
+  public final static native double Model_shareResourcesLazy(long jarg1, Model jarg1_, double jarg2);
+  public final static native double Model_shareResourcesFull(long jarg1, Model jarg1_, double jarg2);
+  public final static native void Model_updateActionsState(long jarg1, Model jarg1_, double jarg2, double jarg3);
+  public final static native void Model_updateActionsStateLazy(long jarg1, Model jarg1_, double jarg2, double jarg3);
+  public final static native void Model_updateActionsStateFull(long jarg1, Model jarg1_, double jarg2, double jarg3);
+  public final static native long Model_getRunningActionSet(long jarg1, Model jarg1_);
+  public final static native void delete_Model(long jarg1);
+  public final static native long new_CpuModel(String jarg1);
+  public final static native void delete_CpuModel(long jarg1);
+  public final static native long CpuModel_createResource(long jarg1, CpuModel jarg1_, String jarg2, double[] jarg3, int jarg4, double jarg5, long jarg6, TmgrTrace jarg6_, int jarg7, int jarg8, long jarg9, TmgrTrace jarg9_, long jarg10, XbtDict jarg10_);
+  public final static native void CpuModel_addTraces(long jarg1, CpuModel jarg1_);
+  public final static native void CpuModel_director_connect(CpuModel obj, long cptr, boolean mem_own, boolean weak_global);
+  public final static native void CpuModel_change_ownership(CpuModel obj, long cptr, boolean take_or_release);
+  public final static native String Resource_getName(long jarg1, Resource jarg1_);
+  public final static native boolean Resource_isUsed(long jarg1, Resource jarg1_);
+  public final static native long Resource_getModel(long jarg1, Resource jarg1_);
+  public final static native int Resource_getState(long jarg1, Resource jarg1_);
+  public final static native long Resource_getConstraint(long jarg1, Resource jarg1_);
+  public final static native long Resource_getProperties(long jarg1, Resource jarg1_);
+  public final static native void Resource_updateState(long jarg1, Resource jarg1_, long jarg2, TmgrTraceEvent jarg2_, double jarg3, double jarg4);
+  public final static native void delete_Resource(long jarg1);
+  public final static native long new_Cpu__SWIG_0(long jarg1, Model jarg1_, String jarg2, long jarg3, XbtDict jarg3_, long jarg4, LmmConstraint jarg4_, int jarg5, double jarg6, double jarg7);
+  public final static native long new_Cpu__SWIG_1(long jarg1, Model jarg1_, String jarg2, long jarg3, XbtDict jarg3_, int jarg4, double jarg5, double jarg6);
+  public final static native void delete_Cpu(long jarg1);
+  public final static native double Cpu_getCurrentPowerPeak(long jarg1, Cpu jarg1_);
+  public final static native double Cpu_getCurrentPowerPeakSwigExplicitCpu(long jarg1, Cpu jarg1_);
+  public final static native long Cpu_execute(long jarg1, Cpu jarg1_, double jarg2);
+  public final static native long Cpu_sleep(long jarg1, Cpu jarg1_, double jarg2);
+  public final static native int Cpu_getCore(long jarg1, Cpu jarg1_);
+  public final static native int Cpu_getCoreSwigExplicitCpu(long jarg1, Cpu jarg1_);
+  public final static native double Cpu_getSpeed(long jarg1, Cpu jarg1_, double jarg2);
+  public final static native double Cpu_getSpeedSwigExplicitCpu(long jarg1, Cpu jarg1_, double jarg2);
+  public final static native double Cpu_getAvailableSpeed(long jarg1, Cpu jarg1_);
+  public final static native double Cpu_getAvailableSpeedSwigExplicitCpu(long jarg1, Cpu jarg1_);
+  public final static native double Cpu_getPowerPeakAt(long jarg1, Cpu jarg1_, int jarg2);
+  public final static native int Cpu_getNbPstates(long jarg1, Cpu jarg1_);
+  public final static native void Cpu_setPowerPeakAt(long jarg1, Cpu jarg1_, int jarg2);
+  public final static native void Cpu_setState(long jarg1, Cpu jarg1_, int jarg2);
+  public final static native void Cpu_director_connect(Cpu obj, long cptr, boolean mem_own, boolean weak_global);
+  public final static native void Cpu_change_ownership(Cpu obj, long cptr, boolean take_or_release);
+  public final static native void delete_NetworkLink(long jarg1);
+  public final static native double NetworkLink_getBandwidth(long jarg1, NetworkLink jarg1_);
+  public final static native void NetworkLink_updateBandwidth__SWIG_0(long jarg1, NetworkLink jarg1_, double jarg2, double jarg3);
+  public final static native void NetworkLink_updateBandwidth__SWIG_1(long jarg1, NetworkLink jarg1_, double jarg2);
+  public final static native double NetworkLink_getLatency(long jarg1, NetworkLink jarg1_);
+  public final static native void NetworkLink_updateLatency__SWIG_0(long jarg1, NetworkLink jarg1_, double jarg2, double jarg3);
+  public final static native void NetworkLink_updateLatency__SWIG_1(long jarg1, NetworkLink jarg1_, double jarg2);
+  public final static native long new_Action(long jarg1, Model jarg1_, double jarg2, boolean jarg3);
+  public final static native void delete_Action(long jarg1);
+  public final static native long Action_getModel(long jarg1, Action jarg1_);
+  public final static native long Action_getVariable(long jarg1, Action jarg1_);
+  public final static native int Action_getState(long jarg1, Action jarg1_);
+  public final static native boolean Action_isSuspended(long jarg1, Action jarg1_);
+  public final static native double Action_getBound(long jarg1, Action jarg1_);
+  public final static native void Action_setBound(long jarg1, Action jarg1_, double jarg2);
+  public final static native void Action_updateRemains(long jarg1, Action jarg1_, double jarg2);
+  public final static native double Action_getRemains(long jarg1, Action jarg1_);
+  public final static native void Action_setPriority(long jarg1, Action jarg1_, double jarg2);
+  public final static native void Action_setState(long jarg1, Action jarg1_, int jarg2);
+  public final static native long new_CpuAction(long jarg1, Model jarg1_, double jarg2, boolean jarg3);
+  public final static native long CpuAction_getCpu(long jarg1, CpuAction jarg1_);
+  public final static native void delete_CpuAction(long jarg1);
+  public final static native void CpuAction_director_connect(CpuAction obj, long cptr, boolean mem_own, boolean weak_global);
+  public final static native void CpuAction_change_ownership(CpuAction obj, long cptr, boolean take_or_release);
+  public final static native double NetworkAction_getLatency(long jarg1, NetworkAction jarg1_);
+  public final static native void delete_NetworkAction(long jarg1);
+  public final static native String RoutingEdge_getName(long jarg1, RoutingEdge jarg1_);
+  public final static native void delete_RoutingEdge(long jarg1);
+  public final static native double LmmConstraint_getUsage(long jarg1, LmmConstraint jarg1_);
+  public final static native long new_LmmConstraint();
+  public final static native void delete_LmmConstraint(long jarg1);
+  public final static native double LmmVariable_getValue(long jarg1, LmmVariable jarg1_);
+  public final static native long new_LmmVariable();
+  public final static native void delete_LmmVariable(long jarg1);
+  public final static native String XbtDict_getValue(long jarg1, XbtDict jarg1_, String jarg2);
+  public final static native long new_XbtDict();
+  public final static native void delete_XbtDict(long jarg1);
+  public final static native int SURF_ACTION_READY_get();
+  public final static native int SURF_RESOURCE_ON_get();
+  public final static native int SURF_RESOURCE_OFF_get();
+  public final static native long CpuModel_SWIGUpcast(long jarg1);
+  public final static native long Cpu_SWIGUpcast(long jarg1);
+  public final static native long NetworkLink_SWIGUpcast(long jarg1);
+  public final static native long CpuAction_SWIGUpcast(long jarg1);
+  public final static native long NetworkAction_SWIGUpcast(long jarg1);
+
+  public static void SwigDirector_Plugin_cpuCreatedCallback(Plugin self, long cpu) {
+    self.cpuCreatedCallback((cpu == 0) ? null : new Cpu(cpu, false));
+  }
+  public static void SwigDirector_Plugin_cpuDestructedCallback(Plugin self, long cpu) {
+    self.cpuDestructedCallback((cpu == 0) ? null : new Cpu(cpu, false));
+  }
+  public static void SwigDirector_Plugin_cpuStateChangedCallback(Plugin self, long cpu, int arg1, int arg2) {
+    self.cpuStateChangedCallback((cpu == 0) ? null : new Cpu(cpu, false), ResourceState.swigToEnum(arg1), ResourceState.swigToEnum(arg2));
+  }
+  public static void SwigDirector_Plugin_cpuActionStateChangedCallback(Plugin self, long action, int arg1, int arg2) {
+    self.cpuActionStateChangedCallback((action == 0) ? null : new CpuAction(action, false), ActionState.swigToEnum(arg1), ActionState.swigToEnum(arg2));
+  }
+  public static void SwigDirector_Plugin_networkLinkCreatedCallback(Plugin self, long link) {
+    self.networkLinkCreatedCallback((link == 0) ? null : new NetworkLink(link, false));
+  }
+  public static void SwigDirector_Plugin_networkLinkDestructedCallback(Plugin self, long link) {
+    self.networkLinkDestructedCallback((link == 0) ? null : new NetworkLink(link, false));
+  }
+  public static void SwigDirector_Plugin_networkLinkStateChangedCallback(Plugin self, long link, int arg1, int arg2) {
+    self.networkLinkStateChangedCallback((link == 0) ? null : new NetworkLink(link, false), ResourceState.swigToEnum(arg1), ResourceState.swigToEnum(arg2));
+  }
+  public static void SwigDirector_Plugin_networkActionStateChangedCallback(Plugin self, long action, int old, int cur) {
+    self.networkActionStateChangedCallback((action == 0) ? null : new NetworkAction(action, false), ActionState.swigToEnum(old), ActionState.swigToEnum(cur));
+  }
+  public static void SwigDirector_Plugin_networkCommunicateCallback(Plugin self, long action, long src, long dst, double size, double rate) {
+    self.networkCommunicateCallback((action == 0) ? null : new NetworkAction(action, false), (src == 0) ? null : new RoutingEdge(src, false), (dst == 0) ? null : new RoutingEdge(dst, false), size, rate);
+  }
+  public static double SwigDirector_CpuModel_shareResources(CpuModel self, double now) {
+    return self.shareResources(now);
+  }
+  public static double SwigDirector_CpuModel_shareResourcesLazy(CpuModel self, double now) {
+    return self.shareResourcesLazy(now);
+  }
+  public static double SwigDirector_CpuModel_shareResourcesFull(CpuModel self, double now) {
+    return self.shareResourcesFull(now);
+  }
+  public static void SwigDirector_CpuModel_updateActionsState(CpuModel self, double now, double delta) {
+    self.updateActionsState(now, delta);
+  }
+  public static void SwigDirector_CpuModel_updateActionsStateLazy(CpuModel self, double now, double delta) {
+    self.updateActionsStateLazy(now, delta);
+  }
+  public static void SwigDirector_CpuModel_updateActionsStateFull(CpuModel self, double now, double delta) {
+    self.updateActionsStateFull(now, delta);
+  }
+  public static long SwigDirector_CpuModel_getRunningActionSet(CpuModel self) {
+    return ActionList.getCPtr(self.getRunningActionSet());
+  }
+  public static long SwigDirector_CpuModel_createResource(CpuModel self, String name, double[] power_peak, int pstate, double power_scale, long power_trace, int core, int state_initial, long state_trace, long cpu_properties) {
+    return Cpu.getCPtr(self.createResource(name, power_peak, pstate, power_scale, (power_trace == 0) ? null : new TmgrTrace(power_trace, false), core, ResourceState.swigToEnum(state_initial), (state_trace == 0) ? null : new TmgrTrace(state_trace, false), (cpu_properties == 0) ? null : new XbtDict(cpu_properties, false)));
+  }
+  public static void SwigDirector_CpuModel_addTraces(CpuModel self) {
+    self.addTraces();
+  }
+  public static boolean SwigDirector_Cpu_isUsed(Cpu self) {
+    return self.isUsed();
+  }
+  public static int SwigDirector_Cpu_getState(Cpu self) {
+    return (self.getState()).swigValue();
+  }
+  public static void SwigDirector_Cpu_updateState(Cpu self, long event_type, double value, double date) {
+    self.updateState((event_type == 0) ? null : new TmgrTraceEvent(event_type, false), value, date);
+  }
+  public static double SwigDirector_Cpu_getCurrentPowerPeak(Cpu self) {
+    return self.getCurrentPowerPeak();
+  }
+  public static long SwigDirector_Cpu_execute(Cpu self, double size) {
+    return CpuAction.getCPtr(self.execute(size));
+  }
+  public static long SwigDirector_Cpu_sleep(Cpu self, double duration) {
+    return CpuAction.getCPtr(self.sleep(duration));
+  }
+  public static int SwigDirector_Cpu_getCore(Cpu self) {
+    return self.getCore();
+  }
+  public static double SwigDirector_Cpu_getSpeed(Cpu self, double load) {
+    return self.getSpeed(load);
+  }
+  public static double SwigDirector_Cpu_getAvailableSpeed(Cpu self) {
+    return self.getAvailableSpeed();
+  }
+  public static double SwigDirector_Cpu_getPowerPeakAt(Cpu self, int pstate_index) {
+    return self.getPowerPeakAt(pstate_index);
+  }
+  public static int SwigDirector_Cpu_getNbPstates(Cpu self) {
+    return self.getNbPstates();
+  }
+  public static void SwigDirector_Cpu_setPowerPeakAt(Cpu self, int pstate_index) {
+    self.setPowerPeakAt(pstate_index);
+  }
+  public static double SwigDirector_CpuAction_getRemains(CpuAction self) {
+    return self.getRemains();
+  }
+  public static void SwigDirector_CpuAction_setPriority(CpuAction self, double priority) {
+    self.setPriority(priority);
+  }
+  public static void SwigDirector_CpuAction_setState(CpuAction self, int state) {
+    self.setState(ActionState.swigToEnum(state));
+  }
+
+  private final static native void swig_module_init();
+  static {
+    swig_module_init();
+  }
+}
diff --git a/src/bindings/java/org/simgrid/surf/TmgrTrace.java b/src/bindings/java/org/simgrid/surf/TmgrTrace.java
new file mode 100644 (file)
index 0000000..1c7555f
--- /dev/null
@@ -0,0 +1,38 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public class TmgrTrace {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected TmgrTrace(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(TmgrTrace obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_TmgrTrace(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/TmgrTraceEvent.java b/src/bindings/java/org/simgrid/surf/TmgrTraceEvent.java
new file mode 100644 (file)
index 0000000..d3f1f7e
--- /dev/null
@@ -0,0 +1,42 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public class TmgrTraceEvent {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected TmgrTraceEvent(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(TmgrTraceEvent obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_TmgrTraceEvent(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  public long getIdx() {
+    return SurfJNI.TmgrTraceEvent_getIdx(swigCPtr, this);
+  }
+
+}
diff --git a/src/bindings/java/org/simgrid/surf/XbtDict.java b/src/bindings/java/org/simgrid/surf/XbtDict.java
new file mode 100644 (file)
index 0000000..dbbc370
--- /dev/null
@@ -0,0 +1,46 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.simgrid.surf;
+
+public class XbtDict {
+  private long swigCPtr;
+  protected boolean swigCMemOwn;
+
+  protected XbtDict(long cPtr, boolean cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = cPtr;
+  }
+
+  protected static long getCPtr(XbtDict obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+
+  protected void finalize() {
+    delete();
+  }
+
+  public synchronized void delete() {
+    if (swigCPtr != 0) {
+      if (swigCMemOwn) {
+        swigCMemOwn = false;
+        SurfJNI.delete_XbtDict(swigCPtr);
+      }
+      swigCPtr = 0;
+    }
+  }
+
+  public String getValue(String key) {
+    return SurfJNI.XbtDict_getValue(swigCPtr, this, key);
+  }
+
+  public XbtDict() {
+    this(SurfJNI.new_XbtDict(), true);
+  }
+
+}
index 2a14056..425f708 100644 (file)
@@ -302,7 +302,7 @@ public final class Trace {
        /**
         * Set the value of a variable of a VM. 
         * 
-        * @param host
+        * @param vm
         * @param variable
         * @param value
         */
diff --git a/src/bindings/java/surf.i b/src/bindings/java/surf.i
new file mode 100644 (file)
index 0000000..70006b3
--- /dev/null
@@ -0,0 +1,386 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+/* File : example.i */
+%module(directors="1") Surf
+
+%include "arrays_java.i"
+%include "std_string.i"
+%include "surfdoc.i"
+
+%pragma(java) jniclassimports=%{
+import org.simgrid.NativeLib;
+%}
+%pragma(java) jniclasscode=%{
+  static {
+    NativeLib.nativeInit("surf-java");
+    Runtime.getRuntime().addShutdownHook(
+      new Thread() {
+        public void run() {
+          Thread.currentThread().setName( "Destroyer" );
+          Surf.clean();
+        }
+      }
+    );
+  }
+%}
+
+%{
+#include "src/surf/surf_interface.hpp"
+#include "src/surf/cpu_interface.hpp"
+#include "src/surf/network_interface.hpp"
+#include "src/surf/trace_mgr_private.h"
+#include "src/bindings/java/surf_swig.hpp"
+#include "src/xbt/dict_private.h"
+
+typedef struct lmm_constraint *lmm_constraint_t;
+typedef xbt_dynar_t DoubleDynar;
+%}
+
+%wrapper %{
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jobject JNICALL Java_org_simgrid_surf_SurfJNI_getAction(JNIEnv *env, jclass cls, jlong jarg1) {
+  Action * action = (Action *)jarg1;
+  jobject res;
+  CpuAction *cpu_action = dynamic_cast<CpuAction*>(action);
+  if (cpu_action) {
+    SwigDirector_CpuAction *dir_cpu_action = dynamic_cast<SwigDirector_CpuAction*>(cpu_action);
+    if (dir_cpu_action) {
+      res = dir_cpu_action->swig_get_self(env);\
+    } else {
+      jclass clss = env->FindClass("org/simgrid/surf/CpuAction");\
+      jmethodID constru = env->GetMethodID(clss, "<init>", "()V");\
+      res = env->NewObject(clss, constru);\
+      res = env->NewGlobalRef(res);\
+    }
+  } else {
+    jclass clss = env->FindClass("org/simgrid/surf/Action");\
+    jmethodID constru = env->GetMethodID(clss, "<init>", "()V");\
+    res = env->NewObject(clss, constru);\
+    res = env->NewGlobalRef(res);\
+  }
+  return res;
+}
+
+#define GETDIRECTOR(NAME) \
+JNIEXPORT jobject JNICALL Java_org_simgrid_surf_SurfJNI_get## NAME ## Director(JNIEnv *env, jclass cls, jlong jarg1)\
+{\
+  NAME * arg1 = (NAME*)jarg1;\
+  SwigDirector_ ##NAME *director = dynamic_cast<SwigDirector_ ##NAME *>(arg1);\
+  jobject res;\
+  if (director) {\
+    res = director->swig_get_self(env);\
+  } else {\
+    jclass clss = env->FindClass("org/simgrid/surf/NAME");\
+    jmethodID constru = env->GetMethodID(clss, "<init>", "()V");\
+    res = env->NewObject(clss, constru);\
+    res = env->NewGlobalRef(res);\
+  }\
+  return res;\
+}
+
+GETDIRECTOR(CpuModel)
+GETDIRECTOR(Cpu)
+GETDIRECTOR(CpuAction)
+
+#ifdef __cplusplus
+}
+#endif
+
+%}
+
+%typemap(freearg) char* name {
+}
+
+/* Handle xbt_dynar_t of NetworkLink */
+JAVA_ARRAYSOFCLASSES(Action);
+%apply Action[] {ActionArrayPtr};
+%typemap(jstype) ActionArrayPtr "Action[]"
+%typemap(javain) ActionArrayPtr "Action.cArrayUnwrap($javainput)"
+%typemap(javaout) ActionArrayPtr {
+  long[] cArray = $jnicall;
+  Action[] arrayWrapper = new Action[cArray.length];
+  for (int i=0; i<cArray.length; i++)
+    arrayWrapper[i] = (Action) Surf.getAction(cArray[i]);
+  return arrayWrapper;
+  //   return Action.cArrayWrap($jnicall, $owner);
+}
+%typemap(out) ActionArrayPtr {
+  long l = 0;
+  for(ActionList::iterator it($1->begin()), itend($1->end()); it != itend ; ++it) {
+    l++;
+  }
+  $result = jenv->NewLongArray(l);
+  jlong *elts = jenv->GetLongArrayElements($result, NULL);
+  l = 0;
+  for(ActionList::iterator it($1->begin()), itend($1->end()); it != itend ; ++it) {
+    elts[l++] = (jlong)static_cast<ActionPtr>(&*it);
+  }
+  jenv->ReleaseLongArrayElements($result, elts, 0);
+}
+
+class ActionList {
+public:
+  //void push_front(Action &action);
+  //void push_back(Action &action);
+%extend {
+  ActionArrayPtr getArray(){
+    return $self;
+  }
+}
+};
+
+/* Handle xbt_dynar_t of NetworkLink */
+JAVA_ARRAYSOFCLASSES(NetworkLink);
+%apply NetworkLink[] {NetworkLinkDynar};
+%typemap(jstype) NetworkLinkDynar "NetworkLink[]"
+%typemap(javain) NetworkLinkDynar "NetworkLink.cArrayUnwrap($javainput)"
+%typemap(javaout) NetworkLinkDynar {
+     return NetworkLink.cArrayWrap($jnicall, $owner);
+}
+%typemap(out) NetworkLinkDynar {
+  long l = xbt_dynar_length($1);
+  $result = jenv->NewLongArray(l);
+  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);
+}
+
+%nodefault DoubleDynar;
+%typemap(jni) DoubleDynar "jdoubleArray"
+%rename(DoubleDynar) Double[];
+%typemap(jtype) DoubleDynar "double[]"
+%typemap(jstype) DoubleDynar "double[]"
+%typemap(out) DoubleDynar {
+  long l = xbt_dynar_length($1);
+  $result = jenv->NewDoubleArray(l);
+  double *lout = (double *)xbt_dynar_to_array($1);
+  jenv->SetDoubleArrayRegion($result, 0, l, (const jdouble*)lout);
+  free(lout);
+}
+%typemap(javadirectorin) DoubleDynar "$jniinput"
+%typemap(directorin,descriptor="[D") DoubleDynar %{
+  long l = xbt_dynar_length($1);
+  $input = jenv->NewDoubleArray(l);
+  double *lout = (double *)xbt_dynar_to_array($1);
+  jenv->SetDoubleArrayRegion($input, 0, l, (const jdouble*)lout);
+  free(lout);
+%}
+%typemap(javain) DoubleDynar "$javainput"
+%typemap(javaout) DoubleDynar {return  $jnicall}
+
+/* Allow to subclass Plugin and send java object to C++ code */
+%feature("director") Plugin;
+
+%native(getAction) jobject getAction(jlong jarg1);
+%native(getCpuModelDirector) jobject getCpuModelDirector(jlong jarg1);
+%typemap(javaout) CpuModel * {
+  long cPtr = $jnicall;
+  return (CpuModel)Surf.getCpuModelDirector(cPtr);
+}
+%native(getCpuDirector) jobject getCpuDirector(jlong jarg1);
+%typemap(javaout) Cpu * {
+  long cPtr = $jnicall;
+  return (Cpu)Surf.getCpuDirector(cPtr);
+}
+%native(getCpuActionDirector) jobject getCpuActionDirector(jlong jarg1);
+%typemap(javaout) CpuAction * {
+  long cPtr = $jnicall;
+  return (CpuAction)Surf.getCpuDirector(cPtr);
+}
+
+%include "src/bindings/java/surf_swig.hpp"
+
+%rename tmgr_trace TmgrTrace;
+%nodefaultctor tmgr_trace;
+struct tmgr_trace {
+  //enum e_trace_type type;
+  /*union {
+    struct {
+      xbt_dynar_t event_list;
+    } s_list;
+    struct {
+      probabilist_event_generator_t event_generator[2];
+      int is_state_trace;
+      int next_event;
+    } s_probabilist;
+  };*/
+  %extend {
+  }
+};
+
+%rename tmgr_trace_event TmgrTraceEvent;
+%nodefaultctor tmgr_trace_event;
+struct tmgr_trace_event {
+  //tmgr_trace_t trace;
+  //unsigned int idx;
+  //void *model;
+  //int free_me;
+  %extend {
+    unsigned int getIdx() {return 0;}//$self->idx;}
+  }
+};
+
+%nodefaultctor Model;
+class Model {
+public:
+  Model(const char *name);
+  const char *getName();
+  virtual double shareResources(double now);
+  virtual double shareResourcesLazy(double now);
+  virtual double shareResourcesFull(double now);
+
+  virtual void updateActionsState(double now, double delta);
+  virtual void updateActionsStateLazy(double now, double delta);
+  virtual void updateActionsStateFull(double now, double delta);
+
+  virtual ActionList *getRunningActionSet();
+};
+
+%feature("director") CpuModel;
+class CpuModel : public Model {
+public:
+  CpuModel(const char *name);
+  virtual ~CpuModel();
+  virtual Cpu *createResource(const char *name, DoubleDynar power_peak,
+                              int pstate, double power_scale,
+                              tmgr_trace *power_trace, int core,
+                              e_surf_resource_state_t state_initial,
+                              tmgr_trace *state_trace,
+                              s_xbt_dict *cpu_properties)=0;
+  virtual void addTraces()=0;
+};
+
+class Resource {
+public:
+  Resource();
+  const char *getName();
+  virtual bool isUsed()=0;
+  Model *getModel();
+
+  virtual e_surf_resource_state_t getState();
+  lmm_constraint *getConstraint();
+  s_xbt_dict *getProperties();
+  virtual void updateState(tmgr_trace_event *event_type, double value, double date)=0;
+};
+
+%feature("director") Cpu;
+class Cpu : public Resource {
+public:
+  Cpu(Model *model, const char *name, s_xbt_dict *props,
+    lmm_constraint *constraint, int core, double powerPeak, double powerScale);
+  Cpu(Model *model, const char *name, s_xbt_dict *props,
+    int core, double powerPeak, double powerScale);
+  virtual ~Cpu();
+  virtual double getCurrentPowerPeak();
+  virtual CpuAction *execute(double size)=0;
+  virtual CpuAction *sleep(double duration)=0;
+  virtual int getCore();
+  virtual double getSpeed(double load);
+  virtual double getAvailableSpeed();
+  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);
+};
+
+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());
+};
+
+%nodefaultctor Action;
+class Action {
+public:
+  Action(Model *model, double cost, bool failed);
+  virtual ~Action();
+  Model *getModel();
+  lmm_variable *getVariable();
+  e_surf_action_state_t getState();
+  bool isSuspended();
+  double getBound();
+  void setBound(double bound);
+  void updateRemains(double delta);
+  virtual double getRemains();
+  virtual void setPriority(double priority);
+  virtual void setState(e_surf_action_state_t state);
+};
+
+%nodefaultctor CpuAction;
+%feature("director") CpuAction;
+class CpuAction : public Action {
+public:
+CpuAction(Model *model, double cost, bool failed);
+%extend {
+  Cpu *getCpu() {return getActionCpu($self);}
+}
+};
+
+%nodefaultctor NetworkAction;
+class NetworkAction : public Action {
+public:
+%extend {
+  double getLatency() {return $self->m_latency;}
+}
+};
+
+
+%nodefaultctor RoutingEdge;
+class RoutingEdge {
+public:
+  virtual char *getName()=0;
+};
+
+%rename lmm_constraint LmmConstraint;
+struct lmm_constraint {
+%extend {
+  double getUsage() {return lmm_constraint_get_usage($self);}
+}
+};
+
+%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/surfJAVA_wrap.cxx b/src/bindings/java/surfJAVA_wrap.cxx
new file mode 100644 (file)
index 0000000..ee52a22
--- /dev/null
@@ -0,0 +1,4207 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGJAVA
+#define SWIG_DIRECTORS
+
+
+#ifdef __cplusplus
+/* SwigValueWrapper is described in swig.swg */
+template<typename T> class SwigValueWrapper {
+  struct SwigMovePointer {
+    T *ptr;
+    SwigMovePointer(T *p) : ptr(p) { }
+    ~SwigMovePointer() { delete ptr; }
+    SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
+  } pointer;
+  SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+  SwigValueWrapper(const SwigValueWrapper<T>& rhs);
+public:
+  SwigValueWrapper() : pointer(0) { }
+  SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
+  operator T&() const { return *pointer.ptr; }
+  T *operator&() { return pointer.ptr; }
+};
+
+template <typename T> T SwigValueInit() {
+  return T();
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ *  This section contains generic SWIG labels for method/variable
+ *  declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+#  define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+#   define SWIGINLINE inline
+# else
+#   define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define SWIGUNUSED __attribute__ ((__unused__))
+#   else
+#     define SWIGUNUSED
+#   endif
+# elif defined(__ICC)
+#   define SWIGUNUSED __attribute__ ((__unused__))
+# else
+#   define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+#   define SWIGUNUSEDPARM(p)
+# else
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#  ifndef GCC_HASCLASSVISIBILITY
+#    define GCC_HASCLASSVISIBILITY
+#  endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   if defined(STATIC_LINKED)
+#     define SWIGEXPORT
+#   else
+#     define SWIGEXPORT __declspec(dllexport)
+#   endif
+# else
+#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+#     define SWIGEXPORT __attribute__ ((visibility("default")))
+#   else
+#     define SWIGEXPORT
+#   endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   define SWIGSTDCALL __stdcall
+# else
+#   define SWIGSTDCALL
+# endif
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+
+/* Fix for jlong on some versions of gcc on Windows */
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+  typedef long long __int64;
+#endif
+
+/* Fix for jlong on 64-bit x86 Solaris */
+#if defined(__x86_64)
+# ifdef _LP64
+#   undef _LP64
+# endif
+#endif
+
+#include <jni.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* Support for throwing Java exceptions */
+typedef enum {
+  SWIG_JavaOutOfMemoryError = 1, 
+  SWIG_JavaIOException, 
+  SWIG_JavaRuntimeException, 
+  SWIG_JavaIndexOutOfBoundsException,
+  SWIG_JavaArithmeticException,
+  SWIG_JavaIllegalArgumentException,
+  SWIG_JavaNullPointerException,
+  SWIG_JavaDirectorPureVirtual,
+  SWIG_JavaUnknownError
+} SWIG_JavaExceptionCodes;
+
+typedef struct {
+  SWIG_JavaExceptionCodes code;
+  const char *java_exception;
+} SWIG_JavaExceptions_t;
+
+
+static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
+  jclass excep;
+  static const SWIG_JavaExceptions_t java_exceptions[] = {
+    { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
+    { SWIG_JavaIOException, "java/io/IOException" },
+    { SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
+    { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
+    { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
+    { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
+    { SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
+    { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
+    { SWIG_JavaUnknownError,  "java/lang/UnknownError" },
+    { (SWIG_JavaExceptionCodes)0,  "java/lang/UnknownError" }
+  };
+  const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
+
+  while (except_ptr->code != code && except_ptr->code)
+    except_ptr++;
+
+  jenv->ExceptionClear();
+  excep = jenv->FindClass(except_ptr->java_exception);
+  if (excep)
+    jenv->ThrowNew(excep, msg);
+}
+
+
+/* Contract support */
+
+#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else
+
+/* -----------------------------------------------------------------------------
+ * director.swg
+ *
+ * This file contains support for director classes that proxy
+ * method calls from C++ to Java extensions.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+
+#if defined(DEBUG_DIRECTOR_OWNED)
+#include <iostream>
+#endif
+
+namespace Swig {
+  /* Java object wrapper */
+  class JObjectWrapper {
+  public:
+    JObjectWrapper() : jthis_(NULL), weak_global_(true) {
+    }
+
+    ~JObjectWrapper() {
+      jthis_ = NULL;
+      weak_global_ = true;
+    }
+
+    bool set(JNIEnv *jenv, jobject jobj, bool mem_own, bool weak_global) {
+      if (!jthis_) {
+        weak_global_ = weak_global || !mem_own; // hold as weak global if explicitly requested or not owned
+        if (jobj)
+          jthis_ = weak_global_ ? jenv->NewWeakGlobalRef(jobj) : jenv->NewGlobalRef(jobj);
+#if defined(DEBUG_DIRECTOR_OWNED)
+        std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> " << jthis_ << std::endl;
+#endif
+        return true;
+      } else {
+#if defined(DEBUG_DIRECTOR_OWNED)
+        std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> already set" << std::endl;
+#endif
+        return false;
+      }
+    }
+
+    jobject get(JNIEnv *jenv) const {
+#if defined(DEBUG_DIRECTOR_OWNED)
+      std::cout << "JObjectWrapper::get(";
+      if (jthis_)
+        std::cout << jthis_;
+      else
+        std::cout << "null";
+      std::cout << ") -> return new local ref" << std::endl;
+#endif
+      return (jthis_ ? jenv->NewLocalRef(jthis_) : jthis_);
+    }
+
+    void release(JNIEnv *jenv) {
+#if defined(DEBUG_DIRECTOR_OWNED)
+      std::cout << "JObjectWrapper::release(" << jthis_ << "): " << (weak_global_ ? "weak global ref" : "global ref") << std::endl;
+#endif
+      if (jthis_) {
+        if (weak_global_) {
+          if (jenv->IsSameObject(jthis_, NULL) == JNI_FALSE)
+            jenv->DeleteWeakGlobalRef((jweak)jthis_);
+        } else
+          jenv->DeleteGlobalRef(jthis_);
+      }
+
+      jthis_ = NULL;
+      weak_global_ = true;
+    }
+
+    /* Only call peek if you know what you are doing wrt to weak/global references */
+    jobject peek() {
+      return jthis_;
+    }
+
+    /* Java proxy releases ownership of C++ object, C++ object is now
+       responsible for destruction (creates NewGlobalRef to pin Java
+       proxy) */
+    void java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) {
+      if (take_or_release) {  /* Java takes ownership of C++ object's lifetime. */
+        if (!weak_global_) {
+          jenv->DeleteGlobalRef(jthis_);
+          jthis_ = jenv->NewWeakGlobalRef(jself);
+          weak_global_ = true;
+        }
+      } else { /* Java releases ownership of C++ object's lifetime */
+        if (weak_global_) {
+          jenv->DeleteWeakGlobalRef((jweak)jthis_);
+          jthis_ = jenv->NewGlobalRef(jself);
+          weak_global_ = false;
+        }
+      }
+    }
+
+  private:
+    /* pointer to Java object */
+    jobject jthis_;
+    /* Local or global reference flag */
+    bool weak_global_;
+  };
+
+  /* director base class */
+  class Director {
+    /* pointer to Java virtual machine */
+    JavaVM *swig_jvm_;
+
+  protected:
+#if defined (_MSC_VER) && (_MSC_VER<1300)
+    class JNIEnvWrapper;
+    friend class JNIEnvWrapper;
+#endif
+    /* Utility class for managing the JNI environment */
+    class JNIEnvWrapper {
+      const Director *director_;
+      JNIEnv *jenv_;
+      int env_status;
+    public:
+      JNIEnvWrapper(const Director *director) : director_(director), jenv_(0), env_status(0) {
+#if defined(__ANDROID__)
+        JNIEnv **jenv = &jenv_;
+#else
+        void **jenv = (void **)&jenv_;
+#endif
+        env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2);
+#if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON)
+        // Attach a daemon thread to the JVM. Useful when the JVM should not wait for 
+        // the thread to exit upon shutdown. Only for jdk-1.4 and later.
+        director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL);
+#else
+        director_->swig_jvm_->AttachCurrentThread(jenv, NULL);
+#endif
+      }
+      ~JNIEnvWrapper() {
+#if !defined(SWIG_JAVA_NO_DETACH_CURRENT_THREAD)
+        // Some JVMs, eg jdk-1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call.
+        // However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak.
+        if (env_status == JNI_EDETACHED)
+          director_->swig_jvm_->DetachCurrentThread();
+#endif
+      }
+      JNIEnv *getJNIEnv() const {
+        return jenv_;
+      }
+    };
+
+    /* Java object wrapper */
+    JObjectWrapper swig_self_;
+
+    /* Disconnect director from Java object */
+    void swig_disconnect_director_self(const char *disconn_method) {
+      JNIEnvWrapper jnienv(this) ;
+      JNIEnv *jenv = jnienv.getJNIEnv() ;
+      jobject jobj = swig_self_.get(jenv);
+#if defined(DEBUG_DIRECTOR_OWNED)
+      std::cout << "Swig::Director::disconnect_director_self(" << jobj << ")" << std::endl;
+#endif
+      if (jobj && jenv->IsSameObject(jobj, NULL) == JNI_FALSE) {
+        jmethodID disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(jobj), disconn_method, "()V");
+        if (disconn_meth) {
+#if defined(DEBUG_DIRECTOR_OWNED)
+          std::cout << "Swig::Director::disconnect_director_self upcall to " << disconn_method << std::endl;
+#endif
+          jenv->CallVoidMethod(jobj, disconn_meth);
+        }
+      }
+      jenv->DeleteLocalRef(jobj);
+    }
+
+  public:
+    Director(JNIEnv *jenv) : swig_jvm_((JavaVM *) NULL), swig_self_() {
+      /* Acquire the Java VM pointer */
+      jenv->GetJavaVM(&swig_jvm_);
+    }
+
+    virtual ~Director() {
+      JNIEnvWrapper jnienv(this) ;
+      JNIEnv *jenv = jnienv.getJNIEnv() ;
+      swig_self_.release(jenv);
+    }
+
+    bool swig_set_self(JNIEnv *jenv, jobject jself, bool mem_own, bool weak_global) {
+      return swig_self_.set(jenv, jself, mem_own, weak_global);
+    }
+
+    jobject swig_get_self(JNIEnv *jenv) const {
+      return swig_self_.get(jenv);
+    }
+
+    // Change C++ object's ownership, relative to Java
+    void swig_java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) {
+      swig_self_.java_change_ownership(jenv, jself, take_or_release);
+    }
+  };
+}
+
+#endif /* __cplusplus */
+
+
+namespace Swig {
+  namespace {
+    jclass jclass_SurfJNI = NULL;
+    jmethodID director_methids[33];
+  }
+}
+
+#if defined(SWIG_NOINCLUDE) || defined(SWIG_NOARRAYS)
+
+
+static int SWIG_JavaArrayInBool (JNIEnv *jenv, jboolean **jarr, bool **carr, jbooleanArray input);
+static void SWIG_JavaArrayArgoutBool (JNIEnv *jenv, jboolean *jarr, bool *carr, jbooleanArray input);
+static jbooleanArray SWIG_JavaArrayOutBool (JNIEnv *jenv, bool *result, jsize sz);
+
+
+static int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input);
+static void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input);
+static jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz);
+
+
+static int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input);
+static void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input);
+static jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz);
+
+
+static int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input);
+static void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input);
+static jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz);
+
+
+static int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input);
+static void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input);
+static jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz);
+
+
+static int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input);
+static void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input);
+static jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz);
+
+
+static int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input);
+static void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input);
+static jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz);
+
+
+static int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input);
+static void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input);
+static jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz);
+
+
+static int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input);
+static void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input);
+static jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz);
+
+
+static int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input);
+static void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input);
+static jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz);
+
+
+static int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input);
+static void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input);
+static jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz);
+
+
+static int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input);
+static void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input);
+static jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz);
+
+
+#else
+
+
+/* bool[] support */
+static int SWIG_JavaArrayInBool (JNIEnv *jenv, jboolean **jarr, bool **carr, jbooleanArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetBooleanArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new bool[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = ((*jarr)[i] != 0);
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutBool (JNIEnv *jenv, jboolean *jarr, bool *carr, jbooleanArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jboolean)carr[i];
+  jenv->ReleaseBooleanArrayElements(input, jarr, 0);
+}
+
+static jbooleanArray SWIG_JavaArrayOutBool (JNIEnv *jenv, bool *result, jsize sz) {
+  jboolean *arr;
+  int i;
+  jbooleanArray jresult = jenv->NewBooleanArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetBooleanArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jboolean)result[i];
+  jenv->ReleaseBooleanArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* signed char[] support */
+static int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetByteArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new signed char[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (signed char)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jbyte)carr[i];
+  jenv->ReleaseByteArrayElements(input, jarr, 0);
+}
+
+static jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz) {
+  jbyte *arr;
+  int i;
+  jbyteArray jresult = jenv->NewByteArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetByteArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jbyte)result[i];
+  jenv->ReleaseByteArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* unsigned char[] support */
+static int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetShortArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new unsigned char[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (unsigned char)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jshort)carr[i];
+  jenv->ReleaseShortArrayElements(input, jarr, 0);
+}
+
+static jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz) {
+  jshort *arr;
+  int i;
+  jshortArray jresult = jenv->NewShortArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetShortArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jshort)result[i];
+  jenv->ReleaseShortArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* short[] support */
+static int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetShortArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new short[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (short)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jshort)carr[i];
+  jenv->ReleaseShortArrayElements(input, jarr, 0);
+}
+
+static jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz) {
+  jshort *arr;
+  int i;
+  jshortArray jresult = jenv->NewShortArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetShortArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jshort)result[i];
+  jenv->ReleaseShortArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* unsigned short[] support */
+static int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetIntArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new unsigned short[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (unsigned short)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jint)carr[i];
+  jenv->ReleaseIntArrayElements(input, jarr, 0);
+}
+
+static jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz) {
+  jint *arr;
+  int i;
+  jintArray jresult = jenv->NewIntArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetIntArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jint)result[i];
+  jenv->ReleaseIntArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* int[] support */
+static int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetIntArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new int[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (int)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jint)carr[i];
+  jenv->ReleaseIntArrayElements(input, jarr, 0);
+}
+
+static jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz) {
+  jint *arr;
+  int i;
+  jintArray jresult = jenv->NewIntArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetIntArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jint)result[i];
+  jenv->ReleaseIntArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* unsigned int[] support */
+static int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetLongArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new unsigned int[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (unsigned int)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jlong)carr[i];
+  jenv->ReleaseLongArrayElements(input, jarr, 0);
+}
+
+static jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz) {
+  jlong *arr;
+  int i;
+  jlongArray jresult = jenv->NewLongArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetLongArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jlong)result[i];
+  jenv->ReleaseLongArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* long[] support */
+static int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetIntArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new long[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (long)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jint)carr[i];
+  jenv->ReleaseIntArrayElements(input, jarr, 0);
+}
+
+static jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz) {
+  jint *arr;
+  int i;
+  jintArray jresult = jenv->NewIntArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetIntArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jint)result[i];
+  jenv->ReleaseIntArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* unsigned long[] support */
+static int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetLongArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new unsigned long[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (unsigned long)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jlong)carr[i];
+  jenv->ReleaseLongArrayElements(input, jarr, 0);
+}
+
+static jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz) {
+  jlong *arr;
+  int i;
+  jlongArray jresult = jenv->NewLongArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetLongArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jlong)result[i];
+  jenv->ReleaseLongArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* jlong[] support */
+static int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetLongArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new jlong[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (jlong)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jlong)carr[i];
+  jenv->ReleaseLongArrayElements(input, jarr, 0);
+}
+
+static jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz) {
+  jlong *arr;
+  int i;
+  jlongArray jresult = jenv->NewLongArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetLongArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jlong)result[i];
+  jenv->ReleaseLongArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* float[] support */
+static int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetFloatArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new float[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (float)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jfloat)carr[i];
+  jenv->ReleaseFloatArrayElements(input, jarr, 0);
+}
+
+static jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz) {
+  jfloat *arr;
+  int i;
+  jfloatArray jresult = jenv->NewFloatArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetFloatArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jfloat)result[i];
+  jenv->ReleaseFloatArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+/* double[] support */
+static int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input) {
+  int i;
+  jsize sz;
+  if (!input) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+    return 0;
+  }
+  sz = jenv->GetArrayLength(input);
+  *jarr = jenv->GetDoubleArrayElements(input, 0);
+  if (!*jarr)
+    return 0; 
+  *carr = new double[sz]; 
+  if (!*carr) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+    return 0;
+  }
+  for (i=0; i<sz; i++)
+    (*carr)[i] = (double)(*jarr)[i];
+  return 1;
+}
+
+static void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input) {
+  int i;
+  jsize sz = jenv->GetArrayLength(input);
+  for (i=0; i<sz; i++)
+    jarr[i] = (jdouble)carr[i];
+  jenv->ReleaseDoubleArrayElements(input, jarr, 0);
+}
+
+static jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) {
+  jdouble *arr;
+  int i;
+  jdoubleArray jresult = jenv->NewDoubleArray(sz);
+  if (!jresult)
+    return NULL;
+  arr = jenv->GetDoubleArrayElements(jresult, 0);
+  if (!arr)
+    return NULL;
+  for (i=0; i<sz; i++)
+    arr[i] = (jdouble)result[i];
+  jenv->ReleaseDoubleArrayElements(jresult, arr, 0);
+  return jresult;
+}
+
+
+#endif
+
+
+#include <string>
+
+
+#include "src/surf/surf_interface.hpp"
+#include "src/surf/cpu_interface.hpp"
+#include "src/surf/network_interface.hpp"
+#include "src/surf/trace_mgr_private.h"
+#include "src/bindings/java/surf_swig.hpp"
+#include "src/xbt/dict_private.h"
+
+typedef struct lmm_constraint *lmm_constraint_t;
+typedef xbt_dynar_t DoubleDynar;
+
+SWIGINTERN ActionArrayPtr ActionList_getArray(ActionList *self){
+    return self;
+  }
+SWIGINTERN unsigned int tmgr_trace_event_getIdx(tmgr_trace_event *self){return 0;}
+SWIGINTERN Cpu *CpuAction_getCpu(CpuAction *self){return getActionCpu(self);}
+SWIGINTERN double NetworkAction_getLatency(NetworkAction *self){return self->m_latency;}
+SWIGINTERN double lmm_constraint_getUsage(lmm_constraint *self){return lmm_constraint_get_usage(self);}
+SWIGINTERN double lmm_variable_getValue(lmm_variable *self){return lmm_variable_getvalue(self);}
+SWIGINTERN char *s_xbt_dict_getValue(s_xbt_dict *self,char *key){return (char*)xbt_dict_get_or_null(self, key);}
+
+
+/* ---------------------------------------------------
+ * C++ director class methods
+ * --------------------------------------------------- */
+
+#include "surfJAVA_wrap.h"
+
+SwigDirector_Plugin::SwigDirector_Plugin(JNIEnv *jenv) : Plugin(), Swig::Director(jenv) {
+}
+
+SwigDirector_Plugin::~SwigDirector_Plugin() {
+  swig_disconnect_director_self("swigDirectorDisconnect");
+}
+
+
+void SwigDirector_Plugin::cpuCreatedCallback(Cpu *cpu) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jcpu = 0 ;
+  
+  if (!swig_override[0]) {
+    Plugin::cpuCreatedCallback(cpu);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((Cpu **)&jcpu) = (Cpu *) cpu; 
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[0], swigjobj, jcpu);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Plugin::cpuDestructedCallback(Cpu *cpu) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jcpu = 0 ;
+  
+  if (!swig_override[1]) {
+    Plugin::cpuDestructedCallback(cpu);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((Cpu **)&jcpu) = (Cpu *) cpu; 
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[1], swigjobj, jcpu);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Plugin::cpuStateChangedCallback(Cpu *cpu, e_surf_resource_state_t arg1, e_surf_resource_state_t arg2) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jcpu = 0 ;
+  jint jarg1  ;
+  jint jarg2  ;
+  
+  if (!swig_override[2]) {
+    Plugin::cpuStateChangedCallback(cpu,arg1,arg2);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((Cpu **)&jcpu) = (Cpu *) cpu; 
+    jarg1 = (jint) arg1;
+    jarg2 = (jint) arg2;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[2], swigjobj, jcpu, jarg1, jarg2);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Plugin::cpuActionStateChangedCallback(CpuAction *action, e_surf_action_state_t arg1, e_surf_action_state_t arg2) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jaction = 0 ;
+  jint jarg1  ;
+  jint jarg2  ;
+  
+  if (!swig_override[3]) {
+    Plugin::cpuActionStateChangedCallback(action,arg1,arg2);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((CpuAction **)&jaction) = (CpuAction *) action; 
+    jarg1 = (jint) arg1;
+    jarg2 = (jint) arg2;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[3], swigjobj, jaction, jarg1, jarg2);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Plugin::networkLinkCreatedCallback(NetworkLink *link) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jlink = 0 ;
+  
+  if (!swig_override[4]) {
+    Plugin::networkLinkCreatedCallback(link);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((NetworkLink **)&jlink) = (NetworkLink *) link; 
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[4], swigjobj, jlink);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Plugin::networkLinkDestructedCallback(NetworkLink *link) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jlink = 0 ;
+  
+  if (!swig_override[5]) {
+    Plugin::networkLinkDestructedCallback(link);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((NetworkLink **)&jlink) = (NetworkLink *) link; 
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[5], swigjobj, jlink);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Plugin::networkLinkStateChangedCallback(NetworkLink *link, e_surf_resource_state_t arg1, e_surf_resource_state_t arg2) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jlink = 0 ;
+  jint jarg1  ;
+  jint jarg2  ;
+  
+  if (!swig_override[6]) {
+    Plugin::networkLinkStateChangedCallback(link,arg1,arg2);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((NetworkLink **)&jlink) = (NetworkLink *) link; 
+    jarg1 = (jint) arg1;
+    jarg2 = (jint) arg2;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[6], swigjobj, jlink, jarg1, jarg2);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Plugin::networkActionStateChangedCallback(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t cur) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jaction = 0 ;
+  jint jold  ;
+  jint jcur  ;
+  
+  if (!swig_override[7]) {
+    Plugin::networkActionStateChangedCallback(action,old,cur);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((NetworkAction **)&jaction) = (NetworkAction *) action; 
+    jold = (jint) old;
+    jcur = (jint) cur;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[7], swigjobj, jaction, jold, jcur);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Plugin::networkCommunicateCallback(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jaction = 0 ;
+  jlong jsrc = 0 ;
+  jlong jdst = 0 ;
+  jdouble jsize  ;
+  jdouble jrate  ;
+  
+  if (!swig_override[8]) {
+    Plugin::networkCommunicateCallback(action,src,dst,size,rate);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((NetworkAction **)&jaction) = (NetworkAction *) action; 
+    *((RoutingEdge **)&jsrc) = (RoutingEdge *) src; 
+    *((RoutingEdge **)&jdst) = (RoutingEdge *) dst; 
+    jsize = (jdouble) size;
+    jrate = (jdouble) rate;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[8], swigjobj, jaction, jsrc, jdst, jsize, jrate);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Plugin::swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global) {
+  static struct {
+    const char *mname;
+    const char *mdesc;
+    jmethodID base_methid;
+  } methods[] = {
+    {
+      "cpuCreatedCallback", "(Lorg/simgrid/surf/Cpu;)V", NULL 
+    },
+    {
+      "cpuDestructedCallback", "(Lorg/simgrid/surf/Cpu;)V", NULL 
+    },
+    {
+      "cpuStateChangedCallback", "(Lorg/simgrid/surf/Cpu;Lorg/simgrid/surf/ResourceState;Lorg/simgrid/surf/ResourceState;)V", NULL 
+    },
+    {
+      "cpuActionStateChangedCallback", "(Lorg/simgrid/surf/CpuAction;Lorg/simgrid/surf/ActionState;Lorg/simgrid/surf/ActionState;)V", NULL 
+    },
+    {
+      "networkLinkCreatedCallback", "(Lorg/simgrid/surf/NetworkLink;)V", NULL 
+    },
+    {
+      "networkLinkDestructedCallback", "(Lorg/simgrid/surf/NetworkLink;)V", NULL 
+    },
+    {
+      "networkLinkStateChangedCallback", "(Lorg/simgrid/surf/NetworkLink;Lorg/simgrid/surf/ResourceState;Lorg/simgrid/surf/ResourceState;)V", NULL 
+    },
+    {
+      "networkActionStateChangedCallback", "(Lorg/simgrid/surf/NetworkAction;Lorg/simgrid/surf/ActionState;Lorg/simgrid/surf/ActionState;)V", NULL 
+    },
+    {
+      "networkCommunicateCallback", "(Lorg/simgrid/surf/NetworkAction;Lorg/simgrid/surf/RoutingEdge;Lorg/simgrid/surf/RoutingEdge;DD)V", NULL 
+    }
+  };
+  
+  static jclass baseclass = 0 ;
+  
+  if (swig_set_self(jenv, jself, swig_mem_own, weak_global)) {
+    if (!baseclass) {
+      baseclass = jenv->FindClass("org/simgrid/surf/Plugin");
+      if (!baseclass) return;
+      baseclass = (jclass) jenv->NewGlobalRef(baseclass);
+    }
+    bool derived = (jenv->IsSameObject(baseclass, jcls) ? false : true);
+    for (int i = 0; i < 9; ++i) {
+      if (!methods[i].base_methid) {
+        methods[i].base_methid = jenv->GetMethodID(baseclass, methods[i].mname, methods[i].mdesc);
+        if (!methods[i].base_methid) return;
+      }
+      swig_override[i] = false;
+      if (derived) {
+        jmethodID methid = jenv->GetMethodID(jcls, methods[i].mname, methods[i].mdesc);
+        swig_override[i] = (methid != methods[i].base_methid);
+        jenv->ExceptionClear();
+      }
+    }
+  }
+}
+
+
+SwigDirector_CpuModel::SwigDirector_CpuModel(JNIEnv *jenv, char const *name) : CpuModel(name), Swig::Director(jenv) {
+}
+
+double SwigDirector_CpuModel::shareResources(double now) {
+  double c_result = SwigValueInit< double >() ;
+  jdouble jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jnow  ;
+  
+  if (!swig_override[0]) {
+    return Model::shareResources(now);
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jnow = (jdouble) now;
+    jresult = (jdouble) jenv->CallStaticDoubleMethod(Swig::jclass_SurfJNI, Swig::director_methids[9], swigjobj, jnow);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (double)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+double SwigDirector_CpuModel::shareResourcesLazy(double now) {
+  double c_result = SwigValueInit< double >() ;
+  jdouble jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jnow  ;
+  
+  if (!swig_override[1]) {
+    return Model::shareResourcesLazy(now);
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jnow = (jdouble) now;
+    jresult = (jdouble) jenv->CallStaticDoubleMethod(Swig::jclass_SurfJNI, Swig::director_methids[10], swigjobj, jnow);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (double)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+double SwigDirector_CpuModel::shareResourcesFull(double now) {
+  double c_result = SwigValueInit< double >() ;
+  jdouble jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jnow  ;
+  
+  if (!swig_override[2]) {
+    return Model::shareResourcesFull(now);
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jnow = (jdouble) now;
+    jresult = (jdouble) jenv->CallStaticDoubleMethod(Swig::jclass_SurfJNI, Swig::director_methids[11], swigjobj, jnow);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (double)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+void SwigDirector_CpuModel::updateActionsState(double now, double delta) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jnow  ;
+  jdouble jdelta  ;
+  
+  if (!swig_override[3]) {
+    Model::updateActionsState(now,delta);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jnow = (jdouble) now;
+    jdelta = (jdouble) delta;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[12], swigjobj, jnow, jdelta);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_CpuModel::updateActionsStateLazy(double now, double delta) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jnow  ;
+  jdouble jdelta  ;
+  
+  if (!swig_override[4]) {
+    Model::updateActionsStateLazy(now,delta);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jnow = (jdouble) now;
+    jdelta = (jdouble) delta;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[13], swigjobj, jnow, jdelta);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_CpuModel::updateActionsStateFull(double now, double delta) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jnow  ;
+  jdouble jdelta  ;
+  
+  if (!swig_override[5]) {
+    Model::updateActionsStateFull(now,delta);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jnow = (jdouble) now;
+    jdelta = (jdouble) delta;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[14], swigjobj, jnow, jdelta);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+ActionList *SwigDirector_CpuModel::getRunningActionSet() {
+  ActionList *c_result = 0 ;
+  jlong jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  
+  if (!swig_override[6]) {
+    return Model::getRunningActionSet();
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jresult = (jlong) jenv->CallStaticLongMethod(Swig::jclass_SurfJNI, Swig::director_methids[15], swigjobj);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = *(ActionList **)&jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+SwigDirector_CpuModel::~SwigDirector_CpuModel() {
+  swig_disconnect_director_self("swigDirectorDisconnect");
+}
+
+
+Cpu *SwigDirector_CpuModel::createResource(char const *name, DoubleDynar power_peak, int pstate, double power_scale, tmgr_trace *power_trace, int core, e_surf_resource_state_t state_initial, tmgr_trace *state_trace, s_xbt_dict *cpu_properties) {
+  Cpu *c_result = 0 ;
+  jlong jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jstring jname = 0 ;
+  jdoubleArray jpower_peak  ;
+  jint jpstate  ;
+  jdouble jpower_scale  ;
+  jlong jpower_trace = 0 ;
+  jint jcore  ;
+  jint jstate_initial  ;
+  jlong jstate_trace = 0 ;
+  jlong jcpu_properties = 0 ;
+  
+  if (!swig_override[7]) {
+    SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method CpuModel::createResource.");
+    return c_result;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jname = 0;
+    if (name) {
+      jname = jenv->NewStringUTF((const char *)name);
+      if (!jname) return c_result;
+    }
+    
+    long l = xbt_dynar_length(power_peak);
+    jpower_peak = jenv->NewDoubleArray(l);
+    double *lout = (double *)xbt_dynar_to_array(power_peak);
+    jenv->SetDoubleArrayRegion(jpower_peak, 0, l, (const jdouble*)lout);
+    free(lout);
+    
+    jpstate = (jint) pstate;
+    jpower_scale = (jdouble) power_scale;
+    *((tmgr_trace **)&jpower_trace) = (tmgr_trace *) power_trace; 
+    jcore = (jint) core;
+    jstate_initial = (jint) state_initial;
+    *((tmgr_trace **)&jstate_trace) = (tmgr_trace *) state_trace; 
+    *((s_xbt_dict **)&jcpu_properties) = (s_xbt_dict *) cpu_properties; 
+    jresult = (jlong) jenv->CallStaticLongMethod(Swig::jclass_SurfJNI, Swig::director_methids[16], swigjobj, jname, jpower_peak, jpstate, jpower_scale, jpower_trace, jcore, jstate_initial, jstate_trace, jcpu_properties);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = *(Cpu **)&jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+void SwigDirector_CpuModel::addTraces() {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  
+  if (!swig_override[8]) {
+    SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method CpuModel::addTraces.");
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[17], swigjobj);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_CpuModel::swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global) {
+  static struct {
+    const char *mname;
+    const char *mdesc;
+    jmethodID base_methid;
+  } methods[] = {
+    {
+      "shareResources", "(D)D", NULL 
+    },
+    {
+      "shareResourcesLazy", "(D)D", NULL 
+    },
+    {
+      "shareResourcesFull", "(D)D", NULL 
+    },
+    {
+      "updateActionsState", "(DD)V", NULL 
+    },
+    {
+      "updateActionsStateLazy", "(DD)V", NULL 
+    },
+    {
+      "updateActionsStateFull", "(DD)V", NULL 
+    },
+    {
+      "getRunningActionSet", "()Lorg/simgrid/surf/ActionList;", NULL 
+    },
+    {
+      "createResource", "(Ljava/lang/String;[DIDLorg/simgrid/surf/TmgrTrace;ILorg/simgrid/surf/ResourceState;Lorg/simgrid/surf/TmgrTrace;Lorg/simgrid/surf/XbtDict;)Lorg/simgrid/surf/Cpu;", NULL 
+    },
+    {
+      "addTraces", "()V", NULL 
+    }
+  };
+  
+  static jclass baseclass = 0 ;
+  
+  if (swig_set_self(jenv, jself, swig_mem_own, weak_global)) {
+    if (!baseclass) {
+      baseclass = jenv->FindClass("org/simgrid/surf/CpuModel");
+      if (!baseclass) return;
+      baseclass = (jclass) jenv->NewGlobalRef(baseclass);
+    }
+    bool derived = (jenv->IsSameObject(baseclass, jcls) ? false : true);
+    for (int i = 0; i < 9; ++i) {
+      if (!methods[i].base_methid) {
+        methods[i].base_methid = jenv->GetMethodID(baseclass, methods[i].mname, methods[i].mdesc);
+        if (!methods[i].base_methid) return;
+      }
+      swig_override[i] = false;
+      if (derived) {
+        jmethodID methid = jenv->GetMethodID(jcls, methods[i].mname, methods[i].mdesc);
+        swig_override[i] = (methid != methods[i].base_methid);
+        jenv->ExceptionClear();
+      }
+    }
+  }
+}
+
+
+SwigDirector_Cpu::SwigDirector_Cpu(JNIEnv *jenv, Model *model, char const *name, s_xbt_dict *props, lmm_constraint *constraint, int core, double powerPeak, double powerScale) : Cpu(model, name, props, constraint, core, powerPeak, powerScale), Swig::Director(jenv) {
+}
+
+SwigDirector_Cpu::SwigDirector_Cpu(JNIEnv *jenv, Model *model, char const *name, s_xbt_dict *props, int core, double powerPeak, double powerScale) : Cpu(model, name, props, core, powerPeak, powerScale), Swig::Director(jenv) {
+}
+
+bool SwigDirector_Cpu::isUsed() {
+  bool c_result = SwigValueInit< bool >() ;
+  jboolean jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  
+  if (!swig_override[0]) {
+    SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method Cpu::isUsed.");
+    return c_result;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jresult = (jboolean) jenv->CallStaticBooleanMethod(Swig::jclass_SurfJNI, Swig::director_methids[18], swigjobj);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = jresult ? true : false; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+e_surf_resource_state_t SwigDirector_Cpu::getState() {
+  e_surf_resource_state_t c_result = SwigValueInit< e_surf_resource_state_t >() ;
+  jint jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  
+  if (!swig_override[1]) {
+    return Resource::getState();
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jresult = (jint) jenv->CallStaticIntMethod(Swig::jclass_SurfJNI, Swig::director_methids[19], swigjobj);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (e_surf_resource_state_t)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+void SwigDirector_Cpu::updateState(tmgr_trace_event *event_type, double value, double date) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jlong jevent_type = 0 ;
+  jdouble jvalue  ;
+  jdouble jdate  ;
+  
+  if (!swig_override[2]) {
+    SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method Cpu::updateState.");
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    *((tmgr_trace_event **)&jevent_type) = (tmgr_trace_event *) event_type; 
+    jvalue = (jdouble) value;
+    jdate = (jdouble) date;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[20], swigjobj, jevent_type, jvalue, jdate);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+SwigDirector_Cpu::~SwigDirector_Cpu() {
+  swig_disconnect_director_self("swigDirectorDisconnect");
+}
+
+
+double SwigDirector_Cpu::getCurrentPowerPeak() {
+  double c_result = SwigValueInit< double >() ;
+  jdouble jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  
+  if (!swig_override[3]) {
+    return Cpu::getCurrentPowerPeak();
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jresult = (jdouble) jenv->CallStaticDoubleMethod(Swig::jclass_SurfJNI, Swig::director_methids[21], swigjobj);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (double)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+CpuAction *SwigDirector_Cpu::execute(double size) {
+  CpuAction *c_result = 0 ;
+  jlong jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jsize  ;
+  
+  if (!swig_override[4]) {
+    SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method Cpu::execute.");
+    return c_result;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jsize = (jdouble) size;
+    jresult = (jlong) jenv->CallStaticLongMethod(Swig::jclass_SurfJNI, Swig::director_methids[22], swigjobj, jsize);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = *(CpuAction **)&jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+CpuAction *SwigDirector_Cpu::sleep(double duration) {
+  CpuAction *c_result = 0 ;
+  jlong jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jduration  ;
+  
+  if (!swig_override[5]) {
+    SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method Cpu::sleep.");
+    return c_result;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jduration = (jdouble) duration;
+    jresult = (jlong) jenv->CallStaticLongMethod(Swig::jclass_SurfJNI, Swig::director_methids[23], swigjobj, jduration);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = *(CpuAction **)&jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+int SwigDirector_Cpu::getCore() {
+  int c_result = SwigValueInit< int >() ;
+  jint jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  
+  if (!swig_override[6]) {
+    return Cpu::getCore();
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jresult = (jint) jenv->CallStaticIntMethod(Swig::jclass_SurfJNI, Swig::director_methids[24], swigjobj);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (int)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+double SwigDirector_Cpu::getSpeed(double load) {
+  double c_result = SwigValueInit< double >() ;
+  jdouble jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jload  ;
+  
+  if (!swig_override[7]) {
+    return Cpu::getSpeed(load);
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jload = (jdouble) load;
+    jresult = (jdouble) jenv->CallStaticDoubleMethod(Swig::jclass_SurfJNI, Swig::director_methids[25], swigjobj, jload);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (double)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+double SwigDirector_Cpu::getAvailableSpeed() {
+  double c_result = SwigValueInit< double >() ;
+  jdouble jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  
+  if (!swig_override[8]) {
+    return Cpu::getAvailableSpeed();
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jresult = (jdouble) jenv->CallStaticDoubleMethod(Swig::jclass_SurfJNI, Swig::director_methids[26], swigjobj);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (double)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+double SwigDirector_Cpu::getPowerPeakAt(int pstate_index) {
+  double c_result = SwigValueInit< double >() ;
+  jdouble jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jint jpstate_index  ;
+  
+  if (!swig_override[9]) {
+    SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method Cpu::getPowerPeakAt.");
+    return c_result;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jpstate_index = (jint) pstate_index;
+    jresult = (jdouble) jenv->CallStaticDoubleMethod(Swig::jclass_SurfJNI, Swig::director_methids[27], swigjobj, jpstate_index);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (double)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+int SwigDirector_Cpu::getNbPstates() {
+  int c_result = SwigValueInit< int >() ;
+  jint jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  
+  if (!swig_override[10]) {
+    SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method Cpu::getNbPstates.");
+    return c_result;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jresult = (jint) jenv->CallStaticIntMethod(Swig::jclass_SurfJNI, Swig::director_methids[28], swigjobj);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (int)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+void SwigDirector_Cpu::setPowerPeakAt(int pstate_index) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jint jpstate_index  ;
+  
+  if (!swig_override[11]) {
+    SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method Cpu::setPowerPeakAt.");
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jpstate_index = (jint) pstate_index;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[29], swigjobj, jpstate_index);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_Cpu::swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global) {
+  static struct {
+    const char *mname;
+    const char *mdesc;
+    jmethodID base_methid;
+  } methods[] = {
+    {
+      "isUsed", "()Z", NULL 
+    },
+    {
+      "getState", "()Lorg/simgrid/surf/ResourceState;", NULL 
+    },
+    {
+      "updateState", "(Lorg/simgrid/surf/TmgrTraceEvent;DD)V", NULL 
+    },
+    {
+      "getCurrentPowerPeak", "()D", NULL 
+    },
+    {
+      "execute", "(D)Lorg/simgrid/surf/CpuAction;", NULL 
+    },
+    {
+      "sleep", "(D)Lorg/simgrid/surf/CpuAction;", NULL 
+    },
+    {
+      "getCore", "()I", NULL 
+    },
+    {
+      "getSpeed", "(D)D", NULL 
+    },
+    {
+      "getAvailableSpeed", "()D", NULL 
+    },
+    {
+      "getPowerPeakAt", "(I)D", NULL 
+    },
+    {
+      "getNbPstates", "()I", NULL 
+    },
+    {
+      "setPowerPeakAt", "(I)V", NULL 
+    }
+  };
+  
+  static jclass baseclass = 0 ;
+  
+  if (swig_set_self(jenv, jself, swig_mem_own, weak_global)) {
+    if (!baseclass) {
+      baseclass = jenv->FindClass("org/simgrid/surf/Cpu");
+      if (!baseclass) return;
+      baseclass = (jclass) jenv->NewGlobalRef(baseclass);
+    }
+    bool derived = (jenv->IsSameObject(baseclass, jcls) ? false : true);
+    for (int i = 0; i < 12; ++i) {
+      if (!methods[i].base_methid) {
+        methods[i].base_methid = jenv->GetMethodID(baseclass, methods[i].mname, methods[i].mdesc);
+        if (!methods[i].base_methid) return;
+      }
+      swig_override[i] = false;
+      if (derived) {
+        jmethodID methid = jenv->GetMethodID(jcls, methods[i].mname, methods[i].mdesc);
+        swig_override[i] = (methid != methods[i].base_methid);
+        jenv->ExceptionClear();
+      }
+    }
+  }
+}
+
+
+SwigDirector_CpuAction::SwigDirector_CpuAction(JNIEnv *jenv, Model *model, double cost, bool failed) : CpuAction(model, cost, failed), Swig::Director(jenv) {
+}
+
+SwigDirector_CpuAction::~SwigDirector_CpuAction() {
+  swig_disconnect_director_self("swigDirectorDisconnect");
+}
+
+
+double SwigDirector_CpuAction::getRemains() {
+  double c_result = SwigValueInit< double >() ;
+  jdouble jresult = 0 ;
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  
+  if (!swig_override[0]) {
+    return Action::getRemains();
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jresult = (jdouble) jenv->CallStaticDoubleMethod(Swig::jclass_SurfJNI, Swig::director_methids[30], swigjobj);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return c_result;
+    c_result = (double)jresult; 
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+  return c_result;
+}
+
+void SwigDirector_CpuAction::setPriority(double priority) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jdouble jpriority  ;
+  
+  if (!swig_override[1]) {
+    Action::setPriority(priority);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jpriority = (jdouble) priority;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[31], swigjobj, jpriority);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_CpuAction::setState(e_surf_action_state_t state) {
+  JNIEnvWrapper swigjnienv(this) ;
+  JNIEnv * jenv = swigjnienv.getJNIEnv() ;
+  jobject swigjobj = (jobject) NULL ;
+  jint jstate  ;
+  
+  if (!swig_override[2]) {
+    Action::setState(state);
+    return;
+  }
+  swigjobj = swig_get_self(jenv);
+  if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
+    jstate = (jint) state;
+    jenv->CallStaticVoidMethod(Swig::jclass_SurfJNI, Swig::director_methids[32], swigjobj, jstate);
+    if (jenv->ExceptionCheck() == JNI_TRUE) return ;
+  } else {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object");
+  }
+  if (swigjobj) jenv->DeleteLocalRef(swigjobj);
+}
+
+void SwigDirector_CpuAction::swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global) {
+  static struct {
+    const char *mname;
+    const char *mdesc;
+    jmethodID base_methid;
+  } methods[] = {
+    {
+      "getRemains", "()D", NULL 
+    },
+    {
+      "setPriority", "(D)V", NULL 
+    },
+    {
+      "setState", "(Lorg/simgrid/surf/ActionState;)V", NULL 
+    }
+  };
+  
+  static jclass baseclass = 0 ;
+  
+  if (swig_set_self(jenv, jself, swig_mem_own, weak_global)) {
+    if (!baseclass) {
+      baseclass = jenv->FindClass("org/simgrid/surf/CpuAction");
+      if (!baseclass) return;
+      baseclass = (jclass) jenv->NewGlobalRef(baseclass);
+    }
+    bool derived = (jenv->IsSameObject(baseclass, jcls) ? false : true);
+    for (int i = 0; i < 3; ++i) {
+      if (!methods[i].base_methid) {
+        methods[i].base_methid = jenv->GetMethodID(baseclass, methods[i].mname, methods[i].mdesc);
+        if (!methods[i].base_methid) return;
+      }
+      swig_override[i] = false;
+      if (derived) {
+        jmethodID methid = jenv->GetMethodID(jcls, methods[i].mname, methods[i].mdesc);
+        swig_override[i] = (methid != methods[i].base_methid);
+        jenv->ExceptionClear();
+      }
+    }
+  }
+}
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jobject JNICALL Java_org_simgrid_surf_SurfJNI_getAction(JNIEnv *env, jclass cls, jlong jarg1) {
+  Action * action = (Action *)jarg1;
+  jobject res;
+  CpuAction *cpu_action = dynamic_cast<CpuAction*>(action);
+  if (cpu_action) {
+    SwigDirector_CpuAction *dir_cpu_action = dynamic_cast<SwigDirector_CpuAction*>(cpu_action);
+    if (dir_cpu_action) {
+      res = dir_cpu_action->swig_get_self(env);\
+    } else {
+      jclass clss = env->FindClass("org/simgrid/surf/CpuAction");\
+      jmethodID constru = env->GetMethodID(clss, "<init>", "()V");\
+      res = env->NewObject(clss, constru);\
+      res = env->NewGlobalRef(res);\
+    }
+  } else {
+    jclass clss = env->FindClass("org/simgrid/surf/Action");\
+    jmethodID constru = env->GetMethodID(clss, "<init>", "()V");\
+    res = env->NewObject(clss, constru);\
+    res = env->NewGlobalRef(res);\
+  }
+  return res;
+}
+
+#define GETDIRECTOR(NAME) \
+JNIEXPORT jobject JNICALL Java_org_simgrid_surf_SurfJNI_get## NAME ## Director(JNIEnv *env, jclass cls, jlong jarg1)\
+{\
+  NAME * arg1 = (NAME*)jarg1;\
+  SwigDirector_ ##NAME *director = dynamic_cast<SwigDirector_ ##NAME *>(arg1);\
+  jobject res;\
+  if (director) {\
+    res = director->swig_get_self(env);\
+  } else {\
+    jclass clss = env->FindClass("org/simgrid/surf/NAME");\
+    jmethodID constru = env->GetMethodID(clss, "<init>", "()V");\
+    res = env->NewObject(clss, constru);\
+    res = env->NewGlobalRef(res);\
+  }\
+  return res;\
+}
+
+GETDIRECTOR(CpuModel)
+GETDIRECTOR(Cpu)
+GETDIRECTOR(CpuAction)
+
+#ifdef __cplusplus
+}
+#endif
+
+
+SWIGEXPORT jlongArray JNICALL Java_org_simgrid_surf_SurfJNI_ActionList_1getArray(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jlongArray jresult = 0 ;
+  ActionList *arg1 = (ActionList *) 0 ;
+  ActionArrayPtr result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(ActionList **)&jarg1; 
+  result = (ActionArrayPtr)ActionList_getArray(arg1);
+  {
+    long l = 0;
+    for(ActionList::iterator it(result->begin()), itend(result->end()); it != itend ; ++it) {
+      l++;
+    }
+    jresult = jenv->NewLongArray(l);
+    jlong *elts = jenv->GetLongArrayElements(jresult, NULL);
+    l = 0;
+    for(ActionList::iterator it(result->begin()), itend(result->end()); it != itend ; ++it) {
+      elts[l++] = (jlong)static_cast<ActionPtr>(&*it);
+    }
+    jenv->ReleaseLongArrayElements(jresult, elts, 0);
+  }
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1ActionList(JNIEnv *jenv, jclass jcls) {
+  jlong jresult = 0 ;
+  ActionList *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (ActionList *)new ActionList();
+  *(ActionList **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1ActionList(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  ActionList *arg1 = (ActionList *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(ActionList **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_getClock(JNIEnv *jenv, jclass jcls) {
+  jdouble jresult = 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (double)getClock();
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_clean(JNIEnv *jenv, jclass jcls) {
+  (void)jenv;
+  (void)jcls;
+  clean();
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_getCpuModel(JNIEnv *jenv, jclass jcls) {
+  jlong jresult = 0 ;
+  CpuModel *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (CpuModel *)getCpuModel();
+  *(CpuModel **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_setCpuModel(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  CpuModel *arg1 = (CpuModel *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CpuModel **)&jarg1; 
+  setCpuModel(arg1);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_setCpu(JNIEnv *jenv, jclass jcls, jstring jarg1, jlong jarg2, jobject jarg2_) {
+  char *arg1 = (char *) 0 ;
+  Cpu *arg2 = (Cpu *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg2_;
+  arg1 = 0;
+  if (jarg1) {
+    arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
+    if (!arg1) return ;
+  }
+  arg2 = *(Cpu **)&jarg2; 
+  setCpu(arg1,arg2);
+  {
+    
+  }
+}
+
+
+SWIGEXPORT jlongArray JNICALL Java_org_simgrid_surf_SurfJNI_getRoute(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) {
+  jlongArray jresult = 0 ;
+  char *arg1 = (char *) 0 ;
+  char *arg2 = (char *) 0 ;
+  NetworkLinkDynar result;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = 0;
+  if (jarg1) {
+    arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
+    if (!arg1) return 0;
+  }
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return 0;
+  }
+  result = getRoute(arg1,arg2);
+  {
+    long l = xbt_dynar_length(result);
+    jresult = jenv->NewLongArray(l);
+    unsigned i;
+    NetworkLink *link;
+    jlong *elts = jenv->GetLongArrayElements(jresult, NULL);
+    xbt_dynar_foreach(result, i, link) {
+      elts[i] = (jlong)link;
+    }
+    jenv->ReleaseLongArrayElements(jresult, elts, 0);
+    xbt_dynar_free(&result);
+  }
+  if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1);
+  if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1Plugin(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(Plugin **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1activateCpuCreatedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Plugin **)&jarg1; 
+  (arg1)->activateCpuCreatedCallback();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1cpuCreatedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  Cpu *arg2 = (Cpu *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(Cpu **)&jarg2; 
+  (arg1)->cpuCreatedCallback(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1cpuCreatedCallbackSwigExplicitPlugin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  Cpu *arg2 = (Cpu *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(Cpu **)&jarg2; 
+  (arg1)->Plugin::cpuCreatedCallback(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1activateCpuDestructedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Plugin **)&jarg1; 
+  (arg1)->activateCpuDestructedCallback();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1cpuDestructedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  Cpu *arg2 = (Cpu *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(Cpu **)&jarg2; 
+  (arg1)->cpuDestructedCallback(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1cpuDestructedCallbackSwigExplicitPlugin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  Cpu *arg2 = (Cpu *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(Cpu **)&jarg2; 
+  (arg1)->Plugin::cpuDestructedCallback(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1activateCpuStateChangedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Plugin **)&jarg1; 
+  (arg1)->activateCpuStateChangedCallback();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1cpuStateChangedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jint jarg3, jint jarg4) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  Cpu *arg2 = (Cpu *) 0 ;
+  e_surf_resource_state_t arg3 ;
+  e_surf_resource_state_t arg4 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(Cpu **)&jarg2; 
+  arg3 = (e_surf_resource_state_t)jarg3; 
+  arg4 = (e_surf_resource_state_t)jarg4; 
+  (arg1)->cpuStateChangedCallback(arg2,arg3,arg4);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1cpuStateChangedCallbackSwigExplicitPlugin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jint jarg3, jint jarg4) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  Cpu *arg2 = (Cpu *) 0 ;
+  e_surf_resource_state_t arg3 ;
+  e_surf_resource_state_t arg4 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(Cpu **)&jarg2; 
+  arg3 = (e_surf_resource_state_t)jarg3; 
+  arg4 = (e_surf_resource_state_t)jarg4; 
+  (arg1)->Plugin::cpuStateChangedCallback(arg2,arg3,arg4);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1activateCpuActionStateChangedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Plugin **)&jarg1; 
+  (arg1)->activateCpuActionStateChangedCallback();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1cpuActionStateChangedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jint jarg3, jint jarg4) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  CpuAction *arg2 = (CpuAction *) 0 ;
+  e_surf_action_state_t arg3 ;
+  e_surf_action_state_t arg4 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(CpuAction **)&jarg2; 
+  arg3 = (e_surf_action_state_t)jarg3; 
+  arg4 = (e_surf_action_state_t)jarg4; 
+  (arg1)->cpuActionStateChangedCallback(arg2,arg3,arg4);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1cpuActionStateChangedCallbackSwigExplicitPlugin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jint jarg3, jint jarg4) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  CpuAction *arg2 = (CpuAction *) 0 ;
+  e_surf_action_state_t arg3 ;
+  e_surf_action_state_t arg4 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(CpuAction **)&jarg2; 
+  arg3 = (e_surf_action_state_t)jarg3; 
+  arg4 = (e_surf_action_state_t)jarg4; 
+  (arg1)->Plugin::cpuActionStateChangedCallback(arg2,arg3,arg4);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1activateNetworkLinkCreatedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Plugin **)&jarg1; 
+  (arg1)->activateNetworkLinkCreatedCallback();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkLinkCreatedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkLink *arg2 = (NetworkLink *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkLink **)&jarg2; 
+  (arg1)->networkLinkCreatedCallback(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkLinkCreatedCallbackSwigExplicitPlugin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkLink *arg2 = (NetworkLink *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkLink **)&jarg2; 
+  (arg1)->Plugin::networkLinkCreatedCallback(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1activateNetworkLinkDestructedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Plugin **)&jarg1; 
+  (arg1)->activateNetworkLinkDestructedCallback();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkLinkDestructedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkLink *arg2 = (NetworkLink *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkLink **)&jarg2; 
+  (arg1)->networkLinkDestructedCallback(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkLinkDestructedCallbackSwigExplicitPlugin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkLink *arg2 = (NetworkLink *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkLink **)&jarg2; 
+  (arg1)->Plugin::networkLinkDestructedCallback(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1activateNetworkLinkStateChangedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Plugin **)&jarg1; 
+  (arg1)->activateNetworkLinkStateChangedCallback();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkLinkStateChangedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jint jarg3, jint jarg4) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkLink *arg2 = (NetworkLink *) 0 ;
+  e_surf_resource_state_t arg3 ;
+  e_surf_resource_state_t arg4 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkLink **)&jarg2; 
+  arg3 = (e_surf_resource_state_t)jarg3; 
+  arg4 = (e_surf_resource_state_t)jarg4; 
+  (arg1)->networkLinkStateChangedCallback(arg2,arg3,arg4);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkLinkStateChangedCallbackSwigExplicitPlugin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jint jarg3, jint jarg4) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkLink *arg2 = (NetworkLink *) 0 ;
+  e_surf_resource_state_t arg3 ;
+  e_surf_resource_state_t arg4 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkLink **)&jarg2; 
+  arg3 = (e_surf_resource_state_t)jarg3; 
+  arg4 = (e_surf_resource_state_t)jarg4; 
+  (arg1)->Plugin::networkLinkStateChangedCallback(arg2,arg3,arg4);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1activateNetworkActionStateChangedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Plugin **)&jarg1; 
+  (arg1)->activateNetworkActionStateChangedCallback();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkActionStateChangedCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jint jarg3, jint jarg4) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkAction *arg2 = (NetworkAction *) 0 ;
+  e_surf_action_state_t arg3 ;
+  e_surf_action_state_t arg4 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkAction **)&jarg2; 
+  arg3 = (e_surf_action_state_t)jarg3; 
+  arg4 = (e_surf_action_state_t)jarg4; 
+  (arg1)->networkActionStateChangedCallback(arg2,arg3,arg4);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkActionStateChangedCallbackSwigExplicitPlugin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jint jarg3, jint jarg4) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkAction *arg2 = (NetworkAction *) 0 ;
+  e_surf_action_state_t arg3 ;
+  e_surf_action_state_t arg4 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkAction **)&jarg2; 
+  arg3 = (e_surf_action_state_t)jarg3; 
+  arg4 = (e_surf_action_state_t)jarg4; 
+  (arg1)->Plugin::networkActionStateChangedCallback(arg2,arg3,arg4);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1activateNetworkCommunicateCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Plugin **)&jarg1; 
+  (arg1)->activateNetworkCommunicateCallback();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkCommunicateCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jlong jarg3, jobject jarg3_, jlong jarg4, jobject jarg4_, jdouble jarg5, jdouble jarg6) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkAction *arg2 = (NetworkAction *) 0 ;
+  RoutingEdge *arg3 = (RoutingEdge *) 0 ;
+  RoutingEdge *arg4 = (RoutingEdge *) 0 ;
+  double arg5 ;
+  double arg6 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  (void)jarg3_;
+  (void)jarg4_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkAction **)&jarg2; 
+  arg3 = *(RoutingEdge **)&jarg3; 
+  arg4 = *(RoutingEdge **)&jarg4; 
+  arg5 = (double)jarg5; 
+  arg6 = (double)jarg6; 
+  (arg1)->networkCommunicateCallback(arg2,arg3,arg4,arg5,arg6);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1networkCommunicateCallbackSwigExplicitPlugin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jlong jarg3, jobject jarg3_, jlong jarg4, jobject jarg4_, jdouble jarg5, jdouble jarg6) {
+  Plugin *arg1 = (Plugin *) 0 ;
+  NetworkAction *arg2 = (NetworkAction *) 0 ;
+  RoutingEdge *arg3 = (RoutingEdge *) 0 ;
+  RoutingEdge *arg4 = (RoutingEdge *) 0 ;
+  double arg5 ;
+  double arg6 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  (void)jarg3_;
+  (void)jarg4_;
+  arg1 = *(Plugin **)&jarg1; 
+  arg2 = *(NetworkAction **)&jarg2; 
+  arg3 = *(RoutingEdge **)&jarg3; 
+  arg4 = *(RoutingEdge **)&jarg4; 
+  arg5 = (double)jarg5; 
+  arg6 = (double)jarg6; 
+  (arg1)->Plugin::networkCommunicateCallback(arg2,arg3,arg4,arg5,arg6);
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Plugin(JNIEnv *jenv, jclass jcls) {
+  jlong jresult = 0 ;
+  Plugin *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (Plugin *)new SwigDirector_Plugin(jenv);
+  *(Plugin **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1director_1connect(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, jboolean jweak_global) {
+  Plugin *obj = *((Plugin **)&objarg);
+  (void)jcls;
+  SwigDirector_Plugin *director = dynamic_cast<SwigDirector_Plugin *>(obj);
+  if (director) {
+    director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), (jswig_mem_own == JNI_TRUE), (jweak_global == JNI_TRUE));
+  }
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Plugin_1change_1ownership(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jtake_or_release) {
+  Plugin *obj = *((Plugin **)&objarg);
+  SwigDirector_Plugin *director = dynamic_cast<SwigDirector_Plugin *>(obj);
+  (void)jcls;
+  if (director) {
+    director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);
+  }
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1TmgrTrace(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  tmgr_trace *arg1 = (tmgr_trace *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(tmgr_trace **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_TmgrTraceEvent_1getIdx(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jlong jresult = 0 ;
+  tmgr_trace_event *arg1 = (tmgr_trace_event *) 0 ;
+  unsigned int result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(tmgr_trace_event **)&jarg1; 
+  result = (unsigned int)tmgr_trace_event_getIdx(arg1);
+  jresult = (jlong)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1TmgrTraceEvent(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  tmgr_trace_event *arg1 = (tmgr_trace_event *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(tmgr_trace_event **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Model(JNIEnv *jenv, jclass jcls, jstring jarg1) {
+  jlong jresult = 0 ;
+  char *arg1 = (char *) 0 ;
+  Model *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = 0;
+  if (jarg1) {
+    arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
+    if (!arg1) return 0;
+  }
+  result = (Model *)new Model((char const *)arg1);
+  *(Model **)&jresult = result; 
+  {
+    
+  }
+  return jresult;
+}
+
+
+SWIGEXPORT jstring JNICALL Java_org_simgrid_surf_SurfJNI_Model_1getName(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jstring jresult = 0 ;
+  Model *arg1 = (Model *) 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  result = (char *)(arg1)->getName();
+  if (result) jresult = jenv->NewStringUTF((const char *)result);
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Model_1shareResources(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  jdouble jresult = 0 ;
+  Model *arg1 = (Model *) 0 ;
+  double arg2 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = (double)jarg2; 
+  result = (double)(arg1)->shareResources(arg2);
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Model_1shareResourcesLazy(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  jdouble jresult = 0 ;
+  Model *arg1 = (Model *) 0 ;
+  double arg2 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = (double)jarg2; 
+  result = (double)(arg1)->shareResourcesLazy(arg2);
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Model_1shareResourcesFull(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  jdouble jresult = 0 ;
+  Model *arg1 = (Model *) 0 ;
+  double arg2 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = (double)jarg2; 
+  result = (double)(arg1)->shareResourcesFull(arg2);
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Model_1updateActionsState(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2, jdouble jarg3) {
+  Model *arg1 = (Model *) 0 ;
+  double arg2 ;
+  double arg3 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = (double)jarg2; 
+  arg3 = (double)jarg3; 
+  (arg1)->updateActionsState(arg2,arg3);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Model_1updateActionsStateLazy(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2, jdouble jarg3) {
+  Model *arg1 = (Model *) 0 ;
+  double arg2 ;
+  double arg3 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = (double)jarg2; 
+  arg3 = (double)jarg3; 
+  (arg1)->updateActionsStateLazy(arg2,arg3);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Model_1updateActionsStateFull(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2, jdouble jarg3) {
+  Model *arg1 = (Model *) 0 ;
+  double arg2 ;
+  double arg3 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = (double)jarg2; 
+  arg3 = (double)jarg3; 
+  (arg1)->updateActionsStateFull(arg2,arg3);
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Model_1getRunningActionSet(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jlong jresult = 0 ;
+  Model *arg1 = (Model *) 0 ;
+  ActionList *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  result = (ActionList *)(arg1)->getRunningActionSet();
+  *(ActionList **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1Model(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  Model *arg1 = (Model *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(Model **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1CpuModel(JNIEnv *jenv, jclass jcls, jstring jarg1) {
+  jlong jresult = 0 ;
+  char *arg1 = (char *) 0 ;
+  CpuModel *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = 0;
+  if (jarg1) {
+    arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
+    if (!arg1) return 0;
+  }
+  result = (CpuModel *)new SwigDirector_CpuModel(jenv,(char const *)arg1);
+  *(CpuModel **)&jresult = result; 
+  {
+    
+  }
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1CpuModel(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  CpuModel *arg1 = (CpuModel *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(CpuModel **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1createResource(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jdoubleArray jarg3, jint jarg4, jdouble jarg5, jlong jarg6, jobject jarg6_, jint jarg7, jint jarg8, jlong jarg9, jobject jarg9_, jlong jarg10, jobject jarg10_) {
+  jlong jresult = 0 ;
+  CpuModel *arg1 = (CpuModel *) 0 ;
+  char *arg2 = (char *) 0 ;
+  DoubleDynar arg3 ;
+  int arg4 ;
+  double arg5 ;
+  tmgr_trace *arg6 = (tmgr_trace *) 0 ;
+  int arg7 ;
+  e_surf_resource_state_t arg8 ;
+  tmgr_trace *arg9 = (tmgr_trace *) 0 ;
+  s_xbt_dict *arg10 = (s_xbt_dict *) 0 ;
+  DoubleDynar *argp3 ;
+  Cpu *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg6_;
+  (void)jarg9_;
+  (void)jarg10_;
+  arg1 = *(CpuModel **)&jarg1; 
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return 0;
+  }
+  argp3 = *(DoubleDynar **)&jarg3; 
+  if (!argp3) {
+    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null DoubleDynar");
+    return 0;
+  }
+  arg3 = *argp3; 
+  arg4 = (int)jarg4; 
+  arg5 = (double)jarg5; 
+  arg6 = *(tmgr_trace **)&jarg6; 
+  arg7 = (int)jarg7; 
+  arg8 = (e_surf_resource_state_t)jarg8; 
+  arg9 = *(tmgr_trace **)&jarg9; 
+  arg10 = *(s_xbt_dict **)&jarg10; 
+  result = (Cpu *)(arg1)->createResource((char const *)arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+  *(Cpu **)&jresult = result; 
+  {
+    
+  }
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1addTraces(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  CpuModel *arg1 = (CpuModel *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CpuModel **)&jarg1; 
+  (arg1)->addTraces();
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1director_1connect(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, jboolean jweak_global) {
+  CpuModel *obj = *((CpuModel **)&objarg);
+  (void)jcls;
+  SwigDirector_CpuModel *director = dynamic_cast<SwigDirector_CpuModel *>(obj);
+  if (director) {
+    director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), (jswig_mem_own == JNI_TRUE), (jweak_global == JNI_TRUE));
+  }
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1change_1ownership(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jtake_or_release) {
+  CpuModel *obj = *((CpuModel **)&objarg);
+  SwigDirector_CpuModel *director = dynamic_cast<SwigDirector_CpuModel *>(obj);
+  (void)jcls;
+  if (director) {
+    director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);
+  }
+}
+
+
+SWIGEXPORT jstring JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1getName(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jstring jresult = 0 ;
+  Resource *arg1 = (Resource *) 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Resource **)&jarg1; 
+  result = (char *)(arg1)->getName();
+  if (result) jresult = jenv->NewStringUTF((const char *)result);
+  return jresult;
+}
+
+
+SWIGEXPORT jboolean JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1isUsed(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jboolean jresult = 0 ;
+  Resource *arg1 = (Resource *) 0 ;
+  bool result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Resource **)&jarg1; 
+  result = (bool)(arg1)->isUsed();
+  jresult = (jboolean)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1getModel(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jlong jresult = 0 ;
+  Resource *arg1 = (Resource *) 0 ;
+  Model *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Resource **)&jarg1; 
+  result = (Model *)(arg1)->getModel();
+  *(Model **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1getState(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jint jresult = 0 ;
+  Resource *arg1 = (Resource *) 0 ;
+  e_surf_resource_state_t result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Resource **)&jarg1; 
+  result = (e_surf_resource_state_t)(arg1)->getState();
+  jresult = (jint)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1getConstraint(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jlong jresult = 0 ;
+  Resource *arg1 = (Resource *) 0 ;
+  lmm_constraint *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Resource **)&jarg1; 
+  result = (lmm_constraint *)(arg1)->getConstraint();
+  *(lmm_constraint **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1getProperties(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jlong jresult = 0 ;
+  Resource *arg1 = (Resource *) 0 ;
+  s_xbt_dict *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Resource **)&jarg1; 
+  result = (s_xbt_dict *)(arg1)->getProperties();
+  *(s_xbt_dict **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1updateState(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jdouble jarg3, jdouble jarg4) {
+  Resource *arg1 = (Resource *) 0 ;
+  tmgr_trace_event *arg2 = (tmgr_trace_event *) 0 ;
+  double arg3 ;
+  double arg4 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg2_;
+  arg1 = *(Resource **)&jarg1; 
+  arg2 = *(tmgr_trace_event **)&jarg2; 
+  arg3 = (double)jarg3; 
+  arg4 = (double)jarg4; 
+  (arg1)->updateState(arg2,arg3,arg4);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1Resource(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  Resource *arg1 = (Resource *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(Resource **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Cpu_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jlong jarg3, jobject jarg3_, jlong jarg4, jobject jarg4_, jint jarg5, jdouble jarg6, jdouble jarg7) {
+  jlong jresult = 0 ;
+  Model *arg1 = (Model *) 0 ;
+  char *arg2 = (char *) 0 ;
+  s_xbt_dict *arg3 = (s_xbt_dict *) 0 ;
+  lmm_constraint *arg4 = (lmm_constraint *) 0 ;
+  int arg5 ;
+  double arg6 ;
+  double arg7 ;
+  Cpu *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg3_;
+  (void)jarg4_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return 0;
+  }
+  arg3 = *(s_xbt_dict **)&jarg3; 
+  arg4 = *(lmm_constraint **)&jarg4; 
+  arg5 = (int)jarg5; 
+  arg6 = (double)jarg6; 
+  arg7 = (double)jarg7; 
+  result = (Cpu *)new SwigDirector_Cpu(jenv,arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7);
+  *(Cpu **)&jresult = result; 
+  {
+    
+  }
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Cpu_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jlong jarg3, jobject jarg3_, jint jarg4, jdouble jarg5, jdouble jarg6) {
+  jlong jresult = 0 ;
+  Model *arg1 = (Model *) 0 ;
+  char *arg2 = (char *) 0 ;
+  s_xbt_dict *arg3 = (s_xbt_dict *) 0 ;
+  int arg4 ;
+  double arg5 ;
+  double arg6 ;
+  Cpu *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  (void)jarg3_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return 0;
+  }
+  arg3 = *(s_xbt_dict **)&jarg3; 
+  arg4 = (int)jarg4; 
+  arg5 = (double)jarg5; 
+  arg6 = (double)jarg6; 
+  result = (Cpu *)new SwigDirector_Cpu(jenv,arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
+  *(Cpu **)&jresult = result; 
+  {
+    
+  }
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1Cpu(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  Cpu *arg1 = (Cpu *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(Cpu **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getCurrentPowerPeak(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  result = (double)(arg1)->getCurrentPowerPeak();
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getCurrentPowerPeakSwigExplicitCpu(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  result = (double)(arg1)->Cpu::getCurrentPowerPeak();
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1execute(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  jlong jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  double arg2 ;
+  CpuAction *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  arg2 = (double)jarg2; 
+  result = (CpuAction *)(arg1)->execute(arg2);
+  *(CpuAction **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1sleep(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  jlong jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  double arg2 ;
+  CpuAction *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  arg2 = (double)jarg2; 
+  result = (CpuAction *)(arg1)->sleep(arg2);
+  *(CpuAction **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getCore(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jint jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  int result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  result = (int)(arg1)->getCore();
+  jresult = (jint)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getCoreSwigExplicitCpu(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jint jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  int result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  result = (int)(arg1)->Cpu::getCore();
+  jresult = (jint)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getSpeed(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  jdouble jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  double arg2 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  arg2 = (double)jarg2; 
+  result = (double)(arg1)->getSpeed(arg2);
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getSpeedSwigExplicitCpu(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  jdouble jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  double arg2 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  arg2 = (double)jarg2; 
+  result = (double)(arg1)->Cpu::getSpeed(arg2);
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getAvailableSpeed(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  result = (double)(arg1)->getAvailableSpeed();
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getAvailableSpeedSwigExplicitCpu(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  result = (double)(arg1)->Cpu::getAvailableSpeed();
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getPowerPeakAt(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
+  jdouble jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  int arg2 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  arg2 = (int)jarg2; 
+  result = (double)(arg1)->getPowerPeakAt(arg2);
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1getNbPstates(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jint jresult = 0 ;
+  Cpu *arg1 = (Cpu *) 0 ;
+  int result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  result = (int)(arg1)->getNbPstates();
+  jresult = (jint)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1setPowerPeakAt(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
+  Cpu *arg1 = (Cpu *) 0 ;
+  int arg2 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  arg2 = (int)jarg2; 
+  (arg1)->setPowerPeakAt(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1setState(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
+  Cpu *arg1 = (Cpu *) 0 ;
+  e_surf_resource_state_t arg2 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Cpu **)&jarg1; 
+  arg2 = (e_surf_resource_state_t)jarg2; 
+  (arg1)->setState(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1director_1connect(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, jboolean jweak_global) {
+  Cpu *obj = *((Cpu **)&objarg);
+  (void)jcls;
+  SwigDirector_Cpu *director = dynamic_cast<SwigDirector_Cpu *>(obj);
+  if (director) {
+    director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), (jswig_mem_own == JNI_TRUE), (jweak_global == JNI_TRUE));
+  }
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1change_1ownership(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jtake_or_release) {
+  Cpu *obj = *((Cpu **)&objarg);
+  SwigDirector_Cpu *director = dynamic_cast<SwigDirector_Cpu *>(obj);
+  (void)jcls;
+  if (director) {
+    director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);
+  }
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1NetworkLink(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  NetworkLink *arg1 = (NetworkLink *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(NetworkLink **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_NetworkLink_1getBandwidth(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  NetworkLink *arg1 = (NetworkLink *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(NetworkLink **)&jarg1; 
+  result = (double)(arg1)->getBandwidth();
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_NetworkLink_1updateBandwidth_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2, jdouble jarg3) {
+  NetworkLink *arg1 = (NetworkLink *) 0 ;
+  double arg2 ;
+  double arg3 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(NetworkLink **)&jarg1; 
+  arg2 = (double)jarg2; 
+  arg3 = (double)jarg3; 
+  (arg1)->updateBandwidth(arg2,arg3);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_NetworkLink_1updateBandwidth_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  NetworkLink *arg1 = (NetworkLink *) 0 ;
+  double arg2 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(NetworkLink **)&jarg1; 
+  arg2 = (double)jarg2; 
+  (arg1)->updateBandwidth(arg2);
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_NetworkLink_1getLatency(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  NetworkLink *arg1 = (NetworkLink *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(NetworkLink **)&jarg1; 
+  result = (double)(arg1)->getLatency();
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_NetworkLink_1updateLatency_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2, jdouble jarg3) {
+  NetworkLink *arg1 = (NetworkLink *) 0 ;
+  double arg2 ;
+  double arg3 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(NetworkLink **)&jarg1; 
+  arg2 = (double)jarg2; 
+  arg3 = (double)jarg3; 
+  (arg1)->updateLatency(arg2,arg3);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_NetworkLink_1updateLatency_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  NetworkLink *arg1 = (NetworkLink *) 0 ;
+  double arg2 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(NetworkLink **)&jarg1; 
+  arg2 = (double)jarg2; 
+  (arg1)->updateLatency(arg2);
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Action(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2, jboolean jarg3) {
+  jlong jresult = 0 ;
+  Model *arg1 = (Model *) 0 ;
+  double arg2 ;
+  bool arg3 ;
+  Action *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = (double)jarg2; 
+  arg3 = jarg3 ? true : false; 
+  result = (Action *)new Action(arg1,arg2,arg3);
+  *(Action **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1Action(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  Action *arg1 = (Action *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(Action **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Action_1getModel(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jlong jresult = 0 ;
+  Action *arg1 = (Action *) 0 ;
+  Model *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  result = (Model *)(arg1)->getModel();
+  *(Model **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Action_1getVariable(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jlong jresult = 0 ;
+  Action *arg1 = (Action *) 0 ;
+  lmm_variable *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  result = (lmm_variable *)(arg1)->getVariable();
+  *(lmm_variable **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_simgrid_surf_SurfJNI_Action_1getState(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jint jresult = 0 ;
+  Action *arg1 = (Action *) 0 ;
+  e_surf_action_state_t result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  result = (e_surf_action_state_t)(arg1)->getState();
+  jresult = (jint)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jboolean JNICALL Java_org_simgrid_surf_SurfJNI_Action_1isSuspended(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jboolean jresult = 0 ;
+  Action *arg1 = (Action *) 0 ;
+  bool result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  result = (bool)(arg1)->isSuspended();
+  jresult = (jboolean)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Action_1getBound(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  Action *arg1 = (Action *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  result = (double)(arg1)->getBound();
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Action_1setBound(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  Action *arg1 = (Action *) 0 ;
+  double arg2 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  arg2 = (double)jarg2; 
+  (arg1)->setBound(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Action_1updateRemains(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  Action *arg1 = (Action *) 0 ;
+  double arg2 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  arg2 = (double)jarg2; 
+  (arg1)->updateRemains(arg2);
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_Action_1getRemains(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  Action *arg1 = (Action *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  result = (double)(arg1)->getRemains();
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Action_1setPriority(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) {
+  Action *arg1 = (Action *) 0 ;
+  double arg2 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  arg2 = (double)jarg2; 
+  (arg1)->setPriority(arg2);
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Action_1setState(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
+  Action *arg1 = (Action *) 0 ;
+  e_surf_action_state_t arg2 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Action **)&jarg1; 
+  arg2 = (e_surf_action_state_t)jarg2; 
+  (arg1)->setState(arg2);
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1CpuAction(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2, jboolean jarg3) {
+  jlong jresult = 0 ;
+  Model *arg1 = (Model *) 0 ;
+  double arg2 ;
+  bool arg3 ;
+  CpuAction *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Model **)&jarg1; 
+  arg2 = (double)jarg2; 
+  arg3 = jarg3 ? true : false; 
+  result = (CpuAction *)new SwigDirector_CpuAction(jenv,arg1,arg2,arg3);
+  *(CpuAction **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_CpuAction_1getCpu(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jlong jresult = 0 ;
+  CpuAction *arg1 = (CpuAction *) 0 ;
+  Cpu *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CpuAction **)&jarg1; 
+  result = (Cpu *)CpuAction_getCpu(arg1);
+  *(Cpu **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1CpuAction(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  CpuAction *arg1 = (CpuAction *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(CpuAction **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_CpuAction_1director_1connect(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, jboolean jweak_global) {
+  CpuAction *obj = *((CpuAction **)&objarg);
+  (void)jcls;
+  SwigDirector_CpuAction *director = dynamic_cast<SwigDirector_CpuAction *>(obj);
+  if (director) {
+    director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), (jswig_mem_own == JNI_TRUE), (jweak_global == JNI_TRUE));
+  }
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_CpuAction_1change_1ownership(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jtake_or_release) {
+  CpuAction *obj = *((CpuAction **)&objarg);
+  SwigDirector_CpuAction *director = dynamic_cast<SwigDirector_CpuAction *>(obj);
+  (void)jcls;
+  if (director) {
+    director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);
+  }
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_NetworkAction_1getLatency(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  NetworkAction *arg1 = (NetworkAction *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(NetworkAction **)&jarg1; 
+  result = (double)NetworkAction_getLatency(arg1);
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1NetworkAction(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  NetworkAction *arg1 = (NetworkAction *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(NetworkAction **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jstring JNICALL Java_org_simgrid_surf_SurfJNI_RoutingEdge_1getName(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jstring jresult = 0 ;
+  RoutingEdge *arg1 = (RoutingEdge *) 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(RoutingEdge **)&jarg1; 
+  result = (char *)(arg1)->getName();
+  if (result) jresult = jenv->NewStringUTF((const char *)result);
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1RoutingEdge(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  RoutingEdge *arg1 = (RoutingEdge *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(RoutingEdge **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_LmmConstraint_1getUsage(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  lmm_constraint *arg1 = (lmm_constraint *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(lmm_constraint **)&jarg1; 
+  result = (double)lmm_constraint_getUsage(arg1);
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1LmmConstraint(JNIEnv *jenv, jclass jcls) {
+  jlong jresult = 0 ;
+  lmm_constraint *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (lmm_constraint *)new lmm_constraint();
+  *(lmm_constraint **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1LmmConstraint(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  lmm_constraint *arg1 = (lmm_constraint *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(lmm_constraint **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jdouble JNICALL Java_org_simgrid_surf_SurfJNI_LmmVariable_1getValue(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jdouble jresult = 0 ;
+  lmm_variable *arg1 = (lmm_variable *) 0 ;
+  double result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(lmm_variable **)&jarg1; 
+  result = (double)lmm_variable_getValue(arg1);
+  jresult = (jdouble)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1LmmVariable(JNIEnv *jenv, jclass jcls) {
+  jlong jresult = 0 ;
+  lmm_variable *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (lmm_variable *)new lmm_variable();
+  *(lmm_variable **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1LmmVariable(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  lmm_variable *arg1 = (lmm_variable *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(lmm_variable **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jstring JNICALL Java_org_simgrid_surf_SurfJNI_XbtDict_1getValue(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
+  jstring jresult = 0 ;
+  s_xbt_dict *arg1 = (s_xbt_dict *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(s_xbt_dict **)&jarg1; 
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return 0;
+  }
+  result = (char *)s_xbt_dict_getValue(arg1,arg2);
+  if (result) jresult = jenv->NewStringUTF((const char *)result);
+  if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1XbtDict(JNIEnv *jenv, jclass jcls) {
+  jlong jresult = 0 ;
+  s_xbt_dict *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (s_xbt_dict *)new s_xbt_dict();
+  *(s_xbt_dict **)&jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1XbtDict(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+  s_xbt_dict *arg1 = (s_xbt_dict *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = *(s_xbt_dict **)&jarg1; 
+  delete arg1;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_simgrid_surf_SurfJNI_SURF_1ACTION_1READY_1get(JNIEnv *jenv, jclass jcls) {
+  jint jresult = 0 ;
+  e_surf_action_state_t result;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (e_surf_action_state_t)SURF_ACTION_READY;
+  jresult = (jint)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_simgrid_surf_SurfJNI_SURF_1RESOURCE_1ON_1get(JNIEnv *jenv, jclass jcls) {
+  jint jresult = 0 ;
+  e_surf_resource_state_t result;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (e_surf_resource_state_t)SURF_RESOURCE_ON;
+  jresult = (jint)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_simgrid_surf_SurfJNI_SURF_1RESOURCE_1OFF_1get(JNIEnv *jenv, jclass jcls) {
+  jint jresult = 0 ;
+  e_surf_resource_state_t result;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (e_surf_resource_state_t)SURF_RESOURCE_OFF;
+  jresult = (jint)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1SWIGUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+    jlong baseptr = 0;
+    (void)jenv;
+    (void)jcls;
+    *(Model **)&baseptr = *(CpuModel **)&jarg1;
+    return baseptr;
+}
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Cpu_1SWIGUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+    jlong baseptr = 0;
+    (void)jenv;
+    (void)jcls;
+    *(Resource **)&baseptr = *(Cpu **)&jarg1;
+    return baseptr;
+}
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_NetworkLink_1SWIGUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+    jlong baseptr = 0;
+    (void)jenv;
+    (void)jcls;
+    *(Resource **)&baseptr = *(NetworkLink **)&jarg1;
+    return baseptr;
+}
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_CpuAction_1SWIGUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+    jlong baseptr = 0;
+    (void)jenv;
+    (void)jcls;
+    *(Action **)&baseptr = *(CpuAction **)&jarg1;
+    return baseptr;
+}
+
+SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_NetworkAction_1SWIGUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+    jlong baseptr = 0;
+    (void)jenv;
+    (void)jcls;
+    *(Action **)&baseptr = *(NetworkAction **)&jarg1;
+    return baseptr;
+}
+
+SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_swig_1module_1init(JNIEnv *jenv, jclass jcls) {
+  int i;
+  
+  static struct {
+    const char *method;
+    const char *signature;
+  } methods[33] = {
+    {
+      "SwigDirector_Plugin_cpuCreatedCallback", "(Lorg/simgrid/surf/Plugin;J)V" 
+    },
+    {
+      "SwigDirector_Plugin_cpuDestructedCallback", "(Lorg/simgrid/surf/Plugin;J)V" 
+    },
+    {
+      "SwigDirector_Plugin_cpuStateChangedCallback", "(Lorg/simgrid/surf/Plugin;JII)V" 
+    },
+    {
+      "SwigDirector_Plugin_cpuActionStateChangedCallback", "(Lorg/simgrid/surf/Plugin;JII)V" 
+    },
+    {
+      "SwigDirector_Plugin_networkLinkCreatedCallback", "(Lorg/simgrid/surf/Plugin;J)V" 
+    },
+    {
+      "SwigDirector_Plugin_networkLinkDestructedCallback", "(Lorg/simgrid/surf/Plugin;J)V" 
+    },
+    {
+      "SwigDirector_Plugin_networkLinkStateChangedCallback", "(Lorg/simgrid/surf/Plugin;JII)V" 
+    },
+    {
+      "SwigDirector_Plugin_networkActionStateChangedCallback", "(Lorg/simgrid/surf/Plugin;JII)V" 
+    },
+    {
+      "SwigDirector_Plugin_networkCommunicateCallback", "(Lorg/simgrid/surf/Plugin;JJJDD)V" 
+    },
+    {
+      "SwigDirector_CpuModel_shareResources", "(Lorg/simgrid/surf/CpuModel;D)D" 
+    },
+    {
+      "SwigDirector_CpuModel_shareResourcesLazy", "(Lorg/simgrid/surf/CpuModel;D)D" 
+    },
+    {
+      "SwigDirector_CpuModel_shareResourcesFull", "(Lorg/simgrid/surf/CpuModel;D)D" 
+    },
+    {
+      "SwigDirector_CpuModel_updateActionsState", "(Lorg/simgrid/surf/CpuModel;DD)V" 
+    },
+    {
+      "SwigDirector_CpuModel_updateActionsStateLazy", "(Lorg/simgrid/surf/CpuModel;DD)V" 
+    },
+    {
+      "SwigDirector_CpuModel_updateActionsStateFull", "(Lorg/simgrid/surf/CpuModel;DD)V" 
+    },
+    {
+      "SwigDirector_CpuModel_getRunningActionSet", "(Lorg/simgrid/surf/CpuModel;)J" 
+    },
+    {
+      "SwigDirector_CpuModel_createResource", "(Lorg/simgrid/surf/CpuModel;Ljava/lang/String;[DIDJIIJJ)J" 
+    },
+    {
+      "SwigDirector_CpuModel_addTraces", "(Lorg/simgrid/surf/CpuModel;)V" 
+    },
+    {
+      "SwigDirector_Cpu_isUsed", "(Lorg/simgrid/surf/Cpu;)Z" 
+    },
+    {
+      "SwigDirector_Cpu_getState", "(Lorg/simgrid/surf/Cpu;)I" 
+    },
+    {
+      "SwigDirector_Cpu_updateState", "(Lorg/simgrid/surf/Cpu;JDD)V" 
+    },
+    {
+      "SwigDirector_Cpu_getCurrentPowerPeak", "(Lorg/simgrid/surf/Cpu;)D" 
+    },
+    {
+      "SwigDirector_Cpu_execute", "(Lorg/simgrid/surf/Cpu;D)J" 
+    },
+    {
+      "SwigDirector_Cpu_sleep", "(Lorg/simgrid/surf/Cpu;D)J" 
+    },
+    {
+      "SwigDirector_Cpu_getCore", "(Lorg/simgrid/surf/Cpu;)I" 
+    },
+    {
+      "SwigDirector_Cpu_getSpeed", "(Lorg/simgrid/surf/Cpu;D)D" 
+    },
+    {
+      "SwigDirector_Cpu_getAvailableSpeed", "(Lorg/simgrid/surf/Cpu;)D" 
+    },
+    {
+      "SwigDirector_Cpu_getPowerPeakAt", "(Lorg/simgrid/surf/Cpu;I)D" 
+    },
+    {
+      "SwigDirector_Cpu_getNbPstates", "(Lorg/simgrid/surf/Cpu;)I" 
+    },
+    {
+      "SwigDirector_Cpu_setPowerPeakAt", "(Lorg/simgrid/surf/Cpu;I)V" 
+    },
+    {
+      "SwigDirector_CpuAction_getRemains", "(Lorg/simgrid/surf/CpuAction;)D" 
+    },
+    {
+      "SwigDirector_CpuAction_setPriority", "(Lorg/simgrid/surf/CpuAction;D)V" 
+    },
+    {
+      "SwigDirector_CpuAction_setState", "(Lorg/simgrid/surf/CpuAction;I)V" 
+    }
+  };
+  Swig::jclass_SurfJNI = (jclass) jenv->NewGlobalRef(jcls);
+  if (!Swig::jclass_SurfJNI) return;
+  for (i = 0; i < (int) (sizeof(methods)/sizeof(methods[0])); ++i) {
+    Swig::director_methids[i] = jenv->GetStaticMethodID(jcls, methods[i].method, methods[i].signature);
+    if (!Swig::director_methids[i]) return;
+  }
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/src/bindings/java/surfJAVA_wrap.h b/src/bindings/java/surfJAVA_wrap.h
new file mode 100644 (file)
index 0000000..cb0143b
--- /dev/null
@@ -0,0 +1,105 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.11
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#ifndef SWIG_Surf_WRAP_H_
+#define SWIG_Surf_WRAP_H_
+
+class SwigDirector_Plugin : public Plugin, public Swig::Director {
+
+public:
+    void swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global);
+    SwigDirector_Plugin(JNIEnv *jenv);
+    virtual ~SwigDirector_Plugin();
+    virtual void cpuCreatedCallback(Cpu *cpu);
+    virtual void cpuDestructedCallback(Cpu *cpu);
+    virtual void cpuStateChangedCallback(Cpu *cpu, e_surf_resource_state_t arg1, e_surf_resource_state_t arg2);
+    virtual void cpuActionStateChangedCallback(CpuAction *action, e_surf_action_state_t arg1, e_surf_action_state_t arg2);
+    virtual void networkLinkCreatedCallback(NetworkLink *link);
+    virtual void networkLinkDestructedCallback(NetworkLink *link);
+    virtual void networkLinkStateChangedCallback(NetworkLink *link, e_surf_resource_state_t arg1, e_surf_resource_state_t arg2);
+    virtual void networkActionStateChangedCallback(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t cur);
+    virtual void networkCommunicateCallback(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate);
+public:
+    bool swig_overrides(int n) {
+      return (n < 9 ? swig_override[n] : false);
+    }
+protected:
+    bool swig_override[9];
+};
+
+class SwigDirector_CpuModel : public CpuModel, public Swig::Director {
+
+public:
+    void swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global);
+    SwigDirector_CpuModel(JNIEnv *jenv, char const *name);
+    virtual double shareResources(double now);
+    virtual double shareResourcesLazy(double now);
+    virtual double shareResourcesFull(double now);
+    virtual void updateActionsState(double now, double delta);
+    virtual void updateActionsStateLazy(double now, double delta);
+    virtual void updateActionsStateFull(double now, double delta);
+    virtual ActionList *getRunningActionSet();
+    virtual ~SwigDirector_CpuModel();
+    virtual Cpu *createResource(char const *name, DoubleDynar power_peak, int pstate, double power_scale, tmgr_trace *power_trace, int core, e_surf_resource_state_t state_initial, tmgr_trace *state_trace, s_xbt_dict *cpu_properties);
+    virtual void addTraces();
+public:
+    bool swig_overrides(int n) {
+      return (n < 9 ? swig_override[n] : false);
+    }
+protected:
+    bool swig_override[9];
+};
+
+class SwigDirector_Cpu : public Cpu, public Swig::Director {
+
+public:
+    void swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global);
+    SwigDirector_Cpu(JNIEnv *jenv, Model *model, char const *name, s_xbt_dict *props, lmm_constraint *constraint, int core, double powerPeak, double powerScale);
+    SwigDirector_Cpu(JNIEnv *jenv, Model *model, char const *name, s_xbt_dict *props, int core, double powerPeak, double powerScale);
+    virtual bool isUsed();
+    virtual e_surf_resource_state_t getState();
+    virtual void updateState(tmgr_trace_event *event_type, double value, double date);
+    virtual ~SwigDirector_Cpu();
+    virtual double getCurrentPowerPeak();
+    virtual CpuAction *execute(double size);
+    virtual CpuAction *sleep(double duration);
+    virtual int getCore();
+    virtual double getSpeed(double load);
+    virtual double getAvailableSpeed();
+    virtual double getPowerPeakAt(int pstate_index);
+    virtual int getNbPstates();
+    virtual void setPowerPeakAt(int pstate_index);
+public:
+    bool swig_overrides(int n) {
+      return (n < 12 ? swig_override[n] : false);
+    }
+protected:
+    bool swig_override[12];
+};
+
+class SwigDirector_CpuAction : public CpuAction, public Swig::Director {
+
+public:
+    void swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global);
+    SwigDirector_CpuAction(JNIEnv *jenv, Model *model, double cost, bool failed);
+    virtual ~SwigDirector_CpuAction();
+    virtual double getRemains();
+    virtual void setPriority(double priority);
+    virtual void setState(e_surf_action_state_t state);
+public:
+    bool swig_overrides(int n) {
+      return (n < 3 ? swig_override[n] : false);
+    }
+protected:
+    bool swig_override[3];
+};
+
+
+#endif
diff --git a/src/bindings/java/surf_swig.cpp b/src/bindings/java/surf_swig.cpp
new file mode 100644 (file)
index 0000000..afff2a9
--- /dev/null
@@ -0,0 +1,91 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <boost/lambda/bind.hpp>
+#include "src/surf/surf_interface.hpp"
+#include "surf_swig.hpp"
+#include "src/simix/smx_private.h"
+
+double getClock() {
+  return surf_get_clock();
+}
+
+void clean() {
+  SIMIX_clean();
+}
+
+CpuModel *getCpuModel(){
+  return surf_cpu_model_pm;
+}
+
+CpuModel *java_cpu_model;
+static void java_cpu_model_init_preparse() {
+  surf_cpu_model_pm = java_cpu_model;
+  xbt_dynar_push(model_list, &java_cpu_model);
+  xbt_dynar_push(model_list_invoke, &java_cpu_model);
+  sg_platf_host_add_cb(parse_cpu_init);
+}
+
+void setCpuModel(CpuModel *cpuModel){
+  java_cpu_model = cpuModel;
+  surf_cpu_model_init_preparse = java_cpu_model_init_preparse;
+}
+
+void setCpu(char *name, Cpu *cpu) {
+  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
+}
+
+NetworkLinkDynar getRoute(char *srcName, char *dstName) {
+  RoutingEdge *src = (RoutingEdge*)xbt_lib_get_or_null(host_lib, srcName, ROUTING_HOST_LEVEL);
+  RoutingEdge *dst = (RoutingEdge*)xbt_lib_get_or_null(host_lib, dstName, ROUTING_HOST_LEVEL);
+  if (src==NULL)
+    xbt_die("TOTO");
+  if (dst==NULL)
+    xbt_die("TOTO");
+  xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL);
+  routing_platf->getRouteAndLatency(src, dst, &route, NULL);
+  return route;
+}
+
+void Plugin::activateCpuCreatedCallback(){
+  surf_callback_connect(cpuCreatedCallbacks, boost::bind(&Plugin::cpuCreatedCallback, this, _1));
+}
+
+void Plugin::activateCpuDestructedCallback(){
+  surf_callback_connect(cpuDestructedCallbacks, boost::bind(&Plugin::cpuDestructedCallback, this, _1));
+}
+
+void Plugin::activateCpuStateChangedCallback(){
+  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, _2, _3));
+}
+
+
+void Plugin::activateNetworkLinkCreatedCallback(){
+  surf_callback_connect(networkLinkCreatedCallbacks, boost::bind(&Plugin::networkLinkCreatedCallback, this, _1));
+}
+
+void Plugin::activateNetworkLinkDestructedCallback(){
+  surf_callback_connect(networkLinkDestructedCallbacks, boost::bind(&Plugin::networkLinkDestructedCallback, this, _1));
+}
+
+void Plugin::activateNetworkLinkStateChangedCallback(){
+  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, _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
new file mode 100644 (file)
index 0000000..4211ce1
--- /dev/null
@@ -0,0 +1,60 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <cstdio>
+#include <iostream>
+#include "src/surf/cpu_interface.hpp"
+#include "src/surf/network_interface.hpp"
+#include "src/surf/maxmin_private.hpp"
+
+typedef xbt_dynar_t NetworkLinkDynar;
+typedef ActionList *ActionArrayPtr;
+
+double getClock();
+
+void clean();
+
+CpuModel *getCpuModel();
+void setCpuModel(CpuModel *cpuModel);
+
+void setCpu(char *name, Cpu *cpu);
+
+NetworkLinkDynar getRoute(char *srcName, char *dstName);
+
+class Plugin {
+public:
+ virtual ~Plugin() {
+   std::cout << "Plugin::~Plugin()" << std:: endl;
+ }
+
+ void activateCpuCreatedCallback();
+ virtual void cpuCreatedCallback(Cpu *cpu) {}
+
+ void activateCpuDestructedCallback();
+ virtual void cpuDestructedCallback(Cpu *cpu) {}
+
+ void activateCpuStateChangedCallback();
+ virtual void cpuStateChangedCallback(Cpu *cpu, e_surf_resource_state_t, e_surf_resource_state_t) {}
+
+ void activateCpuActionStateChangedCallback();
+ virtual void cpuActionStateChangedCallback(CpuAction *action, e_surf_action_state_t, e_surf_action_state_t) {}
+
+
+ void activateNetworkLinkCreatedCallback();
+ virtual void networkLinkCreatedCallback(NetworkLink *link) {}
+
+ void activateNetworkLinkDestructedCallback();
+ virtual void networkLinkDestructedCallback(NetworkLink *link) {}
+
+ void activateNetworkLinkStateChangedCallback();
+ virtual void networkLinkStateChangedCallback(NetworkLink *link, e_surf_resource_state_t, e_surf_resource_state_t) {}
+
+ void activateNetworkActionStateChangedCallback();
+ 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/bindings/java/surfdoc.i b/src/bindings/java/surfdoc.i
new file mode 100644 (file)
index 0000000..362c1e4
--- /dev/null
@@ -0,0 +1,439 @@
+
+%javamethodmodifiers getClock() "
+  /**
+    * @return The current simulated time
+    */
+  public";
+
+%typemap(javaimports) Model "
+/**
+  * A component (e.g., Cpu, Network, Storage, ...) is composed of three classes:
+  * <ul>
+  *  <li> Model: It handle the interactions between resoucses and actions</li>
+  *  <li> Resource: A resource used by the model (e.g., a cpu, a network link)</li>
+  *  <li> Action: An action generated by the resources (e.g., execution, communication)</li>
+  * </ul>
+  * @see Resource
+  * @see Action
+  */"
+
+%javamethodmodifiers Model::Model(const char *name) "
+  /**
+    * Model constructor
+    * @param name The name of the model
+    */
+  public";
+
+%javamethodmodifiers Model::getName() "
+  /**
+    * @return The name of the model
+    */
+  public";
+
+%javamethodmodifiers Model::shareResources(double now) "
+  /**
+    * Share the resources between the actions
+    * @param now the current time
+    * @return the date of the next action of the model will finish
+    */
+  public";
+
+%javamethodmodifiers Model::updateActionsState(double now, double delta) "
+  /**
+    * Update time of actions and eventually their states
+    * @param now the new current time
+    * @param delta the delta between previous and new current time
+    */
+  public";
+
+  %javamethodmodifiers Model::getRunningActionSet() "
+  /**
+    * Get the List of running Actions
+    */
+  public";
+
+
+%typemap(javaimports) CpuModel "
+/**
+  * The generic model for the Cpu component
+  * @see Cpu
+  * @see CpuAction
+  */"
+
+%javamethodmodifiers CpuModel::CpuModel(const char *name) "
+  /**
+    * CpuModel constructon
+    * @param name The name of the cpumodel
+    */
+  public";
+
+
+%javamethodmodifiers CpuModel::createResource(const char *name, DoubleDynar power_peak,
+                              int pstate, double power_scale,
+                              tmgr_trace *power_trace, int core,
+                              e_surf_resource_state_t state_initial,
+                              tmgr_trace *state_trace,
+                              s_xbt_dict *cpu_properties) "
+  /**
+    * Create a new Cpu
+    *
+    * @param name
+    * @param power_peak
+    * @param pstate
+    * @param power_scale
+    * @param power_trace
+    * @param core
+    * @param state_initial
+    * @param state_trace
+    * @param cpu_properties
+    * @return The new Cpu
+    * @see Cpu
+    */
+  public";
+
+
+%typemap(javaimports) Resource "
+/**
+  * A resource used by a model (e.g., a cpu, a network link)
+  * @see Model
+  * @see Action
+  */"
+
+%javamethodmodifiers Resource::getName() "
+  /**
+    * @return The name of the resource
+    */
+  public";
+
+%javamethodmodifiers Resource::isUsed() "
+  /**
+    * @return True if the Resource is used
+    */
+  public";
+
+%javamethodmodifiers Resource::getModel() "
+  /**
+    * @return The model associated to this Resource
+    */
+  public";
+
+%javamethodmodifiers Resource::getState() "
+  /**
+    * @return The state of the resource
+    * @see ResourceState
+    */
+  public";
+
+%javamethodmodifiers Resource::getConstraint() "
+  /**
+    * @return The constraint associatied (if using LMM)
+    */
+  public";
+
+%javamethodmodifiers Resource::getProperties() "
+  /**
+    * @return The XbtDict of properties associated to this Resource
+    */
+  public";
+
+%javamethodmodifiers Resource::updateState(tmgr_trace_event *event_type, double value, double date) "
+  /**
+    * Update the state of the Resource
+    * @param event_type
+    * @param value
+    * @param date
+    */
+  public";
+
+
+%typemap(javaimports) Cpu "
+/**
+  * A generic resource for the cpu component
+  * @see CpuModel
+  * @see CpuAction
+  */"
+
+%javamethodmodifiers Cpu::Cpu(Model *model, const char *name, s_xbt_dict *props,
+    lmm_constraint *constraint, int core, double powerPeak, double powerScale) "
+  /**
+    * A cpu constructor (using LMM)
+    * @param model
+    * @param name
+    * @param properties
+    * @param constraint
+    * @param core
+    * @param powerPeak
+    * @param powerScale
+    */
+  public";
+
+%javamethodmodifiers Cpu::Cpu(Model *model, const char *name, s_xbt_dict *props,
+    int core, double powerPeak, double powerScale) "
+  /**
+    * A cpu constructor
+    * @param model
+    * @param name
+    * @param properties
+    * @param core
+    * @param powerPeak
+    * @param powerScale
+    */
+  public";
+
+%javamethodmodifiers Cpu::getCurrentPowerPeak() "
+  /**
+    * @return The current power peak
+    */
+  public";
+
+%javamethodmodifiers Cpu::execute(double size) "
+  /**
+    * Execute some quantity of computation
+    * @param size The processing amount (in flop) needed to process
+    * @return A cpu action representing code execution
+    */
+  public";
+
+%javamethodmodifiers Cpu::sleep(double duration) "
+  /**
+    * Make a process sleep for duration
+    * @param duration The number of seconds to sleep
+    * @return A cpu action representing sleeping
+    */
+  public";
+
+%javamethodmodifiers Cpu::getCore() "
+  /**
+    * @return The number of cores on the cpu
+    */
+  public";
+
+%javamethodmodifiers Cpu::getSpeed(double load) "
+  /**
+    * TODO
+    * @param load
+    */
+  public";
+
+%javamethodmodifiers Cpu::getAvailableSpeed() "
+  /**
+    * TODO
+    */
+  public";
+
+%javamethodmodifiers Cpu::getPowerPeakAt(int pstate_index) "
+  /**
+    * @param pstate_index index of power peak to get
+    * @return Power peak at index
+    */
+  public";
+
+  %javamethodmodifiers Cpu::getNbPstates() "
+  /**
+    * @return Number of power peak
+    */
+  public";
+
+%javamethodmodifiers Cpu::setPowerPeakAt(int pstate_index) "
+  /**
+    * @param  index of power peak to set
+    */
+  public";
+
+%javamethodmodifiers Cpu::setState(e_surf_resource_state_t state) "
+  /**
+    * @param The new state of the cpu
+    */
+  public";
+
+
+%typemap(javaimports) NetworkLink "
+/**
+ * A generic resource for the network component
+ */"
+
+  %javamethodmodifiers NetworkLink::getBandwidth() "
+  /**
+    * @return The bandwidth of the link
+    */
+  public";
+
+%javamethodmodifiers NetworkLink::updateBandwidth(double value, double date=surf_get_clock()) "
+  /**
+    * @param value The new bandwidth
+    * @param date When to change the bandwidth
+    */
+  public";
+
+  %javamethodmodifiers NetworkLink::getLatency() "
+  /**
+    * @return The latency of the link
+    */
+  public";
+
+%javamethodmodifiers NetworkLink::updateLatency(double value, double date=surf_get_clock()) "
+  /**
+    * @param value The new latency
+    * @param date When to change the latency
+    */
+  public";
+
+
+%typemap(javaimports) Action "
+/**
+  * An action created by a Resource (e.g., a communication, an execution)
+  * @see Model
+  * @see Resource
+  */"
+
+%javamethodmodifiers Action::Action(Model *model, double cost, bool failed) "
+  /**
+    * Action constructor
+    * @param model The model associated
+    * @param cost The cost of the action (e.g., flops, bytes)
+    * @param failed If the action has failed
+    */
+  public";
+
+%javamethodmodifiers Action::getModel() "
+  /**
+    * @return The model associated
+    */
+  public";
+
+%javamethodmodifiers Action::getVariable() "
+  /**
+    * @return The variable associatied (if using LMM)
+    */
+  public";
+
+%javamethodmodifiers Action::getState() "
+  /**
+    * @return The state of the action
+    */
+  public";
+
+%javamethodmodifiers Action::isSuspended() "
+  /**
+    * @return True if suspended
+    */
+  public";
+
+%javamethodmodifiers Action::getBound() "
+  /**
+    * @return TODO
+    */
+  public";
+
+%javamethodmodifiers Action::setBound(double bound) "
+  /**
+    * @param TODO
+    */
+  public";
+
+%javamethodmodifiers Action::updateRemains(double delta) "
+  /**
+    * Update remaining amount of cost to do
+    * @param delta Difference of time since last call to this function
+    */
+  public";
+
+%javamethodmodifiers Action::getRemains() "
+  /**
+    * @return The remaining amount of cost to do
+    */
+  public";
+
+%javamethodmodifiers Action::setPriority(double priority) "
+  /**
+    * @param The new priority of the action
+    */
+  public";
+
+%javamethodmodifiers Action::setState(e_surf_action_state_t state) "
+  /**
+    * @param The new state
+    */
+  public";
+
+
+%typemap(javaimports) CpuAction "
+/**
+  * An cpu action created by a Cpu
+  * @see CpuModel
+  * @see Cpu
+  */"
+
+%javamethodmodifiers CpuAction::CpuAction(Model *model, double cost, bool failed) "
+  /**
+    * CpuAction constructor
+    * @param model The model associated
+    * @param cost The cost of the action (e.g., flops, bytes)
+    * @param failed If the action has failed
+    */
+  public";
+
+%javamethodmodifiers CpuAction::getCpu() "
+  /**
+    * @return The associated cpu
+    */
+  public";
+
+
+%typemap(javaimports) NetworkAction "
+/**
+  * An network action created by network model
+  * @see NetworkLink
+  */"
+
+%javamethodmodifiers NetworkAction::getLatency() "
+  /**
+    * @return The latency of the action
+    */
+  public";
+
+
+%typemap(javaimports) LmmConstraint "
+/**
+  * An linear maxmin generic constraint
+  */"
+
+%javamethodmodifiers LmmConstraint::getUsage() "
+  /**
+    *
+    */
+  public";
+
+%typemap(javaimports) LmmVariable "
+/**
+  * An linear maxmin generic variable
+  */"
+
+%javamethodmodifiers LmmVariable::getValue() "
+  /**
+    *
+    */
+  public";
+
+%typemap(javaimports) XbtDict "
+/**
+  * A c structure handling key:values
+  */"
+
+%javamethodmodifiers XbtDict::getValue(char *key) "
+  /**
+    *
+    */
+  public";
+
+
+%typemap(javaimports) ActionState "
+/**
+  * The possible states of an Action
+  */"
+
+
+%typemap(javaimports) ResourceState "
+/**
+  * The possible states of a Resource
+  */"
index 2cc5834..cd8caab 100644 (file)
@@ -6,10 +6,16 @@
 
 #ifndef MC_DATATYPE_H
 #define MC_DATATYPE_H
+
+#define UNW_LOCAL_ONLY
+
 #include "xbt/misc.h"
 #include "xbt/swag.h"
 #include "xbt/fifo.h"
 
+#include <libunwind.h>
+#include <dwarf.h>
+
 SG_BEGIN_DECL()
 
 /******************************* Transitions **********************************/
@@ -37,34 +43,17 @@ typedef struct s_stack_region{
 void heap_ignore_region_free(mc_heap_ignore_region_t r);
 void heap_ignore_region_free_voidp(void *r);
 
+/************ Object info *************/
+
+typedef struct s_mc_object_info s_mc_object_info_t, *mc_object_info_t;
+
 /************ DWARF structures *************/
 
-typedef enum{
-  e_dw_base_type = 0,
-  e_dw_enumeration_type,
-  e_dw_enumerator,
-  e_dw_typedef,
-  e_dw_const_type,
-  e_dw_array_type,
-  e_dw_pointer_type,
-  e_dw_structure_type,
-  e_dw_union_type,
-  e_dw_subroutine_type,
-  e_dw_volatile_type
-}e_dw_type_type;
-
-typedef struct s_dw_type{
-  e_dw_type_type type;
-  void *id;
-  char *name;
-  int size;
-  char *dw_type_id;
-  xbt_dynar_t members; /* if DW_TAG_structure_type */
-  int is_pointer_type;
-  int offset;
-}s_dw_type_t, *dw_type_t;
-
-char* get_type_description(xbt_dict_t types, char *type_name);
+typedef int e_dw_type_type;
+
+typedef struct s_dw_type s_dw_type_t, *dw_type_t;
+
+char* get_type_description(mc_object_info_t info, char *type_name);
 
 SG_END_DECL()
 #endif                          /* _MC_MC_H */
index 494b651..e207590 100644 (file)
 #include "xbt/fifo.h"
 #include "xbt/dict.h"
 #include "xbt/function_types.h"
-#include "mc/datatypes.h"
 #include "simgrid/simix.h"
 #include "simgrid/modelchecker.h" /* our public interface (and definition of HAVE_MC) */
 #include "xbt/automaton.h"
 #include "xbt/dynar.h"
 
-#define STD_HEAP_SIZE   20480000        /* Maximum size of the system's heap */
+/* Maximum size of the application heap.
+ *
+ * The model-checker heap is placed at this offset from the
+ * beginning of the application heap.
+ *
+ * In the current implementation, if the application uses more
+ * than this for the application heap the application heap will
+ * smash the beginning of the model-checker heap and bad things
+ * will happen.
+ *
+ * For 64 bits systems, we have a lot of virtual memory available
+ * so we wan use a much bigger value in order to avoid bad things
+ * from happening.
+ * */
+
+#define STD_HEAP_SIZE   (sizeof(void*)<=4 ? (100*1024*1024) : (1ll*1024*1024*1024*1024))
 
 SG_BEGIN_DECL()
 
@@ -26,9 +40,12 @@ extern int _sg_do_model_check;
 extern int _sg_mc_checkpoint;
 extern char* _sg_mc_property_file;
 extern int _sg_mc_timeout;
+extern int _sg_mc_hash;
 extern int _sg_mc_max_depth;
 extern int _sg_mc_visited;
 extern char* _sg_mc_dot_output_file;
+extern int _sg_mc_comms_determinism;
+extern int _sg_mc_send_determinism;
 
 extern xbt_dynar_t mc_heap_comparison_ignore;
 extern xbt_dynar_t stacks_areas;
@@ -40,9 +57,12 @@ void _mc_cfg_cb_reduce(const char *name, int pos);
 void _mc_cfg_cb_checkpoint(const char *name, int pos);
 void _mc_cfg_cb_property(const char *name, int pos);
 void _mc_cfg_cb_timeout(const char *name, int pos);
+void _mc_cfg_cb_hash(const char *name, int pos);
 void _mc_cfg_cb_max_depth(const char *name, int pos);
 void _mc_cfg_cb_visited(const char *name, int pos);
 void _mc_cfg_cb_dot_output(const char *name, int pos);
+void _mc_cfg_cb_comms_determinism(const char *name, int pos);
+void _mc_cfg_cb_send_determinism(const char *name, int pos);
 
 XBT_PUBLIC(void) MC_do_the_modelcheck_for_real(void);
 
index 86600a4..ba925ee 100644 (file)
  * @details 
  * A linear maxmin solver to resolves inequations systems.
  * 
- * A system is composed of variables, constraints and elements linking them.
+ * Most SimGrid model rely on a "fluid/steady-state" modeling that
+ * samount to share resources between actions at relatively
+ * coarse-grain.  Such sharing is generally done by solving a set of
+ * linear inequations. Let's take an example and assume we have the
+ * variables \f$x_1\f$, \f$x_2\f$, \f$x_3\f$, and \f$x_4\f$ . Let's
+ * say that \f$x_1\f$ and \f$x_2\f$ correspond to activities running
+ * and the same CPU \f$A\f$ whose capacity is \f$C_A\f$ . In such a
+ * case, we need to enforce:
+ *
+ *   \f[ x_1 + x_2 \leq C_A \f]
+ *
+ * Likewise, if \f$x_3\f$ (resp. \f$x_4\f$) corresponds to a network
+ * flow \f$F_3\f$ (resp. \f$F_4\f$) that goes through a set of links
+ * \f$L_1\f$ and \f$L_2\f$ (resp. \f$L_2\f$ and \f$L_3\f$), then we
+ * need to enforce:
+ *
+ *   \f[ x_3  \leq C_{L_1} \f]
+ *   \f[ x_3 + x_4 \leq C_{L_2} \f]
+ *   \f[ x_4 \leq C_{L_3} \f]
+ * 
+ * One could set every variable to 0 to make sure the constraints are
+ * satisfied but this would obviously not be very realistic. A
+ * possible objective is to try to maximize the minimum of the
+ * \f$x_i\f$ . This ensures that all the \f$x_i\f$ are positive and "as
+ * large as possible". 
+ *
+ * This is called *max-min fairness* and is the most commonly used
+ * objective in SimGrid. Another possibility is to maximize
+ * \f$\sum_if(x_i)\f$, where \f$f\f$ is a strictly increasing concave
+ * function.
+ *
  * Constraint: 
  *  - bound (set)
  *  - shared (set)
  */
 
 extern double sg_maxmin_precision;
-#define MAXMIN_PRECISION sg_maxmin_precision
-static XBT_INLINE void double_update(double *variable, double value)
+extern double sg_surf_precision;
+
+static XBT_INLINE void double_update(double *variable, double value, double precision)
 {
   *variable -= value;
-  if (*variable < MAXMIN_PRECISION)
+  if (*variable < precision)
     *variable = 0.0;
 }
 
-static XBT_INLINE int double_positive(double value)
+static XBT_INLINE int double_positive(double value, double precision)
 {
-  return (value > MAXMIN_PRECISION);
+  return (value > precision);
 }
 
-static XBT_INLINE int double_equals(double value1, double value2)
+static XBT_INLINE int double_equals(double value1, double value2, double precision)
 {
-  return (fabs(value1 - value2) < MAXMIN_PRECISION);
+  return (fabs(value1 - value2) < precision);
 }
 
 SG_BEGIN_DECL()
@@ -107,7 +138,7 @@ XBT_PUBLIC(lmm_constraint_t) lmm_constraint_new(lmm_system_t sys, void *id,
  * 
  * @param cnst The constraint to share
  */
-void lmm_constraint_shared(lmm_constraint_t cnst);
+XBT_PUBLIC(void) lmm_constraint_shared(lmm_constraint_t cnst);
 
 /**
  * @brief Check if a constraint is shared (shared by default)
@@ -115,7 +146,7 @@ void lmm_constraint_shared(lmm_constraint_t cnst);
  * @param cnst The constraint to share
  * @return 1 if shared, 0 otherwise
  */
-int lmm_constraint_is_shared(lmm_constraint_t cnst);
+XBT_PUBLIC(int) lmm_constraint_is_shared(lmm_constraint_t cnst);
 
 /**
  * @brief Free a constraint
@@ -123,7 +154,7 @@ int lmm_constraint_is_shared(lmm_constraint_t cnst);
  * @param sys The system associated to the constraint
  * @param cnst The constraint to free
  */
-void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
+XBT_PUBLIC(void) lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
 
 /**
  * @brief Get the usage of the constraint after the last lmm solve
@@ -131,7 +162,7 @@ void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
  * @param cnst A constraint
  * @return The usage of the constraint
  */
-double lmm_constraint_get_usage(lmm_constraint_t cnst);
+XBT_PUBLIC(double) lmm_constraint_get_usage(lmm_constraint_t cnst);
 
 /**
  * @brief Create a new Linear MaxMin variable
@@ -200,7 +231,7 @@ XBT_PUBLIC(void) lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
  * @param var A variable
  * @param value The value to add to the coefficient associated to the variable in the constraint
  */
-void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
+XBT_PUBLIC(void) lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
                     lmm_variable_t var, double value);
 
 /**
@@ -211,7 +242,7 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
  * @param num The rank of constraint we want to get
  * @return The numth constraint
  */
-lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
+XBT_PUBLIC(lmm_constraint_t) lmm_get_cnst_from_var(lmm_system_t sys,
                                        lmm_variable_t var, int num);
 
 /**
@@ -222,7 +253,7 @@ lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
  * @param num The rank of constraint we want to get
  * @return The numth constraint
  */
-double lmm_get_cnst_weight_from_var(lmm_system_t sys, lmm_variable_t var,
+XBT_PUBLIC(double) lmm_get_cnst_weight_from_var(lmm_system_t sys, lmm_variable_t var,
                                     int num);
 
 /**
@@ -232,7 +263,7 @@ double lmm_get_cnst_weight_from_var(lmm_system_t sys, lmm_variable_t var,
  * @param var A variable
  * @return The number of constraint associated to the variable
  */
-int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
+XBT_PUBLIC(int) lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
 
 /**
  * @brief Get a var associated to a constraint 
@@ -243,7 +274,7 @@ int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
  * @param elem A element of constraint of the constraint or NULL
  * @return A variable associated to a constraint
  */
-lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
+XBT_PUBLIC(lmm_variable_t) lmm_get_var_from_cnst(lmm_system_t sys,
                                      lmm_constraint_t cnst,
                                      lmm_element_t * elem);
 
@@ -253,7 +284,7 @@ lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
  * @param sys A system
  * @return The first active constraint
  */
-lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
+XBT_PUBLIC(lmm_constraint_t) lmm_get_first_active_constraint(lmm_system_t sys);
 
 /**
  * @brief Get the next active constraint of a constraint in a system
@@ -263,7 +294,7 @@ lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
  * 
  * @return The next active constraint
  */
-lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys,
+XBT_PUBLIC(lmm_constraint_t) lmm_get_next_active_constraint(lmm_system_t sys,
                                                 lmm_constraint_t cnst);
 
 #ifdef HAVE_LATENCY_BOUND_TRACKING
@@ -276,7 +307,7 @@ XBT_PUBLIC(int) lmm_is_variable_limited_by_latency(lmm_variable_t var);
  * @param cnst A constraint
  * @return The data associated to the constraint
  */
-void *lmm_constraint_id(lmm_constraint_t cnst);
+XBT_PUBLIC(void *) lmm_constraint_id(lmm_constraint_t cnst);
 
 /**
  * @brief Get the data associated to a variable
@@ -284,7 +315,7 @@ void *lmm_constraint_id(lmm_constraint_t cnst);
  * @param var A variable
  * @return The data associated to the variable
  */
-void *lmm_variable_id(lmm_variable_t var);
+XBT_PUBLIC(void *) lmm_variable_id(lmm_variable_t var);
 
 /**
  * @brief Update the value of element linking the constraint and the variable
@@ -294,7 +325,7 @@ void *lmm_variable_id(lmm_variable_t var);
  * @param var A variable
  * @param value The new value
  */
-void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
+XBT_PUBLIC(void) lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
                 lmm_variable_t var, double value);
 
 /**
@@ -304,7 +335,7 @@ void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
  * @param var A constraint
  * @param bound The new bound
  */
-void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
+XBT_PUBLIC(void) lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
                                double bound);
 
 /**
@@ -324,7 +355,7 @@ XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys,
  * @param var A variable
  * @return The weight of the variable
  */
-double lmm_get_variable_weight(lmm_variable_t var);
+XBT_PUBLIC(double) lmm_get_variable_weight(lmm_variable_t var);
 
 /**
  * @brief Update a constraint bound
@@ -344,7 +375,7 @@ XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys,
  * @param cnst A constraint
  * @return [description]
  */
-int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
+XBT_PUBLIC(int) lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
 
 /**
  * @brief Solve the lmm system
index e83c9fa..1da385d 100644 (file)
@@ -102,7 +102,7 @@ typedef WorkstationCLM03 *surf_workstation_CLM03_t;
 typedef NetworkCm02Link *surf_network_link_t;
 typedef Cpu *surf_cpu_t;
 
-/** @ingroup SURF_c_bindings 
+/** @ingroup SURF_c_bindings
  *  \brief Action structure
  *
  *  Never create s_surf_action_t by yourself ! The actions are created
@@ -165,8 +165,8 @@ typedef enum {
 } e_surf_action_state_t;
 
 /** @ingroup SURF_vm_interface
- * 
- * 
+ *
+ *
  */
 /* FIXME: Where should the VM state be defined? */
 typedef enum {
@@ -217,9 +217,9 @@ XBT_PUBLIC(void) surf_as_cluster_set_backbone(AS_t as, void* backbone);
 
 /** @{ @ingroup SURF_c_bindings */
 
-/** 
+/**
  * @brief Get the name of a surf model
- * 
+ *
  * @param model A model
  * @return The name of the model
  */
@@ -227,7 +227,7 @@ XBT_PUBLIC(const char *) surf_model_name(surf_model_t model);
 
 /**
  * @brief Pop an action from the done actions set
- * 
+ *
  * @param model The model from which the action is extracted
  * @return An action in done state
  */
@@ -235,7 +235,7 @@ XBT_PUBLIC(surf_action_t) surf_model_extract_done_action_set(surf_model_t model)
 
 /**
  * @brief Pop an action from the failed actions set
- * 
+ *
  * @param model The model from which the action is extracted
  * @return An action in failed state
  */
@@ -243,7 +243,7 @@ XBT_PUBLIC(surf_action_t) surf_model_extract_failed_action_set(surf_model_t mode
 
 /**
  * @brief Pop an action from the ready actions set
- * 
+ *
  * @param model The model from which the action is extracted
  * @return An action in ready state
  */
@@ -251,7 +251,7 @@ XBT_PUBLIC(surf_action_t) surf_model_extract_ready_action_set(surf_model_t model
 
 /**
  * @brief Pop an action from the running actions set
- * 
+ *
  * @param model The model from which the action is extracted
  * @return An action in running state
  */
@@ -259,7 +259,7 @@ XBT_PUBLIC(surf_action_t) surf_model_extract_running_action_set(surf_model_t mod
 
 /**
  * @brief Get the size of the running action set of a model
- * 
+ *
  * @param model The model
  * @return The size of the running action set
  */
@@ -268,9 +268,9 @@ XBT_PUBLIC(int) surf_model_running_action_set_size(surf_model_t model);
 /**
  * @brief Execute a parallel task
  * @details [long description]
- * 
+ *
  * @param model The model which handle the parallelisation
- * @param workstation_nb The number of workstations 
+ * @param workstation_nb The number of workstations
  * @param workstation_list The list of workstations on which the task is executed
  * @param computation_amount The processing amount (in flop) needed to process
  * @param communication_amount The amount of data (in bytes) needed to transfer
@@ -286,7 +286,7 @@ XBT_PUBLIC(surf_action_t) surf_workstation_model_execute_parallel_task(surf_work
 
 /**
  * @brief Create a communication between two hosts
- * 
+ *
  * @param model The model which handle the communication
  * @param src The source host
  * @param dst The destination host
@@ -299,7 +299,7 @@ XBT_PUBLIC(surf_action_t) surf_workstation_model_communicate(surf_workstation_mo
 /**
  * @brief Get the route between two hosts
  * @details [long description]
- * 
+ *
  * @param model The model which handle the routes
  * @param src The source host
  * @param dst The destination host
@@ -309,7 +309,7 @@ XBT_PUBLIC(xbt_dynar_t) surf_workstation_model_get_route(surf_workstation_model_
 
 /**
  * @brief Create a new VM on the specified host
- * 
+ *
  * @param name The name of the workstation
  * @param ind_phys_host The host on which the VM is created
  */
@@ -318,7 +318,7 @@ XBT_PUBLIC(void) surf_vm_workstation_model_create(const char *name, surf_resourc
 /**
  * @brief Create a communication between two routing edges [TODO]
  * @details [long description]
- * 
+ *
  * @param model The model which handle the communication
  * @param src The source host
  * @param dst The destination host
@@ -330,7 +330,7 @@ XBT_PUBLIC(surf_action_t) surf_network_model_communicate(surf_network_model_t mo
 
 /**
  * @brief Get the name of a surf resource (cpu, workstation, network, …)
- * 
+ *
  * @param resource The surf resource
  * @return The name of the surf resource
  */
@@ -338,7 +338,7 @@ XBT_PUBLIC(const char * ) surf_resource_name(surf_cpp_resource_t resource);
 
 /**
  * @brief Get the properties of a surf resource (cpu, workstation, network, …)
- * 
+ *
  * @param resource The surf resource
  * @return The properties of the surf resource
  */
@@ -346,7 +346,7 @@ XBT_PUBLIC(xbt_dict_t) surf_resource_get_properties(surf_cpp_resource_t resource
 
 /**
  * @brief Get the state of a surf resource (cpu, workstation, network, …)
- * 
+ *
  * @param resource The surf resource
  * @return The state of the surf resource
  */
@@ -354,7 +354,7 @@ XBT_PUBLIC(e_surf_resource_state_t) surf_resource_get_state(surf_cpp_resource_t
 
 /**
  * @brief Set the state of a surf resource (cpu, workstation, network, …)
- * 
+ *
  * @param resource The surf resource
  * @param state The new state of the surf resource
  */
@@ -362,17 +362,17 @@ XBT_PUBLIC(void) surf_resource_set_state(surf_cpp_resource_t resource, e_surf_re
 
 /**
  * @brief Get the speed of the cpu associtated to a workstation
- * 
+ *
  * @param resource The surf workstation
  * @param load [description]
- * 
+ *
  * @return [description]
  */
 XBT_PUBLIC(double) surf_workstation_get_speed(surf_resource_t resource, double load);
 
 /**
  * @brief Get the available speed of cpu associtated to a workstation
- * 
+ *
  * @param resource The surf workstation
  * @return [description]
  */
@@ -380,7 +380,7 @@ XBT_PUBLIC(double) surf_workstation_get_available_speed(surf_resource_t resource
 
 /**
  * @brief Get the number of cores of the cpu associated to a workstation
- * 
+ *
  * @param resource The surf workstation
  * @return The number of cores
  */
@@ -391,14 +391,14 @@ XBT_PUBLIC(int) surf_workstation_get_core(surf_resource_t resource);
  *
  * @param resource The surf workstation
  * @param size The value of the processing amount (in flop) needed to process
- * 
+ *
  * @return The surf action corresponding to the processing
  */
 XBT_PUBLIC(surf_action_t) surf_workstation_execute(surf_resource_t resource, double size);
 
 /**
  * @brief Make the workstation sleep
- * 
+ *
  * @param resource The surf workstation
  * @param duration The number of seconds to sleep
  * @return The surf action corresponding to the sleep
@@ -407,27 +407,26 @@ XBT_PUBLIC(surf_action_t) surf_workstation_sleep(surf_resource_t resource, doubl
 
 /**
  * @brief Open a file on a workstation
- * 
+ *
  * @param workstation The surf workstation
- * @param mount The mount point
- * @param path The path to the file
+ * @param fullpath The path to the file
  * @return The surf action corresponding to the openning
  */
-XBT_PUBLIC(surf_action_t) surf_workstation_open(surf_resource_t workstation, const char* mount, const char* path);
+XBT_PUBLIC(surf_action_t) surf_workstation_open(surf_resource_t workstation, const char* fullpath);
 
 /**
  * @brief Close a file descriptor on a workstation
- * 
+ *
  * @param workstation The surf workstation
  * @param fd The file descriptor
- * 
+ *
  * @return The surf action corresponding to the closing
  */
 XBT_PUBLIC(surf_action_t) surf_workstation_close(surf_resource_t workstation, surf_file_t fd);
 
 /**
  * @brief Read a file
- * 
+ *
  * @param resource The surf workstation
  * @param fd The file descriptor to read
  * @param size The size in bytes to read
@@ -437,7 +436,7 @@ XBT_PUBLIC(surf_action_t) surf_workstation_read(surf_resource_t resource, surf_f
 
 /**
  * @brief Write a file
- * 
+ *
  * @param resource The surf workstation
  * @param fd The file descriptor to write
  * @param size The size in bytes to write
@@ -453,7 +452,7 @@ XBT_PUBLIC(surf_action_t) surf_workstation_write(surf_resource_t resource, surf_
  *  - the storage name,
  *  - the storage typeId,
  *  - the storage content type
- * 
+ *
  * @param resource The surf workstation
  * @param fd The file descriptor
  * @return An xbt_dynar_t with the file informations
@@ -462,7 +461,7 @@ XBT_PUBLIC(xbt_dynar_t) surf_workstation_get_info(surf_resource_t resource, surf
 
 /**
  * @brief Get the available space of the storage at the mount point
- * 
+ *
  * @param resource The surf workstation
  * @param name The mount point
  * @return The amount of availble space in bytes
@@ -471,7 +470,7 @@ XBT_PUBLIC(sg_size_t) surf_workstation_get_free_size(surf_resource_t resource, c
 
 /**
  * @brief Get the used space of the storage at the mount point
- * 
+ *
  * @param resource The surf workstation
  * @param name The mount point
  * @return The amount of used space in bytes
@@ -480,7 +479,7 @@ XBT_PUBLIC(sg_size_t) surf_workstation_get_used_size(surf_resource_t resource, c
 
 /**
  * @brief Get the VMs hosted on the workstation
- * 
+ *
  * @param resource The surf workstation
  * @return The list of VMs on the workstation
  */
@@ -489,7 +488,7 @@ XBT_PUBLIC(xbt_dynar_t) surf_workstation_get_vms(surf_resource_t resource);
 /**
  * @brief [brief description]
  * @details [long description]
- * 
+ *
  * @param resource [description]
  * @param params [description]
  */
@@ -498,7 +497,7 @@ XBT_PUBLIC(void) surf_workstation_get_params(surf_resource_t resource, ws_params
 /**
  * @brief [brief description]
  * @details [long description]
- * 
+ *
  * @param resource [description]
  * @param params [description]
  */
@@ -506,42 +505,42 @@ XBT_PUBLIC(void) surf_workstation_set_params(surf_resource_t resource, ws_params
 
 /**
  * @brief Destroy a Workstation VM
- * 
+ *
  * @param resource The surf workstation vm
  */
 XBT_PUBLIC(void) surf_vm_workstation_destroy(surf_resource_t resource);
 
 /**
  * @brief Suspend a Workstation VM
- * 
+ *
  * @param resource The surf workstation vm
  */
 XBT_PUBLIC(void) surf_vm_workstation_suspend(surf_resource_t resource);
 
 /**
  * @brief Resume a Workstation VM
- * 
+ *
  * @param resource The surf workstation vm
  */
 XBT_PUBLIC(void) surf_vm_workstation_resume(surf_resource_t resource);
 
 /**
  * @brief Save the Workstation VM (Not yet implemented)
- * 
+ *
  * @param resource The surf workstation vm
  */
 XBT_PUBLIC(void) surf_vm_workstation_save(surf_resource_t resource);
 
 /**
  * @brief Restore the Workstation VM (Not yet implemented)
- * 
+ *
  * @param resource The surf workstation vm
  */
 XBT_PUBLIC(void) surf_vm_workstation_restore(surf_resource_t resource);
 
 /**
  * @brief Migrate the VM to the destination host
- * 
+ *
  * @param resource The surf workstation vm
  * @param ind_vm_ws_dest The destination host
  */
@@ -549,7 +548,7 @@ XBT_PUBLIC(void) surf_vm_workstation_migrate(surf_resource_t resource, surf_reso
 
 /**
  * @brief Get the physical machine hosting the VM
- * 
+ *
  * @param resource The surf workstation vm
  * @return The physical machine hosting the VM
  */
@@ -558,7 +557,7 @@ XBT_PUBLIC(surf_resource_t) surf_vm_workstation_get_pm(surf_resource_t resource)
 /**
  * @brief [brief description]
  * @details [long description]
- * 
+ *
  * @param resource [description]
  * @param bound [description]
  */
@@ -567,7 +566,7 @@ XBT_PUBLIC(void) surf_vm_workstation_set_bound(surf_resource_t resource, double
 /**
  * @brief [brief description]
  * @details [long description]
- * 
+ *
  * @param resource [description]
  * @param cpu [description]
  * @param mask [description]
@@ -576,7 +575,7 @@ XBT_PUBLIC(void) surf_vm_workstation_set_affinity(surf_resource_t resource, surf
 
 /**
  * @brief Execute some quantity of computation
- * 
+ *
  * @param cpu The surf cpu
  * @param size The value of the processing amount (in flop) needed to process
  * @return The surf action corresponding to the processing
@@ -586,7 +585,7 @@ XBT_PUBLIC(surf_action_t) surf_cpu_execute(surf_resource_t cpu, double size);
 /**
  * @brief Make the cpu sleep for duration (in seconds)
  * @details [long description]
- * 
+ *
  * @param cpu The surf cpu
  * @param duration The number of seconds to sleep
  * @return The surf action corresponding to the sleeping
@@ -596,7 +595,7 @@ XBT_PUBLIC(surf_action_t) surf_cpu_sleep(surf_resource_t cpu, double duration);
 /**
  * @brief Get the workstation power peak
  * @details [long description]
- * 
+ *
  * @param host The surf workstation
  * @return The power peak
  */
@@ -605,10 +604,10 @@ XBT_PUBLIC(double) surf_workstation_get_current_power_peak(surf_resource_t host)
 /**
  * @brief [brief description]
  * @details [long description]
- * 
+ *
  * @param host [description]
  * @param pstate_index [description]
- * 
+ *
  * @return [description]
  */
 XBT_PUBLIC(double) surf_workstation_get_power_peak_at(surf_resource_t host, int pstate_index);
@@ -616,7 +615,7 @@ XBT_PUBLIC(double) surf_workstation_get_power_peak_at(surf_resource_t host, int
 /**
  * @brief [brief description]
  * @details [long description]
- * 
+ *
  * @param host [description]
  * @return [description]
  */
@@ -625,7 +624,7 @@ XBT_PUBLIC(int) surf_workstation_get_nb_pstates(surf_resource_t host);
 /**
  * @brief [brief description]
  * @details [long description]
- * 
+ *
  * @param host [description]
  * @param pstate_index [description]
  */
@@ -633,7 +632,7 @@ XBT_PUBLIC(void) surf_workstation_set_power_peak_at(surf_resource_t host, int ps
 
 /**
  * @brief Get the consumed energy (in joules) of a workstation
- * 
+ *
  * @param host The surf workstation
  * @return The consumed energy
  */
@@ -641,7 +640,7 @@ XBT_PUBLIC(double) surf_workstation_get_consumed_energy(surf_resource_t host);
 
 /**
  * @brief Get the list of storages mounted on a workstation
- * 
+ *
  * @param workstation The surf workstation
  * @return Dictionary of mount point, Storage
  */
@@ -657,48 +656,49 @@ XBT_PUBLIC(xbt_dynar_t) surf_workstation_get_attached_storage_list(surf_resource
 
 /**
  * @brief Unlink a file descriptor
- * 
+ *
  * @param workstation The surf workstation
  * @param fd The file descriptor
- * 
+ *
  * @return 0 if failed to unlink, 1 otherwise
  */
 XBT_PUBLIC(int) surf_workstation_unlink(surf_resource_t workstation, surf_file_t fd);
 
-/**
- * @brief List directory contents of a path
- * @details [long description]
- * 
- * @param workstation The surf workstation
- * @param mount The mount point
- * @param path The path to the directory
- * @return The surf action corresponding to the ls action
- */
-XBT_PUBLIC(surf_action_t) surf_workstation_ls(surf_resource_t workstation, const char* mount, const char *path);
-
 /**
  * @brief Get the size of a file on a workstation
- * 
+ *
  * @param workstation The surf workstation
  * @param fd The file descriptor
- * 
+ *
  * @return The size in bytes of the file
  */
 XBT_PUBLIC(size_t) surf_workstation_get_size(surf_resource_t workstation, surf_file_t fd);
 
 /**
  * @brief Get the current position of the file descriptor
- * 
+ *
  * @param workstation The surf workstation
  * @param fd The file descriptor
  * @return The current position of the file descriptor
  */
 XBT_PUBLIC(size_t) surf_workstation_file_tell(surf_resource_t workstation, surf_file_t fd);
 
+/**
+ * @brief Move a file to another location on the *same mount point*.
+ * @details [long description]
+ *
+ * @param workstation The surf workstation
+ * @param fd The file descriptor
+ * @param fullpath The new full path
+ *
+ * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
+ */
+XBT_PUBLIC(int) surf_workstation_file_move(surf_resource_t workstation, surf_file_t fd, const char* fullpath);
+
 /**
  * @brief Set the position indictator assiociated with the file descriptor to a new position
  * @details [long description]
- * 
+ *
  * @param workstation The surf workstation
  * @param fd The file descriptor
  * @param offset The offset from the origin
@@ -713,7 +713,7 @@ XBT_PUBLIC(int) surf_workstation_file_seek(surf_resource_t workstation, surf_fil
 /**
  * @brief [brief description]
  * @details [long description]
- * 
+ *
  * @param link [description]
  * @return [description]
  */
@@ -721,7 +721,7 @@ XBT_PUBLIC(int) surf_network_link_is_shared(surf_cpp_resource_t link);
 
 /**
  * @brief Get the bandwidth of a link in bytes per second
- * 
+ *
  * @param link The surf link
  * @return The bandwidth in bytes per second
  */
@@ -729,7 +729,7 @@ XBT_PUBLIC(double) surf_network_link_get_bandwidth(surf_cpp_resource_t link);
 
 /**
  * @brief Get the latency of a link in seconds
- * 
+ *
  * @param link The surf link
  * @return The latency in seconds
  */
@@ -737,7 +737,7 @@ XBT_PUBLIC(double) surf_network_link_get_latency(surf_cpp_resource_t link);
 
 /**
  * @brief Get the content of a storage
- * 
+ *
  * @param resource The surf storage
  * @return A xbt_dict_t with path as keys and size in bytes as values
  */
@@ -745,24 +745,32 @@ XBT_PUBLIC(xbt_dict_t) surf_storage_get_content(surf_resource_t resource);
 
 /**
  * @brief Get the size in bytes of a storage
- * 
+ *
  * @param resource The surf storage
  * @return The size in bytes of the storage
  */
 XBT_PUBLIC(sg_size_t) surf_storage_get_size(surf_resource_t resource);
 
 /**
- * @brief Rename a path
- * 
+ * @brief Get the available size in bytes of a storage
+ *
  * @param resource The surf storage
- * @param src The old path
- * @param dest The new path
+ * @return The available size in bytes of the storage
  */
-XBT_PUBLIC(void) surf_storage_rename(surf_resource_t resource, const char* src, const char* dest);
+XBT_PUBLIC(sg_size_t) surf_storage_get_free_size(surf_resource_t resource);
+
+/**
+ * @brief Get the size in bytes of a storage
+ *
+ * @param resource The surf storage
+ * @return The used size in bytes of the storage
+ */
+XBT_PUBLIC(sg_size_t) surf_storage_get_used_size(surf_resource_t resource);
+
 
 /**
  * @brief Get the data associated to the action
- * 
+ *
  * @param action The surf action
  * @return The data associated to the action
  */
@@ -771,7 +779,7 @@ XBT_PUBLIC(void*) surf_action_get_data(surf_action_t action);
 /**
  * @brief Set the data associated to the action
  * @details [long description]
- * 
+ *
  * @param action The surf action
  * @param data The new data associated to the action
  */
@@ -779,14 +787,14 @@ XBT_PUBLIC(void) surf_action_set_data(surf_action_t action, void *data);
 
 /**
  * @brief Unreference an action
- * 
+ *
  * @param action The surf action
  */
 XBT_PUBLIC(void) surf_action_unref(surf_action_t action);
 
 /**
  * @brief Get the start time of an action
- * 
+ *
  * @param action The surf action
  * @return The start time in seconds from the beginning of the simulation
  */
@@ -794,7 +802,7 @@ XBT_PUBLIC(double) surf_action_get_start_time(surf_action_t action);
 
 /**
  * @brief Get the finish time of an action
- * 
+ *
  * @param action The surf action
  * @return The finish time in seconds from the beginning of the simulation
  */
@@ -802,7 +810,7 @@ XBT_PUBLIC(double) surf_action_get_finish_time(surf_action_t action);
 
 /**
  * @brief Get the remains amount of work to do of an action
- * 
+ *
  * @param action The surf action
  * @return  The remains amount of work to do
  */
@@ -810,21 +818,21 @@ XBT_PUBLIC(double) surf_action_get_remains(surf_action_t action);
 
 /**
  * @brief Suspend an action
- * 
+ *
  * @param action The surf action
  */
 XBT_PUBLIC(void) surf_action_suspend(surf_action_t action);
 
 /**
  * @brief Resume an action
- * 
+ *
  * @param action The surf action
  */
 XBT_PUBLIC(void) surf_action_resume(surf_action_t action);
 
 /**
  * @brief Cancel an action
- * 
+ *
  * @param action The surf action
  */
 XBT_PUBLIC(void) surf_action_cancel(surf_action_t action);
@@ -832,7 +840,7 @@ XBT_PUBLIC(void) surf_action_cancel(surf_action_t action);
 /**
  * @brief Set the priority of an action
  * @details [long description]
- * 
+ *
  * @param action The surf action
  * @param priority The new priority [TODO]
  */
@@ -841,15 +849,15 @@ XBT_PUBLIC(void) surf_action_set_priority(surf_action_t action, double priority)
 /**
  * @brief Set the category of an action
  * @details [long description]
- * 
+ *
  * @param action The surf action
  * @param category The new category of the action
  */
 XBT_PUBLIC(void) surf_action_set_category(surf_action_t action, const char *category);
 
 /**
- * @brief Get the state of an action 
- * 
+ * @brief Get the state of an action
+ *
  * @param action The surf action
  * @return The state of the action
  */
@@ -857,7 +865,7 @@ XBT_PUBLIC(e_surf_action_state_t) surf_action_get_state(surf_action_t action);
 
 /**
  * @brief Get the cost of an action
- * 
+ *
  * @param action The surf action
  * @return The cost of the action
  */
@@ -866,7 +874,7 @@ XBT_PUBLIC(double) surf_action_get_cost(surf_action_t action);
 /**
  * @brief [brief desrciption]
  * @details [long description]
- * 
+ *
  * @param action The surf cpu action
  * @param cpu [description]
  * @param mask [description]
@@ -876,7 +884,7 @@ XBT_PUBLIC(void) surf_cpu_action_set_affinity(surf_action_t action, surf_resourc
 /**
  * @brief [brief description]
  * @details [long description]
- * 
+ *
  * @param action The surf cpu action
  * @param bound [description]
  */
@@ -892,7 +900,7 @@ XBT_PUBLIC(double) surf_network_action_get_latency_limited(surf_action_t action)
 
 /**
  * @brief Get the file associated to a storage action
- * 
+ *
  * @param action The surf storage action
  * @return The file associated to a storage action
  */
@@ -900,7 +908,7 @@ XBT_PUBLIC(surf_file_t) surf_storage_action_get_file(surf_action_t action);
 
 /**
  * @brief Get the result dictionary of an ls action
- * 
+ *
  * @param action The surf storage action
  * @return The dictionry listing a path
  */
@@ -923,6 +931,9 @@ XBT_PUBLIC(surf_model_t) surf_resource_model(const void *host, int level);
 /* Implementations of model object */
 /**************************************/
 
+XBT_PUBLIC_DATA(int) autoload_surf_cpu_model;
+XBT_PUBLIC_DATA(void_f_void_t) surf_cpu_model_init_preparse;
+
 /** \ingroup SURF_models
  *  \brief The CPU model object for the physical machine layer
  */
@@ -1216,7 +1227,7 @@ XBT_PUBLIC(xbt_dict_t) watched_hosts_lib;
 /*******************************************/
 /*** SURF Platform *************************/
 /*******************************************/
-XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void); 
+XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void);
 XBT_PUBLIC_DATA(const char *) surf_AS_get_name(AS_t as);
 XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_routing_sons(AS_t as);
 XBT_PUBLIC_DATA(const char *) surf_AS_get_model(AS_t as);
@@ -1236,7 +1247,7 @@ XBT_PUBLIC_DATA(e_surf_network_element_type_t) surf_routing_edge_get_rc_type(sg_
  *
  *  This function has to be called to initialize the common
  *  structures.  Then you will have to create the environment by
- *  calling 
+ *  calling
  *  e.g. surf_workstation_model_init_CM02()
  *
  *  \see surf_workstation_model_init_CM02(), surf_workstation_model_init_compound(), surf_exit()
index 39e743a..7864e2c 100644 (file)
@@ -4,26 +4,29 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include <libgen.h>
+#define _GNU_SOURCE
+#define UNW_LOCAL_ONLY
+
+#include <string.h>
+#include <link.h>
 #include "mc_private.h"
 #include "xbt/module.h"
+#include <xbt/mmalloc.h>
+#include "../smpi/private.h"
+
+#include "xbt/mmalloc/mmprivate.h"
 
 #include "../simix/smx_private.h"
 
 #include <libunwind.h>
+#include <libelf.h>
+
+#include "mc_private.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
                                 "Logging specific to mc_checkpoint");
 
-void *start_text_libsimgrid;
-void *start_plt_libsimgrid, *end_plt_libsimgrid;
-void *start_got_plt_libsimgrid, *end_got_plt_libsimgrid;
-void *start_plt_binary, *end_plt_binary;
-void *start_got_plt_binary, *end_got_plt_binary;
 char *libsimgrid_path;
-void *start_data_libsimgrid, *start_bss_libsimgrid;
-void *start_data_binary, *start_bss_binary;
-void *start_text_binary;
 
 /************************************  Free functions **************************************/
 /*****************************************************************************************/
@@ -31,6 +34,7 @@ void *start_text_binary;
 static void MC_snapshot_stack_free(mc_snapshot_stack_t s){
   if(s){
     xbt_dynar_free(&(s->local_variables));
+    xbt_dynar_free(&(s->stack_frames));
     xbt_free(s);
   }
 }
@@ -40,9 +44,7 @@ static void MC_snapshot_stack_free_voidp(void *s){
 }
 
 static void local_variable_free(local_variable_t v){
-  xbt_free(v->frame);
   xbt_free(v->name);
-  xbt_free(v->type);
   xbt_free(v);
 }
 
@@ -52,7 +54,7 @@ static void local_variable_free_voidp(void *v){
 
 static void MC_region_destroy(mc_mem_region_t reg)
 {
-  xbt_free(reg->data);
+  munmap(reg->data, reg->size);
   xbt_free(reg);
 }
 
@@ -64,6 +66,15 @@ void MC_free_snapshot(mc_snapshot_t snapshot){
   xbt_free(snapshot->stack_sizes);
   xbt_dynar_free(&(snapshot->stacks));
   xbt_dynar_free(&(snapshot->to_ignore));
+
+  if(snapshot->privatization_regions){
+    size_t n = snapshot->nb_processes;
+    for(i=0; i!=n; ++i) {
+      MC_region_destroy(snapshot->privatization_regions[i]);
+    }
+    xbt_free(snapshot->privatization_regions);
+  }
+
   xbt_free(snapshot);
 }
 
@@ -73,11 +84,13 @@ void MC_free_snapshot(mc_snapshot_t snapshot){
 
 static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
 {
-  mc_mem_region_t new_reg = xbt_new0(s_mc_mem_region_t, 1);
+  mc_mem_region_t new_reg = xbt_new(s_mc_mem_region_t, 1);
   new_reg->start_addr = start_addr;
   new_reg->size = size;
-  new_reg->data = xbt_malloc0(size);
+  new_reg->data = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
   memcpy(new_reg->data, start_addr, size);
+  mprotect(new_reg->data, size, PROT_READ);
+  madvise(new_reg->data, size, MADV_MERGEABLE);
 
   XBT_DEBUG("New region : type : %d, data : %p (real addr %p), size : %zu", type, new_reg->data, start_addr, size);
   
@@ -101,562 +114,290 @@ static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start
 } 
 
 static void MC_get_memory_regions(mc_snapshot_t snapshot){
-
-  FILE *fp;
-  char *line = NULL;
-  ssize_t read;
-  size_t n = 0;
-  
-  char *lfields[6] = {0}, *tok;
-  void *start_addr, *start_addr1, *end_addr;
-  size_t size;
-  int i;
-
-  fp = fopen("/proc/self/maps", "r");
-  
-  xbt_assert(fp, 
-             "Cannot open /proc/self/maps to investigate the memory map of the process. Please report this bug.");
-
-  setbuf(fp, NULL);
-
-  while((read = xbt_getline(&line, &n, fp)) != -1){
-
-    /* Wipeout the new line character */
-    line[read - 1] = '\0';
-
-    /* Tokenize the line using spaces as delimiters and store each token */
-    lfields[0] = strtok(line, " ");
-
-    for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
-      lfields[i] = strtok(NULL, " ");
+  size_t i;
+
+  void* start_heap = ((xbt_mheap_t)std_heap)->base;
+  void* end_heap   = ((xbt_mheap_t)std_heap)->breakval;
+  MC_snapshot_add_region(snapshot, 0, start_heap, (char*) end_heap - (char*) start_heap);
+  snapshot->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
+
+  MC_snapshot_add_region(snapshot, 1,  mc_libsimgrid_info->start_rw, mc_libsimgrid_info->end_rw - mc_libsimgrid_info->start_rw);
+  if(!smpi_privatize_global_variables) {
+    MC_snapshot_add_region(snapshot, 2,  mc_binary_info->start_rw, mc_binary_info->end_rw - mc_binary_info->start_rw);
+    snapshot->privatization_regions = NULL;
+    snapshot->privatization_index = -1;
+  } else {
+    snapshot->privatization_regions = xbt_new(mc_mem_region_t, SIMIX_process_count());
+    for (i=0; i< SIMIX_process_count(); i++){
+      snapshot->privatization_regions[i] = MC_region_new(-1, mappings[i], size_data_exe);
     }
-
-    /* First get the permissions flags, need write permission */
-    if(lfields[1][1] == 'w'){
-
-      /* Get the start address of the map */
-      tok = strtok(lfields[0], "-");
-      start_addr = (void *)strtoul(tok, NULL, 16);
-    
-      if(start_addr == std_heap){     /* Std_heap ? */
-        tok = strtok(NULL, "-");
-        end_addr = (void *)strtoul(tok, NULL, 16);
-        MC_snapshot_add_region(snapshot, 0, start_addr, (char*)end_addr - (char*)start_addr);
-        snapshot->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
-      }else{ /* map name == libsimgrid || binary_name ? */
-        if(lfields[5] != NULL){
-          if(!memcmp(basename(lfields[5]), "libsimgrid", 10)){
-            tok = strtok(NULL, "-");
-            end_addr = (void *)strtoul(tok, NULL, 16);
-            size = (char*)end_addr - (char*)start_addr;
-            /* BSS and data segments may be separated according to the OS */
-            if((read = xbt_getline(&line, &n, fp)) != -1){
-              line[read - 1] = '\0';
-              lfields[0] = strtok(line, " ");
-              for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
-                lfields[i] = strtok(NULL, " ");
-              }
-              if(lfields[1][1] == 'w' && lfields[5] == NULL){
-                tok = strtok(lfields[0], "-");
-                start_addr1 = (void *)strtoul(tok, NULL, 16);
-                tok = strtok(NULL, "-");
-                size += (char *)(void *)strtoul(tok, NULL, 16) - (char*)start_addr1;
-              }
-            }
-            MC_snapshot_add_region(snapshot, 1, start_addr, size);
-          }else if(!memcmp(basename(lfields[5]), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
-            tok = strtok(NULL, "-");
-            end_addr = (void *)strtoul(tok, NULL, 16);
-            size = (char*)end_addr - (char*)start_addr;
-             /* BSS and data segments may be separated according to the OS */
-            if((read = xbt_getline(&line, &n, fp)) != -1){
-              line[read - 1] = '\0';
-              lfields[0] = strtok(line, " ");
-              for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
-                lfields[i] = strtok(NULL, " ");
-              }
-              tok = strtok(lfields[0], "-");
-              start_addr1 = (void *)strtoul(tok, NULL, 16);
-              if(lfields[1][1] == 'w' && lfields[5] == NULL){
-                if(start_addr1 == std_heap){     /* Std_heap ? */
-                  tok = strtok(NULL, "-");
-                  end_addr = (void *)strtoul(tok, NULL, 16);
-                  MC_snapshot_add_region(snapshot, 0, start_addr1, (char*)end_addr - (char*)start_addr1);
-                  snapshot->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
-                }else if(start_addr1 != raw_heap){
-                  tok = strtok(NULL, "-");
-                  size += (char *)(void *)strtoul(tok, NULL, 16) - (char *)start_addr1;
-                }
-              }
-            }
-            MC_snapshot_add_region(snapshot, 2, start_addr, size);
-          }else if (!memcmp(lfields[5], "[stack]", 7)){
-            maestro_stack_start = start_addr;
-            tok = strtok(NULL, "-");
-            maestro_stack_end = (void *)strtoul(tok, NULL, 16);
-          }
-        }
-      }
-    }
-    
+    snapshot->privatization_index = loaded_page;
   }
-
-  free(line);
-  fclose(fp);
-
 }
 
+/** @brief Finds the range of the different memory segments and binary paths */
 void MC_init_memory_map_info(){
  
   unsigned int i = 0;
   s_map_region_t reg;
   memory_map_t maps = MC_get_memory_map();
 
+  maestro_stack_start = NULL;
+  maestro_stack_end = NULL;
+  libsimgrid_path = NULL;
+
   while (i < maps->mapsize) {
     reg = maps->regions[i];
-    if ((reg.prot & PROT_WRITE)){
-      if (maps->regions[i].pathname != NULL){
-        if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
-          start_data_libsimgrid = reg.start_addr;
-          i++;
-          reg = maps->regions[i];
-          if(reg.pathname == NULL && (reg.prot & PROT_WRITE) && i < maps->mapsize)
-            start_bss_libsimgrid = reg.start_addr;
-        }else if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
-          start_data_binary = reg.start_addr;
-          i++;
-          reg = maps->regions[i];
-          if(reg.pathname == NULL && (reg.prot & PROT_WRITE) && reg.start_addr != std_heap && reg.start_addr != raw_heap && i < maps->mapsize){
-            start_bss_binary = reg.start_addr;
-            i++;
-          }
-        }else if(!memcmp(maps->regions[i].pathname, "[stack]", 7)){
+    if (maps->regions[i].pathname == NULL) {
+      // Nothing to do
+    }
+    else if ((reg.prot & PROT_WRITE) && !memcmp(maps->regions[i].pathname, "[stack]", 7)){
           maestro_stack_start = reg.start_addr;
           maestro_stack_end = reg.end_addr;
-          i++;
-        }
-      }
-    }else if ((reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)){
-      if (maps->regions[i].pathname != NULL){
-        if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
-          start_text_libsimgrid = reg.start_addr;
+    } else if ((reg.prot & PROT_READ) && (reg.prot & PROT_EXEC) && !memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
+      if(libsimgrid_path == NULL)
           libsimgrid_path = strdup(maps->regions[i].pathname);
-        }else if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
-          start_text_binary = reg.start_addr;
-        }
-      }
     }
     i++;
   }
-   
-  MC_free_memory_map(maps);
-
-}
 
-void MC_get_libsimgrid_plt_section(){
+  xbt_assert(maestro_stack_start, "maestro_stack_start");
+  xbt_assert(maestro_stack_end, "maestro_stack_end");
+  xbt_assert(libsimgrid_path, "libsimgrid_path&");
 
-  FILE *fp;
-  char *line = NULL;            /* Temporal storage for each line that is readed */
-  ssize_t read;                 /* Number of bytes readed */
-  size_t n = 0;                 /* Amount of bytes to read by xbt_getline */
-
-  char *lfields[7];
-  int i, plt_found = 0;
-  unsigned long int size, offset;
-
-  char *command = bprintf("objdump --section-headers %s", libsimgrid_path);
+  MC_free_memory_map(maps);
 
-  fp = popen(command, "r");
+}
 
-  if(fp == NULL){
-    perror("popen failed");
-    xbt_abort();
+/** \brief Fill/lookup the "subtype" field.
+ */
+static void MC_resolve_subtype(mc_object_info_t info, dw_type_t type) {
+
+  if(type->dw_type_id==NULL)
+    return;
+  type->subtype = xbt_dict_get_or_null(info->types, type->dw_type_id);
+  if(type->subtype==NULL)
+    return;
+  if(type->subtype->byte_size != 0)
+    return;
+  if(type->subtype->name==NULL)
+    return;
+  // Try to find a more complete description of the type:
+  // We need to fix in order to support C++.
+
+  dw_type_t subtype = xbt_dict_get_or_null(info->full_types_by_name, type->subtype->name);
+  if(subtype!=NULL) {
+    type->subtype = subtype;
   }
 
-  while ((read = xbt_getline(&line, &n, fp)) != -1 && plt_found != 2) {
-
-    if(n == 0)
-      continue;
-
-    /* Wipeout the new line character */
-    line[read - 1] = '\0';
-
-    lfields[0] = strtok(line, " ");
-
-    if(lfields[0] == NULL)
-      continue;
-
-    if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strncmp(lfields[0], libsimgrid_path, strlen(libsimgrid_path)) == 0)
-      continue;
+}
 
-    for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
-      lfields[i] = strtok(NULL, " ");
-    }
+void MC_post_process_types(mc_object_info_t info) {
+  xbt_dict_cursor_t cursor = NULL;
+  char *origin;
+  dw_type_t type;
 
-    if(i>=6){
-      if(strcmp(lfields[1], ".plt") == 0){
-        size = strtoul(lfields[2], NULL, 16);
-        offset = strtoul(lfields[5], NULL, 16);
-        start_plt_libsimgrid = (char *)start_text_libsimgrid + offset;
-        end_plt_libsimgrid = (char *)start_plt_libsimgrid + size;
-        plt_found++;
-      }else if(strcmp(lfields[1], ".got.plt") == 0){
-        size = strtoul(lfields[2], NULL, 16);
-        offset = strtoul(lfields[5], NULL, 16);
-        start_got_plt_libsimgrid = (char *)start_text_libsimgrid + offset;
-        end_got_plt_libsimgrid = (char *)start_got_plt_libsimgrid + size;
-        plt_found++;
-       }
+  // Lookup "subtype" field:
+  xbt_dict_foreach(info->types, cursor, origin, type){
+    MC_resolve_subtype(info, type);
 
+    dw_type_t member;
+    unsigned int i = 0;
+    if(type->members!=NULL) xbt_dynar_foreach(type->members, i, member) {
+      MC_resolve_subtype(info, member);
     }
-    
   }
-
-  xbt_free(command);
-  xbt_free(line);
-  pclose(fp);
-
 }
 
-void MC_get_binary_plt_section(){
-
-  FILE *fp;
-  char *line = NULL;            /* Temporal storage for each line that is readed */
-  ssize_t read;                 /* Number of bytes readed */
-  size_t n = 0;                 /* Amount of bytes to read by xbt_getline */
+/** \brief Fills the position of the segments (executable, read-only, read/write).
+ *
+ * TODO, use dl_iterate_phdr to be more robust
+ * */
+void MC_find_object_address(memory_map_t maps, mc_object_info_t result) {
 
-  char *lfields[7];
-  int i, plt_found = 0;
-  unsigned long int size;
-
-  char *command = bprintf( "objdump --section-headers %s", xbt_binary_name);
-
-  fp = popen(command, "r");
-
-  if(fp == NULL){
-    perror("popen failed");
-    xbt_abort();
+  unsigned int i = 0;
+  s_map_region_t reg;
+  const char* name = basename(result->file_name);
+  while (i < maps->mapsize) {
+    reg = maps->regions[i];
+    if (maps->regions[i].pathname == NULL || strcmp(basename(maps->regions[i].pathname),  name)) {
+      // Nothing to do
+    }
+    else if ((reg.prot & PROT_WRITE)){
+          xbt_assert(!result->start_rw,
+            "Multiple read-write segments for %s, not supported",
+            maps->regions[i].pathname);
+          result->start_rw = reg.start_addr;
+          result->end_rw   = reg.end_addr;
+          // .bss is usually after the .data:
+          s_map_region_t* next = &(maps->regions[i+1]);
+          if(next->pathname == NULL && (next->prot & PROT_WRITE) && next->start_addr == reg.end_addr) {
+            result->end_rw = maps->regions[i+1].end_addr;
+          }
+    } else if ((reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)){
+          xbt_assert(!result->start_exec,
+            "Multiple executable segments for %s, not supported",
+            maps->regions[i].pathname);
+          result->start_exec = reg.start_addr;
+          result->end_exec   = reg.end_addr;
+    }
+    else if((reg.prot & PROT_READ) && !(reg.prot & PROT_EXEC)) {
+        xbt_assert(!result->start_ro,
+          "Multiple read only segments for %s, not supported",
+          maps->regions[i].pathname);
+        result->start_ro = reg.start_addr;
+        result->end_ro   = reg.end_addr;
+    }
+    i++;
   }
 
-  while ((read = xbt_getline(&line, &n, fp)) != -1 && plt_found != 2) {
+  xbt_assert(result->file_name);
+  xbt_assert(result->start_rw);
+  xbt_assert(result->start_exec);
+}
 
-    if(n == 0)
-      continue;
+/************************************* Take Snapshot ************************************/
+/****************************************************************************************/
 
-    /* Wipeout the new line character */
-    line[read - 1] = '\0';
+/** \brief Checks whether the variable is in scope for a given IP.
+ *
+ *  A variable may be defined only from a given value of IP.
+ *
+ *  \param var   Variable description
+ *  \param frame Scope description
+ *  \param ip    Instruction pointer
+ *  \return      true if the variable is valid
+ * */
+static bool mc_valid_variable(dw_variable_t var, dw_frame_t frame, const void* ip) {
+  // The variable is not yet valid:
+  if((const void*)((const char*) frame->low_pc + var->start_scope) > ip)
+    return false;
+  else
+    return true;
+}
 
-    lfields[0] = strtok(line, " ");
+static void mc_fill_local_variables_values(mc_stack_frame_t stack_frame, dw_frame_t scope, xbt_dynar_t result) {
+  void* ip = (void*) stack_frame->ip;
+  if(ip < scope->low_pc || ip>= scope->high_pc)
+    return;
 
-    if(lfields[0] == NULL)
-      continue;
+  unsigned cursor = 0;
+  dw_variable_t current_variable;
+  xbt_dynar_foreach(scope->variables, cursor, current_variable){
 
-    if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strncmp(lfields[0], basename(xbt_binary_name), strlen(xbt_binary_name)) == 0)
+    if(!mc_valid_variable(current_variable, stack_frame->frame, (void*) stack_frame->ip))
       continue;
 
-    for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
-      lfields[i] = strtok(NULL, " ");
+    int region_type;
+    if((long)stack_frame->ip > (long)mc_libsimgrid_info->start_exec)
+      region_type = 1;
+    else
+      region_type = 2;
+
+    local_variable_t new_var = xbt_new0(s_local_variable_t, 1);
+    new_var->subprogram = stack_frame->frame;
+    new_var->ip = stack_frame->ip;
+    new_var->name = xbt_strdup(current_variable->name);
+    new_var->type = current_variable->type;
+    new_var->region= region_type;
+
+    /* if(current_variable->address!=NULL) {
+      new_var->address = current_variable->address;
+    } else */
+    if(current_variable->locations.size != 0){
+      new_var->address = (void*) mc_dwarf_resolve_locations(&current_variable->locations,
+        current_variable->object_info,
+        &(stack_frame->unw_cursor), (void*)stack_frame->frame_base, NULL);
     }
 
-    if(i>=6){
-      if(strcmp(lfields[1], ".plt") == 0){
-        size = strtoul(lfields[2], NULL, 16);
-        start_plt_binary = (void *)strtoul(lfields[3], NULL, 16);
-        end_plt_binary = (char *)start_plt_binary + size;
-        plt_found++;
-      }else if(strcmp(lfields[1], ".got.plt") == 0){
-        size = strtoul(lfields[2], NULL, 16);
-        start_got_plt_binary = (char *)strtoul(lfields[3], NULL, 16);
-        end_got_plt_binary = (char *)start_got_plt_binary + size;
-        plt_found++;
-       }
-    }
-    
-    
+    xbt_dynar_push(result, &new_var);
   }
 
-  xbt_free(command);
-  xbt_free(line);
-  pclose(fp);
-
+  // Recursive processing of nested scopes:
+  dw_frame_t nested_scope = NULL;
+  xbt_dynar_foreach(scope->scopes, cursor, nested_scope) {
+    mc_fill_local_variables_values(stack_frame, nested_scope, result);
+  }
 }
 
-/************************************* Take Snapshot ************************************/
-/****************************************************************************************/
+static xbt_dynar_t MC_get_local_variables_values(xbt_dynar_t stack_frames){
 
-static void MC_get_hash_global(char *snapshot_hash, void *data1, void *data2){
-  
-  /* unsigned int cursor = 0; */
-  /* size_t offset;  */
-  /* global_variable_t current_var;  */
-  /* void *addr_pointed = NULL; */
-  /* void *res = NULL; */
+  unsigned cursor1 = 0;
+  mc_stack_frame_t stack_frame;
+  xbt_dynar_t variables = xbt_dynar_new(sizeof(local_variable_t), local_variable_free_voidp);
 
-  /* xbt_strbuff_t clear = xbt_strbuff_new(); */
-  
-  /* xbt_dynar_foreach(mc_global_variables, cursor, current_var){ */
-  /*   if(current_var->address < start_data_libsimgrid){ /\* binary *\/ */
-  /*     offset = (char *)current_var->address - (char *)start_data_binary; */
-  /*     addr_pointed = *((void **)((char *)data2 + offset)); */
-  /*     if(((addr_pointed >= start_plt_binary && addr_pointed <= end_plt_binary)) || ((addr_pointed >= std_heap && (char *)addr_pointed <= (char *)std_heap + STD_HEAP_SIZE ))) */
-  /*       continue; */
-  /*     res = xbt_malloc0(current_var->size + 1); */
-  /*     memset(res, 0, current_var->size + 1); */
-  /*     memcpy(res, (char*)data2 + offset, current_var->size); */
-  /*   }else{ /\* libsimgrid *\/ */
-  /*     offset = (char *)current_var->address - (char *)start_data_libsimgrid; */
-  /*     addr_pointed = *((void **)((char *)data1 + offset)); */
-  /*     if((addr_pointed >= start_plt_libsimgrid && addr_pointed <= end_plt_libsimgrid) || (addr_pointed >= std_heap && (char *)addr_pointed <= (char *)std_heap + STD_HEAP_SIZE )) */
-  /*       continue; */
-  /*     res = xbt_malloc0(current_var->size + 1); */
-  /*     memset(res, 0, current_var->size + 1); */
-  /*     memcpy(res, (char*)data1 + offset, current_var->size); */
-  /*   } */
-  /*   if(res != NULL){ */
-  /*     xbt_strbuff_append(clear, (const char*)res); */
-  /*     xbt_free(res); */
-  /*     res = NULL; */
-  /*   } */
-  /* } */
-
-  /* xbt_sha(clear->data, snapshot_hash); */
-
-  /* xbt_strbuff_free(clear); */
+  xbt_dynar_foreach(stack_frames,cursor1,stack_frame) {
+    mc_fill_local_variables_values(stack_frame, stack_frame->frame, variables);
+  }
 
+  return variables;
 }
 
-static void MC_get_hash_local(char *snapshot_hash, xbt_dynar_t stacks){
-
-  /* xbt_dynar_t tokens = NULL, s_tokens = NULL; */
-  /* unsigned int cursor1 = 0, cursor2 = 0; */
-  /* mc_snapshot_stack_t current_stack; */
-  /* char *frame_name = NULL; */
-  /* void *addr; */
-
-  /* xbt_strbuff_t clear = xbt_strbuff_new(); */
-
-  /* while(cursor1 < xbt_dynar_length(stacks)){ */
-  /*   current_stack = xbt_dynar_get_as(stacks, cursor1, mc_snapshot_stack_t); */
-  /*   tokens = xbt_str_split(current_stack->local_variables->data, NULL); */
-  /*   cursor2 = 0; */
-  /*   while(cursor2 < xbt_dynar_length(tokens)){ */
-  /*     s_tokens = xbt_str_split(xbt_dynar_get_as(tokens, cursor2, char *), "="); */
-  /*     if(xbt_dynar_length(s_tokens) > 1){ */
-  /*       if(strcmp(xbt_dynar_get_as(s_tokens, 0, char *), "frame_name") == 0){ */
-  /*         xbt_free(frame_name); */
-  /*         frame_name = xbt_strdup(xbt_dynar_get_as(s_tokens, 1, char *)); */
-  /*         xbt_strbuff_append(clear, (const char*)xbt_dynar_get_as(tokens, cursor2, char *)); */
-  /*         cursor2++; */
-  /*         xbt_dynar_free(&s_tokens); */
-  /*         continue; */
-  /*       } */
-  /*       addr = (void *) strtoul(xbt_dynar_get_as(s_tokens, 1, char *), NULL, 16); */
-  /*       if(addr > std_heap && (char *)addr <= (char *)std_heap + STD_HEAP_SIZE){ */
-  /*         cursor2++; */
-  /*         xbt_dynar_free(&s_tokens); */
-  /*         continue; */
-  /*       } */
-  /*       if(is_stack_ignore_variable(frame_name, xbt_dynar_get_as(s_tokens, 0, char *))){ */
-  /*         cursor2++; */
-  /*         xbt_dynar_free(&s_tokens); */
-  /*         continue; */
-  /*       } */
-  /*       xbt_strbuff_append(clear, (const char *)xbt_dynar_get_as(tokens, cursor2, char *)); */
-  /*     } */
-  /*     xbt_dynar_free(&s_tokens); */
-  /*     cursor2++; */
-  /*   } */
-  /*   xbt_dynar_free(&tokens); */
-  /*   cursor1++; */
-  /* } */
-
-  /* xbt_free(frame_name); */
-
-  /* xbt_sha(clear->data, snapshot_hash); */
-
-  /* xbt_strbuff_free(clear); */
-
+static void MC_stack_frame_free_voipd(void *s){
+  mc_stack_frame_t stack_frame = *(mc_stack_frame_t*)s;
+  if(stack_frame) {
+    xbt_free(stack_frame->frame_name);
+    xbt_free(stack_frame);
+  }
 }
 
-static xbt_dynar_t MC_get_local_variables_values(void *stack_context){
-  
+static xbt_dynar_t MC_unwind_stack_frames(void *stack_context) {
+  xbt_dynar_t result = xbt_dynar_new(sizeof(mc_stack_frame_t), MC_stack_frame_free_voipd);
+
   unw_cursor_t c;
-  int ret;
 
-  char frame_name[256];
-  
-  ret = unw_init_local(&c, (unw_context_t *)stack_context);
-  if(ret < 0){
-    XBT_INFO("unw_init_local failed");
-    xbt_abort();
-  }
+  // TODO, check condition check (unw_init_local==0 means end of frame)
+  if(unw_init_local(&c, (unw_context_t *)stack_context)!=0) {
 
-  unw_word_t ip, sp, off;
-  dw_frame_t frame;
+    xbt_die("Could not initialize stack unwinding");
 
-  unsigned int cursor = 0;
-  dw_variable_t current_variable;
-  dw_location_entry_t entry = NULL;
-  dw_location_t location_entry = NULL;
-  unw_word_t res;
-  int frame_found = 0, region_type;
-  void *frame_pointer_address = NULL;
-  unsigned long true_ip, value;
-  int stop = 0;
+  } else while(1) {
 
-  xbt_dynar_t variables = xbt_dynar_new(sizeof(local_variable_t), local_variable_free_voidp);
+    mc_stack_frame_t stack_frame = xbt_new(s_mc_stack_frame_t, 1);
+    xbt_dynar_push(result, &stack_frame);
 
-  while(ret >= 0 && !stop){
+    stack_frame->unw_cursor = c;
+
+    unw_word_t ip, sp;
 
     unw_get_reg(&c, UNW_REG_IP, &ip);
     unw_get_reg(&c, UNW_REG_SP, &sp);
 
-    unw_get_proc_name(&c, frame_name, sizeof (frame_name), &off);
+    stack_frame->ip = ip;
+    stack_frame->sp = sp;
 
-    if(!strcmp(frame_name, "smx_ctx_sysv_wrapper")) /* Stop before context switch with maestro */
-      stop = 1;
+    // TODO, use real addresses in frame_t instead of fixing it here
 
-    if((uintptr_t)ip > (uintptr_t)start_text_libsimgrid)
-      frame = xbt_dict_get_or_null(mc_local_variables_libsimgrid, frame_name);
-    else
-      frame = xbt_dict_get_or_null(mc_local_variables_binary, frame_name);
+    dw_frame_t frame = MC_find_function_by_ip((void*) ip);
+    stack_frame->frame = frame;
 
-    if(frame == NULL){
-      ret = unw_step(&c);
-      continue;
+    if(frame) {
+      stack_frame->frame_name = xbt_strdup(frame->name);
+      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;
     }
-    
-    true_ip = (unsigned long)frame->low_pc + (unsigned long)off;
-    frame_pointer_address = NULL;
-
-    /* Get frame pointer */
-    switch(frame->frame_base->type){
-    case e_dw_loclist:
-      cursor = 0;
-      while(cursor < xbt_dynar_length(frame->frame_base->location.loclist) && !frame_found){
-        entry = xbt_dynar_get_as(frame->frame_base->location.loclist, cursor, dw_location_entry_t);
-        if((true_ip >= entry->lowpc) && (true_ip < entry->highpc)){
-          frame_found = 1;
-          switch(entry->location->type){
-          case e_dw_compose:
-            if(xbt_dynar_length(entry->location->location.compose) > 1){
-              frame_pointer_address = NULL; /* TODO : location list with optimizations enabled */
-            }else{
-              location_entry = xbt_dynar_get_as(entry->location->location.compose, 0, dw_location_t);
-              switch(location_entry->type){
-              case e_dw_register:
-                unw_get_reg(&c, location_entry->location.reg, &res);
-                frame_pointer_address = (void*)(uintptr_t)res;
-                break;
-              case e_dw_bregister_op:
-                unw_get_reg(&c, location_entry->location.breg_op.reg, &res);
-                frame_pointer_address = (void*)((uintptr_t)res + location_entry->location.breg_op.offset);
-                break;
-              default:
-                frame_pointer_address = NULL; /* FIXME : implement other cases (with optimizations enabled) */
-                break;
-              }
-            }
-            break;
-          default:
-            frame_pointer_address = NULL; /* FIXME : implement other cases (with optimizations enabled) */
-            break;
-          }
-        }
-        cursor++;
-      }
-      break;
-    default :
-      frame_pointer_address = NULL; /* FIXME : implement other cases (with optimizations enabled)*/
-      break;
-    }
-
-    frame_found = 0;
-    cursor = 0;
-
-    xbt_dynar_foreach(frame->variables, cursor, current_variable){
-      
-      if((uintptr_t)ip > (uintptr_t)start_text_libsimgrid)
-        region_type = 1;
-      else
-        region_type = 2;
-
-      local_variable_t new_var = xbt_new0(s_local_variable_t, 1);
-      new_var->frame = xbt_strdup(frame_name);
-      new_var->ip = (unsigned long)ip;
-      new_var->name = xbt_strdup(current_variable->name);
-      new_var->type = strdup(current_variable->type_origin);
-      new_var->region= region_type;
-      
-      if(current_variable->address.location != NULL){
-        switch(current_variable->address.location->type){
-        case e_dw_compose:
-          if(xbt_dynar_length(current_variable->address.location->location.compose) > 1){
-            /* TODO : location list with optimizations enabled */
-          }else{
-            location_entry = xbt_dynar_get_as(current_variable->address.location->location.compose, 0, dw_location_t);
-            
-            switch(location_entry->type){
-            case e_dw_register:
-              unw_get_reg(&c, location_entry->location.reg, &res);
-              value = (unsigned long)res;
-              break;
-            case e_dw_bregister_op:
-              unw_get_reg(&c, location_entry->location.breg_op.reg, &res);
-              value = (unsigned long)res + location_entry->location.breg_op.offset;
-              break;
-            case e_dw_fbregister_op:
-              if(frame_pointer_address != NULL)
-                value = (unsigned long)((char *)frame_pointer_address + location_entry->location.fbreg_op);
-              else
-                value = 0;
-              break;
-            default:
-              value = 0; /* FIXME : implement other cases (with optimizations enabled)*/
-              break;
-            }
-
-            if(value)
-              new_var->address = (void *)value;
-            else
-              new_var->address = NULL;
-          }
-          break;
-        default :
-          break;
-        }
-      }
 
-      xbt_dynar_push(variables, &new_var);
+    /* 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.");
     }
-
-    ret = unw_step(&c);
-     
   }
 
-  return variables;
-
-}
-
-
-static void *MC_get_stack_pointer(void *stack_context, void *heap){
-
-  unw_cursor_t c;
-  int ret;
-  unw_word_t sp;
-
-  ret = unw_init_local(&c, (unw_context_t *)stack_context);
-  if(ret < 0){
+  if(xbt_dynar_length(result) == 0){
     XBT_INFO("unw_init_local failed");
     xbt_abort();
   }
 
-  unw_get_reg(&c, UNW_REG_SP, &sp);
-
-  return (char *)heap + ((char *)sp - (char*)std_heap);
-
-}
+  return result;
+};
 
 static xbt_dynar_t MC_take_snapshot_stacks(mc_snapshot_t *snapshot, void *heap){
 
@@ -667,8 +408,12 @@ static xbt_dynar_t MC_take_snapshot_stacks(mc_snapshot_t *snapshot, void *heap){
   
   xbt_dynar_foreach(stacks_areas, cursor, current_stack){
     mc_snapshot_stack_t st = xbt_new(s_mc_snapshot_stack_t, 1);
-    st->local_variables = MC_get_local_variables_values(current_stack->context);
-    st->stack_pointer = MC_get_stack_pointer(current_stack->context, heap);
+    st->stack_frames = MC_unwind_stack_frames(current_stack->context);
+    st->local_variables = MC_get_local_variables_values(st->stack_frames);
+
+    unw_word_t sp = xbt_dynar_get_as(st->stack_frames, 0, mc_stack_frame_t)->sp;
+    st->stack_pointer = ((char *)heap + (size_t)(((char *)((long)sp) - (char*)std_heap)));
+
     st->real_address = current_stack->address;
     xbt_dynar_push(res, &st);
     (*snapshot)->stack_sizes = xbt_realloc((*snapshot)->stack_sizes, (cursor + 1) * sizeof(size_t));
@@ -737,8 +482,14 @@ mc_snapshot_t MC_take_snapshot(int num_state){
 
   if(_sg_mc_visited > 0 || strcmp(_sg_mc_property_file,"")){
     snapshot->stacks = MC_take_snapshot_stacks(&snapshot, snapshot->regions[0]->data);
-    //MC_get_hash_global(snapshot->hash_global, snapshot->regions[1]->data, snapshot->regions[2]->data);
-    //MC_get_hash_local(snapshot->hash_local, snapshot->stacks);
+    if(_sg_mc_hash && snapshot->stacks!=NULL) {
+      snapshot->hash = mc_hash_processes_state(num_state, snapshot->stacks);
+    } else {
+      snapshot->hash = 0;
+    }
+  }
+  else {
+    snapshot->hash = 0;
   }
 
   if(num_state > 0)
@@ -751,9 +502,60 @@ mc_snapshot_t MC_take_snapshot(int num_state){
 void MC_restore_snapshot(mc_snapshot_t snapshot){
   unsigned int i;
   for(i=0; i < NB_REGIONS; i++){
-    MC_region_restore(snapshot->regions[i]);
+    // For privatized, variables we decided it was not necessary to take the snapshot:
+    if(snapshot->regions[i])
+      MC_region_restore(snapshot->regions[i]);
+  }
+
+  if(snapshot->privatization_regions) {
+    for (i=0; i< SIMIX_process_count(); i++){
+      if(snapshot->privatization_regions[i]) {
+        MC_region_restore(snapshot->privatization_regions[i]);
+      }
+    }
+    switch_data_segment(snapshot->privatization_index);
+  }
+}
+
+void* mc_translate_address(uintptr_t addr, mc_snapshot_t snapshot) {
+
+  // If not in a process state/clone:
+  if(!snapshot) {
+    return (uintptr_t*) addr;
+  }
+
+  // If it is in a snapshot:
+  for(size_t i=0; i!=NB_REGIONS; ++i) {
+    mc_mem_region_t region = snapshot->regions[i];
+    uintptr_t start = (uintptr_t) region->start_addr;
+    uintptr_t end = start + region->size;
+
+    // The address is in this region:
+    if(addr >= start && addr < end) {
+      uintptr_t offset = addr - start;
+      return (void*) ((uintptr_t)region->data + offset);
+    }
+
+  }
+
+  // It is not in a snapshot:
+  return (void*) addr;
+}
+
+uintptr_t mc_untranslate_address(void* addr, mc_snapshot_t snapshot) {
+  if(!snapshot) {
+    return (uintptr_t) addr;
+  }
+
+  for(size_t i=0; i!=NB_REGIONS; ++i) {
+    mc_mem_region_t region = snapshot->regions[i];
+    if(addr>=region->data && addr<=(void*)(((char*)region->data)+region->size)) {
+      size_t offset = (size_t) ((char*) addr - (char*) region->data);
+      return ((uintptr_t) region->start_addr) + offset;
+    }
   }
 
+  return (uintptr_t) addr;
 }
 
 mc_snapshot_t SIMIX_pre_mc_snapshot(smx_simcall_t simcall){
index e017b7d..5a6eb58 100644 (file)
@@ -4,6 +4,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <inttypes.h>
+
 #include "mc_private.h"
 
 #include "xbt/mmalloc.h"
@@ -43,38 +45,12 @@ static void pointers_pair_free_voidp(void *p){
 /************************** Snapshot comparison *******************************/
 /******************************************************************************/
 
-static int already_compared_pointers(void *p1, void *p2){
-
-  if(xbt_dynar_is_empty(compared_pointers))
-    return -1;
-
-  unsigned int cursor = 0;
-  int start = 0;
-  int end = xbt_dynar_length(compared_pointers) - 1;
-  pointers_pair_t pair;
-
-  while(start <= end){
-    cursor = (start + end) / 2;
-    pair = (pointers_pair_t)xbt_dynar_get_as(compared_pointers, cursor, pointers_pair_t);
-    if(pair->p1 == p1){
-      if(pair->p2 == p2)
-        return 0;
-      else if(pair->p2 < p2)
-        start = cursor + 1;
-      else
-        end = cursor - 1;
-    }else if(pair->p1 < p1){
-      start = cursor + 1;
-    }else{
-      end = cursor - 1 ;
-    }
-  }
-
-  return -1;
-
-}
-
-static void add_compared_pointers(void *p1, void *p2){
+/** \brief Try to add a pair a compared pointers to the set of compared pointers
+ *
+ *  \result !=0 if the pointers were added (they were not in the set),
+ *      0 otherwise (they were already in the set)
+ */
+static int add_compared_pointers(void *p1, void *p2){
 
   pointers_pair_t new_pair = xbt_new0(s_pointers_pair_t, 1);
   new_pair->p1 = p1;
@@ -82,7 +58,7 @@ static void add_compared_pointers(void *p1, void *p2){
   
   if(xbt_dynar_is_empty(compared_pointers)){
     xbt_dynar_push(compared_pointers, &new_pair);
-    return;
+    return 1;
   }
 
   unsigned int cursor = 0;
@@ -90,138 +66,157 @@ static void add_compared_pointers(void *p1, void *p2){
   int end = xbt_dynar_length(compared_pointers) - 1;
   pointers_pair_t pair = NULL;
 
+  pointers_pair_t* p = (pointers_pair_t*) xbt_dynar_get_ptr(compared_pointers, 0);
+
   while(start <= end){
     cursor = (start + end) / 2;
-    pair = (pointers_pair_t)xbt_dynar_get_as(compared_pointers, cursor, pointers_pair_t);
-    if(pair->p1 == p1){
-      if(pair->p2 == p2){
-        pointers_pair_free(new_pair);
-        return;
-      }else if(pair->p2 < p2)
-        start = cursor + 1;
-      else
-        end = cursor - 1;
-    }else if(pair->p1 < p1){
+    pair = p[cursor];
+    if(pair->p1 < p1){
       start = cursor + 1;
-    }else{
+    } else if(pair->p1 > p1) {
+      end = cursor - 1 ;
+    } else if(pair->p2 < p2){
+      start = cursor + 1;
+    } else if(pair->p2 > p2) {
       end = cursor - 1 ;
+    } else {
+      pointers_pair_free(new_pair);
+      return 0;
     }
   }
 
-  if(pair->p1 == p1){
-    if(pair->p2 < p2)
-      xbt_dynar_insert_at(compared_pointers, cursor + 1, &new_pair);
-    else
-      xbt_dynar_insert_at(compared_pointers, cursor, &new_pair); 
-  }else{
-    if(pair->p1 < p1)
-      xbt_dynar_insert_at(compared_pointers, cursor + 1, &new_pair);
-    else
-      xbt_dynar_insert_at(compared_pointers, cursor, &new_pair);   
-  }
-
+  if(pair->p1 < p1)
+    xbt_dynar_insert_at(compared_pointers, cursor + 1, &new_pair);
+  else if(pair->p1 > p1)
+    xbt_dynar_insert_at(compared_pointers, cursor, &new_pair);
+  else if(pair->p2 < p2)
+    xbt_dynar_insert_at(compared_pointers, cursor + 1, &new_pair);
+  else if(pair->p2 > p2)
+    xbt_dynar_insert_at(compared_pointers, cursor, &new_pair);
+  else
+    xbt_die("Unrecheable");
+
+  return 1;
 }
 
-static int compare_areas_with_type(void *area1, void *area2, xbt_dict_t types, xbt_dict_t other_types, char *type_id, int region_size, int region_type, void *start_data, int pointer_level){
+static int compare_areas_with_type(void *area1, void *area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, dw_type_t type, int region_size, int region_type, void *start_data, int pointer_level){
 
-  dw_type_t type = xbt_dict_get_or_null(types, type_id);;
   unsigned int cursor = 0;
   dw_type_t member, subtype, subsubtype;
-  int elm_size, i, res, switch_types = 0;
+  int elm_size, i, res;
   void *addr_pointed1, *addr_pointed2;
 
   switch(type->type){
-  case e_dw_base_type:
-  case e_dw_enumeration_type:
-  case e_dw_union_type:
-    return (memcmp(area1, area2, type->size) != 0);
-    break;
-  case e_dw_typedef:
-  case e_dw_volatile_type:
-    return compare_areas_with_type(area1, area2, types, other_types, type->dw_type_id, region_size, region_type, start_data, pointer_level);
+  case DW_TAG_unspecified_type:
+    return 1;
+
+  case DW_TAG_base_type:
+  case DW_TAG_enumeration_type:
+  case DW_TAG_union_type:
+    return (memcmp(area1, area2, type->byte_size) != 0);
     break;
-  case e_dw_const_type: /* Const variable cannot be modified */
-    return -1;
+  case DW_TAG_typedef:
+  case DW_TAG_volatile_type:
+  case DW_TAG_const_type:
+    return compare_areas_with_type(area1, area2, snapshot1, snapshot2, type->subtype, region_size, region_type, start_data, pointer_level);
     break;
-  case e_dw_array_type:
-    subtype = xbt_dict_get_or_null(types, type->dw_type_id);
+  case DW_TAG_array_type:
+    subtype = type->subtype;
     switch(subtype->type){
-    case e_dw_base_type:
-    case e_dw_enumeration_type:
-    case e_dw_pointer_type:
-    case e_dw_structure_type:
-    case e_dw_union_type:
-      if(subtype->size == 0){ /*declaration of the type, need the complete description */
-        subtype = xbt_dict_get_or_null(types, get_type_description(types, subtype->name));
-        if(subtype == NULL){
-          subtype = xbt_dict_get_or_null(other_types, get_type_description(other_types, subtype->name));
-          switch_types = 1;
-        }
-      }
-      elm_size = subtype->size;
+    case DW_TAG_unspecified_type:
+      return 1;
+
+    case DW_TAG_base_type:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_pointer_type:
+    case DW_TAG_reference_type:
+    case DW_TAG_rvalue_reference_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_class_type:
+    case DW_TAG_union_type:
+      if(subtype->full_type)
+        subtype = subtype->full_type;
+      elm_size = subtype->byte_size;
       break;
-    case e_dw_typedef:
-    case e_dw_volatile_type:
-      subsubtype = xbt_dict_get_or_null(types, subtype->dw_type_id);
-      if(subsubtype->size == 0){ /*declaration of the type, need the complete description */
-        subsubtype = xbt_dict_get_or_null(types, get_type_description(types, subsubtype->name));
-        if(subsubtype == NULL){
-          subsubtype = xbt_dict_get_or_null(other_types, get_type_description(other_types, subsubtype->name));
-          switch_types = 1;
-        }
-      }
-      elm_size = subsubtype->size;
+    case DW_TAG_const_type:
+    case DW_TAG_typedef:
+    case DW_TAG_volatile_type:
+      subsubtype = subtype->subtype;
+      if(subsubtype->full_type)
+          subsubtype = subsubtype->full_type;
+      elm_size = subsubtype->byte_size;
       break;
     default : 
       return 0;
       break;
     }
-    for(i=0; i<type->size; i++){
-      if(switch_types)
-        res = compare_areas_with_type((char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), other_types, types, type->dw_type_id, region_size, region_type, start_data, pointer_level);
-      else
-        res = compare_areas_with_type((char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), types, other_types, type->dw_type_id, region_size, region_type, start_data, pointer_level);
+    for(i=0; i<type->element_count; i++){
+      res = compare_areas_with_type((char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), snapshot1, snapshot2, type->subtype, region_size, region_type, start_data, pointer_level);
       if(res == 1)
         return res;
     }
     break;
-  case e_dw_pointer_type: 
-    if(type->dw_type_id && ((dw_type_t)xbt_dict_get_or_null(types, type->dw_type_id))->type == e_dw_subroutine_type){
-      addr_pointed1 = *((void **)(area1)); 
-      addr_pointed2 = *((void **)(area2));
+  case DW_TAG_pointer_type:
+  case DW_TAG_reference_type:
+  case DW_TAG_rvalue_reference_type:
+
+    addr_pointed1 = *((void **)(area1));
+    addr_pointed2 = *((void **)(area2));
+
+    if(type->subtype && type->subtype->type == DW_TAG_subroutine_type){
       return (addr_pointed1 != addr_pointed2);
     }else{
-      addr_pointed1 = *((void **)(area1)); 
-      addr_pointed2 = *((void **)(area2));
       
       if(addr_pointed1 == NULL && addr_pointed2 == NULL)
         return 0;
-      if(already_compared_pointers(addr_pointed1, addr_pointed2) != -1)
+      if(!add_compared_pointers(addr_pointed1, addr_pointed2))
         return 0;
-      add_compared_pointers(addr_pointed1, addr_pointed2);
 
       pointer_level++;
       
-      if(addr_pointed1 > std_heap && (char *)addr_pointed1 < (char*) std_heap + STD_HEAP_SIZE && addr_pointed2 > std_heap && (char *)addr_pointed2 < (char*) std_heap + STD_HEAP_SIZE){
-        return compare_heap_area(addr_pointed1, addr_pointed2, NULL, types, other_types, type->dw_type_id, pointer_level); 
-      }else if(addr_pointed1 > start_data && (char*)addr_pointed1 <= (char *)start_data + region_size && addr_pointed2 > start_data && (char*)addr_pointed2 <= (char *)start_data + region_size){
+      // Some cases are not handled here:
+      // * the pointers lead to different areas (one to the heap, the other to the RW segment ...);
+      // * a pointer leads to the read-only segment of the current object;
+      // * a pointer lead to a different ELF object.
+
+      // The pointers are both in the heap:
+      if(addr_pointed1 > std_heap && (char *)addr_pointed1 < (char*) std_heap + STD_HEAP_SIZE){
+        if(!(addr_pointed2 > std_heap && (char *)addr_pointed2 < (char*) std_heap + STD_HEAP_SIZE))
+          return 1;
+        return compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, NULL, type->subtype, pointer_level);
+      }
+
+      // The pointers are both in the current object R/W segment:
+      else if(addr_pointed1 > start_data && (char*)addr_pointed1 <= (char *)start_data + region_size){
+        if(!(addr_pointed2 > start_data && (char*)addr_pointed2 <= (char *)start_data + region_size))
+          return 1;
         if(type->dw_type_id == NULL)
           return  (addr_pointed1 != addr_pointed2);
-        else
-          return  compare_areas_with_type(addr_pointed1, addr_pointed2, types, other_types, type->dw_type_id, region_size, region_type, start_data, pointer_level); 
-      }else{
+        else {
+          void* translated_addr_pointer1 = mc_translate_address((uintptr_t)addr_pointed1, snapshot1);
+          void* translated_addr_pointer2 = mc_translate_address((uintptr_t)addr_pointed2, snapshot2);
+          return  compare_areas_with_type(
+            translated_addr_pointer1, translated_addr_pointer2, snapshot1, snapshot2, type->subtype, region_size, region_type, start_data, pointer_level);
+        }
+      }
+
+      else{
         return (addr_pointed1 != addr_pointed2);
       }
     }
     break;
-  case e_dw_structure_type:
+  case DW_TAG_structure_type:
+  case DW_TAG_class_type:
     xbt_dynar_foreach(type->members, cursor, member){
-      res = compare_areas_with_type((char *)area1 + member->offset, (char *)area2 + member->offset, types, other_types, member->dw_type_id, region_size, region_type, start_data, pointer_level);
+      XBT_DEBUG("Compare member %s", member->name);
+      void* member1 = mc_member_snapshot_resolve(area1, type, member, snapshot1);
+      void* member2 = mc_member_snapshot_resolve(area2, type, member, snapshot2);
+      res = compare_areas_with_type(member1, member2, snapshot1, snapshot2, member->subtype, region_size, region_type, start_data, pointer_level);
       if(res == 1)
         return res;
     }
     break;
-  case e_dw_subroutine_type:
+  case DW_TAG_subroutine_type:
     return -1;
     break;
   default:
@@ -232,43 +227,46 @@ static int compare_areas_with_type(void *area1, void *area2, xbt_dict_t types, x
   return 0;
 }
 
-static int compare_global_variables(int region_type, mc_mem_region_t r1, mc_mem_region_t r2){
+static int compare_global_variables(int region_type, mc_mem_region_t r1, mc_mem_region_t r2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2){
 
   if(!compared_pointers){
     compared_pointers = xbt_dynar_new(sizeof(pointers_pair_t), pointers_pair_free_voidp);
-    MC_ignore_global_variable("compared_pointers");
   }else{
     xbt_dynar_reset(compared_pointers);
   }
 
   xbt_dynar_t variables;
-  xbt_dict_t types, other_types;
   int res;
   unsigned int cursor = 0;
   dw_variable_t current_var;
   size_t offset;
   void *start_data;
+  void* start_data_binary = mc_binary_info->start_rw;
+  void* start_data_libsimgrid = mc_libsimgrid_info->start_rw;
 
+  mc_object_info_t object_info = NULL;
   if(region_type == 2){
-    variables = mc_global_variables_binary;
-    types = mc_variables_type_binary;
-    other_types = mc_variables_type_libsimgrid;
+    object_info = mc_binary_info;
     start_data = start_data_binary;
   }else{
-    variables = mc_global_variables_libsimgrid;
-    types = mc_variables_type_libsimgrid;
-    other_types = mc_variables_type_binary;
+    object_info = mc_libsimgrid_info;
     start_data = start_data_libsimgrid;
   }
+  variables = object_info->global_variables;
 
   xbt_dynar_foreach(variables, cursor, current_var){
 
-    if(region_type == 2)
-      offset = (char *)current_var->address.address - (char *)start_data_binary;
-    else
-      offset = (char *)current_var->address.address - (char *)start_data_libsimgrid;
+    // If the variable is not in this object, skip it:
+    // We do not expect to find a pointer to something which is not reachable
+    // by the global variables.
+    if((char*) current_var->address < (char*) object_info->start_rw
+      || (char*) current_var->address > (char*) object_info->end_rw)
+       continue;
+
+    offset = (char *)current_var->address - (char *)object_info->start_rw;
 
-    res = compare_areas_with_type((char *)r1->data + offset, (char *)r2->data + offset, types, other_types, current_var->type_origin, r1->size, region_type, start_data, 0);
+    dw_type_t bvariable_type = current_var->type;
+    res = compare_areas_with_type((char *)r1->data + offset, (char *)r2->data + offset, snapshot1, snapshot2, bvariable_type, r1->size, region_type, start_data, 0);
     if(res == 1){
       XBT_VERB("Global variable %s (%p - %p) is different between snapshots", current_var->name, (char *)r1->data + offset, (char *)r2->data + offset);
       xbt_dynar_free(&compared_pointers);
@@ -285,11 +283,12 @@ static int compare_global_variables(int region_type, mc_mem_region_t r1, mc_mem_
 
 }
 
-static int compare_local_variables(mc_snapshot_stack_t stack1, mc_snapshot_stack_t stack2, void *heap1, void *heap2){
+static int compare_local_variables(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, mc_snapshot_stack_t stack1, mc_snapshot_stack_t stack2, void *heap1, void *heap2){
+  void* start_data_binary = mc_binary_info->start_rw;
+  void* start_data_libsimgrid = mc_libsimgrid_info->start_rw;
 
   if(!compared_pointers){
     compared_pointers = xbt_dynar_new(sizeof(pointers_pair_t), pointers_pair_free_voidp);
-    MC_ignore_global_variable("compared_pointers");
   }else{
     xbt_dynar_reset(compared_pointers);
   }
@@ -306,19 +305,28 @@ static int compare_local_variables(mc_snapshot_stack_t stack1, mc_snapshot_stack
     while(cursor < xbt_dynar_length(stack1->local_variables)){
       current_var1 = (local_variable_t)xbt_dynar_get_as(stack1->local_variables, cursor, local_variable_t);
       current_var2 = (local_variable_t)xbt_dynar_get_as(stack2->local_variables, cursor, local_variable_t);
-      if(strcmp(current_var1->name, current_var2->name) != 0 || strcmp(current_var1->frame, current_var2->frame) != 0 || current_var1->ip != current_var2->ip){
+      if(strcmp(current_var1->name, current_var2->name) != 0 || current_var1->subprogram != current_var1->subprogram || current_var1->ip != current_var2->ip){
         xbt_dynar_free(&compared_pointers);
-        XBT_VERB("Different name of variable (%s - %s) or frame (%s - %s) or ip (%lu - %lu)", current_var1->name, current_var2->name, current_var1->frame, current_var2->frame, current_var1->ip, current_var2->ip);
+        // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
+        XBT_VERB("Different name of variable (%s - %s) or frame (%s - %s) or ip (%lu - %lu)", current_var1->name, current_var2->name, current_var1->subprogram->name, current_var2->subprogram->name, current_var1->ip, current_var2->ip);
         return 1;
       }
       offset1 = (char *)current_var1->address - (char *)std_heap;
       offset2 = (char *)current_var2->address - (char *)std_heap;
-      if(current_var1->region == 1)
-        res = compare_areas_with_type( (char *)heap1 + offset1, (char *)heap2 + offset2, mc_variables_type_libsimgrid, mc_variables_type_binary, current_var1->type, 0, 1, start_data_libsimgrid, 0);
-      else
-        res = compare_areas_with_type( (char *)heap1 + offset1, (char *)heap2 + offset2, mc_variables_type_binary, mc_variables_type_libsimgrid, current_var1->type, 0, 2, start_data_binary, 0);
+      // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
+      XBT_DEBUG("Compare local variable %s of frame %s", current_var1->subprogram->name, current_var1->subprogram->name);
+
+
+      if(current_var1->region == 1) {
+        dw_type_t subtype = current_var1->type;
+        res = compare_areas_with_type( (char *)heap1 + offset1, (char *)heap2 + offset2, snapshot1, snapshot2, subtype, 0, 1, start_data_libsimgrid, 0);
+      } else {
+        dw_type_t subtype = current_var2->type;
+        res = compare_areas_with_type( (char *)heap1 + offset1, (char *)heap2 + offset2, snapshot1, snapshot2, subtype, 0, 2, start_data_binary, 0);
+      }
       if(res == 1){
-        XBT_VERB("Local variable %s (%p - %p) in frame %s  is different between snapshots", current_var1->name,(char *)heap1 + offset1, (char *)heap2 + offset2, current_var1->frame);
+        // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
+        XBT_VERB("Local variable %s (%p - %p) in frame %s  is different between snapshots", current_var1->name,(char *)heap1 + offset1, (char *)heap2 + offset2, current_var1->subprogram->name);
         xbt_dynar_free(&compared_pointers);
         compared_pointers = NULL;
         return res;
@@ -365,10 +373,25 @@ int snapshot_compare(void *state1, void *state2){
     xbt_os_walltimer_start(timer);
   #endif
 
-  /* Compare size of stacks */
+  int hash_result = 0;
+  if(_sg_mc_hash) {
+    hash_result = (s1->hash != s2->hash);
+    if(hash_result) {
+      XBT_VERB("(%d - %d) Different hash : 0x%" PRIx64 "--0x%" PRIx64, num1, num2, s1->hash, s2->hash);
+#ifndef MC_DEBUG
+      return 1;
+#endif
+    } else {
+      XBT_VERB("(%d - %d) Same hash : 0x%" PRIx64, num1, num2, s1->hash);
+    }
+  }
+
   int i = 0;
   size_t size_used1, size_used2;
   int is_diff = 0;
+
+
+  /* Compare size of stacks */
   while(i < xbt_dynar_length(s1->stacks)){
     size_used1 = s1->stack_sizes[i];
     size_used2 = s2->stack_sizes[i];
@@ -404,62 +427,6 @@ int snapshot_compare(void *state1, void *state2){
     xbt_os_walltimer_start(timer);
   #endif
 
-  /* Compare hash of global variables */
-  if(s1->hash_global != NULL && s2->hash_global != NULL){
-    if(strcmp(s1->hash_global, s2->hash_global) != 0){
-      #ifdef MC_DEBUG
-        xbt_os_walltimer_stop(timer);
-        mc_comp_times->hash_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
-        XBT_DEBUG("Different hash of global variables : %s - %s", s1->hash_global, s2->hash_global); 
-        errors++; 
-      #else
-        #ifdef MC_VERBOSE
-          XBT_VERB("Different hash of global variables : %s - %s", s1->hash_global, s2->hash_global); 
-        #endif
-
-        xbt_os_walltimer_stop(timer);
-        xbt_os_timer_free(timer);
-        xbt_os_walltimer_stop(global_timer);
-        mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
-        xbt_os_timer_free(global_timer);
-
-        return 1;
-      #endif
-    }
-  }
-
-  #ifdef MC_DEBUG
-    xbt_os_walltimer_start(timer);
-  #endif
-
-  /* Compare hash of local variables */
-  if(s1->hash_local != NULL && s2->hash_local != NULL){
-    if(strcmp(s1->hash_local, s2->hash_local) != 0){
-      #ifdef MC_DEBUG
-        xbt_os_walltimer_stop(timer);
-        mc_comp_times->hash_local_variables_comparison_time = xbt_os_timer_elapsed(timer);
-        XBT_DEBUG("Different hash of local variables : %s - %s", s1->hash_local, s2->hash_local); 
-        errors++; 
-      #else
-        #ifdef MC_VERBOSE
-          XBT_VERB("Different hash of local variables : %s - %s", s1->hash_local, s2->hash_local); 
-        #endif
-
-        xbt_os_walltimer_stop(timer);
-        xbt_os_timer_free(timer);
-        xbt_os_walltimer_stop(global_timer);
-        mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
-        xbt_os_timer_free(global_timer);
-
-        return 1;
-      #endif
-    }
-  }
-
-  #ifdef MC_DEBUG
-    xbt_os_walltimer_start(timer);
-  #endif
-
   /* Init heap information used in heap comparison algorithm */
   res_init = init_heap_information((xbt_mheap_t)s1->regions[0]->data, (xbt_mheap_t)s2->regions[0]->data, s1->to_ignore, s2->to_ignore);
   if(res_init == -1){
@@ -492,7 +459,7 @@ int snapshot_compare(void *state1, void *state2){
   while(cursor < xbt_dynar_length(s1->stacks)){
     stack1 = (mc_snapshot_stack_t)xbt_dynar_get_as(s1->stacks, cursor, mc_snapshot_stack_t);
     stack2 = (mc_snapshot_stack_t)xbt_dynar_get_as(s2->stacks, cursor, mc_snapshot_stack_t);
-    diff_local = compare_local_variables(stack1, stack2, s1->regions[0]->data, s2->regions[0]->data);
+    diff_local = compare_local_variables(s1, s2, stack1, stack2, s1->regions[0]->data, s2->regions[0]->data);
     if(diff_local > 0){
       #ifdef MC_DEBUG
         if(is_diff == 0){
@@ -521,55 +488,38 @@ int snapshot_compare(void *state1, void *state2){
     cursor++;
   }
 
-  #ifdef MC_DEBUG
-    if(is_diff == 0)
-      xbt_os_walltimer_stop(timer);
-    xbt_os_walltimer_start(timer);
-  #endif
 
-  /* Compare binary global variables */
-  is_diff = compare_global_variables(2, s1->regions[2], s2->regions[2]);
-  if(is_diff != 0){
-    #ifdef MC_DEBUG
-      xbt_os_walltimer_stop(timer);
-      mc_comp_times->binary_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
-      XBT_DEBUG("(%d - %d) Different global variables in binary", num1, num2);
-      errors++;
-    #else
-      #ifdef MC_VERBOSE
-      XBT_VERB("(%d - %d) Different global variables in binary", num1, num2);
-      #endif
 
-      reset_heap_information();
-      xbt_os_walltimer_stop(timer);
-      xbt_os_timer_free(timer);
-      xbt_os_walltimer_stop(global_timer);
-      mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
-      xbt_os_timer_free(global_timer);
+ const char* names[3] = { "?", "libsimgrid", "binary" };
+#ifdef MC_DEBUG
+ double *times[3] = {
+   NULL,
+   &mc_comp_times->libsimgrid_global_variables_comparison_time,
+   &mc_comp_times->binary_global_variables_comparison_time
+ };
+#endif
 
-      return 1;
+ int k=0;
+ for(k=2; k!=0; --k) {
+    #ifdef MC_DEBUG
+      if(is_diff == 0)
+        xbt_os_walltimer_stop(timer);
+      xbt_os_walltimer_start(timer);
     #endif
-  }
-
-  #ifdef MC_DEBUG
-    if(is_diff == 0)
-      xbt_os_walltimer_stop(timer);
-    xbt_os_walltimer_start(timer);
-  #endif
 
-  /* Compare libsimgrid global variables */
-  is_diff = compare_global_variables(1, s1->regions[1], s2->regions[1]);
+  /* Compare global variables */
+  is_diff = compare_global_variables(k, s1->regions[k], s2->regions[k], s1, s2);
   if(is_diff != 0){
     #ifdef MC_DEBUG
       xbt_os_walltimer_stop(timer);
-      mc_comp_times->libsimgrid_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
-      XBT_DEBUG("(%d - %d) Different global variables in libsimgrid", num1, num2);
+      *times[k] = xbt_os_timer_elapsed(timer);
+      XBT_DEBUG("(%d - %d) Different global variables in %s", num1, num2, names[k]);
       errors++;
     #else
       #ifdef MC_VERBOSE
-      XBT_VERB("(%d - %d) Different global variables in libsimgrid", num1, num2);
+      XBT_VERB("(%d - %d) Different global variables in %s", num1, num2, names[k]);
       #endif
-        
+
       reset_heap_information();
       xbt_os_walltimer_stop(timer);
       xbt_os_timer_free(timer);
@@ -580,13 +530,15 @@ int snapshot_compare(void *state1, void *state2){
       return 1;
     #endif
   }
+ }
 
   #ifdef MC_DEBUG
     xbt_os_walltimer_start(timer);
   #endif
 
   /* Compare heap */
-    if(mmalloc_compare_heap((xbt_mheap_t)s1->regions[0]->data, (xbt_mheap_t)s2->regions[0]->data, mc_variables_type_libsimgrid, mc_variables_type_binary) > 0){
+    if(mmalloc_compare_heap(s1, s2, (xbt_mheap_t)s1->regions[0]->data,
+                            (xbt_mheap_t)s2->regions[0]->data) > 0){
 
     #ifdef MC_DEBUG
       xbt_os_walltimer_stop(timer);
@@ -630,7 +582,25 @@ int snapshot_compare(void *state1, void *state2){
     print_comparison_times();
   #endif
 
-  return errors > 0;
+#ifdef MC_VERBOSE
+   if(errors || hash_result)
+     XBT_VERB("(%d - %d) Difference found", num1, num2);
+   else
+     XBT_VERB("(%d - %d) No difference found", num1, num2);
+#endif
+
+#if defined(MC_DEBUG) && defined(MC_VERBOSE)
+   if(_sg_mc_hash) {
+     // * false positive SHOULD be avoided.
+     // * There MUST not be any false negative.
+
+     XBT_VERB("(%d - %d) State equality hash test is %s %s", num1, num2,
+       (hash_result!=0) == (errors!=0) ? "true" : "false",
+       !hash_result ? "positive" : "negative");
+   }
+#endif
+
+   return errors > 0 || hash_result;
   
 }
 
@@ -657,8 +627,7 @@ int SIMIX_pre_mc_compare_snapshots(smx_simcall_t simcall,
 }
 
 int MC_compare_snapshots(void *s1, void *s2){
-  
-  MC_ignore_local_variable("self", "simcall_BODY_mc_snapshot");
+
   return simcall_mc_compare_snapshots(s1, s2);
 
 }
index fb3c120..5ab8aed 100644 (file)
@@ -13,9 +13,161 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dpor, mc,
 
 xbt_dynar_t visited_states;
 xbt_dict_t first_enabled_state;
+xbt_dynar_t initial_communications_pattern;
+xbt_dynar_t communications_pattern;
+int nb_comm_pattern;
 
 /********** Static functions ***********/
 
+static void comm_pattern_free(mc_comm_pattern_t p){
+  xbt_free(p->rdv);
+  xbt_free(p->data);
+  xbt_free(p);
+  p = NULL;
+}
+
+static void comm_pattern_free_voidp( void *p){
+  comm_pattern_free((mc_comm_pattern_t) * (void **)p);
+}
+
+static mc_comm_pattern_t get_comm_pattern_from_idx(xbt_dynar_t pattern, unsigned int *idx, e_smx_comm_type_t type, unsigned long proc){
+  mc_comm_pattern_t current_comm;
+  while(*idx < xbt_dynar_length(pattern)){
+    current_comm = (mc_comm_pattern_t)xbt_dynar_get_as(pattern, *idx, mc_comm_pattern_t);
+    if(current_comm->type == type && type == SIMIX_COMM_SEND){
+      if(current_comm->src_proc == proc)
+        return current_comm;
+    }else if(current_comm->type == type && type == SIMIX_COMM_RECEIVE){
+      if(current_comm->dst_proc == proc)
+        return current_comm;
+    }
+    (*idx)++;
+  }
+  return NULL;
+}
+
+static int compare_comm_pattern(mc_comm_pattern_t comm1, mc_comm_pattern_t comm2){
+  if(strcmp(comm1->rdv, comm2->rdv) != 0)
+    return 1;
+  if(comm1->src_proc != comm2->src_proc)
+    return 1;
+  if(comm1->dst_proc != comm2->dst_proc)
+    return 1;
+  if(comm1->data_size != comm2->data_size)
+    return 1;
+  if(memcmp(comm1->data, comm2->data, comm1->data_size) != 0)
+    return 1;
+  return 0;
+}
+
+static void deterministic_pattern(xbt_dynar_t initial_pattern, xbt_dynar_t pattern){
+  unsigned int cursor = 0, send_index = 0, recv_index = 0;
+  mc_comm_pattern_t comm1, comm2;
+  int comm_comparison = 0;
+  int current_process = 0;
+  while(current_process < simix_process_maxpid){
+    while(cursor < xbt_dynar_length(initial_pattern)){
+      comm1 = (mc_comm_pattern_t)xbt_dynar_get_as(initial_pattern, cursor, mc_comm_pattern_t);
+      if(comm1->type == SIMIX_COMM_SEND && comm1->src_proc == current_process){
+        comm2 = get_comm_pattern_from_idx(pattern, &send_index, comm1->type, current_process);
+        comm_comparison = compare_comm_pattern(comm1, comm2);
+        if(comm_comparison == 1){
+          initial_state_safety->send_deterministic = 0;
+          initial_state_safety->comm_deterministic = 0;
+          return;
+        }
+        send_index++;
+      }else if(comm1->type == SIMIX_COMM_RECEIVE && comm1->dst_proc == current_process){
+        comm2 = get_comm_pattern_from_idx(pattern, &recv_index, comm1->type, current_process);
+        comm_comparison = compare_comm_pattern(comm1, comm2);
+        if(comm_comparison == 1){
+          initial_state_safety->comm_deterministic = 0;
+        }
+        recv_index++;
+      }
+      cursor++;
+    }
+    cursor = 0;
+    send_index = 0;
+    recv_index = 0;
+    current_process++;
+  }
+}
+
+static int complete_comm_pattern(xbt_dynar_t list, mc_comm_pattern_t pattern){
+  mc_comm_pattern_t current_pattern;
+  unsigned int cursor = 0;
+  xbt_dynar_foreach(list, cursor, current_pattern){
+    if(current_pattern->comm == pattern->comm){
+      if(!current_pattern->completed){
+        current_pattern->src_proc = pattern->comm->comm.src_proc->pid;
+        current_pattern->src_host = simcall_host_get_name(pattern->comm->comm.src_proc->smx_host);
+        current_pattern->dst_proc = pattern->comm->comm.dst_proc->pid;
+        current_pattern->dst_host = simcall_host_get_name(pattern->comm->comm.dst_proc->smx_host);
+        current_pattern->data_size = pattern->comm->comm.src_buff_size;
+        current_pattern->data = xbt_malloc0(current_pattern->data_size);
+        current_pattern->matched_comm = pattern->num;
+        memcpy(current_pattern->data, current_pattern->comm->comm.src_buff, current_pattern->data_size);
+        current_pattern->completed = 1;
+        return current_pattern->num;
+      }
+    }
+  }
+  return -1;
+}
+
+void get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, int call){
+  mc_comm_pattern_t pattern = NULL;
+  pattern = xbt_new0(s_mc_comm_pattern_t, 1);
+  pattern->num = ++nb_comm_pattern;
+  pattern->completed = 0;
+  if(call == 1){ // ISEND
+    pattern->comm = simcall_comm_isend__get__result(request);
+    pattern->type = SIMIX_COMM_SEND;
+    if(pattern->comm->comm.dst_proc != NULL){ 
+      pattern->matched_comm = complete_comm_pattern(list, pattern);
+      pattern->dst_proc = pattern->comm->comm.dst_proc->pid;
+      pattern->completed = 1;
+      pattern->dst_host = simcall_host_get_name(pattern->comm->comm.dst_proc->smx_host);
+    }
+    pattern->src_proc = pattern->comm->comm.src_proc->pid;
+    pattern->src_host = simcall_host_get_name(request->issuer->smx_host);
+    pattern->data_size = pattern->comm->comm.src_buff_size;
+    pattern->data=xbt_malloc0(pattern->data_size);
+    memcpy(pattern->data, pattern->comm->comm.src_buff, pattern->data_size);
+  }else{ // IRECV
+    pattern->comm = simcall_comm_irecv__get__result(request);
+    pattern->type = SIMIX_COMM_RECEIVE;
+    if(pattern->comm->comm.src_proc != NULL){
+      pattern->matched_comm = complete_comm_pattern(list, pattern);
+      pattern->src_proc = pattern->comm->comm.src_proc->pid;
+      pattern->src_host = simcall_host_get_name(pattern->comm->comm.src_proc->smx_host);
+      pattern->completed = 1;
+      pattern->data_size = pattern->comm->comm.src_buff_size;
+      pattern->data=xbt_malloc0(pattern->data_size);
+      memcpy(pattern->data, pattern->comm->comm.src_buff, pattern->data_size);
+    }
+    pattern->dst_proc = pattern->comm->comm.dst_proc->pid;
+    pattern->dst_host = simcall_host_get_name(request->issuer->smx_host);
+  }
+  if(pattern->comm->comm.rdv != NULL)
+    pattern->rdv = strdup(pattern->comm->comm.rdv->name);
+  else
+    pattern->rdv = strdup(pattern->comm->comm.rdv_cpy->name);
+  xbt_dynar_push(list, &pattern);
+}
+
+static void print_communications_pattern(xbt_dynar_t comms_pattern){
+  unsigned int cursor = 0;
+  mc_comm_pattern_t current_comm;
+  xbt_dynar_foreach(comms_pattern, cursor, current_comm){
+    if(current_comm->type == SIMIX_COMM_SEND)
+      XBT_INFO("[(%lu) %s -> %s] %s ", current_comm->src_proc, current_comm->src_host, current_comm->dst_host, "iSend");
+    else
+      XBT_INFO("[(%lu) %s <- %s] %s ", current_comm->dst_proc, current_comm->dst_host, current_comm->src_host, "iRecv");
+  }
+}
+
 static void visited_state_free(mc_visited_state_t state){
   if(state){
     MC_free_snapshot(state->system_state);
@@ -27,6 +179,10 @@ static void visited_state_free_voidp(void *s){
   visited_state_free((mc_visited_state_t) * (void **) s);
 }
 
+/** \brief Save the current state
+ *
+ *  \return Snapshot of the current state.
+ */
 static mc_visited_state_t visited_state_new(){
 
   mc_visited_state_t new_state = NULL;
@@ -41,7 +197,25 @@ static mc_visited_state_t visited_state_new(){
   
 }
 
+/** \brief Find a suitable subrange of candidate duplicates for a given state
+ *
+ *  \param all_ pairs dynamic array of states with candidate duplicates of the current state;
+ *  \param pair current state;
+ *  \param min (output) index of the beginning of the the subrange
+ *  \param max (output) index of the enf of the subrange
+ *
+ *  Given a suitably ordered array of state, this function extracts a subrange
+ *  (with index *min <= i <= *max) with candidate duplicates of the given state.
+ *  This function uses only fast discriminating criterions and does not use the
+ *  full state comparison algorithms.
+ *
+ *  The states in all_pairs MUST be ordered using a (given) weak order
+ *  (based on nb_processes and heap_bytes_used).
+ *  The subrange is the subrange of "equivalence" of the given state.
+ */
 static int get_search_interval(xbt_dynar_t all_states, mc_visited_state_t state, int *min, int *max){
+  XBT_VERB("Searching interval for state %i: nd_processes=%zu heap_bytes_used=%zu",
+    state->num, (size_t)state->nb_processes, (size_t)state->heap_bytes_used);
 
   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
 
@@ -95,6 +269,10 @@ static int get_search_interval(xbt_dynar_t all_states, mc_visited_state_t state,
   return cursor;
 }
 
+/** \brief Take a snapshot the current state and process it.
+ *
+ *  \return number of the duplicate state or -1 (not visited)
+ */
 static int is_visited_state(){
 
   if(_sg_mc_visited == 0)
@@ -125,6 +303,8 @@ static int is_visited_state(){
     index = get_search_interval(visited_states, new_state, &min, &max);
 
     if(min != -1 && max != -1){
+
+      // Parallell implementation
       /*res = xbt_parmap_mc_apply(parmap, snapshot_compare, xbt_dynar_get_ptr(visited_states, min), (max-min)+1, new_state);
       if(res != -1){
         state_test = (mc_visited_state_t)xbt_dynar_get_as(visited_states, (min+res)-1, mc_visited_state_t);
@@ -142,10 +322,13 @@ static int is_visited_state(){
           MC_UNSET_RAW_MEM;
         return new_state->other_num;
         }*/
+
       cursor = min;
       while(cursor <= max){
         state_test = (mc_visited_state_t)xbt_dynar_get_as(visited_states, cursor, mc_visited_state_t);
         if(snapshot_compare(state_test, new_state) == 0){
+          // The state has been visited:
+
           if(state_test->other_num == -1)
             new_state->other_num = state_test->num;
           else
@@ -154,16 +337,24 @@ static int is_visited_state(){
             XBT_DEBUG("State %d already visited ! (equal to state %d)", new_state->num, state_test->num);
           else
             XBT_DEBUG("State %d already visited ! (equal to state %d (state %d in dot_output))", new_state->num, state_test->num, new_state->other_num);
+
+          // Replace the old state with the new one (why?):
           xbt_dynar_remove_at(visited_states, cursor, NULL);
           xbt_dynar_insert_at(visited_states, cursor, &new_state);
+
           if(!raw_mem_set)
             MC_UNSET_RAW_MEM;
           return new_state->other_num;
         }
         cursor++;
       }
+
+      // The state has not been visited, add it to the list:
       xbt_dynar_insert_at(visited_states, min, &new_state);
+
     }else{
+
+      // The state has not been visited: insert the state in the dynamic array.
       state_test = (mc_visited_state_t)xbt_dynar_get_as(visited_states, index, mc_visited_state_t);
       if(state_test->nb_processes < new_state->nb_processes){
         xbt_dynar_insert_at(visited_states, index+1, &new_state);
@@ -173,9 +364,13 @@ static int is_visited_state(){
         else
           xbt_dynar_insert_at(visited_states, index, &new_state);
       }
+
     }
 
+    // We have reached the maximum number of stored states;
     if(xbt_dynar_length(visited_states) > _sg_mc_visited){
+
+      // Find the (index of the) older state:
       int min2 = mc_stats->expanded_states;
       unsigned int cursor2 = 0;
       unsigned int index2 = 0;
@@ -185,6 +380,8 @@ static int is_visited_state(){
           min2 = state_test->num;
         }
       }
+
+      // and drop it:
       xbt_dynar_remove_at(visited_states, index2, NULL);
     }
 
@@ -210,12 +407,17 @@ void MC_dpor_init()
   /* Create the initial state and push it into the exploration stack */
   MC_SET_RAW_MEM;
 
-  initial_state = MC_state_new();
   if(_sg_mc_visited > 0)
     visited_states = xbt_dynar_new(sizeof(mc_visited_state_t), visited_state_free_voidp);
 
   first_enabled_state = xbt_dict_new_homogeneous(&xbt_free_f);
 
+  initial_communications_pattern = xbt_dynar_new(sizeof(mc_comm_pattern_t), comm_pattern_free_voidp);
+  communications_pattern = xbt_dynar_new(sizeof(mc_comm_pattern_t), comm_pattern_free_voidp);
+  nb_comm_pattern = 0;
+
+  initial_state = MC_state_new();
+
   MC_UNSET_RAW_MEM;
 
   XBT_DEBUG("**************************************************");
@@ -263,9 +465,8 @@ void MC_dpor_init()
 }
 
 
-/**
- *   \brief Perform the model-checking operation using a depth-first search exploration
- *         with Dynamic Partial Order Reductions
+/** \brief Model-check the application using a DFS exploration
+ *         with DPOR (Dynamic Partial Order Reductions)
  */
 void MC_dpor(void)
 {
@@ -273,13 +474,15 @@ void MC_dpor(void)
   char *req_str = NULL;
   int value;
   smx_simcall_t req = NULL, prev_req = NULL;
-  mc_state_t state = NULL, prev_state = NULL, next_state = NULL, restore_state=NULL;
+  mc_state_t state = NULL, prev_state = NULL, next_state = NULL, restored_state=NULL;
   smx_process_t process = NULL;
   xbt_fifo_item_t item = NULL;
   mc_state_t state_test = NULL;
   int pos;
   int visited_state = -1;
   int enabled = 0;
+  int interleave_size = 0;
+  int comm_pattern = 0;
 
   while (xbt_fifo_size(mc_stack_safety) > 0) {
 
@@ -292,6 +495,8 @@ void MC_dpor(void)
               xbt_fifo_size(mc_stack_safety), state, state->num,
               MC_state_interleave_size(state), user_max_depth_reached, xbt_dict_size(first_enabled_state));
       
+    interleave_size = MC_state_interleave_size(state);
+
     /* Update statistics */
     mc_stats->visited_states++;
 
@@ -320,10 +525,29 @@ void MC_dpor(void)
       xbt_dict_remove(first_enabled_state, key); 
       xbt_free(key);
       MC_UNSET_RAW_MEM;
+      
+      if(_sg_mc_comms_determinism || _sg_mc_send_determinism){
+        if(req->call == SIMCALL_COMM_ISEND)
+          comm_pattern = 1;
+        else if(req->call == SIMCALL_COMM_IRECV)
+          comm_pattern = 2;
+      }
 
       /* Answer the request */
       SIMIX_simcall_pre(req, value); /* After this call req is no longer usefull */
 
+      if(_sg_mc_comms_determinism || _sg_mc_send_determinism){
+        MC_SET_RAW_MEM;
+        if(comm_pattern != 0){
+          if(!initial_state_safety->initial_communications_pattern_done)
+            get_comm_pattern(initial_communications_pattern, req, comm_pattern);
+          else
+            get_comm_pattern(communications_pattern, req, comm_pattern);
+        }
+        MC_UNSET_RAW_MEM; 
+        comm_pattern = 0;
+      }
+
       /* Wait for requests (schedules processes) */
       MC_wait_for_requests();
 
@@ -415,11 +639,45 @@ void MC_dpor(void)
 
       }
 
-      /* Trash the current state, no longer needed */
       MC_SET_RAW_MEM;
+
+      if(_sg_mc_comms_determinism || _sg_mc_send_determinism){
+        if(initial_state_safety->initial_communications_pattern_done){
+          if(interleave_size == 0){ /* if (interleave_size > 0), process interleaved but not enabled => "incorrect" path, determinism not evaluated */
+            //print_communications_pattern(communications_pattern);
+            deterministic_pattern(initial_communications_pattern, communications_pattern);
+            if(initial_state_safety->comm_deterministic == 0 && _sg_mc_comms_determinism){
+              XBT_INFO("****************************************************");
+              XBT_INFO("***** Non-deterministic communications pattern *****");
+              XBT_INFO("****************************************************");
+              XBT_INFO("Initial communications pattern:");
+              print_communications_pattern(initial_communications_pattern);
+              XBT_INFO("Communications pattern counter-example:");
+              print_communications_pattern(communications_pattern);
+              MC_print_statistics(mc_stats);
+              return;
+            }else if(initial_state_safety->send_deterministic == 0 && _sg_mc_send_determinism){
+              XBT_INFO("****************************************************");
+              XBT_INFO("***** Non-send-deterministic communications pattern *****");
+              XBT_INFO("****************************************************");
+              XBT_INFO("Initial communications pattern:");
+              print_communications_pattern(initial_communications_pattern);
+              XBT_INFO("Communications pattern counter-example:");
+              print_communications_pattern(communications_pattern);
+              MC_print_statistics(mc_stats);
+              return;
+            }
+          }
+        }else{
+          initial_state_safety->initial_communications_pattern_done = 1;
+        }
+      }
+
+      /* Trash the current state, no longer needed */
       xbt_fifo_shift(mc_stack_safety);
       MC_state_delete(state);
       XBT_DEBUG("Delete state %d at depth %d", state->num, xbt_fifo_size(mc_stack_safety) + 1);
+
       MC_UNSET_RAW_MEM;        
       
       /* Check for deadlocks */
@@ -485,15 +743,15 @@ void MC_dpor(void)
               pos = xbt_fifo_size(mc_stack_safety);
               item = xbt_fifo_get_first_item(mc_stack_safety);
               while(pos>0){
-                restore_state = (mc_state_t) xbt_fifo_get_item_content(item);
-                if(restore_state->system_state != NULL){
+                restored_state = (mc_state_t) xbt_fifo_get_item_content(item);
+                if(restored_state->system_state != NULL){
                   break;
                 }else{
                   item = xbt_fifo_get_next_item(item);
                   pos--;
                 }
               }
-              MC_restore_snapshot(restore_state->system_state);
+              MC_restore_snapshot(restored_state->system_state);
               xbt_fifo_unshift(mc_stack_safety, state);
               MC_UNSET_RAW_MEM;
               MC_replay(mc_stack_safety, pos);
@@ -506,6 +764,13 @@ void MC_dpor(void)
           XBT_DEBUG("Back-tracking to state %d at depth %d done", state->num, xbt_fifo_size(mc_stack_safety));
           break;
         } else {
+          req = MC_state_get_internal_request(state);
+          if(_sg_mc_comms_determinism){
+            if(req->call == SIMCALL_COMM_ISEND || req->call == SIMCALL_COMM_IRECV){
+              if(!xbt_dynar_is_empty(communications_pattern))
+                xbt_dynar_remove_at(communications_pattern, xbt_dynar_length(communications_pattern) - 1, NULL);
+            }
+          }
           XBT_DEBUG("Delete state %d at depth %d", state->num, xbt_fifo_size(mc_stack_safety) + 1); 
           MC_state_delete(state);
         }
diff --git a/src/mc/mc_dwarf.c b/src/mc/mc_dwarf.c
new file mode 100644 (file)
index 0000000..cc9a8eb
--- /dev/null
@@ -0,0 +1,960 @@
+/* Copyright (c) 2008-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <stdlib.h>
+#define DW_LANG_Objc DW_LANG_ObjC /* fix spelling error in older dwarf.h */
+#include <dwarf.h>
+#include <elfutils/libdw.h>
+#include <inttypes.h>
+
+#include <simgrid_config.h>
+#include <xbt/log.h>
+#include <xbt/sysdep.h>
+
+#include "mc_private.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dwarf, mc, "DWARF processing");
+
+/** \brief The default DW_TAG_lower_bound for a given DW_AT_language.
+ *
+ *  The default for a given language is defined in the DWARF spec.
+ *
+ *  \param language consant as defined by the DWARf spec
+ */
+static uint64_t MC_dwarf_default_lower_bound(int lang);
+
+/** \brief Computes the the element_count of a DW_TAG_enumeration_type DIE
+ *
+ * This is the number of elements in a given array dimension.
+ *
+ * A reference of the compilation unit (DW_TAG_compile_unit) is
+ * needed because the default lower bound (when there is no DW_AT_lower_bound)
+ * depends of the language of the compilation unit (DW_AT_language).
+ *
+ * \param die  DIE for the DW_TAG_enumeration_type or DW_TAG_subrange_type
+ * \param unit DIE of the DW_TAG_compile_unit
+ */
+static uint64_t MC_dwarf_subrange_element_count(Dwarf_Die* die, Dwarf_Die* unit);
+
+/** \brief Computes the number of elements of a given DW_TAG_array_type.
+ *
+ * \param die DIE for the DW_TAG_array_type
+ */
+static uint64_t MC_dwarf_array_element_count(Dwarf_Die* die, Dwarf_Die* unit);
+
+/** \brief Process a DIE
+ *
+ *  \param info the resulting object fot the library/binary file (output)
+ *  \param die  the current DIE
+ *  \param unit the DIE of the compile unit of the current DIE
+ *  \param frame containg frame if any
+ */
+static void MC_dwarf_handle_die(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace);
+
+/** \brief Process a type DIE
+ */
+static void MC_dwarf_handle_type_die(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace);
+
+/** \brief Calls MC_dwarf_handle_die on all childrend of the given die
+ *
+ *  \param info the resulting object fot the library/binary file (output)
+ *  \param die  the current DIE
+ *  \param unit the DIE of the compile unit of the current DIE
+ *  \param frame containg frame if any
+ */
+static void MC_dwarf_handle_children(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace);
+
+/** \brief Handle a variable (DW_TAG_variable or other)
+ *
+ *  \param info the resulting object fot the library/binary file (output)
+ *  \param die  the current DIE
+ *  \param unit the DIE of the compile unit of the current DIE
+ *  \param frame containg frame if any
+ */
+static void MC_dwarf_handle_variable_die(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace);
+
+/** \brief Get the DW_TAG_type of the DIE
+ *
+ *  \param die DIE
+ *  \return DW_TAG_type attribute as a new string (NULL if none)
+ */
+static char* MC_dwarf_at_type(Dwarf_Die* die);
+
+/** \brief Get the name of an attribute (DW_AT_*) from its code
+ *
+ *  \param attr attribute code (see the DWARF specification)
+ *  \return name of the attribute
+ */
+const char* MC_dwarf_attrname(int attr) {
+  switch (attr) {
+#include "mc_dwarf_attrnames.h"
+  default:
+    return "DW_AT_unknown";
+  }
+}
+
+/** \brief Get the name of a dwarf tag (DW_TAG_*) from its code
+ *
+ *  \param tag tag code (see the DWARF specification)
+ *  \return name of the tag
+ */
+const char* MC_dwarf_tagname(int tag) {
+  switch (tag) {
+#include "mc_dwarf_tagnames.h"
+  case DW_TAG_invalid:
+    return "DW_TAG_invalid";
+  default:
+    return "DW_TAG_unknown";
+  }
+}
+
+/** \brief A class of DWARF tags (DW_TAG_*)
+ */
+typedef enum mc_tag_class {
+  mc_tag_unknown,
+  mc_tag_type,
+  mc_tag_subprogram,
+  mc_tag_variable,
+  mc_tag_scope,
+  mc_tag_namespace
+} mc_tag_class;
+
+static mc_tag_class MC_dwarf_tag_classify(int tag) {
+  switch (tag) {
+
+    case DW_TAG_array_type:
+    case DW_TAG_class_type:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_typedef:
+    case DW_TAG_pointer_type:
+    case DW_TAG_reference_type:
+    case DW_TAG_rvalue_reference_type:
+    case DW_TAG_string_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_subroutine_type:
+    case DW_TAG_union_type:
+    case DW_TAG_ptr_to_member_type:
+    case DW_TAG_set_type:
+    case DW_TAG_subrange_type:
+    case DW_TAG_base_type:
+    case DW_TAG_const_type:
+    case DW_TAG_file_type:
+    case DW_TAG_packed_type:
+    case DW_TAG_volatile_type:
+    case DW_TAG_restrict_type:
+    case DW_TAG_interface_type:
+    case DW_TAG_unspecified_type:
+    case DW_TAG_mutable_type:
+    case DW_TAG_shared_type:
+      return mc_tag_type;
+
+    case DW_TAG_subprogram:
+      return mc_tag_subprogram;
+
+    case DW_TAG_variable:
+    case DW_TAG_formal_parameter:
+      return mc_tag_variable;
+
+    case DW_TAG_lexical_block:
+    case DW_TAG_try_block:
+    case DW_TAG_catch_block:
+    case DW_TAG_inlined_subroutine:
+    case DW_TAG_with_stmt:
+      return mc_tag_scope;
+
+    case DW_TAG_namespace:
+      return mc_tag_namespace;
+
+    default:
+      return mc_tag_unknown;
+
+  }
+}
+
+#define MC_DW_CLASS_UNKNOWN 0
+#define MC_DW_CLASS_ADDRESS 1   // Location in the address space of the program
+#define MC_DW_CLASS_BLOCK 2     // Arbitrary block of bytes
+#define MC_DW_CLASS_CONSTANT 3
+#define MC_DW_CLASS_STRING 3    // String
+#define MC_DW_CLASS_FLAG 4      // Boolean
+#define MC_DW_CLASS_REFERENCE 5 // Reference to another DIE
+#define MC_DW_CLASS_EXPRLOC 6   // DWARF expression/location description
+#define MC_DW_CLASS_LINEPTR 7
+#define MC_DW_CLASS_LOCLISTPTR 8
+#define MC_DW_CLASS_MACPTR 9
+#define MC_DW_CLASS_RANGELISTPTR 10
+
+/** \brief Find the DWARF data class for a given DWARF data form
+ *
+ *  This mapping is defined in the DWARF spec.
+ *
+ *  \param form The form (values taken from the DWARF spec)
+ *  \return An internal representation for the corresponding class
+ * */
+static int MC_dwarf_form_get_class(int form) {
+  switch(form) {
+  case DW_FORM_addr:
+    return MC_DW_CLASS_ADDRESS;
+  case DW_FORM_block2:
+  case DW_FORM_block4:
+  case DW_FORM_block:
+  case DW_FORM_block1:
+    return MC_DW_CLASS_BLOCK;
+  case DW_FORM_data1:
+  case DW_FORM_data2:
+  case DW_FORM_data4:
+  case DW_FORM_data8:
+  case DW_FORM_udata:
+  case DW_FORM_sdata:
+    return MC_DW_CLASS_CONSTANT;
+  case DW_FORM_string:
+  case DW_FORM_strp:
+    return MC_DW_CLASS_STRING;
+  case DW_FORM_ref_addr:
+  case DW_FORM_ref1:
+  case DW_FORM_ref2:
+  case DW_FORM_ref4:
+  case DW_FORM_ref8:
+  case DW_FORM_ref_udata:
+    return MC_DW_CLASS_REFERENCE;
+  case DW_FORM_flag:
+  case DW_FORM_flag_present:
+    return MC_DW_CLASS_FLAG;
+  case DW_FORM_exprloc:
+    return MC_DW_CLASS_EXPRLOC;
+  // TODO sec offset
+  // TODO indirect
+  default:
+    return MC_DW_CLASS_UNKNOWN;
+  }
+}
+
+/** \brief Get the name of the tag of a given DIE
+ *
+ *  \param die DIE
+ *  \return name of the tag of this DIE
+ */
+static inline const char* MC_dwarf_die_tagname(Dwarf_Die* die) {
+  return MC_dwarf_tagname(dwarf_tag(die));
+}
+
+// ***** Attributes
+
+/** \brief Get an attribute of a given DIE as a string
+ *
+ *  \param die       the DIE
+ *  \param attribute attribute
+ *  \return value of the given attribute of the given DIE
+ */
+static const char* MC_dwarf_attr_integrate_string(Dwarf_Die* die, int attribute) {
+  Dwarf_Attribute attr;
+  if (!dwarf_attr_integrate(die, attribute, &attr)) {
+       return NULL;
+  } else {
+       return dwarf_formstring(&attr);
+  }
+}
+
+/** \brief Get the linkage name of a DIE.
+ *
+ *  Use either DW_AT_linkage_name or DW_AT_MIPS_linkage_name.
+ *  DW_AT_linkage_name is standardized since DWARF 4.
+ *  Before this version of DWARF, the MIPS extensions
+ *  DW_AT_MIPS_linkage_name is used (at least by GCC).
+ *
+ *  \param  the DIE
+ *  \return linkage name of the given DIE (or NULL)
+ * */
+static const char* MC_dwarf_at_linkage_name(Dwarf_Die* die) {
+  const char* name = MC_dwarf_attr_integrate_string(die, DW_AT_linkage_name);
+  if (!name)
+    name = MC_dwarf_attr_integrate_string(die, DW_AT_MIPS_linkage_name);
+  return name;
+}
+
+static Dwarf_Off MC_dwarf_attr_dieoffset(Dwarf_Die* die, int attribute) {
+  Dwarf_Attribute attr;
+  if (dwarf_hasattr_integrate(die, attribute)) {
+    dwarf_attr_integrate(die, attribute, &attr);
+    Dwarf_Die subtype_die;
+    if (dwarf_formref_die(&attr, &subtype_die)==NULL) {
+      xbt_die("Could not find DIE");
+    }
+    return dwarf_dieoffset(&subtype_die);
+  }
+  else return 0;
+}
+
+static Dwarf_Off MC_dwarf_attr_integrate_dieoffset(Dwarf_Die* die, int attribute) {
+  Dwarf_Attribute attr;
+  if (dwarf_hasattr_integrate(die, attribute)) {
+    dwarf_attr_integrate(die, DW_AT_type, &attr);
+    Dwarf_Die subtype_die;
+    if (dwarf_formref_die(&attr, &subtype_die)==NULL) {
+      xbt_die("Could not find DIE");
+    }
+    return dwarf_dieoffset(&subtype_die);
+  }
+  else return 0;
+}
+
+/** \brief Find the type/subtype (DW_AT_type) for a DIE
+ *
+ *  \param dit the DIE
+ *  \return DW_AT_type reference as a global offset in hexadecimal (or NULL)
+ */
+static char* MC_dwarf_at_type(Dwarf_Die* die) {
+  Dwarf_Off offset = MC_dwarf_attr_integrate_dieoffset(die, DW_AT_type);
+  return offset == 0 ? NULL : bprintf("%" PRIx64 , offset);
+}
+
+static uint64_t MC_dwarf_attr_integrate_addr(Dwarf_Die* die, int attribute) {
+  Dwarf_Attribute attr;
+  if(dwarf_attr_integrate(die, attribute, &attr)==NULL)
+    return 0;
+  Dwarf_Addr value;
+  if (dwarf_formaddr(&attr, &value) == 0)
+    return (uint64_t) value;
+  else
+    return 0;
+}
+
+static uint64_t MC_dwarf_attr_integrate_uint(Dwarf_Die* die, int attribute, uint64_t default_value) {
+  Dwarf_Attribute attr;
+  if (dwarf_attr_integrate(die, attribute, &attr)==NULL)
+    return default_value;
+  Dwarf_Word value;
+  return dwarf_formudata(dwarf_attr_integrate(die, attribute, &attr), &value) == 0 ? (uint64_t) value : default_value;
+}
+
+static bool MC_dwarf_attr_flag(Dwarf_Die* die, int attribute, bool integrate) {
+  Dwarf_Attribute attr;
+  if ((integrate ? dwarf_attr_integrate(die, attribute, &attr)
+                    : dwarf_attr(die, attribute, &attr))==0)
+    return false;
+
+  bool result;
+  if (dwarf_formflag(&attr, &result))
+    xbt_die("Unexpected form for attribute %s",
+      MC_dwarf_attrname(attribute));
+  return result;
+}
+
+/** \brief Find the default lower bound for a given language
+ *
+ *  The default lower bound of an array (when DW_TAG_lower_bound
+ *  is missing) depends on the language of the compilation unit.
+ *
+ *  \param lang Language of the compilation unit (values defined in the DWARF spec)
+ *  \return     Default lower bound of an array in this compilation unit
+ * */
+static uint64_t MC_dwarf_default_lower_bound(int lang) {
+  switch(lang) {
+  case DW_LANG_C:
+  case DW_LANG_C89:
+  case DW_LANG_C99:
+  case DW_LANG_C_plus_plus:
+  case DW_LANG_D:
+  case DW_LANG_Java:
+  case DW_LANG_ObjC:
+  case DW_LANG_ObjC_plus_plus:
+  case DW_LANG_Python:
+  case DW_LANG_UPC:
+    return 0;
+  case DW_LANG_Ada83:
+  case DW_LANG_Ada95:
+  case DW_LANG_Fortran77:
+  case DW_LANG_Fortran90:
+  case DW_LANG_Fortran95:
+  case DW_LANG_Modula2:
+  case DW_LANG_Pascal83:
+  case DW_LANG_PL1:
+  case DW_LANG_Cobol74:
+  case DW_LANG_Cobol85:
+    return 1;
+  default:
+    xbt_die("No default DW_TAG_lower_bound for language %i and none given", lang);
+    return 0;
+  }
+}
+
+/** \brief Finds the number of elements in a DW_TAG_subrange_type or DW_TAG_enumeration_type DIE
+ *
+ *  \param die  the DIE
+ *  \param unit DIE of the compilation unit
+ *  \return     number of elements in the range
+ * */
+static uint64_t MC_dwarf_subrange_element_count(Dwarf_Die* die, Dwarf_Die* unit) {
+  xbt_assert(dwarf_tag(die)==DW_TAG_enumeration_type ||dwarf_tag(die)==DW_TAG_subrange_type,
+      "MC_dwarf_subrange_element_count called with DIE of type %s", MC_dwarf_die_tagname(die));
+
+  // Use DW_TAG_count if present:
+  if (dwarf_hasattr_integrate(die, DW_AT_count)) {
+    return MC_dwarf_attr_integrate_uint(die, DW_AT_count, 0);
+  }
+
+  // Otherwise compute DW_TAG_upper_bound-DW_TAG_lower_bound + 1:
+
+  if (!dwarf_hasattr_integrate(die, DW_AT_upper_bound)) {
+       // This is not really 0, but the code expects this (we do not know):
+    return 0;
+  }
+  uint64_t upper_bound = MC_dwarf_attr_integrate_uint(die, DW_AT_upper_bound, -1);
+
+  uint64_t lower_bound = 0;
+  if (dwarf_hasattr_integrate(die, DW_AT_lower_bound)) {
+    lower_bound = MC_dwarf_attr_integrate_uint(die, DW_AT_lower_bound, -1);
+  } else {
+       lower_bound = MC_dwarf_default_lower_bound(dwarf_srclang(unit));
+  }
+  return upper_bound - lower_bound + 1;
+}
+
+/** \brief Finds the number of elements in a array type (DW_TAG_array_type)
+ *
+ *  The compilation unit might be needed because the default lower
+ *  bound depends on the language of the compilation unit.
+ *
+ *  \param die the DIE of the DW_TAG_array_type
+ *  \param unit the DIE of the compilation unit
+ *  \return number of elements in this array type
+ * */
+static uint64_t MC_dwarf_array_element_count(Dwarf_Die* die, Dwarf_Die* unit) {
+  xbt_assert(dwarf_tag(die)==DW_TAG_array_type,
+    "MC_dwarf_array_element_count called with DIE of type %s", MC_dwarf_die_tagname(die));
+
+  int result = 1;
+  Dwarf_Die child;
+  int res;
+  for (res=dwarf_child(die, &child); res==0; res=dwarf_siblingof(&child,&child)) {
+       int child_tag = dwarf_tag(&child);
+    if (child_tag==DW_TAG_subrange_type ||child_tag==DW_TAG_enumeration_type) {
+      result *= MC_dwarf_subrange_element_count(&child, unit);
+    }
+  }
+  return result;
+}
+
+// ***** dw_type_t
+
+/** \brief Initialize the location of a member of a type
+ * (DW_AT_data_member_location of a DW_TAG_member).
+ *
+ *  \param  type   a type (struct, class)
+ *  \param  member the member of the type
+ *  \param  child  DIE of the member (DW_TAG_member)
+ */
+static void MC_dwarf_fill_member_location(dw_type_t type, dw_type_t member, Dwarf_Die* child) {
+  if (dwarf_hasattr(child, DW_AT_data_bit_offset)) {
+    xbt_die("Can't groke DW_AT_data_bit_offset.");
+  }
+
+  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 <%"PRIx64">%s",
+          member->name, (uint64_t) type->id, type->name);
+    } else {
+      return;
+    }
+  }
+
+  Dwarf_Attribute attr;
+  dwarf_attr_integrate(child, DW_AT_data_member_location, &attr);
+  int form = dwarf_whatform(&attr);
+  int klass = MC_dwarf_form_get_class(form);
+  switch (klass) {
+  case MC_DW_CLASS_EXPRLOC:
+  case MC_DW_CLASS_BLOCK:
+    // Location expression:
+    {
+      Dwarf_Op* expr;
+      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 <%"PRIx64">%s",
+          MC_dwarf_attr_integrate_string(child, DW_AT_name),
+          (uint64_t) type->id, type->name);
+      }
+      if (len==1 && expr[0].atom == DW_OP_plus_uconst) {
+        member->offset =  expr[0].number;
+      } else {
+        mc_dwarf_expression_init(&member->location, len, expr);
+      }
+      break;
+    }
+  case MC_DW_CLASS_CONSTANT:
+    // Offset from the base address of the object:
+    {
+      Dwarf_Word offset;
+      if (!dwarf_formudata(&attr, &offset))
+        member->offset = offset;
+      else
+        xbt_die("Cannot get %s location <%"PRIx64">%s",
+          MC_dwarf_attr_integrate_string(child, DW_AT_name),
+          (uint64_t) type->id, type->name);
+      break;
+    }
+  case MC_DW_CLASS_LOCLISTPTR:
+    // Reference to a location list:
+    // TODO
+  case MC_DW_CLASS_REFERENCE:
+    // It's supposed to be possible in DWARF2 but I couldn't find its semantic
+    // in the spec.
+  default:
+    xbt_die(
+      "Can't handle form class (%i) / form 0x%x as DW_AT_member_location",
+      klass, form);
+  }
+
+}
+
+static void dw_type_free_voidp(void *t){
+  dw_type_free((dw_type_t) * (void **) t);
+}
+
+/** \brief Populate the list of members of a type
+ *
+ *  \param info ELF object containing the type DIE
+ *  \param die  DIE of the type
+ *  \param unit DIE of the compilation unit containing the type DIE
+ *  \param type the type
+ */
+static void MC_dwarf_add_members(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_type_t type) {
+  int res;
+  Dwarf_Die child;
+  xbt_assert(!type->members);
+  type->members = xbt_dynar_new(sizeof(dw_type_t), (void(*)(void*))dw_type_free_voidp);
+  for (res=dwarf_child(die, &child); res==0; res=dwarf_siblingof(&child,&child)) {
+    int tag = dwarf_tag(&child);
+    if (tag==DW_TAG_member || tag==DW_TAG_inheritance) {
+
+      // Skip declarations:
+      if (MC_dwarf_attr_flag(&child, DW_AT_declaration, false))
+        continue;
+
+      // Skip compile time constants:
+      if(dwarf_hasattr(&child, DW_AT_const_value))
+        continue;
+
+      // TODO, we should use another type (because is is not a type but a member)
+      dw_type_t member = xbt_new0(s_dw_type_t, 1);
+      member->type = tag;
+
+      // Global Offset:
+      member->id = dwarf_dieoffset(&child);
+
+      const char* name = MC_dwarf_attr_integrate_string(&child, DW_AT_name);
+      if(name)
+        member->name = xbt_strdup(name);
+      else
+        member->name = NULL;
+
+      member->byte_size = MC_dwarf_attr_integrate_uint(&child, DW_AT_byte_size, 0);
+      member->element_count = -1;
+      member->dw_type_id = MC_dwarf_at_type(&child);
+      member->members = NULL;
+      member->is_pointer_type = 0;
+      member->offset = 0;
+
+      if(dwarf_hasattr(&child, DW_AT_data_bit_offset)) {
+        xbt_die("Can't groke DW_AT_data_bit_offset.");
+      }
+
+      MC_dwarf_fill_member_location(type, member, &child);
+
+      if (!member->dw_type_id) {
+        xbt_die("Missing type for member %s of <%"PRIx64">%s", member->name, (uint64_t) type->id, type->name);
+      }
+
+      xbt_dynar_push(type->members, &member);
+    }
+  }
+}
+
+/** \brief Create a MC type object from a DIE
+ *
+ *  \param info current object info object
+ *  \param DIE (for a given type);
+ *  \param unit compilation unit of the current DIE
+ *  \return MC representation of the type
+ */
+static dw_type_t MC_dwarf_die_to_type(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
+
+  dw_type_t type = xbt_new0(s_dw_type_t, 1);
+  type->type = -1;
+  type->id = 0;
+  type->name = NULL;
+  type->byte_size = 0;
+  type->element_count = -1;
+  type->dw_type_id = NULL;
+  type->members = NULL;
+  type->is_pointer_type = 0;
+  type->offset = 0;
+
+  type->type = dwarf_tag(die);
+
+  // Global Offset
+  type->id = dwarf_dieoffset(die);
+
+  const char* prefix = "";
+  switch (type->type) {
+  case DW_TAG_structure_type:
+    prefix = "struct ";
+    break;
+  case DW_TAG_union_type:
+    prefix = "union ";
+    break;
+  case DW_TAG_class_type:
+    prefix = "class ";
+    break;
+  default:
+    prefix = "";
+  }
+
+  const char* name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
+  if (name!=NULL) {
+    type->name = namespace ? bprintf("%s%s::%s", prefix, namespace, name) : bprintf("%s%s", prefix, name);
+  }
+
+  type->dw_type_id = MC_dwarf_at_type(die);
+
+  // Computation of the byte_size;
+  if (dwarf_hasattr_integrate(die, DW_AT_byte_size))
+    type->byte_size = MC_dwarf_attr_integrate_uint(die, DW_AT_byte_size, 0);
+  else if (type->type == DW_TAG_array_type || type->type==DW_TAG_structure_type || type->type==DW_TAG_class_type) {
+    Dwarf_Word size;
+    if (dwarf_aggregate_size(die, &size)==0) {
+      type->byte_size = size;
+    }
+  }
+
+  switch (type->type) {
+  case DW_TAG_array_type:
+       type->element_count = MC_dwarf_array_element_count(die, unit);
+       // TODO, handle DW_byte_stride and (not) DW_bit_stride
+       break;
+
+  case DW_TAG_pointer_type:
+  case DW_TAG_reference_type:
+  case DW_TAG_rvalue_reference_type:
+    type->is_pointer_type = 1;
+    break;
+
+  case DW_TAG_structure_type:
+  case DW_TAG_union_type:
+  case DW_TAG_class_type:
+         MC_dwarf_add_members(info, die, unit, type);
+         char* new_namespace = namespace == NULL ? xbt_strdup(type->name)
+           : bprintf("%s::%s", namespace, name);
+         MC_dwarf_handle_children(info, die, unit, frame, new_namespace);
+         free(new_namespace);
+         break;
+  }
+
+  return type;
+}
+
+static void MC_dwarf_handle_type_die(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
+  dw_type_t type = MC_dwarf_die_to_type(info, die, unit, frame, namespace);
+
+  char* key = bprintf("%" PRIx64, (uint64_t) type->id);
+  xbt_dict_set(info->types, key, type, NULL);
+  xbt_free(key);
+
+  if(type->name && type->byte_size!=0) {
+    xbt_dict_set(info->full_types_by_name, type->name, type, NULL);
+  }
+}
+
+static int mc_anonymous_variable_index = 0;
+
+static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
+  // Skip declarations:
+  if (MC_dwarf_attr_flag(die, DW_AT_declaration, false))
+    return NULL;
+
+  // Skip compile time constants:
+  if(dwarf_hasattr(die, DW_AT_const_value))
+    return NULL;
+
+  Dwarf_Attribute attr_location;
+  if (dwarf_attr(die, DW_AT_location, &attr_location)==NULL) {
+    // No location: do not add it ?
+    return NULL;
+  }
+
+  dw_variable_t variable = xbt_new0(s_dw_variable_t, 1);
+  variable->dwarf_offset = dwarf_dieoffset(die);
+  variable->global = frame == NULL; // Can be override base on DW_AT_location
+  variable->object_info = info;
+
+  const char* name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
+  variable->name = xbt_strdup(name);
+
+  variable->type_origin = MC_dwarf_at_type(die);
+
+  int form = dwarf_whatform(&attr_location);
+  int klass = form == DW_FORM_sec_offset ? MC_DW_CLASS_CONSTANT : MC_dwarf_form_get_class(form);
+  switch (klass) {
+  case MC_DW_CLASS_EXPRLOC:
+  case MC_DW_CLASS_BLOCK:
+    // Location expression:
+    {
+      Dwarf_Op* expr;
+      size_t len;
+      if (dwarf_getlocation(&attr_location, &expr, &len)) {
+        xbt_die(
+          "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;
+        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);
+      }
+
+      break;
+    }
+  case MC_DW_CLASS_LOCLISTPTR:
+  case MC_DW_CLASS_CONSTANT:
+    // Reference to location list:
+    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 <%"PRIx64">%s",
+      form, form, klass, klass, (uint64_t) variable->dwarf_offset, variable->name);
+  }
+
+  // Handle start_scope:
+  if (dwarf_hasattr(die, DW_AT_start_scope)) {
+    Dwarf_Attribute attr;
+    dwarf_attr(die, DW_AT_start_scope, &attr);
+    int form  = dwarf_whatform(&attr);
+    int klass = MC_dwarf_form_get_class(form);
+    switch(klass) {
+    case MC_DW_CLASS_CONSTANT:
+    {
+      Dwarf_Word value;
+      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);
+    }
+  }
+
+  if(namespace && variable->global) {
+    char* old_name = variable->name;
+    variable->name = bprintf("%s::%s", namespace, old_name);
+    free(old_name);
+  }
+
+  // The current code needs a variable name,
+  // generate a fake one:
+  if(!variable->name) {
+    variable->name = bprintf("@anonymous#%i", mc_anonymous_variable_index++);
+  }
+
+  return variable;
+}
+
+static void MC_dwarf_handle_variable_die(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
+  dw_variable_t variable = MC_die_to_variable(info, die, unit, frame, namespace);
+  if(variable==NULL)
+      return;
+  MC_dwarf_register_variable(info, frame, variable);
+}
+
+static void mc_frame_free_voipd(dw_frame_t* p) {
+  mc_frame_free(*p);
+  *p = NULL;
+}
+
+static void MC_dwarf_handle_scope_die(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t parent_frame, const char* namespace) {
+  // TODO, handle DW_TAG_type/DW_TAG_location for DW_TAG_with_stmt
+  int tag = dwarf_tag(die);
+  mc_tag_class klass = MC_dwarf_tag_classify(tag);
+
+  // (Template) Subprogram declaration:
+  if(klass==mc_tag_subprogram && MC_dwarf_attr_flag(die, DW_AT_declaration, false))
+    return;
+
+  if(klass==mc_tag_scope)
+    xbt_assert(parent_frame, "No parent scope for this scope");
+
+  dw_frame_t frame = xbt_new0(s_dw_frame_t, 1);
+
+  frame->tag   = tag;
+  frame->id = dwarf_dieoffset(die);
+  frame->object_info = info;
+
+  if(klass==mc_tag_subprogram) {
+    const char* name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
+    frame->name = namespace ? bprintf("%s::%s", namespace, name) : xbt_strdup(name);
+  }
+
+  frame->abstract_origin_id = MC_dwarf_attr_dieoffset(die, DW_AT_abstract_origin);
+
+  // This is the base address for DWARF addresses.
+  // Relocated addresses are offset from this base address.
+  // See DWARF4 spec 7.5
+  void* base = MC_object_base_address(info);
+
+  // 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);
+
+  // 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)) {
+      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");
+
+    }
+  }
+
+  if(klass==mc_tag_subprogram) {
+    Dwarf_Attribute attr_frame_base;
+    if (dwarf_attr_integrate(die, DW_AT_frame_base, &attr_frame_base))
+      mc_dwarf_location_list_init(&frame->frame_base, info, die, &attr_frame_base);
+  }
+
+  frame->scopes = xbt_dynar_new(sizeof(dw_frame_t), (void_f_pvoid_t) mc_frame_free_voipd);
+
+  // Register it:
+  if(klass==mc_tag_subprogram) {
+    char* key = bprintf("%" PRIx64, (uint64_t) frame->id);
+    xbt_dict_set(info->subprograms,  key, frame, NULL);
+    xbt_free(key);
+  } else if(klass==mc_tag_scope) {
+    xbt_dynar_push(parent_frame->scopes, &frame);
+  }
+
+  // Handle children:
+  MC_dwarf_handle_children(info, die, unit, frame, namespace);
+}
+
+static void mc_dwarf_handle_namespace_die(
+    mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
+  const char* name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
+  if(frame)
+    xbt_die("Unexpected namespace in a subprogram");
+  char* new_namespace = namespace == NULL ? xbt_strdup(name)
+    : bprintf("%s::%s", namespace, name);
+  MC_dwarf_handle_children(info, die, unit, frame, new_namespace);
+  xbt_free(new_namespace);
+}
+
+static void MC_dwarf_handle_children(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
+  // For each child DIE:
+  Dwarf_Die child;
+  int res;
+  for (res=dwarf_child(die, &child); res==0; res=dwarf_siblingof(&child,&child)) {
+    MC_dwarf_handle_die(info, &child, unit, frame, namespace);
+  }
+}
+
+static void MC_dwarf_handle_die(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame, const char* namespace) {
+  int tag = dwarf_tag(die);
+  mc_tag_class klass = MC_dwarf_tag_classify(tag);
+  switch (klass) {
+
+    // Type:
+    case mc_tag_type:
+      MC_dwarf_handle_type_die(info, die, unit, frame, namespace);
+      break;
+
+    // Subprogram or scope:
+    case mc_tag_subprogram:
+    case mc_tag_scope:
+      MC_dwarf_handle_scope_die(info, die, unit, frame, namespace);
+      return;
+
+    // Variable:
+    case mc_tag_variable:
+      MC_dwarf_handle_variable_die(info, die, unit, frame, namespace);
+      break;
+
+    case mc_tag_namespace:
+      mc_dwarf_handle_namespace_die(info, die, unit, frame, namespace);
+      break;
+
+    default:
+      break;
+
+  }
+}
+
+/** \brief Populate the debugging informations of the given ELF object
+ *
+ *  Read the DWARf information of the EFFL object and populate the
+ *  lists of types, variables, functions.
+ */
+void MC_dwarf_get_variables(mc_object_info_t info) {
+  int fd = open(info->file_name, O_RDONLY);
+  if (fd<0) {
+    xbt_die("Could not open file %s", info->file_name);
+  }
+  Dwarf *dwarf = dwarf_begin(fd, DWARF_C_READ);
+  if (dwarf==NULL) {
+    xbt_die("Your program must be compiled with -g");
+  }
+
+  // For each compilation unit:
+  Dwarf_Off offset = 0;
+  Dwarf_Off next_offset = 0;
+  size_t length;
+  while (dwarf_nextcu (dwarf, offset, &next_offset, &length, NULL, NULL, NULL) == 0) {
+    Dwarf_Die unit_die;
+    if(dwarf_offdie(dwarf, offset+length, &unit_die)!=NULL) {
+
+      // For each child DIE:
+      Dwarf_Die child;
+      int res;
+      for (res=dwarf_child(&unit_die, &child); res==0; res=dwarf_siblingof(&child,&child)) {
+        MC_dwarf_handle_die(info, &child, &unit_die, NULL, NULL);
+      }
+
+    }
+    offset = next_offset;
+  }
+
+  dwarf_end(dwarf);
+  close(fd);
+}
diff --git a/src/mc/mc_dwarf_attrnames.h b/src/mc/mc_dwarf_attrnames.h
new file mode 100644 (file)
index 0000000..5c83793
--- /dev/null
@@ -0,0 +1,145 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+case 0x01: return "DW_AT_sibling";
+case 0x02: return "DW_AT_location";
+case 0x03: return "DW_AT_name";
+case 0x09: return "DW_AT_ordering";
+case 0x0a: return "DW_AT_subscr_data";
+case 0x0b: return "DW_AT_byte_size";
+case 0x0c: return "DW_AT_bit_offset";
+case 0x0d: return "DW_AT_bit_size";
+case 0x0f: return "DW_AT_element_list";
+case 0x10: return "DW_AT_stmt_list";
+case 0x11: return "DW_AT_low_pc";
+case 0x12: return "DW_AT_high_pc";
+case 0x13: return "DW_AT_language";
+case 0x14: return "DW_AT_member";
+case 0x15: return "DW_AT_discr";
+case 0x16: return "DW_AT_discr_value";
+case 0x17: return "DW_AT_visibility";
+case 0x18: return "DW_AT_import";
+case 0x19: return "DW_AT_string_length";
+case 0x1a: return "DW_AT_common_reference";
+case 0x1b: return "DW_AT_comp_dir";
+case 0x1c: return "DW_AT_const_value";
+case 0x1d: return "DW_AT_containing_type";
+case 0x1e: return "DW_AT_default_value";
+case 0x20: return "DW_AT_inline";
+case 0x21: return "DW_AT_is_optional";
+case 0x22: return "DW_AT_lower_bound";
+case 0x25: return "DW_AT_producer";
+case 0x27: return "DW_AT_prototyped";
+case 0x2a: return "DW_AT_return_addr";
+case 0x2c: return "DW_AT_start_scope";
+case 0x2e: return "DW_AT_bit_stride";
+case 0x2f: return "DW_AT_upper_bound";
+case 0x31: return "DW_AT_abstract_origin";
+case 0x32: return "DW_AT_accessibility";
+case 0x33: return "DW_AT_address_class";
+case 0x34: return "DW_AT_artificial";
+case 0x35: return "DW_AT_base_types";
+case 0x36: return "DW_AT_calling_convention";
+case 0x37: return "DW_AT_count";
+case 0x38: return "DW_AT_data_member_location";
+case 0x39: return "DW_AT_decl_column";
+case 0x3a: return "DW_AT_decl_file";
+case 0x3b: return "DW_AT_decl_line";
+case 0x3c: return "DW_AT_declaration";
+case 0x3d: return "DW_AT_discr_list";
+case 0x3e: return "DW_AT_encoding";
+case 0x3f: return "DW_AT_external";
+case 0x40: return "DW_AT_frame_base";
+case 0x41: return "DW_AT_friend";
+case 0x42: return "DW_AT_identifier_case";
+case 0x43: return "DW_AT_macro_info";
+case 0x44: return "DW_AT_namelist_item";
+case 0x45: return "DW_AT_priority";
+case 0x46: return "DW_AT_segment";
+case 0x47: return "DW_AT_specification";
+case 0x48: return "DW_AT_static_link";
+case 0x49: return "DW_AT_type";
+case 0x4a: return "DW_AT_use_location";
+case 0x4b: return "DW_AT_variable_parameter";
+case 0x4c: return "DW_AT_virtuality";
+case 0x4d: return "DW_AT_vtable_elem_location";
+case 0x4e: return "DW_AT_allocated";
+case 0x4f: return "DW_AT_associated";
+case 0x50: return "DW_AT_data_location";
+case 0x51: return "DW_AT_byte_stride";
+case 0x52: return "DW_AT_entry_pc";
+case 0x53: return "DW_AT_use_UTF8";
+case 0x54: return "DW_AT_extension";
+case 0x55: return "DW_AT_ranges";
+case 0x56: return "DW_AT_trampoline";
+case 0x57: return "DW_AT_call_column";
+case 0x58: return "DW_AT_call_file";
+case 0x59: return "DW_AT_call_line";
+case 0x5a: return "DW_AT_description";
+case 0x5b: return "DW_AT_binary_scale";
+case 0x5c: return "DW_AT_decimal_scale";
+case 0x5d: return "DW_AT_small";
+case 0x5e: return "DW_AT_decimal_sign";
+case 0x5f: return "DW_AT_digit_count";
+case 0x60: return "DW_AT_picture_string";
+case 0x61: return "DW_AT_mutable";
+case 0x62: return "DW_AT_threads_scaled";
+case 0x63: return "DW_AT_explicit";
+case 0x64: return "DW_AT_object_pointer";
+case 0x65: return "DW_AT_endianity";
+case 0x66: return "DW_AT_elemental";
+case 0x67: return "DW_AT_pure";
+case 0x68: return "DW_AT_recursive";
+case 0x69: return "DW_AT_signature";
+case 0x6a: return "DW_AT_main_subprogram";
+case 0x6b: return "DW_AT_data_bit_offset";
+case 0x6c: return "DW_AT_const_expr";
+case 0x6d: return "DW_AT_enum_class";
+case 0x6e: return "DW_AT_linkage_name";
+case 0x2000: return "DW_AT_lo_user";
+case 0x2001: return "DW_AT_MIPS_fde";
+case 0x2002: return "DW_AT_MIPS_loop_begin";
+case 0x2003: return "DW_AT_MIPS_tail_loop_begin";
+case 0x2004: return "DW_AT_MIPS_epilog_begin";
+case 0x2005: return "DW_AT_MIPS_loop_unroll_factor";
+case 0x2006: return "DW_AT_MIPS_software_pipeline_depth";
+case 0x2007: return "DW_AT_MIPS_linkage_name";
+case 0x2008: return "DW_AT_MIPS_stride";
+case 0x2009: return "DW_AT_MIPS_abstract_name";
+case 0x200a: return "DW_AT_MIPS_clone_origin";
+case 0x200b: return "DW_AT_MIPS_has_inlines";
+case 0x200c: return "DW_AT_MIPS_stride_byte";
+case 0x200d: return "DW_AT_MIPS_stride_elem";
+case 0x200e: return "DW_AT_MIPS_ptr_dopetype";
+case 0x200f: return "DW_AT_MIPS_allocatable_dopetype";
+case 0x2010: return "DW_AT_MIPS_assumed_shape_dopetype";
+case 0x2011: return "DW_AT_MIPS_assumed_size";
+case 0x2101: return "DW_AT_sf_names";
+case 0x2102: return "DW_AT_src_info";
+case 0x2103: return "DW_AT_mac_info";
+case 0x2104: return "DW_AT_src_coords";
+case 0x2105: return "DW_AT_body_begin";
+case 0x2106: return "DW_AT_body_end";
+case 0x2107: return "DW_AT_GNU_vector";
+case 0x2108: return "DW_AT_GNU_guarded_by";
+case 0x2109: return "DW_AT_GNU_pt_guarded_by";
+case 0x210a: return "DW_AT_GNU_guarded";
+case 0x210b: return "DW_AT_GNU_pt_guarded";
+case 0x210c: return "DW_AT_GNU_locks_excluded";
+case 0x210d: return "DW_AT_GNU_exclusive_locks_required";
+case 0x210e: return "DW_AT_GNU_shared_locks_required";
+case 0x210f: return "DW_AT_GNU_odr_signature";
+case 0x2110: return "DW_AT_GNU_template_name";
+case 0x2111: return "DW_AT_GNU_call_site_value";
+case 0x2112: return "DW_AT_GNU_call_site_data_value";
+case 0x2113: return "DW_AT_GNU_call_site_target";
+case 0x2114: return "DW_AT_GNU_call_site_target_clobbered";
+case 0x2115: return "DW_AT_GNU_tail_call";
+case 0x2116: return "DW_AT_GNU_all_tail_call_sites";
+case 0x2117: return "DW_AT_GNU_all_call_sites";
+case 0x2118: return "DW_AT_GNU_all_source_call_sites";
+case 0x2119: return "DW_AT_GNU_macros";
+case 0x3fff: return "DW_AT_hi_user";
diff --git a/src/mc/mc_dwarf_expression.c b/src/mc/mc_dwarf_expression.c
new file mode 100644 (file)
index 0000000..e92da2a
--- /dev/null
@@ -0,0 +1,420 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <stdint.h>
+#include <stdarg.h>
+
+#include <dwarf.h>
+#include <elfutils/libdw.h>
+
+#include "mc_private.h"
+
+static int mc_dwarf_push_value(mc_expression_state_t state, Dwarf_Off value) {
+  if(state->stack_size>=MC_EXPRESSION_STACK_SIZE)
+    return MC_EXPRESSION_E_STACK_OVERFLOW;
+
+  state->stack[state->stack_size++] = value;
+  return 0;
+}
+
+static int mc_dwarf_register_to_libunwind(int dwarf_register) {
+  #if defined(UNW_TARGET_X86_64)
+  // It seems for this arch, DWARF and libunwind agree in the numbering:
+  return dwarf_register;
+  #elif defined(UNW_TARGET_X86)
+  // Could't find the authoritative source of information for this.
+  // This is inspired from http://source.winehq.org/source/dlls/dbghelp/cpu_i386.c#L517.
+  switch(dwarf_register) {
+  case 0:  return UNW_X86_EAX;
+  case 1:  return UNW_X86_ECX;
+  case 2:  return UNW_X86_EDX;
+  case 3:  return UNW_X86_EBX;
+  case 4:  return UNW_X86_ESP;
+  case 5:  return UNW_X86_EBP;
+  case 6:  return UNW_X86_ESI;
+  case 7:  return UNW_X86_EDI;
+  case 8:  return UNW_X86_EIP;
+  case 9:  return UNW_X86_EFLAGS;
+  case 10: return UNW_X86_CS;
+  case 11: return UNW_X86_SS;
+  case 12: return UNW_X86_DS;
+  case 13: return UNW_X86_ES;
+  case 14: return UNW_X86_FS;
+  case 15: return UNW_X86_GS;
+  case 16: return UNW_X86_ST0;
+  case 17: return UNW_X86_ST1;
+  case 18: return UNW_X86_ST2;
+  case 19: return UNW_X86_ST3;
+  case 20: return UNW_X86_ST4;
+  case 21: return UNW_X86_ST5;
+  case 22: return UNW_X86_ST6;
+  case 23: return UNW_X86_ST7;
+  default: xbt_die("Bad/unknown register number.");
+  }
+  #else
+  #error This architecture is not supported yet.
+  #endif
+}
+
+int mc_dwarf_execute_expression(
+  size_t n, const Dwarf_Op* ops, mc_expression_state_t state) {
+  for(int i=0; i!=n; ++i) {
+    int error = 0;
+    const Dwarf_Op* op = ops + i;
+    uint8_t atom = op->atom;
+
+    switch (atom) {
+
+    // Registers:
+
+    case DW_OP_breg0: case DW_OP_breg1: case DW_OP_breg2: case DW_OP_breg3:
+    case DW_OP_breg4: case DW_OP_breg5: case DW_OP_breg6: case DW_OP_breg7:
+    case DW_OP_breg8: case DW_OP_breg9: case DW_OP_breg10: case DW_OP_breg11:
+    case DW_OP_breg12: case DW_OP_breg13: case DW_OP_breg14: case DW_OP_breg15:
+    case DW_OP_breg16: case DW_OP_breg17: case DW_OP_breg18: case DW_OP_breg19:
+    case DW_OP_breg20: case DW_OP_breg21: case DW_OP_breg22: case DW_OP_breg23:
+    case DW_OP_breg24: case DW_OP_breg25: case DW_OP_breg26: case DW_OP_breg27:
+    case DW_OP_breg28: case DW_OP_breg29: case DW_OP_breg30: case DW_OP_breg31:{
+        int register_id = mc_dwarf_register_to_libunwind(op->atom - DW_OP_breg0);
+        unw_word_t res;
+        if(!state->cursor)
+          return MC_EXPRESSION_E_MISSING_STACK_CONTEXT;
+        unw_get_reg(state->cursor, register_id, &res);
+        error = mc_dwarf_push_value(state, res + op->number);
+        break;
+      }
+
+    // Push the CFA (Canonical Frame Addresse):
+    case DW_OP_call_frame_cfa:
+    {
+      // UNW_X86_64_CFA does not return the CFA DWARF expects
+      // (it is a synonym for UNW_X86_64_RSP) so copy the cursor,
+      // unwind it once in order to find the parent SP:
+
+      if(!state->cursor)
+        return MC_EXPRESSION_E_MISSING_STACK_CONTEXT;
+
+      // Get frame:
+      unw_cursor_t cursor = *(state->cursor);
+      unw_step(&cursor);
+
+      unw_word_t res;
+      unw_get_reg(&cursor, UNW_TDEP_SP, &res);
+      error = mc_dwarf_push_value(state, res);
+      break;
+    }
+
+    // Frame base:
+
+    case DW_OP_fbreg:
+      {
+        if(!state->frame_base)
+          return MC_EXPRESSION_E_MISSING_FRAME_BASE;
+        error = mc_dwarf_push_value(state, ((uintptr_t)state->frame_base) + op->number);
+        break;
+      }
+
+
+    // Constants:
+
+    case DW_OP_lit0: case DW_OP_lit1: case DW_OP_lit2: case DW_OP_lit3:
+    case DW_OP_lit4: case DW_OP_lit5: case DW_OP_lit6: case DW_OP_lit7:
+    case DW_OP_lit8: case DW_OP_lit9: case DW_OP_lit10: case DW_OP_lit11:
+    case DW_OP_lit12: case DW_OP_lit13: case DW_OP_lit14: case DW_OP_lit15:
+    case DW_OP_lit16: case DW_OP_lit17: case DW_OP_lit18: case DW_OP_lit19:
+    case DW_OP_lit20: case DW_OP_lit21: case DW_OP_lit22: case DW_OP_lit23:
+    case DW_OP_lit24: case DW_OP_lit25: case DW_OP_lit26: case DW_OP_lit27:
+    case DW_OP_lit28: case DW_OP_lit29: case DW_OP_lit30: case DW_OP_lit31:
+      error = mc_dwarf_push_value(state, atom - DW_OP_lit0);
+      break;
+
+    case DW_OP_addr:
+      if(!state->object_info)
+        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)(uintptr_t)MC_object_base_address(state->object_info) + op->number);
+      break;
+
+    case DW_OP_const1u:
+    case DW_OP_const2u:
+    case DW_OP_const4u:
+    case DW_OP_const8u:
+    case DW_OP_const1s:
+    case DW_OP_const2s:
+    case DW_OP_const4s:
+    case DW_OP_const8s:
+    case DW_OP_constu:
+    case DW_OP_consts:
+      if(state->stack_size==MC_EXPRESSION_STACK_SIZE)
+        return MC_EXPRESSION_E_STACK_OVERFLOW;
+      error = mc_dwarf_push_value(state, op->number);
+      break;
+
+    // Stack manipulation:
+
+    // Push the value at the top of the stack:
+    case DW_OP_dup:
+      if(state->stack_size==0)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      else
+        error = mc_dwarf_push_value(state, state->stack[state->stack_size-1]);
+      break;
+
+    case DW_OP_drop:
+      if(state->stack_size==0)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      else
+        state->stack_size--;
+      break;
+
+    case DW_OP_swap:
+      if(state->stack_size<2)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      {
+        uintptr_t temp = state->stack[state->stack_size-2];
+        state->stack[state->stack_size-2] = state->stack[state->stack_size-1];
+        state->stack[state->stack_size-1] = temp;
+      }
+      break;
+
+    case DW_OP_over:
+      if(state->stack_size<2)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      error = mc_dwarf_push_value(state, state->stack[state->stack_size-2]);
+      break;
+
+    // Operations:
+
+    case DW_OP_plus:
+      if(state->stack_size<2)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      {
+        uintptr_t result = state->stack[state->stack_size-2] + state->stack[state->stack_size-1];
+        state->stack[state->stack_size-2] = result;
+        state->stack_size--;
+      }
+      break;
+
+    case DW_OP_mul:
+      if(state->stack_size<2)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      {
+        uintptr_t result = state->stack[state->stack_size-2] - state->stack[state->stack_size-1];
+        state->stack[state->stack_size-2] = result;
+        state->stack_size--;
+      }
+      break;
+
+    case DW_OP_plus_uconst:
+      if(state->stack_size==0)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      state->stack[state->stack_size-1] += op->number;
+      break;
+
+    case DW_OP_not:
+      if(state->stack_size==0)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      state->stack[state->stack_size-1] = ~state->stack[state->stack_size-1];
+      break;
+
+    case DW_OP_neg:
+      if(state->stack_size==0)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      {
+        intptr_t value = state->stack[state->stack_size-1];
+        if(value<0) value = -value;
+        state->stack[state->stack_size-1] = value;
+      }
+      break;
+
+    case DW_OP_minus:
+      if(state->stack_size<2)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      {
+        uintptr_t result = state->stack[state->stack_size-2] - state->stack[state->stack_size-1];
+        state->stack[state->stack_size-2] = result;
+        state->stack_size--;
+      }
+      break;
+
+    case DW_OP_and:
+      if(state->stack_size<2)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      {
+        uintptr_t result = state->stack[state->stack_size-2] & state->stack[state->stack_size-1];
+        state->stack[state->stack_size-2] = result;
+        state->stack_size--;
+      }
+      break;
+
+    case DW_OP_or:
+      if(state->stack_size<2)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      {
+        uintptr_t result = state->stack[state->stack_size-2] | state->stack[state->stack_size-1];
+        state->stack[state->stack_size-2] = result;
+        state->stack_size--;
+      }
+      break;
+
+    case DW_OP_xor:
+      if(state->stack_size<2)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      {
+        uintptr_t result = state->stack[state->stack_size-2] ^ state->stack[state->stack_size-1];
+        state->stack[state->stack_size-2] = result;
+        state->stack_size--;
+      }
+      break;
+
+    case DW_OP_nop:
+      break;
+
+    // Dereference:
+    case DW_OP_deref_size:
+      return MC_EXPRESSION_E_UNSUPPORTED_OPERATION;
+
+    case DW_OP_deref:
+      if(state->stack_size==0)
+        return MC_EXPRESSION_E_STACK_UNDERFLOW;
+      {
+        // Computed address:
+        uintptr_t address = (uintptr_t) state->stack[state->stack_size-1];
+        uintptr_t* p = (uintptr_t*)mc_translate_address(address, state->snapshot);
+        state->stack[state->stack_size-1] = *p;
+      }
+      break;
+
+    // Not handled:
+    default:
+     return MC_EXPRESSION_E_UNSUPPORTED_OPERATION;
+    }
+
+    if(error) return error;
+  }
+  return 0;
+}
+
+// ***** Location
+
+/** \brief Resolve a location expression
+ *  \deprecated Use mc_dwarf_resolve_expression
+ */
+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;
+  state.cursor = c;
+  state.snapshot = snapshot;
+  state.object_info = object_info;
+
+  if(mc_dwarf_execute_expression(expression->size, expression->ops, &state))
+    xbt_die("Error evaluating DWARF expression");
+  if(state.stack_size==0)
+    xbt_die("No value on the stack");
+  else
+    return state.stack[state.stack_size-1];
+}
+
+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) {
+    if(unw_get_reg(c, UNW_REG_IP, &ip))
+      xbt_die("Could not resolve IP");
+  }
+
+  for(size_t i=0; i!=locations->size; ++i) {
+    mc_expression_t expression = locations->locations + i;
+    if( (expression->lowpc==NULL && expression->highpc==NULL)
+      || (c && ip >= (unw_word_t) expression->lowpc && ip < (unw_word_t) expression->highpc)) {
+      return mc_dwarf_resolve_location(expression, object_info, c, frame_pointer_address, snapshot);
+    }
+  }
+  xbt_die("Could not resolve location");
+}
+
+/** \brief Find the frame base of a given frame
+ *
+ *  \param frame
+ *  \param unw_cursor
+ */
+void* mc_find_frame_base(dw_frame_t frame, mc_object_info_t object_info, unw_cursor_t* unw_cursor) {
+  return (void*) mc_dwarf_resolve_locations(&frame->frame_base, object_info, unw_cursor, NULL, NULL);
+}
+
+void mc_dwarf_expression_clear(mc_expression_t expression) {
+  free(expression->ops);
+  expression->ops = NULL;
+  expression->size = 0;
+  expression->lowpc = NULL;
+  expression->highpc = NULL;
+}
+
+void mc_dwarf_location_list_clear(mc_location_list_t list) {
+  for(size_t i=0; i!=list->size; ++i) {
+    mc_dwarf_expression_clear(list->locations + i);
+  }
+  free(list->locations);
+  list->locations = NULL;
+  list->size = 0;
+}
+
+void mc_dwarf_expression_init(mc_expression_t expression, size_t len, Dwarf_Op* ops) {
+  if(expression->ops) {
+    free(expression->ops);
+  }
+  expression->lowpc = NULL;
+  expression->highpc = NULL;
+  expression->size = len;
+  expression->ops = xbt_malloc(len*sizeof(Dwarf_Op));
+  memcpy(expression->ops, ops, len*sizeof(Dwarf_Op));
+}
+
+void mc_dwarf_location_list_init_from_expression(mc_location_list_t target, size_t len, Dwarf_Op* ops) {
+  if(target->locations) {
+    mc_dwarf_location_list_clear(target);
+  }
+  target->size = 1;
+  target->locations = (mc_expression_t) xbt_malloc(sizeof(s_mc_expression_t));
+  mc_dwarf_expression_init(target->locations, len, ops);
+}
+
+void mc_dwarf_location_list_init(mc_location_list_t list, mc_object_info_t info, Dwarf_Die* die, Dwarf_Attribute* attr) {
+  if(list->locations) {
+    mc_dwarf_location_list_clear(list);
+  }
+  list->size = 0;
+
+  ptrdiff_t offset = 0;
+  Dwarf_Addr base, start, end;
+  Dwarf_Op *ops;
+  size_t len;
+
+  while (1) {
+
+    offset = dwarf_getlocations(attr, offset, &base, &start, &end, &ops, &len);
+    if (offset==0)
+      return;
+    else if (offset==-1)
+      xbt_die("Error while loading location list");
+
+    int i = list->size;
+    list->size++;
+    list->locations = (mc_expression_t) realloc(list->locations, list->size*sizeof(s_mc_expression_t));
+    mc_expression_t expression = list->locations + i;
+    expression->ops = NULL;
+    mc_dwarf_expression_init(expression, len, ops);
+
+    void* base = info->flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info);
+    // If start == 0, this is not a location list:
+    expression->lowpc = start == 0 ? NULL : (char*) base + start;
+    expression->highpc = start == 0 ? NULL : (char*) base + end;
+  }
+
+}
diff --git a/src/mc/mc_dwarf_tagnames.h b/src/mc/mc_dwarf_tagnames.h
new file mode 100644 (file)
index 0000000..e87aec4
--- /dev/null
@@ -0,0 +1,80 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+case 0x01: return "DW_TAG_array_type";
+case 0x02: return "DW_TAG_class_type";
+case 0x03: return "DW_TAG_entry_point";
+case 0x04: return "DW_TAG_enumeration_type";
+case 0x05: return "DW_TAG_formal_parameter";
+case 0x08: return "DW_TAG_imported_declaration";
+case 0x0a: return "DW_TAG_label";
+case 0x0b: return "DW_TAG_lexical_block";
+case 0x0d: return "DW_TAG_member";
+case 0x0f: return "DW_TAG_pointer_type";
+case 0x10: return "DW_TAG_reference_type";
+case 0x11: return "DW_TAG_compile_unit";
+case 0x12: return "DW_TAG_string_type";
+case 0x13: return "DW_TAG_structure_type";
+case 0x15: return "DW_TAG_subroutine_type";
+case 0x16: return "DW_TAG_typedef";
+case 0x17: return "DW_TAG_union_type";
+case 0x18: return "DW_TAG_unspecified_parameters";
+case 0x19: return "DW_TAG_variant";
+case 0x1a: return "DW_TAG_common_block";
+case 0x1b: return "DW_TAG_common_inclusion";
+case 0x1c: return "DW_TAG_inheritance";
+case 0x1d: return "DW_TAG_inlined_subroutine";
+case 0x1e: return "DW_TAG_module";
+case 0x1f: return "DW_TAG_ptr_to_member_type";
+case 0x20: return "DW_TAG_set_type";
+case 0x21: return "DW_TAG_subrange_type";
+case 0x22: return "DW_TAG_with_stmt";
+case 0x23: return "DW_TAG_access_declaration";
+case 0x24: return "DW_TAG_base_type";
+case 0x25: return "DW_TAG_catch_block";
+case 0x26: return "DW_TAG_const_type";
+case 0x27: return "DW_TAG_constant";
+case 0x28: return "DW_TAG_enumerator";
+case 0x29: return "DW_TAG_file_type";
+case 0x2a: return "DW_TAG_friend";
+case 0x2b: return "DW_TAG_namelist";
+case 0x2c: return "DW_TAG_namelist_item";
+case 0x2d: return "DW_TAG_packed_type";
+case 0x2e: return "DW_TAG_subprogram";
+case 0x2f: return "DW_TAG_template_type_parameter";
+case 0x30: return "DW_TAG_template_value_parameter";
+case 0x31: return "DW_TAG_thrown_type";
+case 0x32: return "DW_TAG_try_block";
+case 0x33: return "DW_TAG_variant_part";
+case 0x34: return "DW_TAG_variable";
+case 0x35: return "DW_TAG_volatile_type";
+case 0x36: return "DW_TAG_dwarf_procedure";
+case 0x37: return "DW_TAG_restrict_type";
+case 0x38: return "DW_TAG_interface_type";
+case 0x39: return "DW_TAG_namespace";
+case 0x3a: return "DW_TAG_imported_module";
+case 0x3b: return "DW_TAG_unspecified_type";
+case 0x3c: return "DW_TAG_partial_unit";
+case 0x3d: return "DW_TAG_imported_unit";
+case 0x3e: return "DW_TAG_mutable_type";
+case 0x3f: return "DW_TAG_condition";
+case 0x40: return "DW_TAG_shared_type";
+case 0x41: return "DW_TAG_type_unit";
+case 0x42: return "DW_TAG_rvalue_reference_type";
+case 0x43: return "DW_TAG_template_alias";
+case 0x4080: return "DW_TAG_lo_user";
+case 0x4081: return "DW_TAG_MIPS_loop";
+case 0x4101: return "DW_TAG_format_label";
+case 0x4102: return "DW_TAG_function_template";
+case 0x4103: return "DW_TAG_class_template";
+case 0x4104: return "DW_TAG_GNU_BINCL";
+case 0x4105: return "DW_TAG_GNU_EINCL";
+case 0x4106: return "DW_TAG_GNU_template_template_param";
+case 0x4107: return "DW_TAG_GNU_template_parameter_pack";
+case 0x4108: return "DW_TAG_GNU_formal_parameter_pack";
+case 0x4109: return "DW_TAG_GNU_call_site";
+case 0x410a: return "DW_TAG_GNU_call_site_parameter";
+case 0xffff: return "DW_TAG_hi_user";
index 16ebebe..acbc818 100644 (file)
@@ -8,6 +8,8 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/time.h>
+#include <sys/mman.h>
+#include <libgen.h>
 
 #include "simgrid/sg_config.h"
 #include "../surf/surf_private.h"
@@ -29,9 +31,12 @@ int _sg_do_model_check = 0;
 int _sg_mc_checkpoint=0;
 char* _sg_mc_property_file=NULL;
 int _sg_mc_timeout=0;
+int _sg_mc_hash=0;
 int _sg_mc_max_depth=1000;
 int _sg_mc_visited=0;
 char *_sg_mc_dot_output_file = NULL;
+int _sg_mc_comms_determinism=0;
+int _sg_mc_send_determinism=0;
 
 int user_max_depth_reached = 0;
 
@@ -69,6 +74,13 @@ void _mc_cfg_cb_timeout(const char *name, int pos) {
   _sg_mc_timeout= xbt_cfg_get_boolean(_sg_cfg_set, name);
 }
 
+void _mc_cfg_cb_hash(const char *name, int pos) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
+    xbt_die("You are specifying a value to enable/disable the use of global hash to speedup state comparaison, but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
+  }
+  _sg_mc_hash= xbt_cfg_get_boolean(_sg_cfg_set, name);
+}
+
 void _mc_cfg_cb_max_depth(const char *name, int pos) {
   if (_sg_cfg_init_status && !_sg_do_model_check) {
     xbt_die("You are specifying a max depth value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
@@ -90,6 +102,20 @@ void _mc_cfg_cb_dot_output(const char *name, int pos) {
   _sg_mc_dot_output_file= xbt_cfg_get_string(_sg_cfg_set, name);
 }
 
+void _mc_cfg_cb_comms_determinism(const char *name, int pos) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
+    xbt_die("You are specifying a value to enable/disable the detection of determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
+  }
+  _sg_mc_comms_determinism= xbt_cfg_get_boolean(_sg_cfg_set, name);
+}
+
+void _mc_cfg_cb_send_determinism(const char *name, int pos) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
+    xbt_die("You are specifying a value to enable/disable the detection of send-determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
+  }
+  _sg_mc_send_determinism= xbt_cfg_get_boolean(_sg_cfg_set, name);
+}
+
 /* MC global data structures */
 mc_state_t mc_current_state = NULL;
 char mc_replay_mode = FALSE;
@@ -110,16 +136,13 @@ int compare;
 xbt_automaton_t _mc_property_automaton = NULL;
 
 /* Variables */
-xbt_dict_t mc_local_variables_libsimgrid = NULL;
-xbt_dict_t mc_local_variables_binary = NULL;
-xbt_dynar_t mc_global_variables_libsimgrid = NULL;
-xbt_dynar_t mc_global_variables_binary = NULL;
-xbt_dict_t mc_variables_type_libsimgrid = NULL;
-xbt_dict_t mc_variables_type_binary = NULL;
+mc_object_info_t mc_libsimgrid_info = NULL;
+mc_object_info_t mc_binary_info = NULL;
+
+mc_object_info_t mc_object_infos[2] = { NULL, NULL };
+size_t mc_object_infos_size = 2;
 
 /* Ignore mechanism */
-xbt_dynar_t mc_stack_comparison_ignore;
-xbt_dynar_t mc_data_bss_comparison_ignore;
 extern xbt_dynar_t mc_heap_comparison_ignore;
 extern xbt_dynar_t stacks_areas;
 
@@ -133,322 +156,212 @@ const char* colors[13];
 
 /************************** Free functions *************************/
 
-static void dw_location_free(dw_location_t l){
-  if(l){
-    if(l->type == e_dw_loclist)
-      xbt_dynar_free(&(l->location.loclist));
-    else if(l->type == e_dw_compose)
-      xbt_dynar_free(&(l->location.compose));
-    else if(l->type == e_dw_arithmetic)
-      xbt_free(l->location.arithmetic);
-  
-    xbt_free(l);
-  }
-}
-
-static void dw_location_entry_free(dw_location_entry_t e){
-  dw_location_free(e->location);
-  xbt_free(e);
+void mc_frame_free(dw_frame_t frame){
+  xbt_free(frame->name);
+  mc_dwarf_location_list_clear(&(frame->frame_base));
+  xbt_dynar_free(&(frame->variables));
+  xbt_dynar_free(&(frame->scopes));
+  xbt_free(frame);
 }
 
-static void dw_type_free(dw_type_t t){
+void dw_type_free(dw_type_t t){
   xbt_free(t->name);
   xbt_free(t->dw_type_id);
   xbt_dynar_free(&(t->members));
+  mc_dwarf_expression_clear(&t->location);
   xbt_free(t);
 }
 
-static void dw_type_free_voidp(void *t){
-  dw_type_free((dw_type_t) * (void **) t);
-}
-
-static void dw_variable_free(dw_variable_t v){
+void dw_variable_free(dw_variable_t v){
   if(v){
     xbt_free(v->name);
     xbt_free(v->type_origin);
-    if(!v->global)
-      dw_location_free(v->address.location);
+
+    if(v->locations.locations)
+      mc_dwarf_location_list_clear(&v->locations);
     xbt_free(v);
   }
 }
 
-static void dw_variable_free_voidp(void *t){
+void dw_variable_free_voidp(void *t){
   dw_variable_free((dw_variable_t) * (void **) t);
 }
 
-/*************************************************************************/
-
-static dw_location_t MC_dwarf_get_location(xbt_dict_t location_list, char *expr){
-
-  dw_location_t loc = xbt_new0(s_dw_location_t, 1);
+// ***** object_info
 
-  if(location_list != NULL){
-    
-    char *key = bprintf("%lu", strtoul(expr, NULL, 16));
-    loc->type = e_dw_loclist;
-    loc->location.loclist =  (xbt_dynar_t)xbt_dict_get_or_null(location_list, key);
-    if(loc->location.loclist == NULL)
-      XBT_INFO("Key not found in loclist");
-    xbt_free(key);
-    return loc;
-
-  }else{
-
-    int cursor = 0;
-    char *tok = NULL, *tok2 = NULL; 
-    
-    xbt_dynar_t tokens1 = xbt_str_split(expr, ";");
-    xbt_dynar_t tokens2;
-
-    loc->type = e_dw_compose;
-    loc->location.compose = xbt_dynar_new(sizeof(dw_location_t), NULL);
-
-    while(cursor < xbt_dynar_length(tokens1)){
-
-      tok = xbt_dynar_get_as(tokens1, cursor, char*);
-      tokens2 = xbt_str_split(tok, " ");
-      tok2 = xbt_dynar_get_as(tokens2, 0, char*);
-      
-      if(strncmp(tok2, "DW_OP_reg", 9) == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_register;
-        new_element->location.reg = atoi(strtok(tok2, "DW_OP_reg"));
-        xbt_dynar_push(loc->location.compose, &new_element);     
-      }else if(strcmp(tok2, "DW_OP_fbreg:") == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_fbregister_op;
-        new_element->location.fbreg_op = atoi(xbt_dynar_get_as(tokens2, xbt_dynar_length(tokens2) - 1, char*));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strncmp(tok2, "DW_OP_breg", 10) == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_bregister_op;
-        new_element->location.breg_op.reg = atoi(strtok(tok2, "DW_OP_breg"));
-        new_element->location.breg_op.offset = atoi(xbt_dynar_get_as(tokens2, xbt_dynar_length(tokens2) - 1, char*));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strncmp(tok2, "DW_OP_lit", 9) == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_lit;
-        new_element->location.lit = atoi(strtok(tok2, "DW_OP_lit"));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strcmp(tok2, "DW_OP_piece:") == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_piece;
-        new_element->location.piece = atoi(xbt_dynar_get_as(tokens2, xbt_dynar_length(tokens2) - 1, char*));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strcmp(tok2, "DW_OP_plus_uconst:") == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_plus_uconst;
-        new_element->location.plus_uconst = atoi(xbt_dynar_get_as(tokens2, xbt_dynar_length(tokens2) - 1, char *));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strcmp(tok, "DW_OP_abs") == 0 || 
-               strcmp(tok, "DW_OP_and") == 0 ||
-               strcmp(tok, "DW_OP_div") == 0 ||
-               strcmp(tok, "DW_OP_minus") == 0 ||
-               strcmp(tok, "DW_OP_mod") == 0 ||
-               strcmp(tok, "DW_OP_mul") == 0 ||
-               strcmp(tok, "DW_OP_neg") == 0 ||
-               strcmp(tok, "DW_OP_not") == 0 ||
-               strcmp(tok, "DW_OP_or") == 0 ||
-               strcmp(tok, "DW_OP_plus") == 0){               
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_arithmetic;
-        new_element->location.arithmetic = strdup(strtok(tok2, "DW_OP_"));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strcmp(tok, "DW_OP_stack_value") == 0){
-      }else if(strcmp(tok2, "DW_OP_deref_size:") == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_deref;
-        new_element->location.deref_size = (unsigned int short) atoi(xbt_dynar_get_as(tokens2, xbt_dynar_length(tokens2) - 1, char*));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strcmp(tok, "DW_OP_deref") == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_deref;
-        new_element->location.deref_size = sizeof(void *);
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strcmp(tok2, "DW_OP_constu:") == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_uconstant;
-        new_element->location.uconstant.bytes = 1;
-        new_element->location.uconstant.value = (unsigned long int)(atoi(xbt_dynar_get_as(tokens2, xbt_dynar_length(tokens2) - 1, char*)));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strcmp(tok2, "DW_OP_consts:") == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_sconstant;
-        new_element->location.sconstant.bytes = 1;
-        new_element->location.sconstant.value = (long int)(atoi(xbt_dynar_get_as(tokens2, xbt_dynar_length(tokens2) - 1, char*)));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strcmp(tok2, "DW_OP_const1u:") == 0 ||
-               strcmp(tok2, "DW_OP_const2u:") == 0 ||
-               strcmp(tok2, "DW_OP_const4u:") == 0 ||
-               strcmp(tok2, "DW_OP_const8u:") == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_uconstant;
-        new_element->location.uconstant.bytes = tok2[11] - '0';
-        new_element->location.uconstant.value = (unsigned long int)(atoi(xbt_dynar_get_as(tokens2, xbt_dynar_length(tokens2) - 1, char*)));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else if(strcmp(tok, "DW_OP_const1s") == 0 ||
-               strcmp(tok, "DW_OP_const2s") == 0 ||
-               strcmp(tok, "DW_OP_const4s") == 0 ||
-               strcmp(tok, "DW_OP_const8s") == 0){
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_sconstant;
-        new_element->location.sconstant.bytes = tok2[11] - '0';
-        new_element->location.sconstant.value = (long int)(atoi(xbt_dynar_get_as(tokens2, xbt_dynar_length(tokens2) - 1, char*)));
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }else{
-        dw_location_t new_element = xbt_new0(s_dw_location_t, 1);
-        new_element->type = e_dw_unsupported;
-        xbt_dynar_push(loc->location.compose, &new_element);
-      }
 
-      cursor++;
-      xbt_dynar_free(&tokens2);
-
-    }
-    
-    xbt_dynar_free(&tokens1);
-
-    return loc;
-    
-  }
 
+mc_object_info_t MC_new_object_info(void) {
+  mc_object_info_t res = xbt_new0(s_mc_object_info_t, 1);
+  res->subprograms = xbt_dict_new_homogeneous((void (*)(void*))mc_frame_free);
+  res->global_variables = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
+  res->types = xbt_dict_new_homogeneous((void (*)(void*))dw_type_free);
+  res->full_types_by_name = xbt_dict_new_homogeneous(NULL);
+  return res;
 }
 
-static xbt_dict_t MC_dwarf_get_location_list(const char *elf_file){
-
-  char *command = bprintf("objdump -Wo %s", elf_file);
-
-  FILE *fp = popen(command, "r");
+void MC_free_object_info(mc_object_info_t* info) {
+  xbt_free(&(*info)->file_name);
+  xbt_dict_free(&(*info)->subprograms);
+  xbt_dynar_free(&(*info)->global_variables);
+  xbt_dict_free(&(*info)->types);
+  xbt_dict_free(&(*info)->full_types_by_name);
+  xbt_free(info);
+  xbt_dynar_free(&(*info)->functions_index);
+  *info = NULL;
+}
 
-  if(fp == NULL){
-    perror("popen for objdump failed");
-    xbt_abort();
-  }
+// ***** Helpers
 
-  int debug = 0; /*Detect if the program has been compiled with -g */
+void* MC_object_base_address(mc_object_info_t info) {
+  if(info->flags & MC_OBJECT_INFO_EXECUTABLE)
+    return 0;
+  void* result = info->start_exec;
+  if(info->start_rw!=NULL && result > (void*) info->start_rw) result = info->start_rw;
+  if(info->start_ro!=NULL && result > (void*) info->start_ro) result = info->start_ro;
+  return result;
+}
 
-  xbt_dict_t location_list = xbt_dict_new_homogeneous(NULL);
-  char *line = NULL, *loc_expr = NULL;
-  ssize_t read;
-  size_t n = 0;
-  int cursor_remove;
-  xbt_dynar_t split = NULL;
+// ***** Functions index
 
-  while ((read = xbt_getline(&line, &n, fp)) != -1) {
+static int MC_compare_frame_index_items(mc_function_index_item_t a, mc_function_index_item_t b) {
+  if(a->low_pc < b->low_pc)
+    return -1;
+  else if(a->low_pc == b->low_pc)
+    return 0;
+  else
+    return 1;
+}
 
-    /* Wipeout the new line character */
-    line[read - 1] = '\0';
+static void MC_make_functions_index(mc_object_info_t info) {
+  xbt_dynar_t index = xbt_dynar_new(sizeof(s_mc_function_index_item_t), NULL);
 
-    xbt_str_trim(line, NULL);
-    
-    if(n == 0)
+  // Populate the array:
+  dw_frame_t frame = NULL;
+  xbt_dict_cursor_t cursor;
+  char* key;
+  xbt_dict_foreach(info->subprograms, cursor, key, frame) {
+    if(frame->low_pc==NULL)
       continue;
+    s_mc_function_index_item_t entry;
+    entry.low_pc = frame->low_pc;
+    entry.high_pc = frame->high_pc;
+    entry.function = frame;
+    xbt_dynar_push(index, &entry);
+  }
 
-    if(strlen(line) == 0)
-      continue;
+  mc_function_index_item_t base = (mc_function_index_item_t) xbt_dynar_get_ptr(index, 0);
 
-    if(debug == 0){
+  // Sort the array by low_pc:
+  qsort(base,
+    xbt_dynar_length(index),
+    sizeof(s_mc_function_index_item_t),
+    (int (*)(const void *, const void *))MC_compare_frame_index_items);
 
-      if(strncmp(line, elf_file, strlen(elf_file)) == 0)
-        continue;
-      
-      if(strncmp(line, "Contents", 8) == 0)
-        continue;
+  info->functions_index = index;
+}
 
-      if(strncmp(line, "Offset", 6) == 0){
-        debug = 1;
-        continue;
-      }
+mc_object_info_t MC_ip_find_object_info(void* ip) {
+  size_t i;
+  for(i=0; i!=mc_object_infos_size; ++i) {
+    if(ip >= (void*)mc_object_infos[i]->start_exec && ip <= (void*)mc_object_infos[i]->end_exec) {
+      return mc_object_infos[i];
     }
+  }
+  return NULL;
+}
 
-    if(debug == 0){
-      XBT_INFO("Your program must be compiled with -g");
-      xbt_abort();
+static dw_frame_t MC_find_function_by_ip_and_object(void* ip, mc_object_info_t info) {
+  xbt_dynar_t dynar = info->functions_index;
+  mc_function_index_item_t base = (mc_function_index_item_t) xbt_dynar_get_ptr(dynar, 0);
+  int i = 0;
+  int j = xbt_dynar_length(dynar) - 1;
+  while(j>=i) {
+    int k = i + ((j-i)/2);
+    if(ip < base[k].low_pc) {
+      j = k-1;
+    } else if(ip >= base[k].high_pc) {
+      i = k+1;
+    } else {
+      return base[k].function;
     }
+  }
+  return NULL;
+}
 
-    xbt_dynar_t loclist = xbt_dynar_new(sizeof(dw_location_entry_t), NULL);
-
-    xbt_str_strip_spaces(line);
-    split = xbt_str_split(line, " ");
-
-    while(read != -1 && strcmp("<End", (char *)xbt_dynar_get_as(split, 1, char *)) != 0){
-      
-      dw_location_entry_t new_entry = xbt_new0(s_dw_location_entry_t, 1);
-      new_entry->lowpc = strtoul((char *)xbt_dynar_get_as(split, 1, char *), NULL, 16);
-      new_entry->highpc = strtoul((char *)xbt_dynar_get_as(split, 2, char *), NULL, 16);
-      
-      cursor_remove =0;
-      while(cursor_remove < 3){
-        xbt_dynar_remove_at(split, 0, NULL);
-        cursor_remove++;
-      }
-
-      loc_expr = xbt_str_join(split, " ");
-      xbt_str_ltrim(loc_expr, "(");
-      xbt_str_rtrim(loc_expr, ")");
-      new_entry->location = MC_dwarf_get_location(NULL, loc_expr);
-
-      xbt_dynar_push(loclist, &new_entry);
-
-      xbt_dynar_free(&split);
-      free(loc_expr);
-
-      read = xbt_getline(&line, &n, fp);
-      if(read != -1){
-        line[read - 1] = '\0';
-        xbt_str_strip_spaces(line);
-        split = xbt_str_split(line, " ");
-      }
+dw_frame_t MC_find_function_by_ip(void* ip) {
+  mc_object_info_t info = MC_ip_find_object_info(ip);
+  if(info==NULL)
+    return NULL;
+  else
+    return MC_find_function_by_ip_and_object(ip, info);
+}
 
+static void MC_post_process_variables(mc_object_info_t info) {
+  unsigned cursor = 0;
+  dw_variable_t variable = NULL;
+  xbt_dynar_foreach(info->global_variables, cursor, variable) {
+    if(variable->type_origin) {
+      variable->type = xbt_dict_get_or_null(info->types, variable->type_origin);
     }
-
-
-    char *key = bprintf("%lu", strtoul((char *)xbt_dynar_get_as(split, 0, char *), NULL, 16));
-    xbt_dict_set(location_list, key, loclist, NULL);
-    xbt_free(key);
-    
-    xbt_dynar_free(&split);
-
   }
+}
 
-  xbt_free(line);
-  xbt_free(command);
-  pclose(fp);
+static void mc_post_process_scope(mc_object_info_t info, dw_frame_t scope) {
 
-  return location_list;
-}
+  if(scope->tag == DW_TAG_inlined_subroutine) {
 
-static dw_frame_t MC_dwarf_get_frame_by_offset(xbt_dict_t all_variables, unsigned long int offset){
+    // Attach correct namespaced name in inlined subroutine:
+    char* key = bprintf("%" PRIx64, (uint64_t) scope->abstract_origin_id);
+    dw_frame_t abstract_origin = xbt_dict_get_or_null(info->subprograms, key);
+    xbt_assert(abstract_origin, "Could not lookup abstract origin %s", key);
+    xbt_free(key);
+    scope->name = xbt_strdup(abstract_origin->name);
 
-  xbt_dict_cursor_t cursor = NULL;
-  char *name;
-  dw_frame_t res;
+  }
 
-  xbt_dict_foreach(all_variables, cursor, name, res) {
-    if(offset >= res->start && offset < res->end){
-      xbt_dict_cursor_free(&cursor);
-      return res;
+  // Direct:
+  unsigned cursor = 0;
+  dw_variable_t variable = NULL;
+  xbt_dynar_foreach(scope->variables, cursor, variable) {
+    if(variable->type_origin) {
+      variable->type = xbt_dict_get_or_null(info->types, variable->type_origin);
     }
   }
 
-  xbt_dict_cursor_free(&cursor);
-  return NULL;
-  
-}
-
-static dw_variable_t MC_dwarf_get_variable_by_name(dw_frame_t frame, char *var){
+  // Recursive post-processing of nested-scopes:
+  dw_frame_t nested_scope = NULL;
+  xbt_dynar_foreach(scope->scopes, cursor, nested_scope)
+    mc_post_process_scope(info, nested_scope);
 
-  unsigned int cursor = 0;
-  dw_variable_t current_var;
+}
 
-  xbt_dynar_foreach(frame->variables, cursor, current_var){
-    if(strcmp(var, current_var->name) == 0)
-      return current_var;
+static void MC_post_process_functions(mc_object_info_t info) {
+  xbt_dict_cursor_t cursor;
+  char* key;
+  dw_frame_t subprogram = NULL;
+  xbt_dict_foreach(info->subprograms, cursor, key, subprogram) {
+    mc_post_process_scope(info, subprogram);
   }
+}
 
-  return NULL;
+/** \brief Finds informations about a given shared object/executable */
+mc_object_info_t MC_find_object_info(memory_map_t maps, char* name, int executable) {
+  mc_object_info_t result = MC_new_object_info();
+  if(executable)
+    result->flags |= MC_OBJECT_INFO_EXECUTABLE;
+  result->file_name = xbt_strdup(name);
+  MC_find_object_address(maps, result);
+  MC_dwarf_get_variables(result);
+  MC_post_process_types(result);
+  MC_post_process_variables(result);
+  MC_post_process_functions(result);
+  MC_make_functions_index(result);
+  return result;
 }
 
+/*************************************************************************/
+
 static int MC_dwarf_get_variable_index(xbt_dynar_t variables, char* var, void *address){
 
   if(xbt_dynar_is_empty(variables))
@@ -468,9 +381,9 @@ static int MC_dwarf_get_variable_index(xbt_dynar_t variables, char* var, void *a
       end = cursor - 1;
     }else{
       if(address){ /* global variable */
-        if(var_test->address.address == address)
+        if(var_test->address == address)
           return -1;
-        if(var_test->address.address > address)
+        if(var_test->address > address)
           end = cursor - 1;
         else
           start = cursor + 1;
@@ -481,7 +394,7 @@ static int MC_dwarf_get_variable_index(xbt_dynar_t variables, char* var, void *a
   }
 
   if(strcmp(var_test->name, var) == 0){
-    if(address && var_test->address.address < address)
+    if(address && var_test->address < address)
       return cursor+1;
     else
       return cursor;
@@ -492,729 +405,28 @@ static int MC_dwarf_get_variable_index(xbt_dynar_t variables, char* var, void *a
 
 }
 
+void MC_dwarf_register_global_variable(mc_object_info_t info, dw_variable_t variable) {
+  int index = MC_dwarf_get_variable_index(info->global_variables, variable->name, variable->address);
+  if (index != -1)
+    xbt_dynar_insert_at(info->global_variables, index, &variable);
+  // TODO, else ?
+}
 
-static void MC_dwarf_get_variables(const char *elf_file, xbt_dict_t location_list, xbt_dict_t *local_variables, xbt_dynar_t *global_variables, xbt_dict_t *types){
-
-  char *command = bprintf("objdump -Wi %s", elf_file);
-  
-  FILE *fp = popen(command, "r");
-
-  if(fp == NULL)
-    perror("popen for objdump failed");
-
-  char *line = NULL, *origin, *abstract_origin, *current_frame = NULL, 
-    *subprogram_name = NULL, *subprogram_start = NULL, *subprogram_end = NULL,
-    *node_type = NULL, *location_type = NULL, *variable_name = NULL, 
-    *loc_expr = NULL, *name = NULL, *end =NULL, *type_origin = NULL, *global_address = NULL, 
-    *parent_value = NULL;
-
-  ssize_t read =0;
-  size_t n = 0;
-  int global_variable = 0, parent = 0, new_frame = 0, new_variable = 1, size = 0, 
-    is_pointer = 0, struct_decl = 0, member_end = 0,
-    enumeration_size = 0, subrange = 0, union_decl = 0, offset = 0, index = 0;
-  
-  xbt_dynar_t split = NULL, split2 = NULL;
-
-  xbt_dict_t variables_origin = xbt_dict_new_homogeneous(xbt_free);
-  xbt_dict_t subprograms_origin = xbt_dict_new_homogeneous(xbt_free);
-
-  dw_frame_t variable_frame, subroutine_frame = NULL;
-
-  e_dw_type_type type_type = -1;
-
-  read = xbt_getline(&line, &n, fp);
-
-  while (read != -1) {
-
-    /* Wipeout the new line character */
-    line[read - 1] = '\0';
-  
-    if(n == 0 || strlen(line) == 0){
-      read = xbt_getline(&line, &n, fp);
-      continue;
-    }
-
-    xbt_str_ltrim(line, NULL);
-    xbt_str_strip_spaces(line);
-    
-    if(line[0] != '<'){
-      read = xbt_getline(&line, &n, fp);
-      continue;
-    }
-    
-    xbt_dynar_free(&split);
-    split = xbt_str_split(line, " ");
-
-    /* Get node type */
-    node_type = xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *);
-
-    if(strcmp(node_type, "(DW_TAG_subprogram)") == 0){ /* New frame */
-
-      dw_frame_t frame = NULL;
-
-      strtok(xbt_dynar_get_as(split, 0, char *), "<");
-      subprogram_start = xbt_strdup(strtok(NULL, "<"));
-      xbt_str_rtrim(subprogram_start, ">:");
-
-      read = xbt_getline(&line, &n, fp);
-   
-      while(read != -1){
-
-        /* Wipeout the new line character */
-        line[read - 1] = '\0';
-
-        if(n == 0 || strlen(line) == 0){
-          read = xbt_getline(&line, &n, fp);
-          continue;
-        }
-        
-        xbt_dynar_free(&split);
-        xbt_str_rtrim(line, NULL);
-        xbt_str_strip_spaces(line);
-        split = xbt_str_split(line, " ");
-          
-        node_type = xbt_dynar_get_as(split, 1, char *);
-
-        if(strncmp(node_type, "DW_AT_", 6) != 0)
-          break;
-
-        if(strcmp(node_type, "DW_AT_sibling") == 0){
-
-          subprogram_end = xbt_strdup(xbt_dynar_get_as(split, 3, char*));
-          xbt_str_ltrim(subprogram_end, "<0x");
-          xbt_str_rtrim(subprogram_end, ">");
-          
-        }else if(strcmp(node_type, "DW_AT_abstract_origin:") == 0){ /* Frame already in dict */
-          
-          new_frame = 0;
-          abstract_origin = xbt_strdup(xbt_dynar_get_as(split, 2, char*));
-          xbt_str_ltrim(abstract_origin, "<0x");
-          xbt_str_rtrim(abstract_origin, ">");
-          subprogram_name = (char *)xbt_dict_get_or_null(subprograms_origin, abstract_origin);
-          frame = xbt_dict_get_or_null(*local_variables, subprogram_name); 
-          xbt_free(abstract_origin);
-
-        }else if(strcmp(node_type, "DW_AT_name") == 0){
-
-          new_frame = 1;
-          xbt_free(current_frame);
-          frame = xbt_new0(s_dw_frame_t, 1);
-          frame->name = strdup(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *)); 
-          frame->variables = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
-          frame->frame_base = xbt_new0(s_dw_location_t, 1); 
-          current_frame = strdup(frame->name);
-
-          xbt_dict_set(subprograms_origin, subprogram_start, xbt_strdup(frame->name), NULL);
-        
-        }else if(strcmp(node_type, "DW_AT_frame_base") == 0){
-
-          location_type = xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *);
-
-          if(strcmp(location_type, "list)") == 0){ /* Search location in location list */
-
-            frame->frame_base = MC_dwarf_get_location(location_list, xbt_dynar_get_as(split, 3, char *));
-             
-          }else{
-                
-            xbt_str_strip_spaces(line);
-            split2 = xbt_str_split(line, "(");
-            xbt_dynar_remove_at(split2, 0, NULL);
-            loc_expr = xbt_str_join(split2, " ");
-            xbt_str_rtrim(loc_expr, ")");
-            frame->frame_base = MC_dwarf_get_location(NULL, loc_expr);
-            xbt_dynar_free(&split2);
-            xbt_free(loc_expr);
-
-          }
-        }else if(strcmp(node_type, "DW_AT_low_pc") == 0){
-          
-          if(frame != NULL)
-            frame->low_pc = (void *)strtoul(xbt_dynar_get_as(split, 3, char *), NULL, 16);
-
-        }else if(strcmp(node_type, "DW_AT_high_pc") == 0){
-
-          if(frame != NULL)
-            frame->high_pc = (void *)strtoul(xbt_dynar_get_as(split, 3, char *), NULL, 16);
-
-        }else if(strcmp(node_type, "DW_AT_MIPS_linkage_name:") == 0){
-
-          xbt_free(frame->name);
-          xbt_free(current_frame);
-          frame->name = strdup(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *));   
-          current_frame = strdup(frame->name);
-          xbt_dict_set(subprograms_origin, subprogram_start, xbt_strdup(frame->name), NULL);
-
-        }
-
-        read = xbt_getline(&line, &n, fp);
-
-      }
-      if(new_frame == 1){
-        frame->start = strtoul(subprogram_start, NULL, 16);
-        if(subprogram_end != NULL)
-          frame->end = strtoul(subprogram_end, NULL, 16);
-        xbt_dict_set(*local_variables, frame->name, frame, NULL);
-      }
-
-      xbt_free(subprogram_start);
-      xbt_free(subprogram_end);
-      subprogram_end = NULL;
-        
-
-    }else if(strcmp(node_type, "(DW_TAG_variable)") == 0){ /* New variable */
-
-      dw_variable_t var = NULL;
-      
-      parent_value = strdup(xbt_dynar_get_as(split, 0, char *));
-      parent_value = strtok(parent_value,"<");
-      xbt_str_rtrim(parent_value, ">");
-      parent = atoi(parent_value);
-      xbt_free(parent_value);
-
-      if(parent == 1)
-        global_variable = 1;
-    
-      strtok(xbt_dynar_get_as(split, 0, char *), "<");
-      origin = xbt_strdup(strtok(NULL, "<"));
-      xbt_str_rtrim(origin, ">:");
-      
-      read = xbt_getline(&line, &n, fp);
-      
-      while(read != -1){
-
-        /* Wipeout the new line character */
-        line[read - 1] = '\0'; 
-
-        if(n == 0 || strlen(line) == 0){
-          read = xbt_getline(&line, &n, fp);
-          continue;
-        }
-    
-        xbt_dynar_free(&split);
-        xbt_str_rtrim(line, NULL);
-        xbt_str_strip_spaces(line);
-        split = xbt_str_split(line, " ");
-  
-        node_type = xbt_dynar_get_as(split, 1, char *);
-
-        if(strncmp(node_type, "DW_AT_", 6) != 0)
-          break;
-
-        if(strcmp(node_type, "DW_AT_name") == 0){
-
-          var = xbt_new0(s_dw_variable_t, 1);
-          var->name = xbt_strdup(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *));
-          xbt_dict_set(variables_origin, origin, xbt_strdup(var->name), NULL);
-         
-        }else if(strcmp(node_type, "DW_AT_abstract_origin:") == 0){
-
-          new_variable = 0;
-
-          abstract_origin = xbt_dynar_get_as(split, 2, char *);
-          xbt_str_ltrim(abstract_origin, "<0x");
-          xbt_str_rtrim(abstract_origin, ">");
-          
-          variable_name = (char *)xbt_dict_get_or_null(variables_origin, abstract_origin);
-          variable_frame = MC_dwarf_get_frame_by_offset(*local_variables, strtoul(abstract_origin, NULL, 16));
-          var = MC_dwarf_get_variable_by_name(variable_frame, variable_name); 
-
-        }else if(strcmp(node_type, "DW_AT_location") == 0){
-
-          if(var != NULL){
-
-            if(!global_variable){
-
-              location_type = xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *);
-
-              if(strcmp(location_type, "list)") == 0){ /* Search location in location list */
-                var->address.location = MC_dwarf_get_location(location_list, xbt_dynar_get_as(split, 3, char *));
-              }else{
-                xbt_str_strip_spaces(line);
-                split2 = xbt_str_split(line, "(");
-                xbt_dynar_remove_at(split2, 0, NULL);
-                loc_expr = xbt_str_join(split2, " ");
-                xbt_str_rtrim(loc_expr, ")");
-                if(strncmp("DW_OP_addr", loc_expr, 10) == 0){
-                  global_variable = 1;
-                  xbt_dynar_free(&split2);
-                  split2 = xbt_str_split(loc_expr, " ");
-                  if(strcmp(elf_file, xbt_binary_name) != 0)
-                    var->address.address = (char *)start_text_libsimgrid + strtoul(xbt_dynar_get_as(split2, xbt_dynar_length(split2) - 1, char*), NULL, 16);
-                  else
-                    var->address.address = (void *)strtoul(xbt_dynar_get_as(split2, xbt_dynar_length(split2) - 1, char*), NULL, 16);
-                }else{
-                  var->address.location = MC_dwarf_get_location(NULL, loc_expr);
-                }
-                xbt_dynar_free(&split2);
-                xbt_free(loc_expr);
-              }
-            }else{
-              global_address = xbt_strdup(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *));
-              xbt_str_rtrim(global_address, ")");
-              if(strcmp(elf_file, xbt_binary_name) != 0)
-                var->address.address = (char *)start_text_libsimgrid + strtoul(global_address, NULL, 16);
-              else
-                var->address.address = (void *)strtoul(global_address, NULL, 16);
-              xbt_free(global_address);
-              global_address = NULL;
-            }
-
-          }
-                   
-        }else if(strcmp(node_type, "DW_AT_type") == 0){
-          
-          type_origin = xbt_strdup(xbt_dynar_get_as(split, 3, char *));
-          xbt_str_ltrim(type_origin, "<0x");
-          xbt_str_rtrim(type_origin, ">");
-        
-        }else if(strcmp(node_type, "DW_AT_declaration") == 0){
-
-          new_variable = 0;
-          if(new_variable){
-            dw_variable_free(var);
-            var = NULL;
-          }
-        
-        }else if(strcmp(node_type, "DW_AT_artificial") == 0){
-          
-          new_variable = 0;
-          if(new_variable){
-            dw_variable_free(var);
-            var = NULL;
-          }
-        
-        }
-
-        read = xbt_getline(&line, &n, fp);
-      }
-
-      if(new_variable == 1){
-        
-        if(!global_variable){
-          variable_frame = xbt_dict_get_or_null(*local_variables, current_frame);
-          var->type_origin = strdup(type_origin);
-          var->global = 0;
-          index = MC_dwarf_get_variable_index(variable_frame->variables, var->name, NULL);
-          if(index != -1)
-            xbt_dynar_insert_at(variable_frame->variables, index, &var);
-        }else{
-          var->type_origin = strdup(type_origin);
-          var->global = 1;
-          index = MC_dwarf_get_variable_index(*global_variables, var->name, var->address.address);
-          if(index != -1)
-            xbt_dynar_insert_at(*global_variables, index, &var); 
-        }
-
-         xbt_free(type_origin);
-         type_origin = NULL;
-      }
-
-      global_variable = 0;
-      new_variable = 1;
-
-    }else if(strcmp(node_type, "(DW_TAG_inlined_subroutine)") == 0){
-
-      read = xbt_getline(&line, &n, fp);
-
-      while(read != -1){
-
-        /* Wipeout the new line character */
-        line[read - 1] = '\0'; 
-
-        if(n == 0 || strlen(line) == 0){
-          read = xbt_getline(&line, &n, fp);
-          continue;
-        }
-
-        xbt_dynar_free(&split);
-        xbt_str_rtrim(line, NULL);
-        xbt_str_strip_spaces(line);
-        split = xbt_str_split(line, " ");
-        
-        if(strncmp(xbt_dynar_get_as(split, 1, char *), "DW_AT_", 6) != 0)
-          break;
-          
-        node_type = xbt_dynar_get_as(split, 1, char *);
-
-        if(strcmp(node_type, "DW_AT_abstract_origin:") == 0){
-
-          origin = xbt_dynar_get_as(split, 2, char *);
-          xbt_str_ltrim(origin, "<0x");
-          xbt_str_rtrim(origin, ">");
-          
-          subprogram_name = (char *)xbt_dict_get_or_null(subprograms_origin, origin);
-          subroutine_frame = xbt_dict_get_or_null(*local_variables, subprogram_name);
-        
-        }else if(strcmp(node_type, "DW_AT_low_pc") == 0){
-
-          subroutine_frame->low_pc = (void *)strtoul(xbt_dynar_get_as(split, 3, char *), NULL, 16);
-
-        }else if(strcmp(node_type, "DW_AT_high_pc") == 0){
-
-          subroutine_frame->high_pc = (void *)strtoul(xbt_dynar_get_as(split, 3, char *), NULL, 16);
-        }
-
-        read = xbt_getline(&line, &n, fp);
-      
-      }
-
-    }else if(strcmp(node_type, "(DW_TAG_base_type)") == 0 
-             || strcmp(node_type, "(DW_TAG_enumeration_type)") == 0
-             || strcmp(node_type, "(DW_TAG_enumerator)") == 0
-             || strcmp(node_type, "(DW_TAG_typedef)") == 0
-             || strcmp(node_type, "(DW_TAG_const_type)") == 0
-             || strcmp(node_type, "(DW_TAG_subroutine_type)") == 0
-             || strcmp(node_type, "(DW_TAG_volatile_type)") == 0
-             || (is_pointer = !strcmp(node_type, "(DW_TAG_pointer_type)"))){
-
-      if(strcmp(node_type, "(DW_TAG_base_type)") == 0)
-        type_type = e_dw_base_type;
-      else if(strcmp(node_type, "(DW_TAG_enumeration_type)") == 0)
-        type_type = e_dw_enumeration_type;
-      else if(strcmp(node_type, "(DW_TAG_enumerator)") == 0)
-        type_type = e_dw_enumerator;
-      else if(strcmp(node_type, "(DW_TAG_typedef)") == 0)
-        type_type = e_dw_typedef;
-      else if(strcmp(node_type, "(DW_TAG_const_type)") == 0)
-        type_type = e_dw_const_type;
-      else if(strcmp(node_type, "(DW_TAG_pointer_type)") == 0)
-        type_type = e_dw_pointer_type;
-      else if(strcmp(node_type, "(DW_TAG_subroutine_type)") == 0)
-        type_type = e_dw_subroutine_type;
-      else if(strcmp(node_type, "(DW_TAG_volatile_type)") == 0)
-        type_type = e_dw_volatile_type;
-
-      strtok(xbt_dynar_get_as(split, 0, char *), "<");
-      origin = strdup(strtok(NULL, "<"));
-      xbt_str_rtrim(origin, ">:");
-      
-      read = xbt_getline(&line, &n, fp);
-      
-      while(read != -1){
-        
-         /* Wipeout the new line character */
-        line[read - 1] = '\0'; 
-
-        if(n == 0 || strlen(line) == 0){
-          read = xbt_getline(&line, &n, fp);
-          continue;
-        }
-
-        xbt_dynar_free(&split);
-        xbt_str_rtrim(line, NULL);
-        xbt_str_strip_spaces(line);
-        split = xbt_str_split(line, " ");
-        
-        if(strncmp(xbt_dynar_get_as(split, 1, char *), "DW_AT_", 6) != 0)
-          break;
-
-        node_type = xbt_dynar_get_as(split, 1, char *);
-
-        if(strcmp(node_type, "DW_AT_byte_size") == 0){
-          size = strtol(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*), NULL, 10);
-          if(type_type == e_dw_enumeration_type)
-            enumeration_size = size;
-        }else if(strcmp(node_type, "DW_AT_name") == 0){
-          end = xbt_str_join(split, " ");
-          xbt_dynar_free(&split);
-          split = xbt_str_split(end, "):");
-          xbt_str_ltrim(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*), NULL);
-          name = xbt_strdup(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*));
-        }else if(strcmp(node_type, "DW_AT_type") == 0){
-          type_origin = xbt_strdup(xbt_dynar_get_as(split, 3, char *));
-          xbt_str_ltrim(type_origin, "<0x");
-          xbt_str_rtrim(type_origin, ">");
-        }
-        
-        read = xbt_getline(&line, &n, fp);
-      }
-
-      dw_type_t type = xbt_new0(s_dw_type_t, 1);
-      type->type = type_type;
-      if(name)
-        type->name = xbt_strdup(name);
-      else
-        type->name = xbt_strdup("undefined");
-      type->is_pointer_type = is_pointer;
-      type->id = (void *)strtoul(origin, NULL, 16);
-      if(type_origin)
-        type->dw_type_id = xbt_strdup(type_origin);
-      if(type_type == e_dw_enumerator)
-        type->size = enumeration_size;
-      else
-        type->size = size;
-      type->members = NULL;
-
-      xbt_dict_set(*types, origin, type, NULL); 
-
-      xbt_free(name);
-      name = NULL;
-      xbt_free(type_origin);
-      type_origin = NULL;
-      xbt_free(end);
-      end = NULL;
-
-      is_pointer = 0;
-      size = 0;
-      xbt_free(origin);
-
-    }else if(strcmp(node_type, "(DW_TAG_structure_type)") == 0 || strcmp(node_type, "(DW_TAG_union_type)") == 0){
-      
-      if(strcmp(node_type, "(DW_TAG_structure_type)") == 0)
-        struct_decl = 1;
-      else
-        union_decl = 1;
-
-      strtok(xbt_dynar_get_as(split, 0, char *), "<");
-      origin = strdup(strtok(NULL, "<"));
-      xbt_str_rtrim(origin, ">:");
-      
-      read = xbt_getline(&line, &n, fp);
-
-      dw_type_t type = NULL;
-
-      while(read != -1){
-      
-        while(read != -1){
-        
-          /* Wipeout the new line character */
-          line[read - 1] = '\0'; 
-
-          if(n == 0 || strlen(line) == 0){
-            read = xbt_getline(&line, &n, fp);
-            continue;
-          }
-
-          xbt_dynar_free(&split);
-          xbt_str_rtrim(line, NULL);
-          xbt_str_strip_spaces(line);
-          split = xbt_str_split(line, " ");
-        
-          node_type = xbt_dynar_get_as(split, 1, char *);
-
-          if(strncmp(node_type, "DW_AT_", 6) != 0){
-            member_end = 1;
-            break;
-          }
-
-          if(strcmp(node_type, "DW_AT_byte_size") == 0){
-            size = strtol(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*), NULL, 10);
-          }else if(strcmp(node_type, "DW_AT_name") == 0){
-            xbt_free(end);
-            end = xbt_str_join(split, " ");
-            xbt_dynar_free(&split);
-            split = xbt_str_split(end, "):");
-            xbt_str_ltrim(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*), NULL);
-            name = xbt_strdup(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*));
-          }else if(strcmp(node_type, "DW_AT_type") == 0){
-            type_origin = xbt_strdup(xbt_dynar_get_as(split, 3, char *));
-            xbt_str_ltrim(type_origin, "<0x");
-            xbt_str_rtrim(type_origin, ">");
-          }else if(strcmp(node_type, "DW_AT_data_member_location:") == 0){
-            xbt_free(end);
-            end = xbt_str_join(split, " ");
-            xbt_dynar_free(&split);
-            split = xbt_str_split(end, "DW_OP_plus_uconst:");
-            xbt_str_ltrim(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *), NULL);
-            xbt_str_rtrim(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *), ")");
-            offset = strtol(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*), NULL, 10);
-          }
-
-          read = xbt_getline(&line, &n, fp);
-          
-        }
-
-        if(member_end && type){         
-          member_end = 0;
-          
-          dw_type_t member_type = xbt_new0(s_dw_type_t, 1);
-          member_type->name = xbt_strdup(name);
-          member_type->size = size;
-          member_type->is_pointer_type = is_pointer;
-          member_type->id = (void *)strtoul(origin, NULL, 16);
-          member_type->offset = offset;
-          if(type_origin)
-            member_type->dw_type_id = xbt_strdup(type_origin);
-
-          xbt_dynar_push(type->members, &member_type);
-
-          xbt_free(name);
-          name = NULL;
-          xbt_free(end);
-          end = NULL;
-          xbt_free(type_origin);
-          type_origin = NULL;
-          size = 0;
-          offset = 0;
-
-          xbt_free(origin);
-          origin = NULL;
-          strtok(xbt_dynar_get_as(split, 0, char *), "<");
-          origin = strdup(strtok(NULL, "<"));
-          xbt_str_rtrim(origin, ">:");
-
-        }
-
-        if(struct_decl || union_decl){
-          type = xbt_new0(s_dw_type_t, 1);
-          if(struct_decl)
-            type->type = e_dw_structure_type;
-          else
-            type->type = e_dw_union_type;
-          type->name = xbt_strdup(name);
-          type->size = size;
-          type->is_pointer_type = is_pointer;
-          type->id = (void *)strtoul(origin, NULL, 16);
-          if(type_origin)
-            type->dw_type_id = xbt_strdup(type_origin);
-          type->members = xbt_dynar_new(sizeof(dw_type_t), dw_type_free_voidp);
-          
-          xbt_dict_set(*types, origin, type, NULL); 
-          
-          xbt_free(name);
-          name = NULL;
-          xbt_free(end);
-          end = NULL;
-          xbt_free(type_origin);
-          type_origin = NULL;
-          size = 0;
-          struct_decl = 0;
-          union_decl = 0;
-
-        }
-
-        if(strcmp(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *), "(DW_TAG_member)") != 0)
-          break;  
-
-        read = xbt_getline(&line, &n, fp);
-    
-      }
-
-      xbt_free(origin);
-      origin = NULL;
-
-    }else if(strcmp(node_type, "(DW_TAG_array_type)") == 0){
-      
-      strtok(xbt_dynar_get_as(split, 0, char *), "<");
-      origin = strdup(strtok(NULL, "<"));
-      xbt_str_rtrim(origin, ">:");
-      
-      read = xbt_getline(&line, &n, fp);
-
-      dw_type_t type = NULL;
-
-      while(read != -1){
-      
-        while(read != -1){
-        
-          /* Wipeout the new line character */
-          line[read - 1] = '\0'; 
-
-          if(n == 0 || strlen(line) == 0){
-            read = xbt_getline(&line, &n, fp);
-            continue;
-          }
-
-          xbt_dynar_free(&split);
-          xbt_str_rtrim(line, NULL);
-          xbt_str_strip_spaces(line);
-          split = xbt_str_split(line, " ");
-        
-          node_type = xbt_dynar_get_as(split, 1, char *);
-
-          if(strncmp(node_type, "DW_AT_", 6) != 0)
-            break;
-
-          if(strcmp(node_type, "DW_AT_upper_bound") == 0){
-            size = strtol(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*), NULL, 10);
-          }else if(strcmp(node_type, "DW_AT_name") == 0){
-            end = xbt_str_join(split, " ");
-            xbt_dynar_free(&split);
-            split = xbt_str_split(end, "):");
-            xbt_str_ltrim(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*), NULL);
-            name = xbt_strdup(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char*));
-          }else if(strcmp(node_type, "DW_AT_type") == 0){
-            type_origin = xbt_strdup(xbt_dynar_get_as(split, 3, char *));
-            xbt_str_ltrim(type_origin, "<0x");
-            xbt_str_rtrim(type_origin, ">");
-          }
-
-          read = xbt_getline(&line, &n, fp);
-          
-        }
-
-        if(strcmp(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *), "(DW_TAG_subrange_type)") == 0){
-          subrange = 1;         
-        }
-
-        if(subrange && type){         
-          type->size = size;
-      
-          xbt_free(name);
-          name = NULL;
-          xbt_free(end);
-          end = NULL;
-          xbt_free(type_origin);
-          type_origin = NULL;
-          size = 0;
-
-          xbt_free(origin);
-          origin = NULL;
-          strtok(xbt_dynar_get_as(split, 0, char *), "<");
-          origin = strdup(strtok(NULL, "<"));
-          xbt_str_rtrim(origin, ">:");
-
-        }else {
-          
-          type = xbt_new0(s_dw_type_t, 1);
-          type->type = e_dw_array_type;
-          type->name = xbt_strdup(name);
-          type->is_pointer_type = is_pointer;
-          type->id = (void *)strtoul(origin, NULL, 16);
-          if(type_origin)
-            type->dw_type_id = xbt_strdup(type_origin);
-          type->members = NULL;
-          
-          xbt_dict_set(*types, origin, type, NULL); 
-          
-          xbt_free(name);
-          name = NULL;
-          xbt_free(end);
-          end = NULL;
-          xbt_free(type_origin);
-          type_origin = NULL;
-          size = 0;
-        }
-
-        if(strcmp(xbt_dynar_get_as(split, xbt_dynar_length(split) - 1, char *), "(DW_TAG_subrange_type)") != 0)
-          break;  
-
-        read = xbt_getline(&line, &n, fp);
-    
-      }
-
-      xbt_free(origin);
-      origin = NULL;
-
-    }else{
-
-      read = xbt_getline(&line, &n, fp);
-
-    }
+void MC_dwarf_register_non_global_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable) {
+  xbt_assert(frame, "Frame is NULL");
+  int index = MC_dwarf_get_variable_index(frame->variables, variable->name, NULL);
+  if (index != -1)
+    xbt_dynar_insert_at(frame->variables, index, &variable);
+  // TODO, else ?
+}
 
-  }
-  
-  xbt_dynar_free(&split);
-  xbt_dict_free(&variables_origin);
-  xbt_dict_free(&subprograms_origin);
-  xbt_free(line);
-  xbt_free(command);
-  pclose(fp);
-  
+void MC_dwarf_register_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable) {
+  if(variable->global)
+    MC_dwarf_register_global_variable(info, variable);
+  else if(frame==NULL)
+    xbt_die("No frame for this local variable");
+  else
+    MC_dwarf_register_non_global_variable(info, frame, variable);
 }
 
 
@@ -1228,10 +440,6 @@ typedef struct s_mc_stack_ignore_variable{
   char *frame;
 }s_mc_stack_ignore_variable_t, *mc_stack_ignore_variable_t;
 
-typedef struct s_mc_data_bss_ignore_variable{
-  char *name;
-}s_mc_data_bss_ignore_variable_t, *mc_data_bss_ignore_variable_t;
-
 /**************************** Free functions ******************************/
 
 static void stack_ignore_variable_free(mc_stack_ignore_variable_t v){
@@ -1252,15 +460,6 @@ void heap_ignore_region_free_voidp(void *r){
   heap_ignore_region_free((mc_heap_ignore_region_t) * (void **) r);
 }
 
-static void data_bss_ignore_variable_free(mc_data_bss_ignore_variable_t v){
-  xbt_free(v->name);
-  xbt_free(v);
-}
-
-static void data_bss_ignore_variable_free_voidp(void *v){
-  data_bss_ignore_variable_free((mc_data_bss_ignore_variable_t) * (void **) v);
-}
-
 static void checkpoint_ignore_region_free(mc_checkpoint_ignore_region_t r){
   xbt_free(r);
 }
@@ -1375,195 +574,109 @@ void MC_ignore_global_variable(const char *name){
 
   MC_SET_RAW_MEM;
 
-  if(mc_global_variables_libsimgrid){
+  xbt_assert(mc_libsimgrid_info, "MC subsystem not initialized");
 
     unsigned int cursor = 0;
     dw_variable_t current_var;
     int start = 0;
-    int end = xbt_dynar_length(mc_global_variables_libsimgrid) - 1;
+    int end = xbt_dynar_length(mc_libsimgrid_info->global_variables) - 1;
 
     while(start <= end){
       cursor = (start + end) /2;
-      current_var = (dw_variable_t)xbt_dynar_get_as(mc_global_variables_libsimgrid, cursor, dw_variable_t);
+      current_var = (dw_variable_t)xbt_dynar_get_as(mc_libsimgrid_info->global_variables, cursor, dw_variable_t);
       if(strcmp(current_var->name, name) == 0){
-        xbt_dynar_remove_at(mc_global_variables_libsimgrid, cursor, NULL);
+        xbt_dynar_remove_at(mc_libsimgrid_info->global_variables, cursor, NULL);
         start = 0;
-        end = xbt_dynar_length(mc_global_variables_libsimgrid) - 1;
+        end = xbt_dynar_length(mc_libsimgrid_info->global_variables) - 1;
       }else if(strcmp(current_var->name, name) < 0){
         start = cursor + 1;
       }else{
         end = cursor - 1;
       } 
     }
-   
-  }else{
 
-    if(mc_data_bss_comparison_ignore == NULL)
-      mc_data_bss_comparison_ignore = xbt_dynar_new(sizeof(mc_data_bss_ignore_variable_t), data_bss_ignore_variable_free_voidp);
+  if(!raw_mem_set)
+    MC_UNSET_RAW_MEM;
+}
 
-    mc_data_bss_ignore_variable_t var = NULL;
-    var = xbt_new0(s_mc_data_bss_ignore_variable_t, 1);
-    var->name = strdup(name);
+/** \brief Ignore a local variable in a scope
+ *
+ *  Ignore all instances of variables with a given name in
+ *  any (possibly inlined) subprogram with a given namespaced
+ *  name.
+ *
+ *  \param var_name        Name of the local variable (or parameter to ignore)
+ *  \param subprogram_name Name of the subprogram fo ignore (NULL for any)
+ *  \param subprogram      (possibly inlined) Subprogram of the scope
+ *  \param scope           Current scope
+ */
+static void mc_ignore_local_variable_in_scope(
+  const char *var_name, const char *subprogram_name,
+  dw_frame_t subprogram, dw_frame_t scope) {
+  // Processing of direct variables:
 
-    if(xbt_dynar_is_empty(mc_data_bss_comparison_ignore)){
+  // If the current subprogram matche the given name:
+  if(subprogram_name==NULL || strcmp(subprogram_name, subprogram->name)==0) {
 
-      xbt_dynar_insert_at(mc_data_bss_comparison_ignore, 0, &var);
+    // Try to find the variable and remove it:
+    int start = 0;
+    int end = xbt_dynar_length(scope->variables) - 1;
 
-    }else{
-    
-      unsigned int cursor = 0;
-      int start = 0;
-      int end = xbt_dynar_length(mc_data_bss_comparison_ignore) - 1;
-      mc_data_bss_ignore_variable_t current_var = NULL;
-
-      while(start <= end){
-        cursor = (start + end) / 2;
-        current_var = (mc_data_bss_ignore_variable_t)xbt_dynar_get_as(mc_data_bss_comparison_ignore, cursor, mc_data_bss_ignore_variable_t);
-        if(strcmp(current_var->name, name) == 0){
-          data_bss_ignore_variable_free(var);
-          if(!raw_mem_set)
-            MC_UNSET_RAW_MEM;
-          return;
-        }else if(strcmp(current_var->name, name) < 0){
-          start = cursor + 1;
-        }else{
-          end = cursor - 1;
-        }
-      }
+    // Dichotomic search:
+    while(start <= end){
+      int cursor = (start + end) / 2;
+      dw_variable_t current_var = (dw_variable_t)xbt_dynar_get_as(scope->variables, cursor, dw_variable_t);
 
-      if(strcmp(current_var->name, name) < 0)
-        xbt_dynar_insert_at(mc_data_bss_comparison_ignore, cursor + 1, &var);
-      else
-        xbt_dynar_insert_at(mc_data_bss_comparison_ignore, cursor, &var);
+      int compare = strcmp(current_var->name, var_name);
+      if(compare == 0){
+        // Variable found, remove it:
+        xbt_dynar_remove_at(scope->variables, cursor, NULL);
 
+        // and start again:
+        start = 0;
+        end = xbt_dynar_length(scope->variables) - 1;
+      }else if(compare < 0){
+        start = cursor + 1;
+      }else{
+        end = cursor - 1;
+      }
     }
+
   }
 
-  if(!raw_mem_set)
-    MC_UNSET_RAW_MEM;
+  // And recursive processing in nested scopes:
+  unsigned cursor = 0;
+  dw_frame_t nested_scope = NULL;
+  xbt_dynar_foreach(scope->scopes, cursor, nested_scope) {
+    // The new scope may be an inlined subroutine, in this case we want to use its
+    // namespaced name in recursive calls:
+    dw_frame_t nested_subprogram = nested_scope->tag == DW_TAG_inlined_subroutine ? nested_scope : subprogram;
+
+    mc_ignore_local_variable_in_scope(var_name, subprogram_name, nested_subprogram, nested_scope);
+  }
+}
+
+static void MC_ignore_local_variable_in_object(const char *var_name, const char *subprogram_name, mc_object_info_t info) {
+  xbt_dict_cursor_t cursor2;
+  dw_frame_t frame;
+  char* key;
+  xbt_dict_foreach(info->subprograms, cursor2, key, frame) {
+    mc_ignore_local_variable_in_scope(var_name, subprogram_name, frame, frame);
+  }
 }
 
 void MC_ignore_local_variable(const char *var_name, const char *frame_name){
   
   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
 
-  MC_SET_RAW_MEM;
+  if(strcmp(frame_name, "*") == 0)
+    frame_name = NULL;
 
-  if(mc_local_variables_libsimgrid){
-    unsigned int cursor = 0;
-    dw_variable_t current_var;
-    int start, end;
-    if(strcmp(frame_name, "*") == 0){ /* Remove variable in all frames */
-      xbt_dict_cursor_t dict_cursor;
-      char *current_frame_name;
-      dw_frame_t frame;
-      xbt_dict_foreach(mc_local_variables_libsimgrid, dict_cursor, current_frame_name, frame){
-        start = 0;
-        end = xbt_dynar_length(frame->variables) - 1;
-        while(start <= end){
-          cursor = (start + end) / 2;
-          current_var = (dw_variable_t)xbt_dynar_get_as(frame->variables, cursor, dw_variable_t); 
-          if(strcmp(current_var->name, var_name) == 0){
-            xbt_dynar_remove_at(frame->variables, cursor, NULL);
-            start = 0;
-            end = xbt_dynar_length(frame->variables) - 1;
-          }else if(strcmp(current_var->name, var_name) < 0){
-            start = cursor + 1;
-          }else{
-            end = cursor - 1;
-          } 
-        }
-      }
-       xbt_dict_foreach(mc_local_variables_binary, dict_cursor, current_frame_name, frame){
-        start = 0;
-        end = xbt_dynar_length(frame->variables) - 1;
-        while(start <= end){
-          cursor = (start + end) / 2;
-          current_var = (dw_variable_t)xbt_dynar_get_as(frame->variables, cursor, dw_variable_t); 
-          if(strcmp(current_var->name, var_name) == 0){
-            xbt_dynar_remove_at(frame->variables, cursor, NULL);
-            start = 0;
-            end = xbt_dynar_length(frame->variables) - 1;
-          }else if(strcmp(current_var->name, var_name) < 0){
-            start = cursor + 1;
-          }else{
-            end = cursor - 1;
-          } 
-        }
-      }
-    }else{
-      xbt_dynar_t variables_list = ((dw_frame_t)xbt_dict_get_or_null(mc_local_variables_libsimgrid, frame_name))->variables;
-      start = 0;
-      end = xbt_dynar_length(variables_list) - 1;
-      while(start <= end){
-        cursor = (start + end) / 2;
-        current_var = (dw_variable_t)xbt_dynar_get_as(variables_list, cursor, dw_variable_t);
-        if(strcmp(current_var->name, var_name) == 0){
-          xbt_dynar_remove_at(variables_list, cursor, NULL);
-          start = 0;
-          end = xbt_dynar_length(variables_list) - 1;
-        }else if(strcmp(current_var->name, var_name) < 0){
-          start = cursor + 1;
-        }else{
-          end = cursor - 1;
-        } 
-      }
-    } 
-  }else{
-
-    if(mc_stack_comparison_ignore == NULL)
-      mc_stack_comparison_ignore = xbt_dynar_new(sizeof(mc_stack_ignore_variable_t), stack_ignore_variable_free_voidp);
-  
-    mc_stack_ignore_variable_t var = NULL;
-    var = xbt_new0(s_mc_stack_ignore_variable_t, 1);
-    var->var_name = strdup(var_name);
-    var->frame = strdup(frame_name);
-  
-    if(xbt_dynar_is_empty(mc_stack_comparison_ignore)){
-
-      xbt_dynar_insert_at(mc_stack_comparison_ignore, 0, &var);
-
-    }else{
-    
-      unsigned int cursor = 0;
-      int start = 0;
-      int end = xbt_dynar_length(mc_stack_comparison_ignore) - 1;
-      mc_stack_ignore_variable_t current_var = NULL;
-
-      while(start <= end){
-        cursor = (start + end) / 2;
-        current_var = (mc_stack_ignore_variable_t)xbt_dynar_get_as(mc_stack_comparison_ignore, cursor, mc_stack_ignore_variable_t);
-        if(strcmp(current_var->frame, frame_name) == 0){
-          if(strcmp(current_var->var_name, var_name) == 0){
-            stack_ignore_variable_free(var);
-            if(!raw_mem_set)
-              MC_UNSET_RAW_MEM;
-            return;
-          }else if(strcmp(current_var->var_name, var_name) < 0){
-            start = cursor + 1;
-          }else{
-            end = cursor - 1;
-          }
-        }else if(strcmp(current_var->frame, frame_name) < 0){
-          start = cursor + 1;
-        }else{
-          end = cursor - 1;
-        }
-      }
+  MC_SET_RAW_MEM;
 
-      if(strcmp(current_var->frame, frame_name) == 0){
-        if(strcmp(current_var->var_name, var_name) < 0){
-          xbt_dynar_insert_at(mc_stack_comparison_ignore, cursor + 1, &var);
-        }else{
-          xbt_dynar_insert_at(mc_stack_comparison_ignore, cursor, &var);
-        }
-      }else if(strcmp(current_var->frame, frame_name) < 0){
-        xbt_dynar_insert_at(mc_stack_comparison_ignore, cursor + 1, &var);
-      }else{
-        xbt_dynar_insert_at(mc_stack_comparison_ignore, cursor, &var);
-      }
-    }
-  }
+  MC_ignore_local_variable_in_object(var_name, frame_name, mc_libsimgrid_info);
+  if(frame_name!=NULL)
+    MC_ignore_local_variable_in_object(var_name, frame_name, mc_binary_info);
 
   if(!raw_mem_set)
     MC_UNSET_RAW_MEM;
@@ -1655,44 +768,50 @@ void MC_ignore(void *addr, size_t size){
 /*******************************  Initialisation of MC *******************************/
 /*********************************************************************************/
 
-static void MC_dump_ignored_local_variables(void){
-
-  if(mc_stack_comparison_ignore == NULL || xbt_dynar_is_empty(mc_stack_comparison_ignore))
-    return;
-
-  unsigned int cursor = 0;
-  mc_stack_ignore_variable_t current_var;
+static void MC_post_process_object_info(mc_object_info_t info) {
+  xbt_dict_cursor_t cursor = NULL;
+  char* key = NULL;
+  dw_type_t type = NULL;
+  xbt_dict_foreach(info->types, cursor, key, type){
+
+    // Resolve full_type:
+    if(type->name && type->byte_size == 0) {
+      for(size_t i=0; i!=mc_object_infos_size; ++i) {
+        dw_type_t same_type =  xbt_dict_get_or_null(mc_object_infos[i]->full_types_by_name, type->name);
+        if(same_type && same_type->name && same_type->byte_size) {
+          type->full_type = same_type;
+          break;
+        }
+      }
+    }
 
-  xbt_dynar_foreach(mc_stack_comparison_ignore, cursor, current_var){
-    MC_ignore_local_variable(current_var->var_name, current_var->frame);
   }
-
-  xbt_dynar_free(&mc_stack_comparison_ignore);
-  mc_stack_comparison_ignore = NULL;
 }
 
-static void MC_dump_ignored_global_variables(void){
+static void MC_init_debug_info(void) {
+  XBT_INFO("Get debug information ...");
 
-  if(mc_data_bss_comparison_ignore == NULL || xbt_dynar_is_empty(mc_data_bss_comparison_ignore))
-    return;
+  memory_map_t maps = MC_get_memory_map();
 
-  unsigned int cursor = 0;
-  mc_data_bss_ignore_variable_t current_var;
+  /* Get local variables for state equality detection */
+  mc_binary_info = MC_find_object_info(maps, xbt_binary_name, 1);
+  mc_object_infos[0] = mc_binary_info;
 
-  xbt_dynar_foreach(mc_data_bss_comparison_ignore, cursor, current_var){
-    MC_ignore_global_variable(current_var->name);
-  } 
+  mc_libsimgrid_info = MC_find_object_info(maps, libsimgrid_path, 0);
+  mc_object_infos[1] = mc_libsimgrid_info;
 
-  xbt_dynar_free(&mc_data_bss_comparison_ignore);
-  mc_data_bss_comparison_ignore = NULL;
+  // Use information of the other objects:
+  MC_post_process_object_info(mc_binary_info);
+  MC_post_process_object_info(mc_libsimgrid_info);
 
+  MC_free_memory_map(maps);
+  XBT_INFO("Get debug information done !");
 }
 
 void MC_init(){
 
   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
-  
+
   compare = 0;
 
   /* Initialize the data structures that must be persistent across every
@@ -1701,36 +820,7 @@ void MC_init(){
   MC_SET_RAW_MEM;
 
   MC_init_memory_map_info();
-  
-  mc_local_variables_libsimgrid = xbt_dict_new_homogeneous(NULL);
-  mc_local_variables_binary = xbt_dict_new_homogeneous(NULL);
-  mc_global_variables_libsimgrid = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
-  mc_global_variables_binary = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
-  mc_variables_type_libsimgrid = xbt_dict_new_homogeneous(NULL);
-  mc_variables_type_binary = xbt_dict_new_homogeneous(NULL);
-
-  XBT_INFO("Get debug information ...");
-
-  /* Get local variables in binary for state equality detection */
-  xbt_dict_t binary_location_list = MC_dwarf_get_location_list(xbt_binary_name);
-  MC_dwarf_get_variables(xbt_binary_name, binary_location_list, &mc_local_variables_binary, &mc_global_variables_binary, &mc_variables_type_binary);
-
-  /* Get local variables in libsimgrid for state equality detection */
-  xbt_dict_t libsimgrid_location_list = MC_dwarf_get_location_list(libsimgrid_path);
-  MC_dwarf_get_variables(libsimgrid_path, libsimgrid_location_list, &mc_local_variables_libsimgrid, &mc_global_variables_libsimgrid, &mc_variables_type_libsimgrid);
-
-  xbt_dict_free(&libsimgrid_location_list);
-  xbt_dict_free(&binary_location_list);
-
-  XBT_INFO("Get debug information done !");
-
-  /* Remove variables ignored before getting list of variables */
-  MC_dump_ignored_local_variables();
-  MC_dump_ignored_global_variables();
-  
-  /* Get .plt section (start and end addresses) for data libsimgrid and data program comparison */
-  MC_get_libsimgrid_plt_section();
-  MC_get_binary_plt_section();
+  MC_init_debug_info();
 
    /* Init parmap */
   parmap = xbt_parmap_mc_new(xbt_os_get_numcores(), XBT_PARMAP_DEFAULT);
@@ -1747,12 +837,14 @@ void MC_init(){
   MC_ignore_local_variable("_throw_ctx", "*");
   MC_ignore_local_variable("ctx", "*");
 
+  MC_ignore_local_variable("self", "simcall_BODY_mc_snapshot");
   MC_ignore_local_variable("next_context", "smx_ctx_sysv_suspend_serial");
   MC_ignore_local_variable("i", "smx_ctx_sysv_suspend_serial");
 
   /* Ignore local variable about time used for tracing */
   MC_ignore_local_variable("start_time", "*"); 
 
+  MC_ignore_global_variable("compared_pointers");
   MC_ignore_global_variable("mc_comp_times");
   MC_ignore_global_variable("mc_snapshot_comparison_time"); 
   MC_ignore_global_variable("mc_time");
@@ -1760,6 +852,7 @@ void MC_init(){
   MC_ignore_global_variable("counter"); /* Static variable used for tracing */
   MC_ignore_global_variable("maestro_stack_start");
   MC_ignore_global_variable("maestro_stack_end");
+  MC_ignore_global_variable("smx_total_comms");
 
   MC_ignore_heap(&(simix_global->process_to_run), sizeof(simix_global->process_to_run));
   MC_ignore_heap(&(simix_global->process_that_ran), sizeof(simix_global->process_that_ran));
@@ -1865,8 +958,7 @@ void MC_modelcheck_safety(void)
   }else{
     MC_SET_RAW_MEM;
     MC_init_memory_map_info();
-    MC_get_libsimgrid_plt_section();
-    MC_get_binary_plt_section();
+    MC_init_debug_info();
     MC_UNSET_RAW_MEM;
   }
 
@@ -1876,6 +968,9 @@ void MC_modelcheck_safety(void)
   /* Save the initial state */
   initial_state_safety = xbt_new0(s_mc_global_t, 1);
   initial_state_safety->snapshot = MC_take_snapshot(0);
+  initial_state_safety->initial_communications_pattern_done = 0;
+  initial_state_safety->comm_deterministic = 1;
+  initial_state_safety->send_deterministic = 1;
   MC_UNSET_RAW_MEM;
 
   MC_dpor();
@@ -1930,6 +1025,7 @@ void MC_modelcheck_liveness(){
 void MC_exit(void)
 {
   xbt_free(mc_time);
+
   MC_memory_exit();
   //xbt_abort();
 }
@@ -1998,6 +1094,7 @@ void MC_replay(xbt_fifo_t stack, int start)
   xbt_fifo_item_t item, start_item;
   mc_state_t state;
   smx_process_t process = NULL;
+  int comm_pattern = 0;
 
   XBT_DEBUG("**** Begin Replay ****");
 
@@ -2027,6 +1124,8 @@ void MC_replay(xbt_fifo_t stack, int start)
       xbt_free(key);
     }
   }
+  if(_sg_mc_comms_determinism || _sg_mc_send_determinism)
+    xbt_dynar_reset(communications_pattern);
   MC_UNSET_RAW_MEM;
   
 
@@ -2056,8 +1155,25 @@ void MC_replay(xbt_fifo_t stack, int start)
         xbt_free(req_str);
       }
     }
-    
+
+    if(_sg_mc_comms_determinism || _sg_mc_send_determinism){
+      if(req->call == SIMCALL_COMM_ISEND)
+        comm_pattern = 1;
+      else if(req->call == SIMCALL_COMM_IRECV)
+      comm_pattern = 2;
+    }
+
     SIMIX_simcall_pre(req, value);
+
+    if(_sg_mc_comms_determinism || _sg_mc_send_determinism){
+      MC_SET_RAW_MEM;
+      if(comm_pattern != 0){
+        get_comm_pattern(communications_pattern, req, comm_pattern);
+      }
+      MC_UNSET_RAW_MEM;
+      comm_pattern = 0;
+    }
+    
     MC_wait_for_requests();
 
     count++;
@@ -2338,6 +1454,12 @@ void MC_print_statistics(mc_stats_t stats)
     fprintf(dot_output, "}\n");
     fclose(dot_output);
   }
+  if(initial_state_safety != NULL){
+    if(_sg_mc_comms_determinism)
+      XBT_INFO("Communication-deterministic : %s", !initial_state_safety->comm_deterministic ? "No" : "Yes");
+    if (_sg_mc_send_determinism)
+      XBT_INFO("Send-deterministic : %s", !initial_state_safety->send_deterministic ? "No" : "Yes");
+  }
   MC_UNSET_RAW_MEM;
 }
 
diff --git a/src/mc/mc_hash.c b/src/mc/mc_hash.c
new file mode 100644 (file)
index 0000000..c4ba6c6
--- /dev/null
@@ -0,0 +1,312 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "mc_private.h"
+#include "mc/datatypes.h"
+#include <mc/mc.h>
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_hash, mc,
+                                "Logging specific to mc_hash");
+
+// This is djb2:
+typedef uint64_t mc_hash_t;
+#define MC_HASH_INIT ((uint64_t)5381)
+
+// #define MC_HASH(hash, value) hash = (((hash << 5) + hash) + (uint64_t) value)
+#define MC_HASH(hash, value) \
+  { hash = (((hash << 5) + hash) + (uint64_t) value);\
+  XBT_DEBUG("%s:%i: %"PRIx64" -> %"PRIx64, __FILE__, __LINE__, (uint64_t) value, hash); }
+
+// ***** Hash state
+
+typedef struct s_mc_hashing_state {
+  // Set of pointers/addresses already processed (avoid loops):
+  mc_address_set_t handled_addresses;
+} mc_hashing_state;
+
+void mc_hash_state_init(mc_hashing_state* state);
+void mc_hash_state_destroy(mc_hashing_state* state);
+
+void mc_hash_state_init(mc_hashing_state* state) {
+  state->handled_addresses = mc_address_set_new();
+}
+
+void mc_hash_state_destroy(mc_hashing_state* state) {
+   mc_address_set_free(&state->handled_addresses);
+}
+
+// TODO, detect and avoid loops
+
+static bool mc_ignored(const void* address, size_t size) {
+  mc_heap_ignore_region_t region;
+  unsigned int cursor = 0;
+  const void* end = (char*) address + size;
+  xbt_dynar_foreach(mc_heap_comparison_ignore, cursor, region) {
+   void* istart = region->address;
+   void* iend   = (char*) region->address + region->size;
+
+   if(address>=istart && address<iend && end>=istart && end<iend)
+     return true;
+  }
+
+  return false;
+}
+
+static void mc_hash_binary(mc_hash_t *hash, const void* s, size_t len) {
+  const char* p = (const void*) s;
+  int i;
+  for(i=0; i!=len; ++i) {
+    MC_HASH(*hash, p[i]);
+  }
+}
+
+/** \brief Compute a hash for a given value of a given type
+ *
+ *  We try to be very conservative (do not hash too ambiguous things).
+ *
+ *  \param address address of the variable
+ *  \param type type of the variable
+ * */
+static void mc_hash_value(mc_hash_t* hash, mc_hashing_state* state, mc_object_info_t info, const void* address, dw_type_t type) {
+  top:
+
+  switch(type->type){
+
+  // Not relevant, do nothing:
+  case DW_TAG_unspecified_type:
+    return;
+
+  // Simple case, hash this has binary:
+  case DW_TAG_base_type:
+  case DW_TAG_enumeration_type:
+  {
+    if(mc_ignored(address, 1))
+      return;
+    mc_hash_binary(hash, address, type->byte_size);
+    return;
+  }
+
+  case DW_TAG_array_type:
+  {
+    if(mc_ignored(address, type->byte_size))
+      return;
+
+    long element_count = type->element_count;
+    dw_type_t subtype = type->subtype;
+    if(subtype==NULL) {
+      XBT_DEBUG("Hash array without subtype");
+      return;
+    }
+    int i;
+    for(i=0; i!=element_count; ++i) {
+      XBT_DEBUG("Hash array element %i", i);
+      void* subaddress = ((char*)address)+i*subtype->byte_size;
+      mc_hash_value(hash, state, info, subaddress, subtype);
+    }
+    return;
+  }
+
+  // Get the raw type:
+  case DW_TAG_typedef:
+  case DW_TAG_volatile_type:
+  case DW_TAG_const_type:
+  case DW_TAG_restrict_type:
+  {
+    type = type->subtype;
+    if(type==NULL)
+      return;
+    else
+      goto top;
+  }
+
+  case DW_TAG_structure_type:
+  case DW_TAG_class_type:
+  {
+    if(mc_ignored(address, type->byte_size))
+      return;
+
+    unsigned int cursor = 0;
+    dw_type_t member;
+    xbt_dynar_foreach(type->members, cursor, member){
+      XBT_DEBUG("Hash struct member %s", member->name);
+      if(type->subtype==NULL)
+        return;
+      void* member_variable = mc_member_resolve(address, type, member, NULL);
+      mc_hash_value(hash, state, info, member_variable, type->subtype);
+    }
+    return;
+  }
+
+  // Pointer, we hash a single value but it might be an array.
+  case DW_TAG_pointer_type:
+  case DW_TAG_reference_type:
+  case DW_TAG_rvalue_reference_type:
+  {
+    if(mc_ignored(address, 1))
+      return;
+
+    void* pointed = *(void**)address;
+    if(pointed==NULL) {
+      XBT_DEBUG("Hashed pinter is NULL");
+      return;
+    }
+
+    // Avoid loops:
+    if(mc_address_test(state->handled_addresses, pointed)) {
+      XBT_DEBUG("Hashed pointed data %p already hashed", pointed);
+      return;
+    }
+    mc_address_add(state->handled_addresses, pointed);
+
+    // Anything outside the R/W segments and the heap is not hashed:
+    bool valid_pointer = (pointed >= (void*) mc_binary_info->start_rw && pointed <= (void*) mc_binary_info->end_rw)
+        || (pointed >= (void*) mc_libsimgrid_info->start_rw && pointed <= (void*) mc_libsimgrid_info->end_rw)
+        || (pointed >= std_heap && pointed < (void*) ((const char*)std_heap + STD_HEAP_SIZE));
+    if(!valid_pointer) {
+      XBT_DEBUG("Hashed pointed data %p is in an ignored range", pointed);
+      return;
+    }
+
+    if(type->subtype==NULL) {
+      XBT_DEBUG("Missing type for %p (type=%s)", pointed, type->dw_type_id);
+      return;
+    }
+
+    address = pointed;
+    type = type->subtype;
+    goto top;
+  }
+
+  // Skip this:
+  case DW_TAG_union_type:
+  case DW_TAG_subroutine_type:
+  default:
+    return;
+  }
+}
+
+
+static void mc_hash_object_globals(mc_hash_t *hash, mc_hashing_state* state, mc_object_info_t info) {
+  unsigned int cursor = 0;
+  dw_variable_t variable;
+  xbt_dynar_foreach(info->global_variables, cursor, variable) {
+    XBT_DEBUG("Hash global variable %s", variable->name);
+
+    if(variable->type_origin == NULL) {
+      // Nothing
+      continue;
+    }
+
+    dw_type_t type = variable->type;
+    if(type==NULL) {
+      // Nothing
+      continue;
+    }
+
+    const char* address = variable->address;
+    bool valid_pointer = (address >= mc_binary_info->start_rw && address <= mc_binary_info->end_rw)
+        || (address >= mc_libsimgrid_info->start_rw && address <= mc_libsimgrid_info->end_rw)
+        || (address >= (const char*) std_heap && address < (const char *)std_heap + STD_HEAP_SIZE);
+    if(!valid_pointer) continue;
+
+    mc_hash_value(hash, state, info, variable->address, type);
+  }
+}
+
+static void mc_hash_stack_frame(
+  mc_hash_t *hash,
+    mc_object_info_t info, unw_cursor_t* unw_cursor, dw_frame_t frame, char* frame_pointer, mc_hashing_state* state
+    ) {
+
+  // return; // TEMP
+
+  unsigned int cursor = 0;
+  dw_variable_t variable;
+  xbt_dynar_foreach(frame->variables, cursor, variable){
+
+    if(variable->type_origin==NULL) {
+      XBT_DEBUG("Hash local variable %s without type", variable->name);
+      continue;
+    }
+    if(variable->locations.size == 0) {
+      XBT_DEBUG("Hash local variable %s without location", variable->name);
+      continue;
+    }
+
+    XBT_DEBUG("Hash local variable %s", variable->name);
+
+    void* variable_address = (void*) mc_dwarf_resolve_locations(
+      &variable->locations, variable->object_info, unw_cursor, frame_pointer, NULL);
+
+    dw_type_t type = variable->type;
+    if(type==NULL) {
+      XBT_DEBUG("Hash local variable %s without loctypeation", variable->name);
+      continue;
+    }
+
+    mc_hash_value(hash, state, info, variable_address, type);
+  }
+
+  // TODO, handle nested scopes
+}
+
+static void mc_hash_stack(mc_hash_t *hash, mc_snapshot_stack_t stack, mc_hashing_state* state) {
+
+  unsigned cursor = 0;
+  mc_stack_frame_t stack_frame;
+
+  xbt_dynar_foreach(stack->stack_frames, cursor, stack_frame) {
+
+    MC_HASH(*hash, stack_frame->ip);
+
+    mc_object_info_t info;
+    if(stack_frame->ip >= (unw_word_t) mc_libsimgrid_info->start_exec && stack_frame->ip < (unw_word_t) mc_libsimgrid_info->end_exec)
+      info = mc_libsimgrid_info;
+    else if(stack_frame->ip >= (unw_word_t) mc_binary_info->start_exec && stack_frame->ip < (unw_word_t) mc_binary_info->end_exec)
+      info = mc_binary_info;
+    else
+      continue;
+
+    mc_hash_stack_frame(hash, info, &(stack_frame->unw_cursor), stack_frame->frame, (void*)stack_frame->frame_base, state);
+
+  }
+}
+
+static void mc_hash_stacks(mc_hash_t *hash, mc_hashing_state* state, xbt_dynar_t stacks) {
+  unsigned int cursor = 0;
+  mc_snapshot_stack_t current_stack;
+
+  MC_HASH(*hash, xbt_dynar_length(stacks_areas));
+
+  int i=0;
+  xbt_dynar_foreach(stacks, cursor, current_stack){
+    XBT_DEBUG("Stack %i", i);
+    mc_hash_stack(hash, current_stack, state);
+    ++i;
+  }
+}
+
+uint64_t mc_hash_processes_state(int num_state, xbt_dynar_t stacks) {
+  XBT_DEBUG("START hash %i", num_state);
+
+  mc_hashing_state state;
+  mc_hash_state_init(&state);
+
+  mc_hash_t hash = MC_HASH_INIT;
+
+  MC_HASH(hash, xbt_swag_size(simix_global->process_list)); // process count
+  mc_hash_object_globals(&hash, &state, mc_binary_info);
+  // mc_hash_object_globals(&hash, &state, mc_libsimgrid_info);
+  mc_hash_stacks(&hash, &state, stacks);
+
+  mc_hash_state_destroy(&state);
+
+  XBT_DEBUG("END hash %i", num_state);
+  return hash;
+}
index acc5803..96e6513 100644 (file)
@@ -36,6 +36,10 @@ static xbt_dynar_t get_atomic_propositions_values(){
   return values;
 }
 
+/** \brief Find a suitable subrange of candidate duplicates for a given state
+ *
+ *  See mc_dpor.c with a similar (same?) function.
+ */
 static int get_search_interval(xbt_dynar_t all_pairs, mc_visited_pair_t pair, int *min, int *max){
 
   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
@@ -114,12 +118,15 @@ static mc_visited_pair_t is_reached_acceptance_pair(int pair_num, xbt_automaton_
     index = get_search_interval(acceptance_pairs, pair, &min, &max);
 
     if(min != -1 && max != -1){ // Acceptance pair with same number of processes and same heap bytes used exists
+
+      // Parallell implementation
       /*res = xbt_parmap_mc_apply(parmap, snapshot_compare, xbt_dynar_get_ptr(acceptance_pairs, min), (max-min)+1, pair);
       if(res != -1){
         if(!raw_mem_set)
           MC_UNSET_RAW_MEM;
         return ((mc_pair_t)xbt_dynar_get_as(acceptance_pairs, (min+res)-1, mc_pair_t))->num;
         }*/
+
       cursor = min;
       while(cursor <= max){
         pair_test = (mc_visited_pair_t)xbt_dynar_get_as(acceptance_pairs, cursor, mc_visited_pair_t);
@@ -192,6 +199,9 @@ static void remove_acceptance_pair(int pair_num){
     MC_UNSET_RAW_MEM;
 }
 
+/** \brief Checks whether a given state has already been visited by the algorithm.
+ *
+ */
 static int is_visited_pair(mc_visited_pair_t pair, int pair_num, xbt_automaton_state_t automaton_state, xbt_dynar_t atomic_propositions){
 
   if(_sg_mc_visited == 0)
@@ -264,7 +274,7 @@ static int is_visited_pair(mc_visited_pair_t pair, int pair_num, xbt_automaton_s
                 if(dot_output == NULL)
                   XBT_DEBUG("Pair %d already visited ! (equal to pair %d)", new_pair->num, pair_test->num);
                 else
-                  XBT_DEBUG("Pair %d already visited ! (equal to pair %d (pair %d in dot_output))", new_pair->num, pair_test->num, pair->other_num);
+                  XBT_DEBUG("Pair %d already visited ! (equal to pair %d (pair %d in dot_output))", new_pair->num, pair_test->num, new_pair->other_num);
                 xbt_dynar_remove_at(visited_pairs, cursor, NULL);
                 xbt_dynar_insert_at(visited_pairs, cursor, &new_pair);
                 pair_test->visited_removed = 1;
diff --git a/src/mc/mc_member.c b/src/mc/mc_member.c
new file mode 100644 (file)
index 0000000..a3c2c4b
--- /dev/null
@@ -0,0 +1,57 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "mc_private.h"
+
+/** Resolve snapshot in the process address space
+ *
+ * @param object   Process address of the struct/class
+ * @param type     Type of the struct/class
+ * @param member   Member description
+ * @param snapshot Snapshot (or NULL)
+ * @return Process address of the given member of the 'object' struct/class
+ */
+void* mc_member_resolve(const void* base, dw_type_t type, dw_type_t member, mc_snapshot_t snapshot) {
+  if(!member->location.size) {
+    return ((char*) base) + member->offset;
+  }
+
+  s_mc_expression_state_t state;
+  memset(&state, 0, sizeof(s_mc_expression_state_t));
+  state.frame_base = NULL;
+  state.cursor = NULL;
+  state.snapshot = snapshot;
+  state.stack_size = 1;
+  state.stack[0] = (uintptr_t) base;
+
+  if(mc_dwarf_execute_expression(member->location.size, member->location.ops, &state))
+    xbt_die("Error evaluating DWARF expression");
+  if(state.stack_size==0)
+    xbt_die("No value on the stack");
+  else
+    return (void*) state.stack[state.stack_size-1];
+}
+
+/** Resolve snapshot in the snapshot address space
+ *
+ * @param  object Snapshot address of the struct/class
+ * @param  type Type of the struct/class
+ * @param  member Member description
+ * @param  snapshot Snapshot (or NULL)
+ * @return Snapshot address of the given member of the 'object' struct/class
+ */
+void* mc_member_snapshot_resolve(const void* object, dw_type_t type, dw_type_t member, mc_snapshot_t snapshot) {
+  if(!member->location.size) {
+    return (char*) object + member->offset;
+  } else {
+    // Translate the problem in the process address space:
+    void* real_area = (void*) mc_untranslate_address((void *)object, snapshot);
+    // Resolve the member in the process address space:
+    void* real_member = mc_member_resolve(real_area, type, member, snapshot);
+    // Translate back in the snapshot address space:
+    return mc_translate_address((uintptr_t)real_member, snapshot);
+  }
+}
index aa38112..f734ec7 100644 (file)
@@ -30,7 +30,7 @@ void MC_memory_init()
   raw_heap = NULL;
 #else
   /* Create the second region a page after the first one ends + safety gap */
-  raw_heap = xbt_mheap_new(-1, (char*)(std_heap) + STD_HEAP_SIZE + getpagesize());
+  raw_heap = xbt_mheap_new(-1, (char*)(std_heap) + STD_HEAP_SIZE + xbt_pagesize);
   xbt_assert(raw_heap != NULL);
 #endif
 }
@@ -39,6 +39,9 @@ void MC_memory_init()
 #include "xbt_modinter.h"
 void MC_memory_exit(void)
 {
+  MC_free_object_info(&mc_binary_info);
+  MC_free_object_info(&mc_libsimgrid_info);
+
   if (raw_heap)
     xbt_mheap_destroy(raw_heap);
 }
index 0f2a556..0de7560 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef WIN32
 #include <sys/mman.h>
 #endif
+#include <elfutils/libdw.h>
+
 #include "mc/mc.h"
 #include "mc/datatypes.h"
 #include "xbt/fifo.h"
 #include "xbt/strbuff.h"
 #include "xbt/parmap.h"
 
+typedef struct s_dw_frame s_dw_frame_t, *dw_frame_t;
+typedef struct s_mc_function_index_item s_mc_function_index_item_t, *mc_function_index_item_t;
+
 /****************************** Snapshots ***********************************/
 
 #define NB_REGIONS 3 /* binary data (data + BSS) (type = 2), libsimgrid data (data + BSS) (type = 1), std_heap (type = 0)*/ 
 
 typedef struct s_mc_mem_region{
+  // Real address:
   void *start_addr;
+  // Copy of the datra:
   void *data;
+  // Size of the data region:
   size_t size;
 } s_mc_mem_region_t, *mc_mem_region_t;
 
@@ -40,17 +48,33 @@ typedef struct s_mc_snapshot{
   size_t heap_bytes_used;
   mc_mem_region_t regions[NB_REGIONS];
   int nb_processes;
+  mc_mem_region_t* privatization_regions;
+  int privatization_index;
   size_t *stack_sizes;
   xbt_dynar_t stacks;
   xbt_dynar_t to_ignore;
-  char hash_global[41];
-  char hash_local[41];
+  uint64_t hash;
 } s_mc_snapshot_t, *mc_snapshot_t;
 
+/** Information about a given stack frame
+ *
+ */
+typedef struct s_mc_stack_frame {
+  /** Instruction pointer */
+  unw_word_t ip;
+  /** Stack pointer */
+  unw_word_t sp;
+  unw_word_t frame_base;
+  dw_frame_t frame;
+  char* frame_name;
+  unw_cursor_t unw_cursor;
+} s_mc_stack_frame_t, *mc_stack_frame_t;
+
 typedef struct s_mc_snapshot_stack{
   xbt_dynar_t local_variables;
   void *stack_pointer;
   void *real_address;
+  xbt_dynar_t stack_frames; // mc_stack_frame_t
 }s_mc_snapshot_stack_t, *mc_snapshot_stack_t;
 
 typedef struct s_mc_global_t{
@@ -58,6 +82,9 @@ typedef struct s_mc_global_t{
   int raw_mem_set;
   int prev_pair;
   char *prev_req;
+  int initial_communications_pattern_done;
+  int comm_deterministic;
+  int send_deterministic;
 }s_mc_global_t, *mc_global_t;
 
 typedef struct s_mc_checkpoint_ignore_region{
@@ -70,6 +97,31 @@ mc_snapshot_t MC_take_snapshot(int num_state);
 void MC_restore_snapshot(mc_snapshot_t);
 void MC_free_snapshot(mc_snapshot_t);
 
+/** \brief Translate a pointer from process address space to snapshot address space
+ *
+ *  The address space contains snapshot of the main/application memory:
+ *  this function finds the address in a given snaphot for a given
+ *  real/application address.
+ *
+ *  For read only memory regions and other regions which are not int the
+ *  snapshot, the address is not changed.
+ *
+ *  \param addr     Application address
+ *  \param snapshot The snapshot of interest (if NULL no translation is done)
+ *  \return         Translated address in the snapshot address space
+ * */
+void* mc_translate_address(uintptr_t addr, mc_snapshot_t snapshot);
+
+/** \brief Translate a pointer from the snapshot address space to the application address space
+ *
+ *  This is the inverse of mc_translate_address.
+ *
+ * \param addr    Address in the snapshot address space
+ * \param snapsot Snapshot of interest (if NULL no translation is done)
+ * \return        Translated address in the application address space
+ */
+uintptr_t mc_untranslate_address(void* addr, mc_snapshot_t snapshot);
+
 extern xbt_dynar_t mc_checkpoint_ignore;
 
 /********************************* MC Global **********************************/
@@ -218,25 +270,8 @@ typedef struct s_memory_map {
 void MC_init_memory_map_info(void);
 memory_map_t MC_get_memory_map(void);
 void MC_free_memory_map(memory_map_t map);
-void MC_get_libsimgrid_plt_section(void);
-void MC_get_binary_plt_section(void);
 
-extern void *start_data_libsimgrid;
-extern void *start_data_binary;
-extern void *start_bss_binary;
 extern char *libsimgrid_path;
-extern void *start_text_libsimgrid;
-extern void *start_text_binary;
-extern void *start_bss_libsimgrid;
-extern void *start_plt_libsimgrid;
-extern void *end_plt_libsimgrid;
-extern void *start_plt_binary;
-extern void *end_plt_binary;
-extern void *start_got_plt_libsimgrid;
-extern void *end_got_plt_libsimgrid;
-extern void *start_got_plt_binary;
-extern void *end_got_plt_binary;
-
 
 /********************************** Snapshot comparison **********************************/
 
@@ -248,8 +283,6 @@ typedef struct s_mc_comparison_times{
   double libsimgrid_global_variables_comparison_time;
   double heap_comparison_time;
   double stacks_comparison_time;
-  double hash_global_variables_comparison_time;
-  double hash_local_variables_comparison_time;
 }s_mc_comparison_times_t, *mc_comparison_times_t;
 
 extern __thread mc_comparison_times_t mc_comp_times;
@@ -262,7 +295,6 @@ void print_comparison_times(void);
 //#define MC_DEBUG 1
 #define MC_VERBOSE 1
 
-
 /********************************** DPOR for safety property **************************************/
 
 typedef enum {
@@ -294,8 +326,6 @@ extern xbt_fifo_t mc_stack_liveness;
 extern mc_global_t initial_state_liveness;
 extern xbt_automaton_t _mc_property_automaton;
 extern int compare;
-extern xbt_dynar_t mc_stack_comparison_ignore;
-extern xbt_dynar_t mc_data_bss_comparison_ignore;
 
 typedef struct s_mc_pair{
   int num;
@@ -333,105 +363,231 @@ void MC_dump_stack_liveness(xbt_fifo_t stack);
 
 /********************************** Variables with DWARF **********************************/
 
-extern xbt_dict_t mc_local_variables_libsimgrid;
-extern xbt_dict_t mc_local_variables_binary;
-extern xbt_dynar_t mc_global_variables_libsimgrid;
-extern xbt_dynar_t mc_global_variables_binary;
-extern xbt_dict_t mc_variables_type_libsimgrid;
-extern xbt_dict_t mc_variables_type_binary;
+#define MC_OBJECT_INFO_EXECUTABLE 1
+
+struct s_mc_object_info {
+  size_t flags;
+  char* file_name;
+  char *start_exec, *end_exec; // Executable segment
+  char *start_rw, *end_rw; // Read-write segment
+  char *start_ro, *end_ro; // read-only segment
+  xbt_dict_t subprograms; // xbt_dict_t<origin as hexadecimal string, dw_frame_t>
+  xbt_dynar_t global_variables; // xbt_dynar_t<dw_variable_t>
+  xbt_dict_t types; // xbt_dict_t<origin as hexadecimal string, dw_type_t>
+  xbt_dict_t full_types_by_name; // xbt_dict_t<name, dw_type_t> (full defined type only)
+
+  // Here we sort the minimal information for an efficient (and cache-efficient)
+  // lookup of a function given an instruction pointer.
+  // The entries are sorted by low_pc and a binary search can be used to look them up.
+  xbt_dynar_t functions_index;
+};
+
+mc_object_info_t MC_new_object_info(void);
+mc_object_info_t MC_find_object_info(memory_map_t maps, char* name, int executable);
+void MC_free_object_info(mc_object_info_t* p);
+
+void MC_dwarf_get_variables(mc_object_info_t info);
+void MC_dwarf_get_variables_libdw(mc_object_info_t info);
+const char* MC_dwarf_attrname(int attr);
+const char* MC_dwarf_tagname(int tag);
+
+dw_frame_t MC_find_function_by_ip(void* ip);
+mc_object_info_t MC_ip_find_object_info(void* ip);
+
+extern mc_object_info_t mc_libsimgrid_info;
+extern mc_object_info_t mc_binary_info;
+extern mc_object_info_t mc_object_infos[2];
+extern size_t mc_object_infos_size;
+
+void MC_find_object_address(memory_map_t maps, mc_object_info_t result);
+void MC_post_process_types(mc_object_info_t info);
+
+// ***** Expressions
+
+/** \brief a DWARF expression with optional validity contraints */
+typedef struct s_mc_expression {
+  size_t size;
+  Dwarf_Op* ops;
+  // Optional validity:
+  void* lowpc, *highpc;
+} s_mc_expression_t, *mc_expression_t;
 
-typedef enum {
-  e_dw_loclist,
-  e_dw_register,
-  e_dw_bregister_op,
-  e_dw_lit,
-  e_dw_fbregister_op,
-  e_dw_piece,
-  e_dw_arithmetic,
-  e_dw_plus_uconst,
-  e_dw_compose,
-  e_dw_deref,
-  e_dw_uconstant,
-  e_dw_sconstant,
-  e_dw_unsupported
-} e_dw_location_type;
-
-typedef struct s_dw_location{
-  e_dw_location_type type;
-  union{
-    
-    xbt_dynar_t loclist;
-    
-    int reg;
-    
-    struct{
-      unsigned int reg;
-      int offset;
-    }breg_op;
-
-    unsigned int lit;
-
-    int fbreg_op;
-
-    int piece;
-
-    unsigned short int deref_size;
-
-    xbt_dynar_t compose;
-
-    char *arithmetic;
-
-    struct{
-      int bytes;
-      long unsigned int value;
-    }uconstant;
-
-    struct{
-      int bytes;
-      long signed int value;
-    }sconstant;
-
-    unsigned int plus_uconst;
-
-  }location;
-}s_dw_location_t, *dw_location_t;
-
-typedef struct s_dw_location_entry{
-  unsigned long lowpc;
-  unsigned long highpc;
-  dw_location_t location;
-}s_dw_location_entry_t, *dw_location_entry_t;
+/** A location list (list of location expressions) */
+typedef struct s_mc_location_list {
+  size_t size;
+  mc_expression_t locations;
+} s_mc_location_list_t, *mc_location_list_t;
+
+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);
+
+void mc_dwarf_location_list_clear(mc_location_list_t list);
+
+void mc_dwarf_location_list_init_from_expression(mc_location_list_t target, size_t len, Dwarf_Op* ops);
+void mc_dwarf_location_list_init(mc_location_list_t target, mc_object_info_t info, Dwarf_Die* die, Dwarf_Attribute* attr);
+
+// ***** Variables and functions
+
+struct s_dw_type{
+  e_dw_type_type type;
+  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 */
+  char *dw_type_id; /* DW_AT_type id */
+  xbt_dynar_t members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
+  int is_pointer_type;
+
+  // Location (for members) is either of:
+  struct s_mc_expression location;
+  int offset;
+
+  dw_type_t subtype; // DW_AT_type
+  dw_type_t full_type; // The same (but more complete) type
+};
+
+void* mc_member_resolve(const void* base, dw_type_t type, dw_type_t member, mc_snapshot_t snapshot);
+void* mc_member_snapshot_resolve(const void* base, dw_type_t type, dw_type_t member, mc_snapshot_t snapshot);
 
 typedef struct s_dw_variable{
+  Dwarf_Off dwarf_offset; /* Global offset of the field. */
   int global;
   char *name;
   char *type_origin;
-  union{
-    dw_location_t location;
-    void *address;
-  }address;
+  dw_type_t type;
+
+  // Use either of:
+  s_mc_location_list_t locations;
+  void* address;
+
+  size_t start_scope;
+  mc_object_info_t object_info;
+
 }s_dw_variable_t, *dw_variable_t;
 
-typedef struct s_dw_frame{
+struct s_dw_frame{
+  int tag;
   char *name;
   void *low_pc;
   void *high_pc;
-  dw_location_t frame_base;
-  xbt_dynar_t variables; /* Cannot use dict, there may be several variables with the same name (in different lexical blocks)*/
-  unsigned long int start;
-  unsigned long int end;
-}s_dw_frame_t, *dw_frame_t;
+  s_mc_location_list_t frame_base;
+  xbt_dynar_t /* <dw_variable_t> */ variables; /* Cannot use dict, there may be several variables with the same name (in different lexical blocks)*/
+  unsigned long int id; /* DWARF offset of the subprogram */
+  xbt_dynar_t /* <dw_frame_t> */ scopes;
+  Dwarf_Off abstract_origin_id;
+  mc_object_info_t object_info;
+};
+
+struct s_mc_function_index_item {
+  void* low_pc, *high_pc;
+  dw_frame_t function;
+};
+
+void mc_frame_free(dw_frame_t freme);
+
+void dw_type_free(dw_type_t t);
+void dw_variable_free(dw_variable_t v);
+void dw_variable_free_voidp(void *t);
+
+void MC_dwarf_register_global_variable(mc_object_info_t info, dw_variable_t variable);
+void MC_register_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
+void MC_dwarf_register_non_global_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
+void MC_dwarf_register_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
+
+/** Find the DWARF offset for this ELF object
+ *
+ *  An offset is applied to address found in DWARF:
+ *
+ *  <ul>
+ *    <li>for an executable obejct, addresses are virtual address
+ *        (there is no offset) i.e. \f$\text{virtual address} = \{dwarf address}\f$;</li>
+ *    <li>for a shared object, the addreses are offset from the begining
+ *        of the shared object (the base address of the mapped shared
+ *        object must be used as offset
+ *        i.e. \f$\text{virtual address} = \text{shared object base address}
+ *             + \text{dwarf address}\f$.</li>
+ *
+ */
+void* MC_object_base_address(mc_object_info_t info);
+
+/********************************** DWARF **********************************/
+
+#define MC_EXPRESSION_STACK_SIZE 64
+
+#define MC_EXPRESSION_OK 0
+#define MC_EXPRESSION_E_UNSUPPORTED_OPERATION 1
+#define MC_EXPRESSION_E_STACK_OVERFLOW 2
+#define MC_EXPRESSION_E_STACK_UNDERFLOW 3
+#define MC_EXPRESSION_E_MISSING_STACK_CONTEXT 4
+#define MC_EXPRESSION_E_MISSING_FRAME_BASE 5
+#define MC_EXPRESSION_E_NO_BASE_ADDRESS 6
+
+typedef struct s_mc_expression_state {
+  uintptr_t stack[MC_EXPRESSION_STACK_SIZE];
+  size_t stack_size;
+
+  unw_cursor_t* cursor;
+  void* frame_base;
+  mc_snapshot_t snapshot;
+  mc_object_info_t object_info;
+} s_mc_expression_state_t, *mc_expression_state_t;
+
+int mc_dwarf_execute_expression(size_t n, const Dwarf_Op* ops, mc_expression_state_t state);
+
+void* mc_find_frame_base(dw_frame_t frame, mc_object_info_t object_info, unw_cursor_t* unw_cursor);
 
 /********************************** Miscellaneous **********************************/
 
 typedef struct s_local_variable{
-  char *frame;
+  dw_frame_t subprogram;
   unsigned long ip;
   char *name;
-  char *type;
+  dw_type_t type;
   void *address;
   int region;
 }s_local_variable_t, *local_variable_t;
 
+/********************************* Communications pattern ***************************/
+
+typedef struct s_mc_comm_pattern{
+  int num;
+  smx_action_t comm;
+  e_smx_comm_type_t type;
+  int completed;
+  unsigned long src_proc;
+  unsigned long dst_proc;
+  const char *src_host;
+  const char *dst_host;
+  char *rdv;
+  size_t data_size;
+  void *data;
+  int matched_comm;
+}s_mc_comm_pattern_t, *mc_comm_pattern_t;
+
+extern xbt_dynar_t communications_pattern;
+
+void get_comm_pattern(xbt_dynar_t communications_pattern, smx_simcall_t request, int call);
+
+/* *********** Sets *********** */
+
+typedef struct s_mc_address_set *mc_address_set_t;
+
+mc_address_set_t mc_address_set_new();
+void mc_address_set_free(mc_address_set_t* p);
+void mc_address_add(mc_address_set_t p, const void* value);
+bool mc_address_test(mc_address_set_t p, const void* value);
+
+/* *********** Hash *********** */
+
+/** \brief Hash the current state
+ *  \param num_state number of states
+ *  \param stacks stacks (mc_snapshot_stak_t) used fot the stack unwinding informations
+ *  \result resulting hash
+ * */
+uint64_t mc_hash_processes_state(int num_state, xbt_dynar_t stacks);
+
 #endif
 
index 1392a35..9fb5ad5 100644 (file)
@@ -17,7 +17,11 @@ int MC_request_depend(smx_simcall_t r1, smx_simcall_t r2) {
     return TRUE;
 
   if (r1->issuer == r2->issuer)
-      return FALSE;
+    return FALSE;
+
+  /* Wait with timeout transitions are not considered by the independance theorem, thus we consider them as dependant with all other transitions */
+  if((r1->call == SIMCALL_COMM_WAIT && simcall_comm_wait__get__timeout(r1) > 0) || (r2->call == SIMCALL_COMM_WAIT && simcall_comm_wait__get__timeout(r2) > 0))
+    return TRUE;
 
   if(r1->call == SIMCALL_COMM_ISEND && r2->call == SIMCALL_COMM_IRECV)
     return FALSE;
@@ -275,9 +279,9 @@ char *MC_request_to_string(smx_simcall_t req, int value)
   }
 
   if(args != NULL){
-    str = bprintf("[(%lu)%s (%s)] %s(%s) (%d)", req->issuer->pid , MSG_host_get_name(req->issuer->smx_host), req->issuer->name, type, args, req->call);
+    str = bprintf("[(%lu)%s (%s)] %s(%s)", req->issuer->pid , MSG_host_get_name(req->issuer->smx_host), req->issuer->name, type, args);
   }else{
-    str = bprintf("[(%lu)%s (%s)] %s (%d) ", req->issuer->pid , MSG_host_get_name(req->issuer->smx_host), req->issuer->name, type, req->call);
+    str = bprintf("[(%lu)%s (%s)] %s ", req->issuer->pid , MSG_host_get_name(req->issuer->smx_host), req->issuer->name, type);
   }
 
   xbt_free(args);
@@ -335,6 +339,8 @@ int MC_request_is_enabled(smx_simcall_t req)
       }
     }else{
       act = simcall_comm_wait__get__comm(req);
+      if(act->comm.detached && act->comm.src_proc == NULL && act->comm.type == SIMIX_COMM_READY)
+        return (act->comm.dst_proc != NULL);
       return (act->comm.src_proc && act->comm.dst_proc);
     }
     break;
diff --git a/src/mc/mc_set.cpp b/src/mc/mc_set.cpp
new file mode 100644 (file)
index 0000000..03613c4
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright (c) 2007-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <stddef.h>
+#include <set>
+
+typedef std::set<const void*>*  mc_address_set_t;
+
+extern "C" {
+
+mc_address_set_t mc_address_set_new();
+void mc_address_set_free(mc_address_set_t* p);
+void mc_address_add(mc_address_set_t p, const void* value);
+bool mc_address_test(mc_address_set_t p, const void* value);
+
+mc_address_set_t mc_address_set_new() {
+  return new std::set<const void*>();
+}
+
+void mc_address_set_free(mc_address_set_t* p) {
+  delete *p;
+  *p = NULL;
+}
+
+void mc_address_add(mc_address_set_t p, const void* value) {
+  p->insert(value);
+}
+
+bool mc_address_test(mc_address_set_t p, const void* value) {
+  return p->find(value) != p->end();
+}
+
+};
index d0cef47..64dcb1a 100644 (file)
@@ -143,6 +143,7 @@ smx_simcall_t MC_state_get_request(mc_state_t state, int *value)
   smx_process_t process = NULL;
   mc_procstate_t procstate = NULL;
   unsigned int start_count;
+  smx_action_t act = NULL;
 
   xbt_swag_foreach(process, simix_global->process_list){
     procstate = &state->proc_status[process->pid];
@@ -186,11 +187,14 @@ smx_simcall_t MC_state_get_request(mc_state_t state, int *value)
             break;
 
           case SIMCALL_COMM_WAIT:
-            if(simcall_comm_wait__get__comm(&process->simcall)->comm.src_proc
-               && simcall_comm_wait__get__comm(&process->simcall)->comm.dst_proc){
+            act = simcall_comm_wait__get__comm(&process->simcall);
+            if(act->comm.src_proc && act->comm.dst_proc){
               *value = 0;
             }else{
-              *value = -1;
+              if(act->comm.src_proc == NULL && act->comm.type == SIMIX_COMM_READY && act->comm.detached == 1)
+                *value = 0;
+              else
+                *value = -1;
             }
             procstate->state = MC_DONE;
             return &process->simcall;
index 52d88d8..018afcb 100644 (file)
@@ -25,6 +25,11 @@ static void MSG_exit(void);
 
 /********************************* MSG **************************************/
 
+static void _sg_cfg_cb_msg_debug_multiple_use(const char *name, int pos)
+{
+  msg_global->debug_multiple_use = xbt_cfg_get_boolean(_sg_cfg_set, name);
+}
+
 /**
  * \ingroup msg_simulation
  * \brief Initialize MSG with less verifications
@@ -39,10 +44,15 @@ void MSG_init_nocheck(int *argc, char **argv) {
   xbt_getpid = MSG_process_self_PID;
   if (!msg_global) {
 
-    SIMIX_global_init(argc, argv);
-    
     msg_global = xbt_new0(s_MSG_Global_t, 1);
 
+    xbt_cfg_register(&_sg_cfg_set, "msg/debug_multiple_use",
+                     "Print backtraces of both processes when there is a conflict of multiple use of a task",
+                     xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_msg_debug_multiple_use, NULL);
+    xbt_cfg_setdefault_boolean(_sg_cfg_set, "msg/debug_multiple_use", "no");
+
+    SIMIX_global_init(argc, argv);
+
 #ifdef MSG_USE_DEPRECATED
     msg_global->max_channel = 0;
 #endif
@@ -58,7 +68,7 @@ void MSG_init_nocheck(int *argc, char **argv) {
 
     sg_platf_postparse_add_cb(MSG_post_create_environment);
   }
-  
+
   if(MC_is_active()){
     /* Ignore total amount of messages sent during the simulation for heap comparison */
     MC_ignore_heap(&(msg_global->sent_msg), sizeof(msg_global->sent_msg));
index dbf0eac..7c01ce1 100644 (file)
@@ -58,7 +58,7 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task)
 
   xbt_assert((!simdata->compute) && (task->simdata->isused == 0),
              "This task is executed somewhere else. Go fix your code! %d",
-             task->simdata->isused);
+             task->simdata->isused!=NULL);
 
   XBT_DEBUG("Computing on %s", MSG_process_get_name(MSG_process_self()));
 
@@ -71,8 +71,10 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task)
 
 
   TRY {
-
-    simdata->isused=1;
+    if (msg_global->debug_multiple_use)
+      MSG_BT(simdata->isused, "Using Backtrace");
+    else
+      simdata->isused = (void*)1;
 
     if (simdata->host_nb > 0) {
       simdata->compute = simcall_host_parallel_execute(task->name,
@@ -103,7 +105,9 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task)
 
     p_simdata->waiting_action = NULL;
 
-    simdata->isused=0;
+    if (msg_global->debug_multiple_use && simdata->isused!=0)
+      xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+    simdata->isused = 0;
 
     XBT_DEBUG("Execution task '%s' finished in state %d",
               task->name, (int)comp_state);
@@ -405,10 +409,22 @@ msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias,
   t_simdata->sender = process;
   t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
 
-  xbt_assert(t_simdata->isused == 0,
-              "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
+  if (t_simdata->isused != 0) {
+    if (msg_global->debug_multiple_use){
+      XBT_ERROR("This task is already used in there:");
+      xbt_backtrace_display(t_simdata->isused);
+      XBT_ERROR("And you try to reuse it from here:");
+      xbt_backtrace_display_current();
+    } else {
+      xbt_assert(t_simdata->isused == 0,
+                 "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)");
+    }
+  }
 
-  t_simdata->isused = 1;
+  if (msg_global->debug_multiple_use)
+    MSG_BT(t_simdata->isused, "Using Backtrace");
+  else
+    t_simdata->isused = (void*)1;
   t_simdata->comm = NULL;
   msg_global->sent_msg++;
 
@@ -614,7 +630,10 @@ int MSG_comm_test(msg_comm_t comm)
 
     if (finished && comm->task_received != NULL) {
       /* I am the receiver */
-      (*comm->task_received)->simdata->isused = 0;
+      simdata_task_t simdata = (*comm->task_received)->simdata;
+      if (msg_global->debug_multiple_use && simdata->isused!=0)
+        xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+      simdata->isused = 0;
     }
   }
   CATCH(e) {
@@ -688,7 +707,10 @@ int MSG_comm_testany(xbt_dynar_t comms)
 
     if (status == MSG_OK && comm->task_received != NULL) {
       /* I am the receiver */
-      (*comm->task_received)->simdata->isused = 0;
+      simdata_task_t simdata = (*comm->task_received)->simdata;
+      if (msg_global->debug_multiple_use && simdata->isused!=0)
+        xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+      simdata->isused = 0;
     }
   }
 
@@ -721,7 +743,10 @@ msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout)
 
     if (comm->task_received != NULL) {
       /* I am the receiver */
-      (*comm->task_received)->simdata->isused = 0;
+      simdata_task_t simdata = (*comm->task_received)->simdata;
+      if (msg_global->debug_multiple_use && simdata->isused!=0)
+        xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+      simdata->isused = 0;
     }
 
     /* FIXME: these functions are not traceable */
@@ -808,7 +833,10 @@ int MSG_comm_waitany(xbt_dynar_t comms)
 
   if (comm->task_received != NULL) {
     /* I am the receiver */
-    (*comm->task_received)->simdata->isused = 0;
+    simdata_task_t simdata = (*comm->task_received)->simdata;
+    if (msg_global->debug_multiple_use && simdata->isused!=0)
+      xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+    simdata->isused = 0;
   }
 
   return finished_index;
index b5667c2..d5e1690 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "msg_private.h"
 #include "xbt/log.h"
+#include "msg_mailbox.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg,
                                 "Logging specific to MSG (io)");
@@ -73,61 +74,129 @@ void MSG_file_dump (msg_file_t fd){
 
   msg_file_priv_t priv = MSG_file_priv(fd);
   XBT_INFO("File Descriptor information:\n"
-           "\t\tFull name: '%s'\n"
+           "\t\tFull path: '%s'\n"
            "\t\tSize: %llu\n"
            "\t\tMount point: '%s'\n"
            "\t\tStorage Id: '%s'\n"
            "\t\tStorage Type: '%s'\n"
            "\t\tContent Type: '%s'",
-           priv->fullname, priv->size, priv->mount_point,
+           priv->fullpath, priv->size, priv->mount_point,
            priv->storageId, priv->storage_type,
            priv->content_type);
 }
 
 /** \ingroup msg_file_management
- * \brief Read a file
+ * \brief Read a file (local or remote)
  *
  * \param size of the file to read
  * \param fd is a the file descriptor
- * \return the number of bytes successfully read
+ * \return the number of bytes successfully read or -1 if an error occurred
  */
 sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size)
 {
-  msg_file_priv_t priv = MSG_file_priv(fd);
-  return simcall_file_read(priv->simdata->smx_file, size);
+  msg_file_priv_t file_priv = MSG_file_priv(fd);
+  sg_size_t read_size;
+
+  /* Find the host where the file is physically located and read it */
+  msg_storage_t storage_src =(msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId);
+  msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
+  msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname);
+  read_size = simcall_file_read(file_priv->simdata->smx_file, size, attached_host);
+
+  if(strcmp(storage_priv_src->hostname, MSG_host_get_name(MSG_host_self()))){
+    /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
+    XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, read_size);
+    msg_host_t *m_host_list = NULL;
+    m_host_list = calloc(2, sizeof(msg_host_t));
+
+    m_host_list[0] = MSG_host_self();
+    m_host_list[1] = attached_host;
+    double computation_amount[] = { 0, 0 };
+    double communication_amount[] = { 0, 0, (double)read_size, 0 };
+
+    msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, computation_amount, communication_amount, NULL);
+    msg_error_t transfer = MSG_parallel_task_execute(task);
+    MSG_task_destroy(task);
+    free(m_host_list);
+    if(transfer != MSG_OK){
+      if (transfer == MSG_HOST_FAILURE)
+        XBT_WARN("Transfer error, %s remote host just turned off!", MSG_host_get_name(attached_host));
+      if (transfer == MSG_TASK_CANCELED)
+        XBT_WARN("Transfer error, task has been canceled!");
+
+      return -1;
+    }
+  }
+  return read_size;
 }
 
 /** \ingroup msg_file_management
- * \brief Write into a file
+ * \brief Write into a file (local or remote)
  *
  * \param size of the file to write
  * \param fd is a the file descriptor
- * \return the number of bytes successfully write
+ * \return the number of bytes successfully write or -1 if an error occurred
  */
 sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size)
 {
-  msg_file_priv_t priv = MSG_file_priv(fd);
-  return simcall_file_write(priv->simdata->smx_file, size);
+  msg_file_priv_t file_priv = MSG_file_priv(fd);
+  sg_size_t write_size;
+
+  /* Find the host where the file is physically located (remote or local)*/
+  msg_storage_t storage_src =(msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId);
+  msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
+  msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname);
+
+  if(strcmp(storage_priv_src->hostname, MSG_host_get_name(MSG_host_self()))){
+    /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
+    XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, size);
+    msg_host_t *m_host_list = NULL;
+    m_host_list = calloc(2, sizeof(msg_host_t));
+
+    m_host_list[0] = MSG_host_self();
+    m_host_list[1] = attached_host;
+    double computation_amount[] = { 0, 0 };
+    double communication_amount[] = { 0, (double)size, 0, 0 };
+
+    msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, computation_amount, communication_amount, NULL);
+    msg_error_t transfer = MSG_parallel_task_execute(task);
+    MSG_task_destroy(task);
+    free(m_host_list);
+    if(transfer != MSG_OK){
+      if (transfer == MSG_HOST_FAILURE)
+        XBT_WARN("Transfer error, %s remote host just turned off!", MSG_host_get_name(attached_host));
+      if (transfer == MSG_TASK_CANCELED)
+        XBT_WARN("Transfer error, task has been canceled!");
+
+      return -1;
+    }
+  }
+  /* Write file on local or remote host */
+  write_size = simcall_file_write(file_priv->simdata->smx_file, size, attached_host);
+
+  return write_size;
 }
 
 /** \ingroup msg_file_management
  * \brief Opens the file whose name is the string pointed to by path
  *
- * \param mount is the mount point where find the file is located
- * \param fullname is the file location on the storage
+ * \param fullpath is the file location on the storage
  * \param data user data to attach to the file
  *
  * \return An #msg_file_t associated to the file
  */
-msg_file_t MSG_file_open(const char* mount,const char* fullname, void* data)
+msg_file_t MSG_file_open(const char* fullpath, void* data)
 {
   msg_file_priv_t priv = xbt_new(s_msg_file_priv_t, 1);
   priv->data = data;
-  priv->fullname = xbt_strdup(fullname);
+  priv->fullpath = xbt_strdup(fullpath);
   priv->simdata = xbt_new0(s_simdata_file_t,1);
-  priv->simdata->smx_file = simcall_file_open(mount, fullname);
-  xbt_lib_set(file_lib, fullname, MSG_FILE_LEVEL, priv);
-  return (msg_file_t) xbt_lib_get_elm_or_null(file_lib, fullname);
+  priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self());
+  xbt_lib_set(file_lib, fullpath, MSG_FILE_LEVEL, priv);
+  msg_file_t fd = (msg_file_t) xbt_lib_get_elm_or_null(file_lib, fullpath);
+  __MSG_file_get_info(fd);
+
+  return fd;
 }
 
 /**
@@ -148,8 +217,8 @@ void __MSG_file_priv_free(msg_file_priv_t priv)
 int MSG_file_close(msg_file_t fd)
 {
   msg_file_priv_t priv = MSG_file_priv(fd);
-  int res = simcall_file_close(priv->simdata->smx_file);
-  xbt_lib_unset(file_lib, priv->fullname, MSG_FILE_LEVEL, 1);
+  int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self());
+  xbt_lib_unset(file_lib, priv->fullpath, MSG_FILE_LEVEL, 1);
   return res;
 }
 
@@ -159,7 +228,7 @@ int MSG_file_close(msg_file_t fd)
  * \param fd is the file descriptor (#msg_file_t)
  * \return 0 on success or 1 on error
  */
-int MSG_file_unlink(msg_file_t fd)
+msg_error_t MSG_file_unlink(msg_file_t fd)
 {
   msg_file_priv_t priv = MSG_file_priv(fd);
   int res = simcall_file_unlink(priv->simdata->smx_file);
@@ -177,30 +246,6 @@ sg_size_t MSG_file_get_size(msg_file_t fd){
   return simcall_file_get_size(priv->simdata->smx_file);
 }
 
-/** \ingroup msg_file_management
- * \brief Search for file
- *
- * \param mount is the mount point where find the file is located
- * \param path the file regex to find
- * \return a xbt_dict_t of file where key is the name of file and the
- * value the msg_stat_t corresponding to the key
- */
-xbt_dict_t MSG_file_ls(const char *mount, const char *path)
-{
-  xbt_assert(path,"You must set path");
-  int size = strlen(path);
-  if(size && path[size-1] != '/')
-  {
-    char *new_path = bprintf("%s/",path);
-    XBT_DEBUG("Change '%s' for '%s'",path,new_path);
-    xbt_dict_t dict = simcall_file_ls(mount, new_path);
-    xbt_free(new_path);
-    return dict;
-  }
-
-  return simcall_file_ls(mount, path);
-}
-
 /**
  * \ingroup msg_file_management
  * \brief Set the file position indicator in the msg_file_t by adding offset bytes
@@ -240,15 +285,122 @@ sg_size_t MSG_file_tell(msg_file_t fd)
 const char *MSG_file_get_name(msg_file_t fd) {
   xbt_assert((fd != NULL), "Invalid parameters");
   msg_file_priv_t priv = MSG_file_priv(fd);
-  return priv->fullname;
+  return priv->fullpath;
 }
 
+/**
+ * \ingroup msg_file_management
+ * \brief Move a file to another location on the *same mount point*.
+ *
+ */
+msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath)
+{
+  msg_file_priv_t priv = MSG_file_priv(fd);
+  return simcall_file_move(priv->simdata->smx_file, fullpath);
+}
+
+/**
+ * \ingroup msg_file_management
+ * \brief Copy a file to another location on a remote host.
+ * \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
+ * MSG_TASK_CANCELED.
+ */
+msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpath)
+{
+  msg_file_priv_t file_priv = MSG_file_priv(file);
+  sg_size_t read_size;
+
+  /* Find the host where the file is physically located and read it */
+  msg_storage_t storage_src =(msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId);
+  msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
+  msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname);
+  read_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, attached_host);
+
+  /* Find the real host destination where the file will be physically stored */
+  xbt_dict_cursor_t cursor = NULL;
+  char *mount_name, *storage_name, *file_mount_name, *host_name_dest;
+  msg_storage_t storage_dest = NULL;
+  msg_host_t host_dest;
+  size_t longest_prefix_length = 0;
+
+  xbt_dict_t storage_list = simcall_host_get_mounted_storage_list(host);
+  xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
+    file_mount_name = (char *) xbt_malloc ((strlen(mount_name)+1));
+    strncpy(file_mount_name,fullpath,strlen(mount_name)+1);
+    file_mount_name[strlen(mount_name)] = '\0';
+
+    if(!strcmp(file_mount_name,mount_name) && strlen(mount_name)>longest_prefix_length){
+      /* The current mount name is found in the full path and is bigger than the previous*/
+      longest_prefix_length = strlen(mount_name);
+      storage_dest = (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, storage_name);
+    }
+    free(file_mount_name);
+  }
+  if(longest_prefix_length>0){
+    /* Mount point found, retrieve the host the storage is attached to */
+    msg_storage_priv_t storage_dest_priv = MSG_storage_priv(storage_dest);
+    host_name_dest = (char*)storage_dest_priv->hostname;
+    host_dest = MSG_get_host_by_name(host_name_dest);
+
+  }else{
+    XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, SIMIX_host_get_name(host));
+    return MSG_TASK_CANCELED;
+  }
 
-/*
+  XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname, host_name_dest);
+  msg_host_t *m_host_list = NULL;
+  m_host_list = calloc(2, sizeof(msg_host_t));
+
+  m_host_list[0] = attached_host;
+  m_host_list[1] = host_dest;
+  double computation_amount[] = { 0, 0 };
+  double communication_amount[] = { 0, (double)read_size, 0, 0 };
+
+  msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, computation_amount, communication_amount, NULL);
+  msg_error_t transfer = MSG_parallel_task_execute(task);
+  MSG_task_destroy(task);
+  free(m_host_list);
+  if(transfer != MSG_OK){
+    if (transfer == MSG_HOST_FAILURE)
+      XBT_WARN("Transfer error, %s remote host just turned off!", host_name_dest);
+    if (transfer == MSG_TASK_CANCELED)
+      XBT_WARN("Transfer error, task has been canceled!");
+
+    return -1;
+  }
+
+  /* Create file on remote host, write it and close it */
+  smx_file_t smx_file = simcall_file_open(fullpath, host_dest);
+  simcall_file_write(smx_file, read_size, host_dest);
+  simcall_file_close(smx_file, host_dest);
+  return MSG_OK;
+
+}
+
+/**
+ * \ingroup msg_file_management
+ * \brief Move a file to another location on a remote host.
+ * \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
+ * MSG_TASK_CANCELED.
+ */
+msg_error_t MSG_file_rmove (msg_file_t file, msg_host_t host, const char* fullpath)
+{
+  msg_error_t res = MSG_file_rcopy(file, host, fullpath);
+  MSG_file_unlink(file);
+  return res;
+}
+
+/**
  * \brief Destroys a file (internal call only)
  */
 void __MSG_file_destroy(msg_file_priv_t file) {
-  xbt_free(file->fullname);
+  xbt_free(file->fullpath);
   xbt_free(file->simdata);
   xbt_free(file);
 }
@@ -265,12 +417,12 @@ msg_storage_t __MSG_storage_create(smx_storage_t storage)
   const char *name = SIMIX_storage_get_name(storage);
   const char *host = SIMIX_storage_get_host(storage);
   msg_storage_priv_t storage_private = xbt_new0(s_msg_storage_priv_t, 1);
-  storage_private->host = host;
+  storage_private->hostname = host;
   xbt_lib_set(storage_lib,name,MSG_STORAGE_LEVEL,storage_private);
   return xbt_lib_get_elm_or_null(storage_lib, name);
 }
 
-/*
+/**
  * \brief Destroys a storage (internal call only)
  */
 void __MSG_storage_destroy(msg_storage_priv_t storage) {
@@ -291,20 +443,20 @@ const char *MSG_storage_get_name(msg_storage_t storage) {
 
 /** \ingroup msg_storage_management
  * \brief Returns the free space size of a storage element
- * \param name the name of a storage
+ * \param storage a storage
  * \return the free space size of the storage element (as a #sg_size_t)
  */
-sg_size_t MSG_storage_get_free_size(const char* name){
-  return simcall_storage_get_free_size(name);
+sg_size_t MSG_storage_get_free_size(msg_storage_t storage){
+  return simcall_storage_get_free_size(storage);
 }
 
 /** \ingroup msg_storage_management
  * \brief Returns the used space size of a storage element
- * \param name the name of a storage
+ * \param storage a storage
  * \return the used space size of the storage element (as a #sg_size_t)
  */
-sg_size_t MSG_storage_get_used_size(const char* name){
-  return simcall_storage_get_used_size(name);
+sg_size_t MSG_storage_get_used_size(msg_storage_t storage){
+  return simcall_storage_get_used_size(storage);
 }
 
 /** \ingroup msg_storage_management
@@ -403,30 +555,6 @@ sg_size_t MSG_storage_get_size(msg_storage_t storage)
   return SIMIX_storage_get_size(storage);
 }
 
-/**
- * \ingroup msg_storage_management
- *
- * \brief Rename the file in the contents of its associated storage.
- */
-msg_error_t MSG_storage_file_rename(msg_storage_t storage, const char* src,  const char* dest)
-{
-  simcall_storage_file_rename(storage, src, dest);
-  return MSG_OK;
-}
-
-/**
- * \ingroup msg_storage_management
- * \brief Move a file to another location. Depending on the values of dest, dest, mount,
- * and fullname, this move can be local or remote and, within a host, on the same
- * mounted disk or between mounted disks.
- *
- */
-msg_error_t MSG_storage_file_move (msg_file_t fd, msg_host_t dest, char* mount, char* fullname)
-{
-  THROW_UNIMPLEMENTED;
-  return MSG_OK;
-}
-
 /** \ingroup msg_storage_management
  *
  * \brief Returns the host name the storage is attached to
@@ -436,5 +564,5 @@ msg_error_t MSG_storage_file_move (msg_file_t fd, msg_host_t dest, char* mount,
 const char *MSG_storage_get_host(msg_storage_t storage) {
   xbt_assert((storage != NULL), "Invalid parameters");
   msg_storage_priv_t priv = MSG_storage_priv(storage);
-  return priv->host;
+  return priv->hostname;
 }
index b8b63a2..557b26a 100644 (file)
@@ -58,13 +58,13 @@ msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
 /** \ingroup msg_mailbox_management
  * \brief Set the mailbox to receive in asynchronous mode
  *
- * All messages sent to this mailbox will be transferred to 
- * the receiver without waiting for the receive call. 
+ * All messages sent to this mailbox will be transferred to
+ * the receiver without waiting for the receive call.
  * The receive call will still be necessary to use the received data.
- * If there is a need to receive some messages asynchronously, and some not, 
+ * If there is a need to receive some messages asynchronously, and some not,
  * two different mailboxes should be used.
  *
- * \param alias The name of the mailbox 
+ * \param alias The name of the mailbox
  */
 void MSG_mailbox_set_async(const char *alias){
   msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
@@ -132,7 +132,10 @@ MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * task,
   TRY {
     simcall_comm_recv(mailbox, task, NULL, NULL, NULL, timeout, rate);
     XBT_DEBUG("Got task %s from %p",(*task)->name,mailbox);
-    (*task)->simdata->isused=0;
+    simdata_task_t simdata = (*task)->simdata;
+    if (msg_global->debug_multiple_use && simdata->isused!=0)
+      xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+    simdata->isused = 0;
   }
   CATCH(e) {
     switch (e.category) {
@@ -180,10 +183,22 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task,
   t_simdata->sender = process;
   t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
 
-  xbt_assert(t_simdata->isused == 0,
-              "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
+  if (t_simdata->isused != 0) {
+    if (msg_global->debug_multiple_use){
+      XBT_ERROR("This task is already used in there:");
+      xbt_backtrace_display(t_simdata->isused);
+      XBT_ERROR("And you try to reuse it from here:");
+      xbt_backtrace_display_current();
+    } else {
+      xbt_assert(t_simdata->isused == 0,
+                 "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)");
+    }
+  }
 
-  t_simdata->isused=1;
+  if (msg_global->debug_multiple_use)
+    MSG_BT(t_simdata->isused, "Using Backtrace");
+  else
+    t_simdata->isused = (void*)1;
   t_simdata->comm = NULL;
   msg_global->sent_msg++;
 
@@ -222,6 +237,8 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task,
     xbt_ex_free(e);
 
     /* If the send failed, it is not used anymore */
+    if (msg_global->debug_multiple_use && t_simdata->isused!=0)
+      xbt_ex_free(*(xbt_ex_t*)t_simdata->isused);
     t_simdata->isused = 0;
   }
 
index 5644882..e5f4cad 100644 (file)
@@ -22,6 +22,22 @@ SG_BEGIN_DECL()
 
 /********************************* Task **************************************/
 
+
+#define MSG_BT(ptr, m)                              \
+  do {xbt_ex_t *_xbt_ex_t = xbt_new0(xbt_ex_t, 1); \
+  /* build the exception */                                             \
+  _xbt_ex_t->msg      = (bprintf(m));                                 \
+  _xbt_ex_t->category = (xbt_errcat_t)(0);                   \
+  _xbt_ex_t->value    = (0);                                 \
+  _xbt_ex_t->procname = (char*)xbt_procname();               \
+  _xbt_ex_t->pid      = xbt_getpid();                        \
+  _xbt_ex_t->file     = (char*)__FILE__;                     \
+  _xbt_ex_t->line     = __LINE__;                            \
+  _xbt_ex_t->func     = (char*)_XBT_FUNCTION;                \
+  _xbt_ex_t->bt_strings = NULL;                              \
+  xbt_backtrace_current(_xbt_ex_t); \
+  ptr = _xbt_ex_t; } while(0)
+
 typedef struct simdata_task {
   smx_action_t compute;         /* SIMIX modeling of computation */
   smx_action_t comm;            /* SIMIX modeling of communication */
@@ -37,7 +53,7 @@ typedef struct simdata_task {
   /* CPU affinity database of this task */
   xbt_dict_t affinity_mask_db; /* smx_host_t host => unsigned long mask */
 
-  int isused;  /* Indicates whether the task is used in SIMIX currently */
+  void *isused;  /* Indicates whether the task is used in SIMIX currently */
   int host_nb;                  /* ==0 if sequential task; parallel task if not */
   /*******  Parallel Tasks Only !!!! *******/
   smx_host_t *host_list;
@@ -114,6 +130,7 @@ typedef struct MSG_Global {
   int max_channel;
 #endif
   int session;
+  int debug_multiple_use;
   unsigned long int sent_msg;   /* Total amount of messages sent during the simulation */
   void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst);
   void_f_pvoid_t process_data_cleanup;
index bdbbc47..7c775a4 100644 (file)
@@ -10,8 +10,8 @@
 #include "xbt/log.h"
 
 /** @addtogroup m_task_management
- *    
- * 
+ *
+ *
  *  Since most scheduling algorithms rely on a concept of task
  *  that can be either <em>computed</em> locally or
  *  <em>transferred</em> on another processor, it seems to be the
@@ -310,7 +310,10 @@ msg_error_t MSG_task_cancel(msg_task_t task)
   }
   else if (task->simdata->comm) {
     simcall_comm_cancel(task->simdata->comm);
-    task->simdata->isused = 0;
+    simdata_task_t simdata = task->simdata;
+    if (msg_global->debug_multiple_use && simdata->isused!=0)
+      xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+    simdata->isused = 0;
   }
   return MSG_OK;
 }
@@ -351,7 +354,7 @@ void MSG_task_set_compute_duration(msg_task_t task,
  * \brief set the amount data attached with a task #msg_task_t.
  *
  * \warning If the transfer is ongoing (already started and not finished),
- * it is not modified by this call. 
+ * it is not modified by this call.
  */
 
 void MSG_task_set_data_size(msg_task_t task,
@@ -428,7 +431,7 @@ double MSG_task_get_data_size(msg_task_t task)
 
 
 /** \ingroup m_task_management
- * \brief Changes the priority of a computation task. This priority doesn't affect 
+ * \brief Changes the priority of a computation task. This priority doesn't affect
  *        the transfer rate. A priority of 2 will make a task receive two times more
  *        cpu power than the other ones.
  *
index 108e640..911d596 100644 (file)
@@ -281,6 +281,15 @@ double SD_workstation_get_power(SD_workstation_t workstation)
 {
   return surf_workstation_get_speed(workstation, 1.0);
 }
+/**
+ * \brief Returns the amount of cores of a workstation
+ *
+ * \param workstation a workstation
+ * \return the amount of cores of this workstation
+ */
+int SD_workstation_get_cores(SD_workstation_t workstation) {
+  return surf_workstation_get_core(workstation);
+}
 
 /**
  * \brief Returns the proportion of available power in a workstation
index 64ebadd..bd6c7e2 100644 (file)
@@ -258,6 +258,11 @@ static void _sg_cfg_cb__maxmin_precision(const char* name, int pos)
   sg_maxmin_precision = xbt_cfg_get_double(_sg_cfg_set, name);
 }
 
+static void _sg_cfg_cb__surf_precision(const char* name, int pos)
+{
+  sg_surf_precision = xbt_cfg_get_double(_sg_cfg_set, name);
+}
+
 static void _sg_cfg_cb__sender_gap(const char* name, int pos)
 {
   sg_sender_gap = xbt_cfg_get_double(_sg_cfg_set, name);
@@ -388,6 +393,12 @@ static void _sg_cfg_cb_context_stack_size(const char *name, int pos)
   smx_context_stack_size = xbt_cfg_get_int(_sg_cfg_set, name) * 1024;
 }
 
+static void _sg_cfg_cb_context_guard_size(const char *name, int pos)
+{
+  smx_context_guard_size_was_set = 1;
+  smx_context_guard_size = xbt_cfg_get_int(_sg_cfg_set, name) * xbt_pagesize;
+}
+
 static void _sg_cfg_cb_contexts_nthreads(const char *name, int pos)
 {
   SIMIX_context_set_nthreads(xbt_cfg_get_int(_sg_cfg_set, name));
@@ -528,8 +539,13 @@ void sg_config_init(int *argc, char **argv)
                      xbt_cfgelm_double, 1, 1, _sg_cfg_cb__tcp_gamma, NULL);
     xbt_cfg_setdefault_double(_sg_cfg_set, "network/TCP_gamma", 4194304.0);
 
+    xbt_cfg_register(&_sg_cfg_set, "surf/precision",
+                     "Numerical precision used when updating simulation times (hence this value is expressed in seconds)",
+                     xbt_cfgelm_double, 1, 1, _sg_cfg_cb__surf_precision, NULL);
+    xbt_cfg_setdefault_double(_sg_cfg_set, "surf/precision", 0.00001);
+
     xbt_cfg_register(&_sg_cfg_set, "maxmin/precision",
-                     "Numerical precision used when updating simulation models (epsilon in double comparisons)",
+                     "Numerical precision used when computing resource sharing (hence this value is expressed in ops/sec or bytes/sec)",
                      xbt_cfgelm_double, 1, 1, _sg_cfg_cb__maxmin_precision, NULL);
     xbt_cfg_setdefault_double(_sg_cfg_set, "maxmin/precision", 0.00001);
 
@@ -592,6 +608,18 @@ void sg_config_init(int *argc, char **argv)
                      xbt_cfgelm_string, 1, 1, _mc_cfg_cb_property, NULL);
     xbt_cfg_setdefault_string(_sg_cfg_set, "model-check/property", "");
 
+    /* do communications determinism model-checking */
+    xbt_cfg_register(&_sg_cfg_set, "model-check/communications_determinism",
+                     "Enable/disable the detection of determinism in the communications schemes",
+                     xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_comms_determinism, NULL);
+    xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/communications_determinism", "no");
+
+    /* do send determinism model-checking */
+    xbt_cfg_register(&_sg_cfg_set, "model-check/send_determinism",
+                     "Enable/disable the detection of send-determinism in the communications schemes",
+                     xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_send_determinism, NULL);
+    xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/send_determinism", "no");
+
     /* Specify the kind of model-checking reduction */
     xbt_cfg_register(&_sg_cfg_set, "model-check/reduction",
                      "Specify the kind of exploration reduction (either none or DPOR)",
@@ -604,6 +632,12 @@ void sg_config_init(int *argc, char **argv)
                      xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_timeout, NULL);
     xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/timeout", "no");
 
+    /* Enable/disable global hash computation with model-checking */
+    xbt_cfg_register(&_sg_cfg_set, "model-check/hash",
+                     "Enable/Disable state hash for state comparison (exprimental)",
+                     xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_hash, NULL);
+    xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/hash", "no");
+
     /* Set max depth exploration */
     xbt_cfg_register(&_sg_cfg_set, "model-check/max_depth",
                      "Specify the max depth of exploration (default : 1000)",
@@ -658,6 +692,18 @@ void sg_config_init(int *argc, char **argv)
     /* No, it was not set yet (the above setdefault() changed this to 1). */
     smx_context_stack_size_was_set = 0;
 
+    /* guard size for contexts stacks in memory pages */
+    xbt_cfg_register(&_sg_cfg_set, "contexts/guard_size",
+                     "Guard size for contexts stacks in memory pages",
+                     xbt_cfgelm_int, 1, 1, _sg_cfg_cb_context_guard_size, NULL);
+#if defined(_XBT_WIN32) || (PTH_STACKGROWTH != -1)
+    xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/guard_size", 0);
+#else
+    xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/guard_size", 1);
+#endif
+    /* No, it was not set yet (the above setdefault() changed this to 1). */
+    smx_context_guard_size_was_set = 0;
+
     /* number of parallel threads for user processes */
     xbt_cfg_register(&_sg_cfg_set, "contexts/nthreads",
                      "Number of parallel threads used to execute user contexts",
@@ -739,6 +785,11 @@ void sg_config_init(int *argc, char **argv)
                      xbt_cfgelm_int, 1, 1, NULL, NULL);
     xbt_cfg_setdefault_int(_sg_cfg_set, "smpi/send_is_detached_thres", 65536);
 
+    xbt_cfg_register(&_sg_cfg_set, "smpi/privatize_global_variables",
+                     "Boolean indicating whether we should privatize global variable at runtime.",
+                     xbt_cfgelm_boolean, 1, 1, NULL, NULL);
+    xbt_cfg_setdefault_boolean(_sg_cfg_set, "smpi/privatize_global_variables", "no");
+
     //For smpi/bw_factor and smpi/lat_factor
     //Default value have to be "threshold0:value0;threshold1:value1;...;thresholdN:valueN"
     //test is if( size >= thresholdN ) return valueN;
@@ -905,13 +956,17 @@ void surf_config_models_setup()
     xbt_assert(network_model_name,
                 "Set a network model to use with the 'compound' workstation model");
 
+    if(surf_cpu_model_init_preparse){
+      surf_cpu_model_init_preparse();
+    } else {
+      cpu_id =
+          find_model_description(surf_cpu_model_description, cpu_model_name);
+      surf_cpu_model_description[cpu_id].model_init_preparse();
+    }
+
     network_id =
         find_model_description(surf_network_model_description,
                                network_model_name);
-    cpu_id =
-        find_model_description(surf_cpu_model_description, cpu_model_name);
-
-    surf_cpu_model_description[cpu_id].model_init_preparse();
     surf_network_model_description[network_id].model_init_preparse();
   }
 
index 8328b47..d4b61ae 100644 (file)
@@ -108,19 +108,18 @@ sem_would_block True (int) (sem, void*, smx_sem_t)
 sem_acquire False (void) (sem, void*, smx_sem_t)
 sem_acquire_timeout False (void) (sem, void*, smx_sem_t) (timeout, double)
 sem_get_capacity True (int) (sem, void*, smx_sem_t)
-file_read False (sg_size_t) (fd, void*, smx_file_t) (size, sg_size_t)
-file_write False (sg_size_t) (fd, void*, smx_file_t) (size, sg_size_t)
-file_open False (void*, smx_file_t) (mount, const char*) (path, const char*)
-file_close False (int) (fd, void*, smx_file_t)
+file_read False (sg_size_t) (fd, void*, smx_file_t) (size, sg_size_t) (host, void*, smx_host_t)
+file_write False (sg_size_t) (fd, void*, smx_file_t) (size, sg_size_t) (host, void*, smx_host_t)
+file_open False (void*, smx_file_t) (fullpath, const char*) (host, void*, smx_host_t)
+file_close False (int) (fd, void*, smx_file_t) (host, void*, smx_host_t)
 file_unlink True (int) (fd, void*, smx_file_t)
-file_ls False (void*, xbt_dict_t) (mount, const char*) (path, const char*)
 file_get_size True (sg_size_t) (fd, void*, smx_file_t)
 file_tell True (sg_size_t) (fd, void*, smx_file_t)
 file_seek True (int) (fd, void*, smx_file_t) (offset, sg_size_t) (origin, int)
 file_get_info True (void*, xbt_dynar_t) (fd, void*, smx_file_t)
-storage_file_rename True (void) (storage, void*, smx_storage_t) (src, const char*) (dest, const char*)
-storage_get_free_size True (sg_size_t) (name, const char*)
-storage_get_used_size True (sg_size_t) (name, const char*)
+file_move True (int) (fd, void*, smx_file_t) (fullpath, const char*)
+storage_get_free_size True (sg_size_t) (storage, void*, smx_storage_t)
+storage_get_used_size True (sg_size_t) (name, void*, smx_storage_t)
 storage_get_properties True (void*, xbt_dict_t) (storage, void*, smx_storage_t)
 storage_get_content True (void*, xbt_dict_t) (storage, void*, smx_storage_t)
 asr_get_properties True (void*, xbt_dict_t) (name, const char*)
index 052c837..f73e443 100644 (file)
@@ -1064,6 +1064,12 @@ static inline sg_size_t simcall_file_read__get__size(smx_simcall_t simcall){
 static inline void simcall_file_read__set__size(smx_simcall_t simcall, sg_size_t arg){
     simcall->args[1].sgsz = arg;
 }
+static inline smx_host_t simcall_file_read__get__host(smx_simcall_t simcall){
+  return (smx_host_t) simcall->args[2].dp;
+}
+static inline void simcall_file_read__set__host(smx_simcall_t simcall, void* arg){
+    simcall->args[2].dp = arg;
+}
 static inline smx_file_t simcall_file_write__get__fd(smx_simcall_t simcall){
   return (smx_file_t) simcall->args[0].dp;
 }
@@ -1076,17 +1082,23 @@ static inline sg_size_t simcall_file_write__get__size(smx_simcall_t simcall){
 static inline void simcall_file_write__set__size(smx_simcall_t simcall, sg_size_t arg){
     simcall->args[1].sgsz = arg;
 }
-static inline const char* simcall_file_open__get__mount(smx_simcall_t simcall){
+static inline smx_host_t simcall_file_write__get__host(smx_simcall_t simcall){
+  return (smx_host_t) simcall->args[2].dp;
+}
+static inline void simcall_file_write__set__host(smx_simcall_t simcall, void* arg){
+    simcall->args[2].dp = arg;
+}
+static inline const char* simcall_file_open__get__fullpath(smx_simcall_t simcall){
   return  simcall->args[0].cc;
 }
-static inline void simcall_file_open__set__mount(smx_simcall_t simcall, const char* arg){
+static inline void simcall_file_open__set__fullpath(smx_simcall_t simcall, const char* arg){
     simcall->args[0].cc = arg;
 }
-static inline const char* simcall_file_open__get__path(smx_simcall_t simcall){
-  return  simcall->args[1].cc;
+static inline smx_host_t simcall_file_open__get__host(smx_simcall_t simcall){
+  return (smx_host_t) simcall->args[1].dp;
 }
-static inline void simcall_file_open__set__path(smx_simcall_t simcall, const char* arg){
-    simcall->args[1].cc = arg;
+static inline void simcall_file_open__set__host(smx_simcall_t simcall, void* arg){
+    simcall->args[1].dp = arg;
 }
 static inline smx_file_t simcall_file_close__get__fd(smx_simcall_t simcall){
   return (smx_file_t) simcall->args[0].dp;
@@ -1094,24 +1106,18 @@ static inline smx_file_t simcall_file_close__get__fd(smx_simcall_t simcall){
 static inline void simcall_file_close__set__fd(smx_simcall_t simcall, void* arg){
     simcall->args[0].dp = arg;
 }
+static inline smx_host_t simcall_file_close__get__host(smx_simcall_t simcall){
+  return (smx_host_t) simcall->args[1].dp;
+}
+static inline void simcall_file_close__set__host(smx_simcall_t simcall, void* arg){
+    simcall->args[1].dp = arg;
+}
 static inline smx_file_t simcall_file_unlink__get__fd(smx_simcall_t simcall){
   return (smx_file_t) simcall->args[0].dp;
 }
 static inline void simcall_file_unlink__set__fd(smx_simcall_t simcall, void* arg){
     simcall->args[0].dp = arg;
 }
-static inline const char* simcall_file_ls__get__mount(smx_simcall_t simcall){
-  return  simcall->args[0].cc;
-}
-static inline void simcall_file_ls__set__mount(smx_simcall_t simcall, const char* arg){
-    simcall->args[0].cc = arg;
-}
-static inline const char* simcall_file_ls__get__path(smx_simcall_t simcall){
-  return  simcall->args[1].cc;
-}
-static inline void simcall_file_ls__set__path(smx_simcall_t simcall, const char* arg){
-    simcall->args[1].cc = arg;
-}
 static inline smx_file_t simcall_file_get_size__get__fd(smx_simcall_t simcall){
   return (smx_file_t) simcall->args[0].dp;
 }
@@ -1148,35 +1154,29 @@ static inline smx_file_t simcall_file_get_info__get__fd(smx_simcall_t simcall){
 static inline void simcall_file_get_info__set__fd(smx_simcall_t simcall, void* arg){
     simcall->args[0].dp = arg;
 }
-static inline smx_storage_t simcall_storage_file_rename__get__storage(smx_simcall_t simcall){
-  return (smx_storage_t) simcall->args[0].dp;
+static inline smx_file_t simcall_file_move__get__fd(smx_simcall_t simcall){
+  return (smx_file_t) simcall->args[0].dp;
 }
-static inline void simcall_storage_file_rename__set__storage(smx_simcall_t simcall, void* arg){
+static inline void simcall_file_move__set__fd(smx_simcall_t simcall, void* arg){
     simcall->args[0].dp = arg;
 }
-static inline const char* simcall_storage_file_rename__get__src(smx_simcall_t simcall){
+static inline const char* simcall_file_move__get__fullpath(smx_simcall_t simcall){
   return  simcall->args[1].cc;
 }
-static inline void simcall_storage_file_rename__set__src(smx_simcall_t simcall, const char* arg){
+static inline void simcall_file_move__set__fullpath(smx_simcall_t simcall, const char* arg){
     simcall->args[1].cc = arg;
 }
-static inline const char* simcall_storage_file_rename__get__dest(smx_simcall_t simcall){
-  return  simcall->args[2].cc;
-}
-static inline void simcall_storage_file_rename__set__dest(smx_simcall_t simcall, const char* arg){
-    simcall->args[2].cc = arg;
-}
-static inline const char* simcall_storage_get_free_size__get__name(smx_simcall_t simcall){
-  return  simcall->args[0].cc;
+static inline smx_storage_t simcall_storage_get_free_size__get__storage(smx_simcall_t simcall){
+  return (smx_storage_t) simcall->args[0].dp;
 }
-static inline void simcall_storage_get_free_size__set__name(smx_simcall_t simcall, const char* arg){
-    simcall->args[0].cc = arg;
+static inline void simcall_storage_get_free_size__set__storage(smx_simcall_t simcall, void* arg){
+    simcall->args[0].dp = arg;
 }
-static inline const char* simcall_storage_get_used_size__get__name(smx_simcall_t simcall){
-  return  simcall->args[0].cc;
+static inline smx_storage_t simcall_storage_get_used_size__get__name(smx_simcall_t simcall){
+  return (smx_storage_t) simcall->args[0].dp;
 }
-static inline void simcall_storage_get_used_size__set__name(smx_simcall_t simcall, const char* arg){
-    simcall->args[0].cc = arg;
+static inline void simcall_storage_get_used_size__set__name(smx_simcall_t simcall, void* arg){
+    simcall->args[0].dp = arg;
 }
 static inline smx_storage_t simcall_storage_get_properties__get__storage(smx_simcall_t simcall){
   return (smx_storage_t) simcall->args[0].dp;
index 8b98b8e..2674738 100644 (file)
     }    
     return self->simcall.result.i;
   }
-  inline static sg_size_t simcall_BODY_file_read(smx_file_t fd, sg_size_t size) {
+  inline static sg_size_t simcall_BODY_file_read(smx_file_t fd, sg_size_t size, smx_host_t host) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_FILE_READ;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
     self->simcall.args[0].dp = (void*) fd;
     self->simcall.args[1].sgsz = (sg_size_t) size;
+    self->simcall.args[2].dp = (void*) host;
     if (self != simix_global->maestro_process) {
       XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
     }    
     return self->simcall.result.sgsz;
   }
-  inline static sg_size_t simcall_BODY_file_write(smx_file_t fd, sg_size_t size) {
+  inline static sg_size_t simcall_BODY_file_write(smx_file_t fd, sg_size_t size, smx_host_t host) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_FILE_WRITE;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
     self->simcall.args[0].dp = (void*) fd;
     self->simcall.args[1].sgsz = (sg_size_t) size;
+    self->simcall.args[2].dp = (void*) host;
     if (self != simix_global->maestro_process) {
       XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
     }    
     return self->simcall.result.sgsz;
   }
-  inline static smx_file_t simcall_BODY_file_open(const char* mount, const char* path) {
+  inline static smx_file_t simcall_BODY_file_open(const char* fullpath, smx_host_t host) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_FILE_OPEN;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].cc = (const char*) mount;
-    self->simcall.args[1].cc = (const char*) path;
+    self->simcall.args[0].cc = (const char*) fullpath;
+    self->simcall.args[1].dp = (void*) host;
     if (self != simix_global->maestro_process) {
       XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
     }    
     return self->simcall.result.dp;
   }
-  inline static int simcall_BODY_file_close(smx_file_t fd) {
+  inline static int simcall_BODY_file_close(smx_file_t fd, smx_host_t host) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_FILE_CLOSE;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
     self->simcall.args[0].dp = (void*) fd;
+    self->simcall.args[1].dp = (void*) host;
     if (self != simix_global->maestro_process) {
       XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
     }    
     return self->simcall.result.i;
   }
-  inline static xbt_dict_t simcall_BODY_file_ls(const char* mount, const char* path) {
-    smx_process_t self = SIMIX_process_self();
-    self->simcall.call = SIMCALL_FILE_LS;
-    memset(&self->simcall.result, 0, sizeof(self->simcall.result));
-    memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].cc = (const char*) mount;
-    self->simcall.args[1].cc = (const char*) path;
-    if (self != simix_global->maestro_process) {
-      XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
-                SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
-      SIMIX_process_yield(self);
-    } else {
-      SIMIX_simcall_pre(&self->simcall, 0);
-    }    
-    return self->simcall.result.dp;
-  }
   inline static sg_size_t simcall_BODY_file_get_size(smx_file_t fd) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_FILE_GET_SIZE;
     }    
     return self->simcall.result.dp;
   }
-  inline static void simcall_BODY_storage_file_rename(smx_storage_t storage, const char* src, const char* dest) {
+  inline static int simcall_BODY_file_move(smx_file_t fd, const char* fullpath) {
     smx_process_t self = SIMIX_process_self();
-    self->simcall.call = SIMCALL_STORAGE_FILE_RENAME;
+    self->simcall.call = SIMCALL_FILE_MOVE;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].dp = (void*) storage;
-    self->simcall.args[1].cc = (const char*) src;
-    self->simcall.args[2].cc = (const char*) dest;
+    self->simcall.args[0].dp = (void*) fd;
+    self->simcall.args[1].cc = (const char*) fullpath;
     if (self != simix_global->maestro_process) {
       XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
     } else {
       SIMIX_simcall_pre(&self->simcall, 0);
     }    
-    
+    return self->simcall.result.i;
   }
-  inline static sg_size_t simcall_BODY_storage_get_free_size(const char* name) {
+  inline static sg_size_t simcall_BODY_storage_get_free_size(smx_storage_t storage) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_STORAGE_GET_FREE_SIZE;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].cc = (const char*) name;
+    self->simcall.args[0].dp = (void*) storage;
     if (self != simix_global->maestro_process) {
       XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
     }    
     return self->simcall.result.sgsz;
   }
-  inline static sg_size_t simcall_BODY_storage_get_used_size(const char* name) {
+  inline static sg_size_t simcall_BODY_storage_get_used_size(smx_storage_t name) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_STORAGE_GET_USED_SIZE;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].cc = (const char*) name;
+    self->simcall.args[0].dp = (void*) name;
     if (self != simix_global->maestro_process) {
       XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
index aa0946a..e7ebf72 100644 (file)
@@ -502,19 +502,19 @@ case SIMCALL_SEM_GET_CAPACITY:
       break;  
 
 case SIMCALL_FILE_READ:
-       SIMIX_pre_file_read(simcall , (smx_file_t) simcall->args[0].dp,  simcall->args[1].sgsz);
+       SIMIX_pre_file_read(simcall , (smx_file_t) simcall->args[0].dp,  simcall->args[1].sgsz, (smx_host_t) simcall->args[2].dp);
        break;  
 
 case SIMCALL_FILE_WRITE:
-       SIMIX_pre_file_write(simcall , (smx_file_t) simcall->args[0].dp,  simcall->args[1].sgsz);
+       SIMIX_pre_file_write(simcall , (smx_file_t) simcall->args[0].dp,  simcall->args[1].sgsz, (smx_host_t) simcall->args[2].dp);
        break;  
 
 case SIMCALL_FILE_OPEN:
-       SIMIX_pre_file_open(simcall ,  simcall->args[0].cc,  simcall->args[1].cc);
+       SIMIX_pre_file_open(simcall ,  simcall->args[0].cc, (smx_host_t) simcall->args[1].dp);
        break;  
 
 case SIMCALL_FILE_CLOSE:
-       SIMIX_pre_file_close(simcall , (smx_file_t) simcall->args[0].dp);
+       SIMIX_pre_file_close(simcall , (smx_file_t) simcall->args[0].dp, (smx_host_t) simcall->args[1].dp);
        break;  
 
 case SIMCALL_FILE_UNLINK:
@@ -522,10 +522,6 @@ case SIMCALL_FILE_UNLINK:
       SIMIX_simcall_answer(simcall);
       break;  
 
-case SIMCALL_FILE_LS:
-       SIMIX_pre_file_ls(simcall ,  simcall->args[0].cc,  simcall->args[1].cc);
-       break;  
-
 case SIMCALL_FILE_GET_SIZE:
       simcall->result.sgsz = SIMIX_pre_file_get_size(simcall , (smx_file_t) simcall->args[0].dp);
       SIMIX_simcall_answer(simcall);
@@ -546,18 +542,18 @@ case SIMCALL_FILE_GET_INFO:
       SIMIX_simcall_answer(simcall);
       break;  
 
-case SIMCALL_STORAGE_FILE_RENAME:
-       SIMIX_pre_storage_file_rename(simcall , (smx_storage_t) simcall->args[0].dp,  simcall->args[1].cc,  simcall->args[2].cc);
+case SIMCALL_FILE_MOVE:
+      simcall->result.i = SIMIX_pre_file_move(simcall , (smx_file_t) simcall->args[0].dp,  simcall->args[1].cc);
       SIMIX_simcall_answer(simcall);
       break;  
 
 case SIMCALL_STORAGE_GET_FREE_SIZE:
-      simcall->result.sgsz = SIMIX_pre_storage_get_free_size(simcall ,  simcall->args[0].cc);
+      simcall->result.sgsz = SIMIX_pre_storage_get_free_size(simcall , (smx_storage_t) simcall->args[0].dp);
       SIMIX_simcall_answer(simcall);
       break;  
 
 case SIMCALL_STORAGE_GET_USED_SIZE:
-      simcall->result.sgsz = SIMIX_pre_storage_get_used_size(simcall ,  simcall->args[0].cc);
+      simcall->result.sgsz = SIMIX_pre_storage_get_used_size(simcall , (smx_storage_t) simcall->args[0].dp);
       SIMIX_simcall_answer(simcall);
       break;  
 
index f3a064e..5337849 100644 (file)
@@ -112,12 +112,11 @@ SIMCALL_FILE_WRITE,
 SIMCALL_FILE_OPEN,
 SIMCALL_FILE_CLOSE,
 SIMCALL_FILE_UNLINK,
-SIMCALL_FILE_LS,
 SIMCALL_FILE_GET_SIZE,
 SIMCALL_FILE_TELL,
 SIMCALL_FILE_SEEK,
 SIMCALL_FILE_GET_INFO,
-SIMCALL_STORAGE_FILE_RENAME,
+SIMCALL_FILE_MOVE,
 SIMCALL_STORAGE_GET_FREE_SIZE,
 SIMCALL_STORAGE_GET_USED_SIZE,
 SIMCALL_STORAGE_GET_PROPERTIES,
index bcee194..defe198 100644 (file)
@@ -455,12 +455,6 @@ static inline int simcall_file_unlink__get__result(smx_simcall_t simcall){
 static inline void simcall_file_unlink__set__result(smx_simcall_t simcall, int result){
     simcall->result.i = result;
 }
-static inline xbt_dict_t simcall_file_ls__get__result(smx_simcall_t simcall){
-  return (xbt_dict_t) simcall->result.dp;
-}
-static inline void simcall_file_ls__set__result(smx_simcall_t simcall, void* result){
-    simcall->result.dp = result;
-}
 static inline sg_size_t simcall_file_get_size__get__result(smx_simcall_t simcall){
   return  simcall->result.sgsz;
 }
@@ -485,8 +479,12 @@ static inline xbt_dynar_t simcall_file_get_info__get__result(smx_simcall_t simca
 static inline void simcall_file_get_info__set__result(smx_simcall_t simcall, void* result){
     simcall->result.dp = result;
 }
-
-
+static inline int simcall_file_move__get__result(smx_simcall_t simcall){
+  return  simcall->result.i;
+}
+static inline void simcall_file_move__set__result(smx_simcall_t simcall, int result){
+    simcall->result.i = result;
+}
 static inline sg_size_t simcall_storage_get_free_size__get__result(smx_simcall_t simcall){
   return  simcall->result.sgsz;
 }
index ed629fa..d409da2 100644 (file)
 [SIMCALL_FILE_OPEN] = "SIMCALL_FILE_OPEN",
 [SIMCALL_FILE_CLOSE] = "SIMCALL_FILE_CLOSE",
 [SIMCALL_FILE_UNLINK] = "SIMCALL_FILE_UNLINK",
-[SIMCALL_FILE_LS] = "SIMCALL_FILE_LS",
 [SIMCALL_FILE_GET_SIZE] = "SIMCALL_FILE_GET_SIZE",
 [SIMCALL_FILE_TELL] = "SIMCALL_FILE_TELL",
 [SIMCALL_FILE_SEEK] = "SIMCALL_FILE_SEEK",
 [SIMCALL_FILE_GET_INFO] = "SIMCALL_FILE_GET_INFO",
-[SIMCALL_STORAGE_FILE_RENAME] = "SIMCALL_STORAGE_FILE_RENAME",
+[SIMCALL_FILE_MOVE] = "SIMCALL_FILE_MOVE",
 [SIMCALL_STORAGE_GET_FREE_SIZE] = "SIMCALL_STORAGE_GET_FREE_SIZE",
 [SIMCALL_STORAGE_GET_USED_SIZE] = "SIMCALL_STORAGE_GET_USED_SIZE",
 [SIMCALL_STORAGE_GET_PROPERTIES] = "SIMCALL_STORAGE_GET_PROPERTIES",
index 12552da..f222f62 100644 (file)
 #include "smx_private.h"
 #include "simgrid/sg_config.h"
 #include "internal_config.h"
+#include "simgrid/modelchecker.h"
+
+
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <sys/mman.h>
+#endif
+
+#ifdef __MINGW32__ 
+#define _aligned_malloc __mingw_aligned_malloc 
+#define _aligned_free  __mingw_aligned_free 
+#endif //MINGW
+
+
+
+#ifdef HAVE_VALGRIND_VALGRIND_H
+# include <valgrind/valgrind.h>
+#endif
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_context, simix,
                                 "Context switching mechanism");
@@ -21,6 +40,8 @@ char* smx_context_factory_name = NULL; /* factory name specified by --cfg=contex
 smx_ctx_factory_initializer_t smx_factory_initializer_to_use = NULL;
 int smx_context_stack_size;
 int smx_context_stack_size_was_set = 0;
+int smx_context_guard_size;
+int smx_context_guard_size_was_set = 0;
 #ifdef HAVE_THREAD_LOCAL_STORAGE
 static __thread smx_context_t smx_current_context_parallel;
 #else
@@ -101,11 +122,85 @@ void SIMIX_context_mod_exit(void)
 
 void *SIMIX_context_stack_new(void)
 {
-  return xbt_malloc0(smx_context_stack_size);
+  void *stack;
+
+  /* FIXME: current code for stack overflow protection assumes that stacks are
+   * growing downward (PTH_STACKGROWTH == -1).  Protected pages need to be put
+   * after the stack when PTH_STACKGROWTH == 1. */
+
+  if (smx_context_guard_size > 0 && !MC_is_active()) {
+
+#if defined(_XBT_WIN32) || (PTH_STACKGROWTH != -1)
+    static int warned_once = 0;
+    if (!warned_once) {
+      XBT_WARN("Stack overflow protection is known to be broken on your system.  Either you're on Windows or PTH_STACKGROWTH != -1 (current value is %d).",
+               PTH_STACKGROWTH);
+      warned_once = 1;
+    }
+#endif
+
+    size_t size = smx_context_stack_size + smx_context_guard_size;
+#ifdef HAVE_MC
+    /* Cannot use posix_memalign when HAVE_MC. Align stack by hand, and save the
+     * pointer returned by xbt_malloc0. */
+    char *alloc = xbt_malloc0(size + xbt_pagesize);
+    stack = alloc - ((uintptr_t)alloc & (xbt_pagesize - 1)) + xbt_pagesize;
+    *((void **)stack - 1) = alloc;
+#elif !defined(_XBT_WIN32)
+    if (posix_memalign(&stack, xbt_pagesize, size) != 0)
+      xbt_die("Failed to allocate stack.");
+#else
+    stack = _aligned_malloc(size, xbt_pagesize);
+#endif
+
+#ifndef _XBT_WIN32
+    if (mprotect(stack, smx_context_guard_size, PROT_NONE) == -1) {
+      XBT_WARN("Failed to protect stack: %s", strerror(errno));
+      /* That's not fatal, pursue anyway. */
+    }
+#endif
+    stack = (char *)stack + smx_context_guard_size;
+  } else {
+    stack = xbt_malloc0(smx_context_stack_size);
+  }
+
+#ifdef HAVE_VALGRIND_VALGRIND_H
+  unsigned int valgrind_stack_id =
+    VALGRIND_STACK_REGISTER(stack, (char *)stack + smx_context_stack_size);
+  memcpy((char *)stack + smx_context_usable_stack_size, &valgrind_stack_id,
+         sizeof valgrind_stack_id);
+#endif
+
+  return stack;
 }
 
 void SIMIX_context_stack_delete(void *stack)
 {
+  if (!stack)
+    return;
+
+#ifdef HAVE_VALGRIND_VALGRIND_H
+  unsigned int valgrind_stack_id;
+  memcpy(&valgrind_stack_id, (char *)stack + smx_context_usable_stack_size,
+         sizeof valgrind_stack_id);
+  VALGRIND_STACK_DEREGISTER(valgrind_stack_id);
+#endif
+
+#ifndef WIN32
+  if (smx_context_guard_size > 0 && !MC_is_active()) {
+    stack = (char *)stack - smx_context_guard_size;
+    if (mprotect(stack, smx_context_guard_size,
+                 PROT_READ | PROT_WRITE | PROT_EXEC) == -1) {
+      XBT_WARN("Failed to remove page protection: %s", strerror(errno));
+      /* try to pursue anyway */
+    }
+#ifdef HAVE_MC
+    /* Retrieve the saved pointer.  See SIMIX_context_stack_new above. */
+    stack = *((void **)stack - 1);
+#endif
+  }
+#endif
+
   xbt_free(stack);
 }
 
index df733cd..37e0763 100644 (file)
 #include "xbt/parmap.h"
 #include "mc/mc.h"
 
-#ifdef HAVE_VALGRIND_VALGRIND_H
-#  include <valgrind/valgrind.h>
-#endif                          /* HAVE_VALGRIND_VALGRIND_H */
-
 typedef char * raw_stack_t;
 typedef void (*rawctx_entry_point_t)(void *);
 
@@ -21,9 +17,6 @@ typedef struct s_smx_ctx_raw {
   s_smx_ctx_base_t super;         /* Fields of super implementation */
   char *malloced_stack;           /* malloced area containing the stack */
   raw_stack_t stack_top;          /* pointer to stack top (within previous area) */
-#ifdef HAVE_VALGRIND_VALGRIND_H
-  unsigned int valgrind_stack_id; /* the valgrind stack id */
-#endif
 #ifdef TIME_BENCH_PER_SR
   unsigned int thread;            /* Just for measuring purposes */
 #endif
@@ -62,6 +55,7 @@ __asm__ (
 #endif
    "   mov %rdi,%rax\n"      /* stack */
    "   add %rsi,%rax\n"      /* size  */
+   "   andq $-16, %rax\n"    /* align stack */
    "   movq $0,   -8(%rax)\n" /* @return for func */
    "   mov %rdx,-16(%rax)\n" /* func */
    "   mov %rcx,-24(%rax)\n" /* arg/rdi */
@@ -137,6 +131,7 @@ __asm__ (
 #endif
    "   movl 4(%esp),%eax\n"   /* stack */
    "   addl 8(%esp),%eax\n"   /* size  */
+   "   andl $-16, %eax\n"     /* align stack */
    "   movl 12(%esp),%ecx\n"  /* func  */
    "   movl 16(%esp),%edx\n"  /* arg   */
    "   movl %edx, -4(%eax)\n"
@@ -318,14 +313,9 @@ smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv,
      if (code) {
        context->malloced_stack = SIMIX_context_stack_new();
        context->stack_top =
-           raw_makecontext(context->malloced_stack, smx_context_stack_size,
-               (void_f_pvoid_t) smx_ctx_raw_wrapper, context);
-
-#ifdef HAVE_VALGRIND_VALGRIND_H
-       context->valgrind_stack_id =
-           VALGRIND_STACK_REGISTER(context->malloced_stack,
-               context->malloced_stack + smx_context_stack_size);
-#endif                          /* HAVE_VALGRIND_VALGRIND_H */
+           raw_makecontext(context->malloced_stack,
+                           smx_context_usable_stack_size,
+                           (void_f_pvoid_t)smx_ctx_raw_wrapper, context);
 
      } else {
        if(process != NULL && raw_maestro_context==NULL)
@@ -346,14 +336,7 @@ smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv,
 static void smx_ctx_raw_free(smx_context_t context)
 {
   if (context) {
-
-#ifdef HAVE_VALGRIND_VALGRIND_H
-    VALGRIND_STACK_DEREGISTER(((smx_ctx_raw_t)
-        context)->valgrind_stack_id);
-#endif                          /* HAVE_VALGRIND_VALGRIND_H */
-
     SIMIX_context_stack_delete(((smx_ctx_raw_t) context)->malloced_stack);
-
   }
   smx_ctx_base_free(context);
 }
index 7b5e292..cb5b022 100644 (file)
 #include "mc/mc.h"
 
 #ifdef _XBT_WIN32
-#  include <win32_ucontext.h>     /* context relative declarations */
+#  include <xbt/win32_ucontext.h>     /* context relative declarations */
 #else
 #  include <ucontext.h>           /* context relative declarations */
 #endif
 
-#ifdef HAVE_VALGRIND_VALGRIND_H
-#  include <valgrind/valgrind.h>
-#endif                          /* HAVE_VALGRIND_VALGRIND_H */
-
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
 
 typedef struct s_smx_ctx_sysv {
   s_smx_ctx_base_t super;       /* Fields of super implementation */
   ucontext_t uc;                /* the ucontext that executes the code */
-#ifdef HAVE_VALGRIND_VALGRIND_H
-  unsigned int valgrind_stack_id;       /* the valgrind stack id */
-#endif
   char *stack;                  /* the thread stack */
 } s_smx_ctx_sysv_t, *smx_ctx_sysv_t;
 
@@ -46,12 +39,6 @@ static unsigned long sysv_process_index = 0;   /* index of the next process to r
 static smx_ctx_sysv_t sysv_maestro_context;
 
 static int smx_ctx_sysv_factory_finalize(smx_context_factory_t *factory);
-static smx_context_t
-smx_ctx_sysv_create_context_sized(size_t structure_size,
-                                  xbt_main_func_t code, int argc,
-                                  char **argv,
-                                  void_pfn_smxprocess_t cleanup_func,
-                                  smx_process_t process);
 static void smx_ctx_sysv_free(smx_context_t context);
 static smx_context_t
 smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
@@ -117,19 +104,19 @@ static int smx_ctx_sysv_factory_finalize(smx_context_factory_t *factory)
 }
 
 static smx_context_t
-smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code,
-                                  int argc, char **argv,
-                                  void_pfn_smxprocess_t cleanup_func,
-                                  smx_process_t process)
+smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
+                            void_pfn_smxprocess_t cleanup_func,
+                            smx_process_t process)
 {
   int ctx_addr[CTX_ADDR_LEN];
   smx_ctx_sysv_t context =
-      (smx_ctx_sysv_t) smx_ctx_base_factory_create_context_sized(size,
-                                                                 code,
-                                                                 argc,
-                                                                 argv,
-                                                                 cleanup_func,
-                                                                 process);
+    (smx_ctx_sysv_t) smx_ctx_base_factory_create_context_sized(
+      sizeof(s_smx_ctx_sysv_t),
+      code,
+      argc,
+      argv,
+      cleanup_func,
+      process);
 
   /* if the user provided a function for the process then use it,
      otherwise it is the context for maestro */
@@ -141,17 +128,11 @@ smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code,
     context->uc.uc_link = NULL;
 
     context->uc.uc_stack.ss_sp =
-        pth_skaddr_makecontext(context->stack, smx_context_stack_size);
+        pth_skaddr_makecontext(context->stack, smx_context_usable_stack_size);
 
     context->uc.uc_stack.ss_size =
-        pth_sksize_makecontext(context->stack, smx_context_stack_size);
-
-#ifdef HAVE_VALGRIND_VALGRIND_H
-    context->valgrind_stack_id =
-        VALGRIND_STACK_REGISTER(context->uc.uc_stack.ss_sp,
-                                ((char *) context->uc.uc_stack.ss_sp) +
-                                context->uc.uc_stack.ss_size);
-#endif                          /* HAVE_VALGRIND_VALGRIND_H */
+        pth_sksize_makecontext(context->stack, smx_context_usable_stack_size);
+
     memcpy(ctx_addr, &context, sizeof(smx_ctx_sysv_t));
     switch (CTX_ADDR_LEN) {
     case 1:
@@ -172,33 +153,16 @@ smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code,
   }
 
   if(MC_is_active() && code)
-    MC_new_stack_area(context, ((smx_context_t)context)->process->name,
-                      &(context->uc), size);
+    MC_new_stack_area(context->stack, ((smx_context_t)context)->process->name,
+                      &(context->uc), smx_context_usable_stack_size);
 
   return (smx_context_t) context;
 }
 
-static smx_context_t
-smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
-                            void_pfn_smxprocess_t cleanup_func,
-                            smx_process_t process)
-{
-
-  return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t),
-                                           code, argc, argv, cleanup_func,
-                                           process);
-
-}
-
 static void smx_ctx_sysv_free(smx_context_t context)
 {
 
   if (context) {
-
-#ifdef HAVE_VALGRIND_VALGRIND_H
-    VALGRIND_STACK_DEREGISTER(((smx_ctx_sysv_t)
-                               context)->valgrind_stack_id);
-#endif                          /* HAVE_VALGRIND_VALGRIND_H */
     SIMIX_context_stack_delete(((smx_ctx_sysv_t)context)->stack);
   }
   smx_ctx_base_free(context);
index ea06db0..fbde818 100644 (file)
@@ -94,6 +94,8 @@ smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc,
     context->end = xbt_os_sem_init(0);
     if (smx_context_stack_size_was_set)
       xbt_os_thread_setstacksize(smx_context_stack_size);
+    if (smx_context_guard_size_was_set)
+      xbt_os_thread_setguardsize(smx_context_guard_size);
 
     /* create and start the process */
     /* NOTE: The first argument to xbt_os_thread_create used to be the process *
@@ -150,7 +152,14 @@ static void smx_ctx_thread_stop(smx_context_t pcontext)
 static void *smx_ctx_thread_wrapper(void *param)
 {
   smx_ctx_thread_t context = (smx_ctx_thread_t) param;
-
+#ifndef WIN32
+  /* Install alternate signal stack, for SIGSEGV handler. */
+  stack_t stack;
+  stack.ss_sp = sigsegv_stack;
+  stack.ss_size = sizeof sigsegv_stack;
+  stack.ss_flags = 0;
+  sigaltstack(&stack, NULL);
+#endif
   /* Tell the maestro we are starting, and wait for its green light */
   xbt_os_sem_release(context->end);
   xbt_os_sem_acquire(context->begin);
index 213b41b..fffa264 100644 (file)
@@ -24,8 +24,6 @@ static void* SIMIX_action_mallocator_new_f(void);
 static void SIMIX_action_mallocator_free_f(void* action);
 static void SIMIX_action_mallocator_reset_f(void* action);
 
-static void SIMIX_clean(void);
-
 /* FIXME: Yeah, I'll do it in a portable maner one day [Mt] */
 #include <signal.h>
 
@@ -42,6 +40,71 @@ static void _XBT_CALL inthandler(int ignored)
   exit(1);
 }
 
+#ifndef WIN32
+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.\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)) {
+      fprintf(stderr,
+              "siginfo = {si_signo = %d, si_errno = %d, si_code = %d, si_addr = %p}\n",
+              siginfo->si_signo, siginfo->si_errno, siginfo->si_code, siginfo->si_addr);
+    }
+  }
+  raise(signum);
+}
+
+char sigsegv_stack[SIGSTKSZ];   /* alternate stack for SIGSEGV handler */
+
+/**
+ * Install signal handler for SIGSEGV.  Check that nobody has already installed
+ * its own handler.  For example, the Java VM does this.
+ */
+static void install_segvhandler(void)
+{
+  stack_t stack, old_stack;
+  stack.ss_sp = sigsegv_stack;
+  stack.ss_size = sizeof sigsegv_stack;
+  stack.ss_flags = 0;
+
+  if (sigaltstack(&stack, &old_stack) == -1) {
+    XBT_WARN("Failed to register alternate signal stack: %s",
+             strerror(errno));
+    return;
+  }
+  if (!(old_stack.ss_flags & SS_DISABLE)) {
+    XBT_DEBUG("An alternate stack was already installed (sp=%p, size=%zd, flags=%x). Restore it.",
+              old_stack.ss_sp, old_stack.ss_size, old_stack.ss_flags);
+    sigaltstack(&old_stack, NULL);
+  }
+
+  struct sigaction action, old_action;
+  action.sa_sigaction = segvhandler;
+  action.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
+  sigemptyset(&action.sa_mask);
+
+  if (sigaction(SIGSEGV, &action, &old_action) == -1) {
+    XBT_WARN("Failed to register signal handler for SIGSEGV: %s",
+             strerror(errno));
+    return;
+  }
+  if ((old_action.sa_flags & SA_SIGINFO) || old_action.sa_handler != SIG_DFL) {
+    XBT_DEBUG("A signal handler was already installed for SIGSEGV (%p). Restore it.",
+             (old_action.sa_flags & SA_SIGINFO) ?
+             (void*)old_action.sa_sigaction : (void*)old_action.sa_handler);
+    sigaction(SIGSEGV, &old_action, NULL);
+  }
+}
+
+#endif
 /********************************* SIMIX **************************************/
 
 XBT_INLINE double SIMIX_timer_next(void)
@@ -99,6 +162,10 @@ void SIMIX_global_init(int *argc, char **argv)
     /* Prepare to display some more info when dying on Ctrl-C pressing */
     signal(SIGINT, inthandler);
 
+#ifndef WIN32
+    /* Install SEGV handler */
+    install_segvhandler();
+#endif
     /* register a function to be called by SURF after the environment creation */
     sg_platf_init();
     sg_platf_postparse_add_cb(SIMIX_post_create_environment);
@@ -124,12 +191,14 @@ void SIMIX_global_init(int *argc, char **argv)
  *
  * This functions remove the memory used by SIMIX
  */
-static void SIMIX_clean(void)
+void SIMIX_clean(void)
 {
+  static int cleaned = 0;
 #ifdef TIME_BENCH_PER_SR
   smx_ctx_raw_new_sr();
 #endif
-
+  if (cleaned) return; // to avoid double cleaning by java and C
+  cleaned = 1;
   /* Kill everyone (except maestro) */
   SIMIX_process_killall(simix_global->maestro_process, 1);
 
@@ -317,7 +386,7 @@ void SIMIX_run(void)
     /* Handle any pending timer */
     while (xbt_heap_size(simix_timers) > 0 && SIMIX_get_clock() >= SIMIX_timer_next()) {
        //FIXME: make the timers being real callbacks
-       // (i.e. provide dispatchers that read and expand the args) 
+       // (i.e. provide dispatchers that read and expand the args)
        timer = xbt_heap_pop(simix_timers);
        if (timer->func)
          ((void (*)(void*))timer->func)(timer->args);
@@ -351,7 +420,7 @@ void SIMIX_run(void)
 
 
     XBT_DEBUG("### time %f, empty %d", time, xbt_dynar_is_empty(simix_global->process_to_run));
-    // !(time == -1.0 && xbt_dynar_is_empty()) 
+    // !(time == -1.0 && xbt_dynar_is_empty())
 
 
   } while (time != -1.0 || !xbt_dynar_is_empty(simix_global->process_to_run));
index eee26b2..cd48e0a 100644 (file)
@@ -50,17 +50,16 @@ void SIMIX_storage_destroy(void *s)
 }
 
 //SIMIX FILE READ
-void SIMIX_pre_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size)
+void SIMIX_pre_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, smx_host_t host)
 {
-  smx_action_t action = SIMIX_file_read(simcall->issuer, fd, size);
+  smx_action_t action = SIMIX_file_read(simcall->issuer, fd, size, host);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
 
-smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_size_t size)
+smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_size_t size, smx_host_t host)
 {
   smx_action_t action;
-  smx_host_t host = process->smx_host;
 
   /* check if the host is active */
   if (surf_resource_get_state(surf_workstation_resource_priv(host)) != SURF_RESOURCE_ON) {
@@ -85,17 +84,16 @@ smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_size_t siz
 }
 
 //SIMIX FILE WRITE
-void SIMIX_pre_file_write(smx_simcall_t simcall, smx_file_t fd, sg_size_t size)
+void SIMIX_pre_file_write(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, smx_host_t host)
 {
-  smx_action_t action = SIMIX_file_write(simcall->issuer, fd,  size);
+  smx_action_t action = SIMIX_file_write(simcall->issuer, fd,  size, host);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
 
-smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t size)
+smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t size, smx_host_t host)
 {
   smx_action_t action;
-  smx_host_t host = process->smx_host;
 
   /* check if the host is active */
   if (surf_resource_get_state(surf_workstation_resource_priv(host)) != SURF_RESOURCE_ON) {
@@ -120,19 +118,16 @@ smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t si
 }
 
 //SIMIX FILE OPEN
-void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
-                         const char* path)
+void SIMIX_pre_file_open(smx_simcall_t simcall, const char* fullpath, smx_host_t host)
 {
-  smx_action_t action = SIMIX_file_open(simcall->issuer, mount, path);
+  smx_action_t action = SIMIX_file_open(simcall->issuer, fullpath, host);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
 
-smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount,
-                             const char* path)
+smx_action_t SIMIX_file_open(smx_process_t process, const char* fullpath, smx_host_t host)
 {
   smx_action_t action;
-  smx_host_t host = process->smx_host;
 
   /* check if the host is active */
   if (surf_resource_get_state(surf_workstation_resource_priv(host)) != SURF_RESOURCE_ON) {
@@ -148,7 +143,7 @@ smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount,
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_open(host, mount, path);
+  action->io.surf_io = surf_workstation_open(host, fullpath);
 
   surf_action_set_data(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -157,17 +152,16 @@ smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount,
 }
 
 //SIMIX FILE CLOSE
-void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd)
+void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd, smx_host_t host)
 {
-  smx_action_t action = SIMIX_file_close(simcall->issuer, fd);
+  smx_action_t action = SIMIX_file_close(simcall->issuer, fd, host);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
 
-smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd)
+smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd, smx_host_t host)
 {
   smx_action_t action;
-  smx_host_t host = process->smx_host;
 
   /* check if the host is active */
   if (surf_resource_get_state(surf_workstation_resource_priv(host)) != SURF_RESOURCE_ON) {
@@ -207,44 +201,9 @@ int SIMIX_file_unlink(smx_process_t process, smx_file_t fd)
            sg_host_name(host));
   }
 
-  if (surf_workstation_unlink(host, fd->surf_file)){
-    xbt_free(fd);
-    return 1;
-  } else
-    return 0;
-}
-
-//SIMIX FILE LS
-void SIMIX_pre_file_ls(smx_simcall_t simcall,
-                       const char* mount, const char* path)
-{
-  smx_action_t action = SIMIX_file_ls(simcall->issuer, mount, path);
-  xbt_fifo_push(action->simcalls, simcall);
-  simcall->issuer->waiting_action = action;
-}
-smx_action_t SIMIX_file_ls(smx_process_t process, const char* mount, const char *path)
-{
-  smx_action_t action;
-  smx_host_t host = process->smx_host;
-  /* check if the host is active */
-  if (surf_resource_get_state(surf_workstation_resource_priv(host)) != SURF_RESOURCE_ON) {
-    THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           sg_host_name(host));
-  }
-
-  action = xbt_mallocator_get(simix_global->action_mallocator);
-  action->type = SIMIX_ACTION_IO;
-  action->name = NULL;
-#ifdef HAVE_TRACING
-  action->category = NULL;
-#endif
-
-  action->io.host = host;
-  action->io.surf_io = surf_workstation_ls(host,mount,path);
-
-  surf_action_set_data(action->io.surf_io, action);
-  XBT_DEBUG("Create io action %p", action);
-  return action;
+  int res = surf_workstation_unlink(host, fd->surf_file);
+  xbt_free(fd);
+  return !!res;
 }
 
 sg_size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd)
@@ -292,36 +251,40 @@ int SIMIX_file_seek(smx_process_t process, smx_file_t fd, sg_size_t offset, int
   return  surf_workstation_file_seek(host, fd->surf_file, offset, origin);
 }
 
-void SIMIX_pre_storage_file_rename(smx_simcall_t simcall, smx_storage_t storage, const char* src, const char* dest)
+int SIMIX_pre_file_move(smx_simcall_t simcall, smx_file_t file, const char* fullpath)
 {
-  return SIMIX_storage_file_rename(simcall->issuer, storage, src, dest);
+  return SIMIX_file_move(simcall->issuer, file, fullpath);
 }
 
-void SIMIX_storage_file_rename(smx_process_t process, smx_storage_t storage, const char* src, const char* dest)
+int SIMIX_file_move(smx_process_t process, smx_file_t file, const char* fullpath)
 {
-  return  surf_storage_rename(storage, src, dest);
+  smx_host_t host = process->smx_host;
+  return  surf_workstation_file_move(host, file->surf_file, fullpath);
+}
+
+sg_size_t SIMIX_storage_get_size(smx_storage_t storage){
+  xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)");
+  return surf_storage_get_size(storage);
 }
 
-sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, const char* name)
+sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, smx_storage_t storage)
 {
-  return SIMIX_storage_get_free_size(simcall->issuer, name);
+  return SIMIX_storage_get_free_size(simcall->issuer, storage);
 }
 
-sg_size_t SIMIX_storage_get_free_size(smx_process_t process, const char* name)
+sg_size_t SIMIX_storage_get_free_size(smx_process_t process, smx_storage_t storage)
 {
-  smx_host_t host = process->smx_host;
-  return  surf_workstation_get_free_size(host, name);
+  return  surf_storage_get_free_size(storage);
 }
 
-sg_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall, const char* name)
+sg_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall, smx_storage_t storage)
 {
-  return SIMIX_storage_get_used_size(simcall->issuer, name);
+  return SIMIX_storage_get_used_size(simcall->issuer, storage);
 }
 
-sg_size_t SIMIX_storage_get_used_size(smx_process_t process, const char* name)
+sg_size_t SIMIX_storage_get_used_size(smx_process_t process, smx_storage_t storage)
 {
-  smx_host_t host = process->smx_host;
-  return  surf_workstation_get_used_size(host, name);
+  return  surf_storage_get_used_size(storage);
 }
 
 xbt_dict_t SIMIX_pre_storage_get_properties(smx_simcall_t simcall, smx_storage_t storage){
@@ -350,11 +313,6 @@ xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage){
   return surf_storage_get_content(storage);
 }
 
-sg_size_t SIMIX_storage_get_size(smx_storage_t storage){
-  xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)");
-  return surf_storage_get_size(storage);
-}
-
 const char* SIMIX_pre_storage_get_host(smx_simcall_t simcall, smx_storage_t storage){
    return SIMIX_storage_get_host(storage);
 }
@@ -393,17 +351,6 @@ void SIMIX_post_io(smx_action_t action)
       simcall_file_read__set__result(simcall, surf_action_get_cost(action->io.surf_io));
       break;
 
-    case SIMCALL_FILE_LS:
-//      xbt_dict_foreach((action->io.surf_io)->ls_dict,cursor,key, src){
-//        // if there is a stat we have to duplicate it
-//        if(src){
-//          dst = xbt_new0(s_file_stat_t,1);
-//          file_stat_copy(src, dst);
-//          xbt_dict_set((action->io.surf_io)->ls_dict,key,dst,xbt_free);
-//        }
-//      }
-      simcall_file_ls__set__result(simcall, surf_storage_action_get_ls_dict(action->io.surf_io));
-      break;
     default:
       break;
     }
index ad7598d..8ddde55 100644 (file)
@@ -17,44 +17,37 @@ typedef struct s_smx_storage_priv {
 
 
 static inline smx_storage_priv_t SIMIX_storage_priv(smx_storage_t storage){
-  return xbt_lib_get_level(storage, SIMIX_STORAGE_LEVEL);
+  return (smx_storage_priv_t) xbt_lib_get_level(storage, SIMIX_STORAGE_LEVEL);
 }
 
 smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data);
 void SIMIX_storage_destroy(void *s);
-void SIMIX_pre_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size);
-void SIMIX_pre_file_write(smx_simcall_t simcall,smx_file_t fd, sg_size_t size);
-void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
-                        const char* path);
-void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd);
+void SIMIX_pre_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, smx_host_t host);
+void SIMIX_pre_file_write(smx_simcall_t simcall,smx_file_t fd, sg_size_t size, smx_host_t host);
+void SIMIX_pre_file_open(smx_simcall_t simcall, const char* fullpath, smx_host_t host);
+void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd, smx_host_t host);
 int SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd);
-void SIMIX_pre_file_ls(smx_simcall_t simcall,
-                       const char* mount, const char* path);
 sg_size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd);
 sg_size_t SIMIX_pre_file_tell(smx_simcall_t simcall, smx_file_t fd);
 xbt_dynar_t SIMIX_pre_file_get_info(smx_simcall_t simcall, smx_file_t fd);
 int SIMIX_pre_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_size_t offset, int origin);
-void SIMIX_pre_storage_file_rename(smx_simcall_t simcall,smx_storage_t storage, const char* src, const char* dest);
-
-smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_size_t size);
-smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t size);
-smx_action_t SIMIX_file_open(smx_process_t process, const char* storage,
-                             const char* path);
-smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd);
+int SIMIX_pre_file_move(smx_simcall_t simcall, smx_file_t fd, const char* fullpath);
+smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_size_t size, smx_host_t host);
+smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t size, smx_host_t host);
+smx_action_t SIMIX_file_open(smx_process_t process, const char* fullpath, smx_host_t host);
+smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd, smx_host_t host);
 int SIMIX_file_unlink(smx_process_t process, smx_file_t fd);
-smx_action_t SIMIX_file_ls(smx_process_t process, const char *mount,
-                           const char *path);
 sg_size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd);
 sg_size_t SIMIX_file_tell(smx_process_t process, smx_file_t fd);
 xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd);
 int SIMIX_file_seek(smx_process_t process, smx_file_t fd, sg_size_t offset, int origin);
+int SIMIX_file_move(smx_process_t process, smx_file_t fd, const char* fullpath);
 
-void SIMIX_storage_file_rename(smx_process_t process, smx_storage_t storage, const char* src, const char* dest);
-sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,const char* name);
-sg_size_t SIMIX_storage_get_free_size(smx_process_t process,const char* name);
+sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,smx_storage_t storage);
+sg_size_t SIMIX_storage_get_free_size(smx_process_t process,smx_storage_t storage);
 
-sg_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall,const char* name);
-sg_size_t SIMIX_storage_get_used_size(smx_process_t process,const char* name);
+sg_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall,smx_storage_t storage);
+sg_size_t SIMIX_storage_get_used_size(smx_process_t process,smx_storage_t storage);
 
 xbt_dict_t SIMIX_storage_get_properties(smx_storage_t storage);
 xbt_dict_t SIMIX_pre_storage_get_properties(smx_simcall_t, smx_storage_t);
index fc3f4b8..b6c5e60 100644 (file)
@@ -31,8 +31,6 @@ static void SIMIX_comm_start(smx_action_t action);
 void SIMIX_network_init(void)
 {
   rdv_points = xbt_dict_new_homogeneous(SIMIX_rdv_free);
-  if(MC_is_active())
-    MC_ignore_global_variable("smx_total_comms");
 }
 
 void SIMIX_network_exit(void)
index 87a76e4..24d8a2c 100644 (file)
@@ -59,6 +59,14 @@ extern unsigned long simix_process_maxpid;
 
 extern xbt_dict_t watched_hosts_lib;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+XBT_PUBLIC(void) SIMIX_clean(void);
+#ifdef __cplusplus
+}
+#endif
+
 /******************************** Exceptions *********************************/
 
 #define SMX_EXCEPTION(issuer, c, v, m)                                  \
@@ -135,8 +143,8 @@ typedef struct s_smx_action {
       smx_rdv_t rdv;                  /* Rendez-vous where the comm is queued */
 
 #ifdef HAVE_MC
-      smx_rdv_t rdv_cpy;              /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR 
-                                         (comm.rdv set to NULL when the communication is removed from the mailbox 
+      smx_rdv_t rdv_cpy;              /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
+                                         (comm.rdv set to NULL when the communication is removed from the mailbox
                                          (used as garbage collector)) */
 #endif
       int refcount;                   /* Number of processes involved in the cond */
@@ -165,7 +173,7 @@ typedef struct s_smx_action {
 
       void* src_data;                 /* User data associated to communication */
       void* dst_data;
-    } comm;    
+    } comm;
 
     struct {
       smx_host_t host;                /* The host that is sleeping */
@@ -201,6 +209,20 @@ typedef struct s_smx_action {
 void SIMIX_context_mod_init(void);
 void SIMIX_context_mod_exit(void);
 
+#ifndef WIN32
+XBT_PUBLIC_DATA(char sigsegv_stack[SIGSTKSZ]);
+#endif
+
+/* We are using the bottom of the stack to save some information, like the
+ * valgrind_stack_id. Define smx_context_usable_stack_size to give the remaining
+ * size for the stack. */
+#ifdef HAVE_VALGRIND_VALGRIND_H
+# define smx_context_usable_stack_size                                  \
+  (smx_context_stack_size - sizeof(unsigned int)) /* for valgrind_stack_id */
+#else
+# define smx_context_usable_stack_size smx_context_stack_size
+#endif
+
 void *SIMIX_context_stack_new(void);
 void SIMIX_context_stack_delete(void *stack);
 
@@ -220,12 +242,12 @@ void SIMIX_ctx_raw_factory_init(smx_context_factory_t *factory);
 /* Scenario for the end of a context:
  *
  * CASE 1: death after end of the main function
- *   the context_wrapper, called internally by the context module, calls 
- *   SIMIX_context_stop after user code stops, smx_context_stop calls user 
+ *   the context_wrapper, called internally by the context module, calls
+ *   SIMIX_context_stop after user code stops, smx_context_stop calls user
  *   cleanup_func if any (in context settings), add current process to trashbin
  *   and yields back to maestro.
  *   From time to time, maestro calls SIMIX_context_empty_trash, which destroy
- *   all the process and context data structures, and frees the memory 
+ *   all the process and context data structures, and frees the memory
  *
  * CASE 2: brutal death
  *   SIMIX_process_kill (from any process) set process->iwannadie = 1 and then
@@ -256,7 +278,7 @@ static XBT_INLINE smx_context_t SIMIX_context_new(xbt_main_func_t code,
 }
 
 /**
- * \brief destroy a context 
+ * \brief destroy a context
  * \param context the context to destroy
  * Argument must be stopped first -- runs in maestro context
  */
@@ -295,7 +317,7 @@ static XBT_INLINE void SIMIX_context_runall(void)
 }
 
 /**
- \brief returns the current running context 
+ \brief returns the current running context
  */
 static XBT_INLINE smx_context_t SIMIX_context_self(void)
 {
index 8feee85..18be610 100644 (file)
@@ -1318,36 +1318,36 @@ int simcall_sem_get_capacity(smx_sem_t sem)
  * \ingroup simix_file_management
  *
  */
-sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size)
+sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, smx_host_t host)
 {
-  return simcall_BODY_file_read(fd, size);
+  return simcall_BODY_file_read(fd, size, host);
 }
 
 /**
  * \ingroup simix_file_management
  *
  */
-sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size)
+sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, smx_host_t host)
 {
-  return simcall_BODY_file_write(fd, size);
+  return simcall_BODY_file_write(fd, size, host);
 }
 
 /**
  * \ingroup simix_file_management
  * \brief
  */
-smx_file_t simcall_file_open(const char* mount, const char* path)
+smx_file_t simcall_file_open(const char* fullpath, smx_host_t host)
 {
-  return simcall_BODY_file_open(mount, path);
+  return simcall_BODY_file_open(fullpath, host);
 }
 
 /**
  * \ingroup simix_file_management
  *
  */
-int simcall_file_close(smx_file_t fd)
+int simcall_file_close(smx_file_t fd,  smx_host_t host)
 {
-  return simcall_BODY_file_close(fd);
+  return simcall_BODY_file_close(fd, host);
 }
 
 /**
@@ -1359,14 +1359,6 @@ int simcall_file_unlink(smx_file_t fd)
   return simcall_BODY_file_unlink(fd);
 }
 
-/**
- * \ingroup simix_file_management
- *
- */
-xbt_dict_t simcall_file_ls(const char* mount, const char* path)
-{
-  return simcall_BODY_file_ls(mount, path);
-}
 /**
  * \ingroup simix_file_management
  *
@@ -1402,31 +1394,32 @@ int simcall_file_seek(smx_file_t fd, sg_size_t offset, int origin){
 
 /**
  * \ingroup simix_file_management
+ * \brief Move a file to another location on the *same mount point*.
  *
  */
-void simcall_storage_file_rename(smx_storage_t storage, const char* src,  const char* dest)
+int simcall_file_move(smx_file_t fd, const char* fullpath)
 {
-  return simcall_BODY_storage_file_rename(storage, src, dest);
+  return simcall_BODY_file_move(fd, fullpath);
 }
 
 /**
  * \ingroup simix_storage_management
  * \brief Returns the free space size on a given storage element.
- * \param storage name
+ * \param storage a storage
  * \return Return the free space size on a given storage element (as sg_size_t)
  */
-sg_size_t simcall_storage_get_free_size (const char* name){
-  return simcall_BODY_storage_get_free_size(name);
+sg_size_t simcall_storage_get_free_size (smx_storage_t storage){
+  return simcall_BODY_storage_get_free_size(storage);
 }
 
 /**
  * \ingroup simix_storage_management
  * \brief Returns the used space size on a given storage element.
- * \param storage name
+ * \param storage a storage
  * \return Return the used space size on a given storage element (as sg_size_t)
  */
-sg_size_t simcall_storage_get_used_size (const char* name){
-  return simcall_BODY_storage_get_used_size(name);
+sg_size_t simcall_storage_get_used_size (smx_storage_t storage){
+  return simcall_BODY_storage_get_used_size(storage);
 }
 
 /**
index f6e09f6..38331fa 100644 (file)
@@ -315,10 +315,20 @@ int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
 // utilities
 extern double smpi_cpu_threshold;
 extern double smpi_running_power;
+extern int smpi_privatize_global_variables;
+extern char* start_data_exe; //start of the data+bss segment of the executable
+extern int size_data_exe; //size of the data+bss segment of the executable
+
+
+void switch_data_segment(int);
+void smpi_get_executable_global_size(void);
+void smpi_initialize_global_memory_segments(void);
+void smpi_destroy_global_memory_segments(void);
 void smpi_bench_destroy(void);
 void smpi_bench_begin(void);
 void smpi_bench_end(void);
 
+
 // f77 wrappers
 void mpi_init_(int*);
 void mpi_finalize_(int*);
@@ -593,5 +603,8 @@ void TRACE_smpi_finalize(int rank);
 
 const char* encode_datatype(MPI_Datatype datatype);
 
+// TODO, make this static and expose it more cleanly
+extern void** mappings;
+extern int loaded_page;
 
 #endif
index 5fccdc5..f2085f2 100644 (file)
@@ -376,6 +376,12 @@ void smpi_mpi_start(MPI_Request request)
       if(request->old_type->has_subtype == 0){
         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_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);
         }
@@ -587,6 +593,15 @@ static void finish_wait(MPI_Request * request, MPI_Status * status)
     MPI_Datatype datatype = req->old_type;
 
     if(datatype->has_subtype == 1){
+      if (!_xbt_replay_is_active()){
+        if( smpi_privatize_global_variables
+            && ((char*)req->old_buf >= start_data_exe)
+            && ((char*)req->old_buf < start_data_exe + size_data_exe )
+        ){
+            XBT_VERB("Privatization : We are unserializing to a zone in global memory - Switch data segment ");
+            switch_data_segment(smpi_process_index());
+        }
+      }
       // This part handles the problem of non-contignous memory
       // the unserialization at the reception
       s_smpi_subtype_t *subtype = datatype->substruct;
@@ -774,7 +789,7 @@ void smpi_mpi_wait(MPI_Request * request, MPI_Status * status)
   if ((*request)->action != NULL) { // this is not a detached send
     simcall_comm_wait((*request)->action, -1.0);
 #ifdef HAVE_MC
-  if(MC_is_active())
+  if(MC_is_active() && (*request)->action)
     (*request)->action->comm.dst_data = NULL; // dangling pointer : dst_data is freed with a wait, need to set it to NULL for system state comparison
 #endif
   }
index 9387099..f7464db 100644 (file)
@@ -4,6 +4,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "internal_config.h"
 #include "private.h"
 #include "xbt/dict.h"
 #include "xbt/sysdep.h"
 #include <string.h>
 #include <stdio.h>
 
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi,
                                 "Logging specific to SMPI (benchmarking)");
 
@@ -69,6 +74,13 @@ __thread int smpi_current_rank = 0;      /* Updated after each MPI call */
 double smpi_cpu_threshold;
 double smpi_running_power;
 
+int* fds;
+void** mappings;
+int loaded_page = -1;
+char* start_data_exe = NULL;
+int size_data_exe = 0;
+int smpi_privatize_global_variables;
+
 typedef struct {
   int fd;
   int count;
@@ -174,8 +186,11 @@ void smpi_execute(double duration)
   }
 }
 
+void switch_data_segment(int dest);
+
 void smpi_bench_begin(void)
 {
+  switch_data_segment(smpi_process_index());
   xbt_os_threadtimer_start(smpi_process_timer());
   smpi_current_rank = smpi_process_index();
 }
@@ -184,6 +199,7 @@ void smpi_bench_end(void)
 {
   xbt_os_timer_t timer = smpi_process_timer();
   xbt_os_threadtimer_stop(timer);
+//  switch_data_segment(smpi_process_count());
   if (smpi_process_get_sampling()) {
     XBT_CRITICAL("Cannot do recursive benchmarks.");
     XBT_CRITICAL("Are you trying to make a call to MPI within a SMPI_SAMPLE_ block?");
@@ -228,11 +244,11 @@ int smpi_gettimeofday(struct timeval *tv)
   return 0;
 }
 
-extern double sg_maxmin_precision;
+extern double sg_surf_precision;
 unsigned long long smpi_rastro_resolution (void)
 {
   smpi_bench_end();
-  double resolution = (1/sg_maxmin_precision);
+  double resolution = (1/sg_surf_precision);
   smpi_bench_begin();
   return (unsigned long long)resolution;
 }
@@ -554,3 +570,195 @@ void* smpi_shared_set_call(const char* func, const char* input, void* data) {
    free(loc);
    return data;
 }
+
+
+
+
+#define TOPAGE(addr) (void *)(((unsigned long)(addr) / xbt_pagesize) * xbt_pagesize)
+
+
+/*
+ * - read the executable data+bss section addresses and sizes
+ * - for each process create a copy of these sections with mmap
+ * - store them in a dynar
+ *
+ */
+
+
+
+void switch_data_segment(int dest){
+
+  if(size_data_exe == 0)//no need to switch
+    return;
+
+  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);
+  if (tmp != TOPAGE(start_data_exe))
+    xbt_die("Couldn't map the new region");
+  loaded_page=dest;
+#endif
+}
+
+void smpi_get_executable_global_size(){
+  int size_bss_binary=0;
+  int size_data_binary=0;
+  FILE *fp;
+  char *line = NULL;            /* Temporal storage for each line that is readed */
+  ssize_t read;                 /* Number of bytes readed */
+  size_t n = 0;                 /* Amount of bytes to read by xbt_getline */
+
+  char *lfields[7];
+  int i, found = 0;
+
+  char *command = bprintf("objdump --section-headers %s", xbt_binary_name);
+
+  fp = popen(command, "r");
+
+  if(fp == NULL){
+    perror("popen failed");
+    xbt_abort();
+  }
+
+  while ((read = xbt_getline(&line, &n, fp)) != -1 && found != 2) {
+
+    if(n == 0)
+      continue;
+
+    /* Wipeout the new line character */
+    line[read - 1] = '\0';
+
+    lfields[0] = strtok(line, " ");
+
+    if(lfields[0] == NULL)
+      continue;
+
+    if(strcmp(lfields[0], "Sections:") == 0
+        || strcmp(lfields[0], "Idx") == 0
+        || strncmp(lfields[0], xbt_binary_name, strlen(xbt_binary_name)) == 0)
+      continue;
+
+    for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
+      lfields[i] = strtok(NULL, " ");
+    }
+
+    /*
+     * we are looking for these fields
+    23 .data         02625a20  00000000006013e0  00000000006013e0  000013e0  2**5
+                     CONTENTS, ALLOC, LOAD, DATA
+    24 .bss          02625a40  0000000002c26e00  0000000002c26e00  02626e00  2**5
+                     ALLOC
+    */
+
+    if(i>=6){
+      if(strcmp(lfields[1], ".data") == 0){
+        size_data_binary = strtoul(lfields[2], NULL, 16);
+        start_data_exe = (char*) strtoul(lfields[4], NULL, 16);
+        found++;
+      }else if(strcmp(lfields[1], ".bss") == 0){
+        //the beginning of bss is not exactly the end of data if not aligned, grow bss reported size accordingly
+        //TODO : check if this is OK, as some segments may be inserted between them.. 
+        size_bss_binary = ((char*) strtoul(lfields[4], NULL, 16) - (start_data_exe + size_data_binary))
+                          + strtoul(lfields[2], NULL, 16);
+        found++;
+       }
+
+    }
+
+  }
+
+  size_data_exe =(unsigned long)start_data_exe - (unsigned long)TOPAGE(start_data_exe)+ size_data_binary+size_bss_binary;
+  xbt_free(command);
+  xbt_free(line);
+  pclose(fp);
+
+}
+
+void smpi_initialize_global_memory_segments(){
+
+#ifndef HAVE_MMAP
+  smpi_privatize_global_variables=0;
+  return;
+#else
+
+  unsigned int i = 0;
+  smpi_get_executable_global_size();
+
+  XBT_DEBUG ("bss+data segment found : size %d starting at %p",size_data_exe, start_data_exe );
+
+  if(size_data_exe == 0){//no need to switch
+    smpi_privatize_global_variables=0;
+    return;
+  }
+
+  fds= (int*)xbt_malloc((smpi_process_count())*sizeof(int));
+  mappings= (void**)xbt_malloc((smpi_process_count())*sizeof(void*));
+
+
+  for (i=0; i< SIMIX_process_count(); i++){
+      //create SIMIX_process_count() mappings of this size with the same data inside
+      void *address = NULL, *tmp = NULL;
+      char path[] = "/dev/shm/my-buffer-XXXXXX";
+      int status;
+      int file_descriptor= mkstemp (path);
+      if (file_descriptor < 0)
+        xbt_die("Impossible to create temporary file for memory mapping");
+      status = unlink (path);
+      if (status)
+        xbt_die("Impossible to unlink temporary file for memory mapping");
+
+      status = ftruncate(file_descriptor, size_data_exe);
+      if(status)
+        xbt_die("Impossible to set the size of the temporary file for memory mapping");
+
+      /* Ask for a free region */
+      address = mmap (NULL, size_data_exe, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+
+      if (address == MAP_FAILED)
+        xbt_die("Couldn't find a free region for memory mapping");
+
+      tmp = mmap (address, size_data_exe, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, file_descriptor, 0);
+
+      if (tmp != address)
+        xbt_die("Couldn't obtain the right address");
+      //initialize the values
+      memcpy(address,TOPAGE(start_data_exe),size_data_exe);
+
+      //store the address of the mapping for further switches
+      fds[i]=file_descriptor;
+      mappings[i]= address;
+  }
+
+#endif
+
+}
+
+void smpi_destroy_global_memory_segments(){
+  if(size_data_exe == 0)//no need to switch
+    return;
+#ifdef HAVE_MMAP
+  int i;
+  for (i=0; i< smpi_process_count(); i++){
+    if(munmap(mappings[i],size_data_exe) < 0) {
+      XBT_WARN("Unmapping of fd %d failed: %s", fds[i], strerror(errno));
+    }
+    close(fds[i]);
+  }
+  xbt_free(mappings);
+  xbt_free(fds);
+
+#endif
+
+}
+
index 7c3e483..95c40d7 100644 (file)
@@ -23,29 +23,24 @@ static int running_processes = 0;
 /* Bindings for MPI special values */
 union u_smpi_common {
   struct s_smpi_common {
-    integer mpi_in_place;
-    integer mpi_bottom;
-    integer mpi_status_ignore;
-    integer mpi_statuses_ignore;
-  } f90;                        /* with gftortran */
-  struct s_smpi_common *f77;    /* with f2c */
-} smpi_;
+    integer _MPI_IN_PLACE;
+    integer _MPI_BOTTOM;
+    integer _MPI_STATUS_IGNORE;
+    integer _MPI_STATUSES_IGNORE;
+  } *f77;                       /* with f2c, remains NULL with gfortran */
+  struct s_smpi_common f90;     /* with gfortran */
+} smpi_ = { NULL };
 
 /* Convert between Fortran and C */
-static XBT_INLINE void *f2c_addr(void *addr, void *cval, void *chk1, void *chk2)
-{
-  return (addr == chk1 || addr == chk2) ? cval : addr;
-}
-#define F2C_ADDR(addr, cval, fval) \
-  f2c_addr(addr, cval, &smpi_.f90.fval, &smpi_.f77[smpi_current_rank].fval)
-#define F2C_BOTTOM(addr) \
-  F2C_ADDR(addr, MPI_BOTTOM, mpi_bottom)
-#define F2C_IN_PLACE(addr) \
-  F2C_ADDR(addr, MPI_IN_PLACE, mpi_in_place)
-#define F2C_STATUS_IGNORE(addr) \
-  F2C_ADDR(addr, MPI_STATUS_IGNORE, mpi_status_ignore)
-#define F2C_STATUSES_IGNORE(addr) \
-  F2C_ADDR(addr, MPI_STATUSES_IGNORE, mpi_statuses_ignore)
+#define F2C_ADDR(addr, val)                                             \
+  (((void *)(addr) == (void *)(smpi_.f77                                \
+                               ? &smpi_.f77[smpi_current_rank]._ ## val \
+                               : &smpi_.f90._ ## val))                  \
+   ? (val) : (void *)(addr))
+#define F2C_BOTTOM(addr)          F2C_ADDR(addr, MPI_BOTTOM)
+#define F2C_IN_PLACE(addr)        F2C_ADDR(addr, MPI_IN_PLACE)
+#define F2C_STATUS_IGNORE(addr)   F2C_ADDR(addr, MPI_STATUS_IGNORE)
+#define F2C_STATUSES_IGNORE(addr) F2C_ADDR(addr, MPI_STATUSES_IGNORE)
 
 #define KEY_SIZE (sizeof(int) * 2 + 1)
 
index 966ec52..3315d44 100644 (file)
@@ -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);
 }
@@ -102,6 +111,12 @@ void smpi_process_destroy(void)
  */
 void smpi_process_finalize(void)
 {
+#if 0
+  // wait for all pending asynchronous comms to finish
+  while (SIMIX_process_has_pending_comms(SIMIX_process_self())) {
+    simcall_process_sleep(0.01);
+  }
+#else
   int i;
   int size = smpi_comm_size(MPI_COMM_WORLD);
   int rank = smpi_comm_rank(MPI_COMM_WORLD);
@@ -133,7 +148,7 @@ void smpi_process_finalize(void)
     smpi_mpi_waitall( size-1, requests+1, MPI_STATUSES_IGNORE );
     free( requests );
   }
-
+#endif
 }
 
 /**
@@ -322,7 +337,29 @@ static void smpi_comm_copy_buffer_callback(smx_action_t comm,
 {
   XBT_DEBUG("Copy the data over");
   if(_xbt_replay_is_active()) return;
-  memcpy(comm->comm.dst_buff, buff, buff_size);
+  void* tmpbuff=buff;
+
+  if((smpi_privatize_global_variables)
+      && ((char*)buff >= start_data_exe)
+      && ((char*)buff < start_data_exe + size_data_exe )
+    ){
+       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);
+  }
+
+
+  if((smpi_privatize_global_variables)
+      && ((char*)comm->comm.dst_buff >= start_data_exe)
+      && ((char*)comm->comm.dst_buff < start_data_exe + size_data_exe )
+    ){
+       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);
+  }
+
+
+  memcpy(comm->comm.dst_buff, tmpbuff, buff_size);
   if (comm->comm.detached) {
     // if this is a detached send, the source buffer was duplicated by SMPI
     // sender to make the original buffer available to the application ASAP
@@ -333,6 +370,9 @@ static void smpi_comm_copy_buffer_callback(smx_action_t comm,
     //inside the user data and should be free 
     comm->comm.src_buff = NULL;
   }
+
+  if(tmpbuff!=buff)xbt_free(tmpbuff);
+
 }
 
 void smpi_global_init(void)
@@ -377,6 +417,8 @@ void smpi_global_init(void)
              "Use the option \"--cfg=smpi/running_power:<flops>\" to set its value."
              "Check http://simgrid.org/simgrid/latest/doc/options.html#options_smpi_bench for more information. ");
   }
+  if(smpi_privatize_global_variables)
+    smpi_initialize_global_memory_segments();
 }
 
 void smpi_global_destroy(void)
@@ -400,7 +442,8 @@ void smpi_global_destroy(void)
   }
   xbt_free(process_data);
   process_data = NULL;
-
+  if(smpi_privatize_global_variables)
+    smpi_destroy_global_memory_segments();
   smpi_free_static();
 }
 
@@ -559,6 +602,7 @@ int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[])
 
   smpi_cpu_threshold = sg_cfg_get_double("smpi/cpu_threshold");
   smpi_running_power = sg_cfg_get_double("smpi/running_power");
+  smpi_privatize_global_variables = sg_cfg_get_boolean("smpi/privatize_global_variables");
   if (smpi_cpu_threshold < 0)
     smpi_cpu_threshold = DBL_MAX;
 
index 8be8134..ee348b8 100644 (file)
@@ -1489,6 +1489,11 @@ void smpi_op_destroy(MPI_Op op)
 void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
                    MPI_Datatype * datatype)
 {
+  if(smpi_privatize_global_variables){ //we need to switch here, as the called function may silently touch global variables
+    XBT_VERB("Applying operation, switch to the right data frame ");
+    switch_data_segment(smpi_process_index());
+  }
+
   if(!_xbt_replay_is_active())
   op->func(invec, inoutvec, len, datatype);
 }
index cb8c79c..b42f6a6 100644 (file)
@@ -74,8 +74,8 @@ int PMPI_Get_version (int *version,int *subversion){
 int PMPI_Get_library_version (char *version,int *len){
   int retval = MPI_SUCCESS;
   smpi_bench_end();
-  snprintf(version,MPI_MAX_LIBRARY_VERSION_STRING,"SMPI Version %d.%d. Copyright The Simgrid Team 2007-2013",SIMGRID_VERSION_MAJOR,
-           SIMGRID_VERSION_MINOR);
+  snprintf(version,MPI_MAX_LIBRARY_VERSION_STRING,"SMPI Version %d.%d. Copyright The Simgrid Team 2007-2014",SIMGRID_VERSION_MAJOR,
+          SIMGRID_VERSION_MINOR);
   *len = strlen(version) > MPI_MAX_LIBRARY_VERSION_STRING ? MPI_MAX_LIBRARY_VERSION_STRING : strlen(version);
   smpi_bench_begin();
   return retval;
@@ -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,15 +323,13 @@ 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;
 }
 
 int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
-                               MPI_Group group2, int *ranks2)
+                              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,16 +358,14 @@ 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;
 }
 
 int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
-                     MPI_Group * newgroup)
+                    MPI_Group * newgroup)
 {
   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,16 +396,14 @@ int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
-                            MPI_Group * newgroup)
+                           MPI_Group * newgroup)
 {
   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) {
@@ -523,10 +484,10 @@ int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
     } else if (n == smpi_group_size(group)) {
       *newgroup = group;
       if(group!= smpi_comm_group(MPI_COMM_WORLD)
-         && group != MPI_GROUP_NULL
-         && group != smpi_comm_group(MPI_COMM_SELF)
-         && group != MPI_GROUP_EMPTY)
-        smpi_group_use(group);
+                && group != MPI_GROUP_NULL
+                && group != smpi_comm_group(MPI_COMM_SELF)
+                && group != MPI_GROUP_EMPTY)
+      smpi_group_use(group);
     } else {
       *newgroup = smpi_group_new(n);
       for (i = 0; i < n; i++) {
@@ -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) {
@@ -553,10 +512,10 @@ int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
     if (n == 0) {
       *newgroup = group;
       if(group!= smpi_comm_group(MPI_COMM_WORLD)
-         && group != MPI_GROUP_NULL
-         && group != smpi_comm_group(MPI_COMM_SELF)
-         && group != MPI_GROUP_EMPTY)
-        smpi_group_use(group);
+                && group != MPI_GROUP_NULL
+                && group != smpi_comm_group(MPI_COMM_SELF)
+                && group != MPI_GROUP_EMPTY)
+      smpi_group_use(group);
     } else if (n == smpi_group_size(group)) {
       *newgroup = MPI_GROUP_EMPTY;
     } else {
@@ -583,16 +542,14 @@ int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
-                          MPI_Group * newgroup)
+                         MPI_Group * newgroup)
 {
   int retval, i, j, rank, size, index;
 
-  smpi_bench_end();
   if (group == MPI_GROUP_NULL) {
     retval = MPI_ERR_GROUP;
   } else if (newgroup == NULL) {
@@ -605,16 +562,16 @@ int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
       for (i = 0; i < n; i++) {
         for (rank = ranges[i][0];       /* First */
              rank >= 0; /* Last */
-             ) {
+              ) {
           size++;
 
           rank += ranges[i][2]; /* Stride */
          if (ranges[i][0]<ranges[i][1]){
-            if(rank > ranges[i][1])
-              break;
+             if(rank > ranges[i][1])
+               break;
          }else{
-            if(rank < ranges[i][1])
-              break;
+             if(rank < ranges[i][1])
+               break;
          }
         }
       }
@@ -641,16 +598,14 @@ int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
     }
     retval = MPI_SUCCESS;
   }
-  smpi_bench_begin();
   return retval;
 }
 
 int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
-                          MPI_Group * newgroup)
+                         MPI_Group * newgroup)
 {
   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) {
@@ -659,25 +614,25 @@ int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
     if (n == 0) {
       *newgroup = group;
       if(group!= smpi_comm_group(MPI_COMM_WORLD)
-         && group != MPI_GROUP_NULL
-         && group != smpi_comm_group(MPI_COMM_SELF)
-         && group != MPI_GROUP_EMPTY)
-        smpi_group_use(group);
+                && group != MPI_GROUP_NULL
+                && group != smpi_comm_group(MPI_COMM_SELF)
+                && group != MPI_GROUP_EMPTY)
+      smpi_group_use(group);
     } else {
       size = smpi_group_size(group);
       for (i = 0; i < n; i++) {
         for (rank = ranges[i][0];       /* First */
              rank >= 0; /* Last */
-             ) {
+              ) {
           size--;
 
           rank += ranges[i][2]; /* Stride */
          if (ranges[i][0]<ranges[i][1]){
-            if(rank > ranges[i][1])
-              break;
+             if(rank > ranges[i][1])
+               break;
          }else{
-            if(rank < ranges[i][1])
-              break;
+             if(rank < ranges[i][1])
+               break;
          }
         }
       }
@@ -692,18 +647,18 @@ int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
           for (i = 0; i < n; i++) {
             for (rank = ranges[i][0];rank >= 0;){
               if(rank==oldrank){
-                add=0;
-                break;
+                  add=0;
+                  break;
               }
 
               rank += ranges[i][2]; /* Stride */
 
               if (ranges[i][0]<ranges[i][1]){
-                if(rank > ranges[i][1])
-                  break;
+                  if(rank > ranges[i][1])
+                    break;
               }else{
-                if(rank < ranges[i][1])
-                  break;
+                  if(rank < ranges[i][1])
+                    break;
               }
             }
           }
@@ -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) {
@@ -786,13 +731,12 @@ int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
   } else {
     *group = smpi_comm_group(comm);
     if(*group!= smpi_comm_group(MPI_COMM_WORLD)
-       && *group != MPI_GROUP_NULL
-       && *group != smpi_comm_group(MPI_COMM_SELF)
-       && *group != MPI_GROUP_EMPTY)
-      smpi_group_use(*group);
+              && *group != MPI_GROUP_NULL
+              && *group != smpi_comm_group(MPI_COMM_SELF)
+              && *group != MPI_GROUP_EMPTY)
+    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) {
@@ -810,15 +753,14 @@ int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
       *result = MPI_IDENT;
     } else {
       *result =
-        smpi_group_compare(smpi_comm_group(comm1),
-                           smpi_comm_group(comm2));
+          smpi_group_compare(smpi_comm_group(comm1),
+                             smpi_comm_group(comm2));
       if (*result == MPI_IDENT) {
         *result = MPI_CONGRUENT;
       }
     }
     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), smpi_comm_topo(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, NULL);
     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;
 }
 
@@ -1190,7 +1125,7 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype,
 }
 
 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
-              MPI_Comm comm, MPI_Status * status)
+             MPI_Comm comm, MPI_Status * status)
 {
   int retval = 0;
 
@@ -1213,27 +1148,27 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
     retval = MPI_ERR_TAG;
   } else {
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int src_traced = smpi_group_index(smpi_comm_group(comm), src);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_RECV;
-    extra->send_size = count;
-    extra->src = src_traced;
-    extra->dst = rank;
-    extra->datatype1 = encode_datatype(datatype);
-    TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int src_traced = smpi_group_index(smpi_comm_group(comm), src);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_RECV;
+  extra->send_size = count;
+  extra->src = src_traced;
+  extra->dst = rank;
+  extra->datatype1 = encode_datatype(datatype);
+  TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
 #endif
 
     smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
     retval = MPI_SUCCESS;
 
 #ifdef HAVE_TRACING
-    //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
-    if(status!=MPI_STATUS_IGNORE){
-      src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
-      TRACE_smpi_recv(rank, src_traced, rank);
-    }
-    TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
+  //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
+  if(status!=MPI_STATUS_IGNORE){
+    src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
+    TRACE_smpi_recv(rank, src_traced, rank);
+  }
+  TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
 #endif
   }
 
@@ -1242,7 +1177,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
 }
 
 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
-              MPI_Comm comm)
+             MPI_Comm comm)
 {
   int retval = 0;
 
@@ -1265,23 +1200,23 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
   } else {
 
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_SEND;
-    extra->send_size = count;
-    extra->src = rank;
-    extra->dst = dst_traced;
-    extra->datatype1 = encode_datatype(datatype);
-    TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
-    TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_SEND;
+  extra->send_size = count;
+  extra->src = rank;
+  extra->dst = dst_traced;
+  extra->datatype1 = encode_datatype(datatype);
+  TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
+  TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
 #endif
 
     smpi_mpi_send(buf, count, datatype, dst, tag, comm);
     retval = MPI_SUCCESS;
 
 #ifdef HAVE_TRACING
-    TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
+  TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
 #endif
   }
 
@@ -1294,52 +1229,52 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
   int retval = 0;
 
-  smpi_bench_end();
-
-  if (comm == MPI_COMM_NULL) {
-    retval = MPI_ERR_COMM;
-  } else if (dst == MPI_PROC_NULL) {
-    retval = MPI_SUCCESS;
-  } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
-    retval = MPI_ERR_RANK;
-  } else if (count < 0) {
-    retval = MPI_ERR_COUNT;
-  } else if (buf==NULL && count > 0) {
-    retval = MPI_ERR_COUNT;
-  } else if (datatype == MPI_DATATYPE_NULL){
-    retval = MPI_ERR_TYPE;
-  } else if(tag<0 && tag !=  MPI_ANY_TAG){
-    retval = MPI_ERR_TAG;
-  } else {
-
-#ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_SSEND;
-    extra->send_size = count;
-    extra->src = rank;
-    extra->dst = dst_traced;
-    extra->datatype1 = encode_datatype(datatype);
-    TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);   TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
-#endif
-
-    smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
-    retval = MPI_SUCCESS;
-
-#ifdef HAVE_TRACING
-    TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
-#endif
-  }
-
-  smpi_bench_begin();
-  return retval;}
+   smpi_bench_end();
+
+   if (comm == MPI_COMM_NULL) {
+     retval = MPI_ERR_COMM;
+   } else if (dst == MPI_PROC_NULL) {
+     retval = MPI_SUCCESS;
+   } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
+     retval = MPI_ERR_RANK;
+   } else if (count < 0) {
+     retval = MPI_ERR_COUNT;
+   } else if (buf==NULL && count > 0) {
+     retval = MPI_ERR_COUNT;
+   } else if (datatype == MPI_DATATYPE_NULL){
+     retval = MPI_ERR_TYPE;
+   } else if(tag<0 && tag !=  MPI_ANY_TAG){
+     retval = MPI_ERR_TAG;
+   } else {
+
+ #ifdef HAVE_TRACING
+   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+   int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
+   instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+   extra->type = TRACING_SSEND;
+   extra->send_size = count;
+   extra->src = rank;
+   extra->dst = dst_traced;
+   extra->datatype1 = encode_datatype(datatype);
+   TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);   TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
+ #endif
+
+     smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
+     retval = MPI_SUCCESS;
+
+ #ifdef HAVE_TRACING
+   TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
+ #endif
+   }
+
+   smpi_bench_begin();
+   return retval;}
 
 
 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
-                  int dst, int sendtag, void *recvbuf, int recvcount,
-                  MPI_Datatype recvtype, int src, int recvtag,
-                  MPI_Comm comm, MPI_Status * status)
+                 int dst, int sendtag, void *recvbuf, int recvcount,
+                 MPI_Datatype recvtype, int src, int recvtag,
+                 MPI_Comm comm, MPI_Status * status)
 {
   int retval = 0;
 
@@ -1351,14 +1286,14 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
              || recvtype == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_TYPE;
   } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
-    smpi_empty_status(status);
-    status->MPI_SOURCE = MPI_PROC_NULL;
-    retval = MPI_SUCCESS;
+      smpi_empty_status(status);
+      status->MPI_SOURCE = MPI_PROC_NULL;
+      retval = MPI_SUCCESS;
   }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
-            (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
+      (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
     retval = MPI_ERR_RANK;
   } else if (sendcount < 0 || recvcount<0) {
-    retval = MPI_ERR_COUNT;
+      retval = MPI_ERR_COUNT;
   } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
     retval = MPI_ERR_COUNT;
   } else if((sendtag<0 && sendtag !=  MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
@@ -1366,20 +1301,20 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   } else {
 
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
-    int src_traced = smpi_group_index(smpi_comm_group(comm), src);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_SENDRECV;
-    extra->send_size = sendcount;
-    extra->recv_size = recvcount;
-    extra->src = src_traced;
-    extra->dst = dst_traced;
-    extra->datatype1 = encode_datatype(sendtype);
-    extra->datatype2 = encode_datatype(recvtype);
-
-    TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
-    TRACE_smpi_send(rank, rank, dst_traced,sendcount*smpi_datatype_size(sendtype));
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
+  int src_traced = smpi_group_index(smpi_comm_group(comm), src);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_SENDRECV;
+  extra->send_size = sendcount;
+  extra->recv_size = recvcount;
+  extra->src = src_traced;
+  extra->dst = dst_traced;
+  extra->datatype1 = encode_datatype(sendtype);
+  extra->datatype2 = encode_datatype(recvtype);
+
+  TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
+  TRACE_smpi_send(rank, rank, dst_traced,sendcount*smpi_datatype_size(sendtype));
 #endif
 
 
@@ -1388,8 +1323,8 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
     retval = MPI_SUCCESS;
 
 #ifdef HAVE_TRACING
-    TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
-    TRACE_smpi_recv(rank, src_traced, rank);
+  TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
+  TRACE_smpi_recv(rank, src_traced, rank);
 #endif
 
   }
@@ -1399,24 +1334,24 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 }
 
 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
-                          int dst, int sendtag, int src, int recvtag,
-                          MPI_Comm comm, MPI_Status * status)
+                         int dst, int sendtag, int src, int recvtag,
+                         MPI_Comm comm, MPI_Status * status)
 {
   //TODO: suboptimal implementation
   void *recvbuf;
   int retval = 0;
   if (datatype == MPI_DATATYPE_NULL) {
-    retval = MPI_ERR_TYPE;
+      retval = MPI_ERR_TYPE;
   } else if (count < 0) {
-    retval = MPI_ERR_COUNT;
+      retval = MPI_ERR_COUNT;
   } else {
     int size = smpi_datatype_get_extent(datatype) * count;
     recvbuf = xbt_new0(char, size);
     retval =
-      MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
-                   datatype, src, recvtag, comm, status);
+        MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
+                     datatype, src, recvtag, comm, status);
     if(retval==MPI_SUCCESS){
-      smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
+        smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
     }
     xbt_free(recvbuf);
 
@@ -1444,7 +1379,7 @@ int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
 }
 
 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
-                 MPI_Status * status)
+                MPI_Status * status)
 {
   int retval = 0;
 
@@ -1607,8 +1542,8 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta
     if (is_wait_for_receive) {
       if(srcs[*index]==MPI_ANY_SOURCE)
         src_traced = (status!=MPI_STATUSES_IGNORE) ?
-          smpi_group_rank(smpi_comm_group(comms[*index]), status->MPI_SOURCE) :
-          srcs[*index];
+                      smpi_group_rank(smpi_comm_group(comms[*index]), status->MPI_SOURCE) :
+                      srcs[*index];
       TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
     }
     TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
@@ -1659,16 +1594,16 @@ int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
 #ifdef HAVE_TRACING
   for (i = 0; i < count; i++) {
     if(valid[i]){
-      //int src_traced = srcs[*index];
-      //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
+    //int src_traced = srcs[*index];
+    //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
       int src_traced = srcs[i];
       int dst_traced = dsts[i];
       int is_wait_for_receive = recvs[i];
       if (is_wait_for_receive) {
         if(src_traced==MPI_ANY_SOURCE)
-          src_traced = (status!=MPI_STATUSES_IGNORE) ?
-            smpi_group_rank(smpi_comm_group(comms[i]), status[i].MPI_SOURCE) :
-            srcs[i];
+        src_traced = (status!=MPI_STATUSES_IGNORE) ?
+                          smpi_group_rank(smpi_comm_group(comms[i]), status[i].MPI_SOURCE) :
+                          srcs[i];
         TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
       }
     }
@@ -1686,7 +1621,7 @@ int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
 }
 
 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
-                  int *indices, MPI_Status status[])
+                 int *indices, MPI_Status status[])
 {
   int retval = 0;
 
@@ -1702,19 +1637,19 @@ int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
 }
 
 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
-                  int* indices, MPI_Status status[])
+                 int* indices, MPI_Status status[])
 {
   int retval = 0;
 
-  smpi_bench_end();
-  if (outcount == NULL) {
-    retval = MPI_ERR_ARG;
-  } else {
-    *outcount = smpi_mpi_testsome(incount, requests, indices, status);
-    retval = MPI_SUCCESS;
-  }
-  smpi_bench_begin();
-  return retval;
+   smpi_bench_end();
+   if (outcount == NULL) {
+     retval = MPI_ERR_ARG;
+   } else {
+     *outcount = smpi_mpi_testsome(incount, requests, indices, status);
+     retval = MPI_SUCCESS;
+   }
+   smpi_bench_begin();
+   return retval;
 }
 
 
@@ -1728,21 +1663,21 @@ int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm c
     retval = MPI_ERR_COMM;
   } else {
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
 
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_BCAST;
-    extra->send_size = count;
-    extra->root = root_traced;
-    extra->datatype1 = encode_datatype(datatype);
-    TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_BCAST;
+  extra->send_size = count;
+  extra->root = root_traced;
+  extra->datatype1 = encode_datatype(datatype);
+  TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
 
 #endif
     mpi_coll_bcast_fun(buf, count, datatype, root, comm);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
 #endif
   }
 
@@ -1760,15 +1695,15 @@ int PMPI_Barrier(MPI_Comm comm)
     retval = MPI_ERR_COMM;
   } else {
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_BARRIER;
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_BARRIER;
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
 #endif
     mpi_coll_barrier_fun(comm);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
 
@@ -1777,8 +1712,8 @@ int PMPI_Barrier(MPI_Comm comm)
 }
 
 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
-                void *recvbuf, int recvcount, MPI_Datatype recvtype,
-                int root, MPI_Comm comm)
+               void *recvbuf, int recvcount, MPI_Datatype recvtype,
+               int root, MPI_Comm comm)
 {
   int retval = 0;
 
@@ -1787,10 +1722,10 @@ int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
-             ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
+            ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
     retval = MPI_ERR_TYPE;
   } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
-             ((smpi_comm_rank(comm) == root) && (recvcount <0))){
+            ((smpi_comm_rank(comm) == root) && (recvcount <0))){
     retval = MPI_ERR_COUNT;
   } else {
 
@@ -1802,25 +1737,25 @@ int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
       sendtmptype=recvtype;
     }
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int root_traced = smpi_group_index(smpi_comm_group(comm), root);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_GATHER;
-    extra->send_size = sendtmpcount;
-    extra->recv_size = recvcount;
-    extra->root = root_traced;
-    extra->datatype1 = encode_datatype(sendtmptype);
-    extra->datatype2 = encode_datatype(recvtype);
-
-    TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_GATHER;
+  extra->send_size = sendtmpcount;
+  extra->recv_size = recvcount;
+  extra->root = root_traced;
+  extra->datatype1 = encode_datatype(sendtmptype);
+  extra->datatype2 = encode_datatype(recvtype);
+
+  TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
 #endif
     mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
-                        recvtype, root, comm);
+                    recvtype, root, comm);
 
 
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
 #endif
   }
 
@@ -1829,8 +1764,8 @@ int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 }
 
 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
-                 void *recvbuf, int *recvcounts, int *displs,
-                 MPI_Datatype recvtype, int root, MPI_Comm comm)
+                void *recvbuf, int *recvcounts, int *displs,
+                MPI_Datatype recvtype, int root, MPI_Comm comm)
 {
   int retval = 0;
 
@@ -1839,7 +1774,7 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
-             ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
+            ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
     retval = MPI_ERR_TYPE;
   } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
     retval = MPI_ERR_COUNT;
@@ -1855,28 +1790,28 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
     }
 
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int root_traced = smpi_group_index(smpi_comm_group(comm), root);
-    int i=0;
-    int size = smpi_comm_size(comm);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_GATHERV;
-    extra->send_size = sendtmpcount;
-    extra->recvcounts= xbt_malloc(size*sizeof(int));
-    for(i=0; i< size; i++)//copy data to avoid bad free
-      extra->recvcounts[i] = recvcounts[i];
-    extra->num_processes = size;
-    extra->root = root_traced;
-    extra->datatype1 = encode_datatype(sendtmptype);
-    extra->datatype2 = encode_datatype(recvtype);
-
-    TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+  int i=0;
+  int size = smpi_comm_size(comm);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_GATHERV;
+  extra->send_size = sendtmpcount;
+  extra->recvcounts= xbt_malloc(size*sizeof(int));
+  for(i=0; i< size; i++)//copy data to avoid bad free
+    extra->recvcounts[i] = recvcounts[i];
+  extra->num_processes = size;
+  extra->root = root_traced;
+  extra->datatype1 = encode_datatype(sendtmptype);
+  extra->datatype2 = encode_datatype(recvtype);
+
+  TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
 #endif
     smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
                      displs, recvtype, root, comm);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
 #endif
   }
 
@@ -1885,8 +1820,8 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 }
 
 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
-                   void *recvbuf, int recvcount, MPI_Datatype recvtype,
-                   MPI_Comm comm)
+                  void *recvbuf, int recvcount, MPI_Datatype recvtype,
+                  MPI_Comm comm)
 {
   int retval = 0;
 
@@ -1895,10 +1830,10 @@ int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
-             (recvtype == MPI_DATATYPE_NULL)){
+            (recvtype == MPI_DATATYPE_NULL)){
     retval = MPI_ERR_TYPE;
   } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
-             (recvcount <0)){
+            (recvcount <0)){
     retval = MPI_ERR_COUNT;
   } else {
     if(sendbuf == MPI_IN_PLACE) {
@@ -1907,22 +1842,22 @@ int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
       sendtype=recvtype;
     }
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_ALLGATHER;
-    extra->send_size = sendcount;
-    extra->recv_size = recvcount;
-    extra->datatype1 = encode_datatype(sendtype);
-    extra->datatype2 = encode_datatype(recvtype);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_ALLGATHER;
+  extra->send_size = sendcount;
+  extra->recv_size = recvcount;
+  extra->datatype1 = encode_datatype(sendtype);
+  extra->datatype2 = encode_datatype(recvtype);
 
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
 #endif
     mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
                            recvtype, comm);
     retval = MPI_SUCCESS;
 
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
   smpi_bench_begin();
@@ -1930,8 +1865,8 @@ int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 }
 
 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
-                    void *recvbuf, int *recvcounts, int *displs,
-                    MPI_Datatype recvtype, MPI_Comm comm)
+                   void *recvbuf, int *recvcounts, int *displs,
+                   MPI_Datatype recvtype, MPI_Comm comm)
 {
   int retval = 0;
 
@@ -1940,7 +1875,7 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
-             (recvtype == MPI_DATATYPE_NULL)){
+            (recvtype == MPI_DATATYPE_NULL)){
     retval = MPI_ERR_TYPE;
   } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
     retval = MPI_ERR_COUNT;
@@ -1954,26 +1889,26 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
       sendtype=recvtype;
     }
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int i=0;
-    int size = smpi_comm_size(comm);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_ALLGATHERV;
-    extra->send_size = sendcount;
-    extra->recvcounts= xbt_malloc(size*sizeof(int));
-    for(i=0; i< size; i++)//copy data to avoid bad free
-      extra->recvcounts[i] = recvcounts[i];
-    extra->num_processes = size;
-    extra->datatype1 = encode_datatype(sendtype);
-    extra->datatype2 = encode_datatype(recvtype);
-
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int i=0;
+  int size = smpi_comm_size(comm);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_ALLGATHERV;
+  extra->send_size = sendcount;
+  extra->recvcounts= xbt_malloc(size*sizeof(int));
+  for(i=0; i< size; i++)//copy data to avoid bad free
+    extra->recvcounts[i] = recvcounts[i];
+  extra->num_processes = size;
+  extra->datatype1 = encode_datatype(sendtype);
+  extra->datatype2 = encode_datatype(recvtype);
+
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
 #endif
     mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
-                            displs, recvtype, comm);
+                        displs, recvtype, comm);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
 
@@ -1982,8 +1917,8 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 }
 
 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
-                 void *recvbuf, int recvcount, MPI_Datatype recvtype,
-                 int root, MPI_Comm comm)
+                void *recvbuf, int recvcount, MPI_Datatype recvtype,
+                int root, MPI_Comm comm)
 {
   int retval = 0;
 
@@ -1997,27 +1932,27 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   } else {
 
     if (recvbuf == MPI_IN_PLACE) {
-      recvtype=sendtype;
-      recvcount=sendcount;
+        recvtype=sendtype;
+        recvcount=sendcount;
     }
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int root_traced = smpi_group_index(smpi_comm_group(comm), root);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_SCATTER;
-    extra->send_size = sendcount;
-    extra->recv_size= recvcount;
-    extra->root = root_traced;
-    extra->datatype1 = encode_datatype(sendtype);
-    extra->datatype2 = encode_datatype(recvtype);
-
-    TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_SCATTER;
+  extra->send_size = sendcount;
+  extra->recv_size= recvcount;
+  extra->root = root_traced;
+  extra->datatype1 = encode_datatype(sendtype);
+  extra->datatype2 = encode_datatype(recvtype);
+
+  TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
 #endif
     mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
-                         recvtype, root, comm);
+                     recvtype, root, comm);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
 #endif
   }
 
@@ -2026,8 +1961,8 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 }
 
 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
-                  MPI_Datatype sendtype, void *recvbuf, int recvcount,
-                  MPI_Datatype recvtype, int root, MPI_Comm comm)
+                 MPI_Datatype sendtype, void *recvbuf, int recvcount,
+                 MPI_Datatype recvtype, int root, MPI_Comm comm)
 {
   int retval = 0;
 
@@ -2042,33 +1977,33 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
     retval = MPI_ERR_TYPE;
   } else {
     if (recvbuf == MPI_IN_PLACE) {
-      recvtype=sendtype;
-      recvcount=sendcounts[smpi_comm_rank(comm)];
+        recvtype=sendtype;
+        recvcount=sendcounts[smpi_comm_rank(comm)];
     }
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int root_traced = smpi_group_index(smpi_comm_group(comm), root);
-    int i=0;
-    int size = smpi_comm_size(comm);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_SCATTERV;
-    extra->recv_size = recvcount;
-    extra->sendcounts= xbt_malloc(size*sizeof(int));
-    for(i=0; i< size; i++)//copy data to avoid bad free
-      extra->sendcounts[i] = sendcounts[i];
-    extra->num_processes = size;
-    extra->root = root_traced;
-    extra->datatype1 = encode_datatype(sendtype);
-    extra->datatype2 = encode_datatype(recvtype);
-
-    TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+  int i=0;
+  int size = smpi_comm_size(comm);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_SCATTERV;
+  extra->recv_size = recvcount;
+  extra->sendcounts= xbt_malloc(size*sizeof(int));
+  for(i=0; i< size; i++)//copy data to avoid bad free
+    extra->sendcounts[i] = sendcounts[i];
+  extra->num_processes = size;
+  extra->root = root_traced;
+  extra->datatype1 = encode_datatype(sendtype);
+  extra->datatype2 = encode_datatype(recvtype);
+
+  TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
 
 #endif
     smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
                       recvcount, recvtype, root, comm);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
 #endif
   }
 
@@ -2077,7 +2012,7 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
 }
 
 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
-                MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
+               MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
 {
   int retval = 0;
 
@@ -2089,21 +2024,21 @@ int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
     retval = MPI_ERR_ARG;
   } else {
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int root_traced = smpi_group_index(smpi_comm_group(comm), root);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_REDUCE;
-    extra->send_size = count;
-    extra->datatype1 = encode_datatype(datatype);
-    extra->root = root_traced;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int root_traced = smpi_group_index(smpi_comm_group(comm), root);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_REDUCE;
+  extra->send_size = count;
+  extra->datatype1 = encode_datatype(datatype);
+  extra->root = root_traced;
 
-    TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
+  TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
 #endif
     mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
 
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
 #endif
   }
 
@@ -2112,22 +2047,22 @@ int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
 }
 
 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
-                      MPI_Datatype datatype, MPI_Op op){
+    MPI_Datatype datatype, MPI_Op op){
   int retval = 0;
 
-  smpi_bench_end();
-  if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
-    retval = MPI_ERR_ARG;
-  } else {
-    smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
-    retval=MPI_SUCCESS;
-  }
-  smpi_bench_begin();
-  return retval;
+    smpi_bench_end();
+    if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
+      retval = MPI_ERR_ARG;
+    } else {
+      smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
+      retval=MPI_SUCCESS;
+    }
+    smpi_bench_begin();
+    return retval;
 }
 
 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
-                   MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+                  MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
 {
   int retval = 0;
 
@@ -2147,13 +2082,13 @@ int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
       smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
     }
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_ALLREDUCE;
-    extra->send_size = count;
-    extra->datatype1 = encode_datatype(datatype);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_ALLREDUCE;
+  extra->send_size = count;
+  extra->datatype1 = encode_datatype(datatype);
 
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
 #endif
     mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
 
@@ -2163,7 +2098,7 @@ int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
 
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
 
@@ -2172,7 +2107,7 @@ int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
 }
 
 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
-              MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+             MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
 {
   int retval = 0;
 
@@ -2186,18 +2121,18 @@ int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
     retval = MPI_ERR_OP;
   } else {
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_SCAN;
-    extra->send_size = count;
-    extra->datatype1 = encode_datatype(datatype);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_SCAN;
+  extra->send_size = count;
+  extra->datatype1 = encode_datatype(datatype);
 
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
 #endif
     smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
 
@@ -2219,18 +2154,18 @@ int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
     retval = MPI_ERR_OP;
   } else {
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_EXSCAN;
-    extra->send_size = count;
-    extra->datatype1 = encode_datatype(datatype);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_EXSCAN;
+  extra->send_size = count;
+  extra->datatype1 = encode_datatype(datatype);
 
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
 #endif
     smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
 
@@ -2239,7 +2174,7 @@ int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
 }
 
 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
-                        MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+                       MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
 {
   int retval = 0;
   smpi_bench_end();
@@ -2254,19 +2189,19 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
     retval = MPI_ERR_ARG;
   } else {
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int i=0;
-    int size = smpi_comm_size(comm);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_REDUCE_SCATTER;
-    extra->send_size = 0;
-    extra->recvcounts= xbt_malloc(size*sizeof(int));
-    for(i=0; i< size; i++)//copy data to avoid bad free
-      extra->recvcounts[i] = recvcounts[i];
-    extra->num_processes = size;
-    extra->datatype1 = encode_datatype(datatype);
-
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int i=0;
+  int size = smpi_comm_size(comm);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_REDUCE_SCATTER;
+  extra->send_size = 0;
+  extra->recvcounts= xbt_malloc(size*sizeof(int));
+  for(i=0; i< size; i++)//copy data to avoid bad free
+    extra->recvcounts[i] = recvcounts[i];
+  extra->num_processes = size;
+  extra->datatype1 = encode_datatype(datatype);
+
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
 #endif
     void* sendtmpbuf=sendbuf;
     if(sendbuf==MPI_IN_PLACE){
@@ -2274,10 +2209,10 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
     }
 
     mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
-                                datatype,  op, comm);
+                       datatype,  op, comm);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
 
@@ -2286,7 +2221,7 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
 }
 
 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
-                              MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+                       MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
 {
   int retval,i;
   smpi_bench_end();
@@ -2303,26 +2238,26 @@ int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
     int count=smpi_comm_size(comm);
 
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_REDUCE_SCATTER;
-    extra->send_size = 0;
-    extra->recvcounts= xbt_malloc(count*sizeof(int));
-    for(i=0; i< count; i++)//copy data to avoid bad free
-      extra->recvcounts[i] = recvcount;
-    extra->num_processes = count;
-    extra->datatype1 = encode_datatype(datatype);
-
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_REDUCE_SCATTER;
+  extra->send_size = 0;
+  extra->recvcounts= xbt_malloc(count*sizeof(int));
+  for(i=0; i< count; i++)//copy data to avoid bad free
+    extra->recvcounts[i] = recvcount;
+  extra->num_processes = count;
+  extra->datatype1 = encode_datatype(datatype);
+
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
 #endif
     int* recvcounts=(int*)xbt_malloc(count);
     for (i=0; i<count;i++)recvcounts[i]=recvcount;
     mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
-                                datatype,  op, comm);
+                       datatype,  op, comm);
     xbt_free(recvcounts);
     retval = MPI_SUCCESS;
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
 
@@ -2331,8 +2266,8 @@ int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
 }
 
 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
-                  void *recvbuf, int recvcount, MPI_Datatype recvtype,
-                  MPI_Comm comm)
+                 void *recvbuf, int recvcount, MPI_Datatype recvtype,
+                 MPI_Comm comm)
 {
   int retval = 0;
 
@@ -2345,19 +2280,19 @@ int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
     retval = MPI_ERR_TYPE;
   } else {
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_ALLTOALL;
-    extra->send_size = sendcount;
-    extra->recv_size = recvcount;
-    extra->datatype1 = encode_datatype(sendtype);
-    extra->datatype2 = encode_datatype(recvtype);
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_ALLTOALL;
+  extra->send_size = sendcount;
+  extra->recv_size = recvcount;
+  extra->datatype1 = encode_datatype(sendtype);
+  extra->datatype2 = encode_datatype(recvtype);
 
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
 #endif
     retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
 
@@ -2366,8 +2301,8 @@ int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 }
 
 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
-                   MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
-                   int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
+                  MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
+                  int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
 {
   int retval = 0;
 
@@ -2383,36 +2318,36 @@ int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
     retval = MPI_ERR_ARG;
   } else {
 #ifdef HAVE_TRACING
-    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
-    int i=0;
-    int size = smpi_comm_size(comm);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_ALLTOALLV;
-    extra->send_size = 0;
-    extra->recv_size = 0;
-    extra->recvcounts= xbt_malloc(size*sizeof(int));
-    extra->sendcounts= xbt_malloc(size*sizeof(int));
-
-    for(i=0; i< size; i++){//copy data to avoid bad free
-      extra->send_size += sendcounts[i];
-      extra->recv_size += recvcounts[i];
-
-      extra->sendcounts[i] = sendcounts[i];
-      extra->recvcounts[i] = recvcounts[i];
-    }
-    extra->num_processes = size;
+  int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+  int i=0;
+  int size = smpi_comm_size(comm);
+  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+  extra->type = TRACING_ALLTOALLV;
+  extra->send_size = 0;
+  extra->recv_size = 0;
+  extra->recvcounts= xbt_malloc(size*sizeof(int));
+  extra->sendcounts= xbt_malloc(size*sizeof(int));
 
-    extra->datatype1 = encode_datatype(sendtype);
-    extra->datatype2 = encode_datatype(recvtype);
+  for(i=0; i< size; i++){//copy data to avoid bad free
+    extra->send_size += sendcounts[i];
+    extra->recv_size += recvcounts[i];
 
-    TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+    extra->sendcounts[i] = sendcounts[i];
+    extra->recvcounts[i] = recvcounts[i];
+  }
+  extra->num_processes = size;
+
+  extra->datatype1 = encode_datatype(sendtype);
+  extra->datatype2 = encode_datatype(recvtype);
+
+  TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
 #endif
     retval =
-      mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
-                             recvbuf, recvcounts, recvdisps, recvtype,
-                             comm);
+        mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
+                                  recvbuf, recvcounts, recvdisps, recvtype,
+                                  comm);
 #ifdef HAVE_TRACING
-    TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
 #endif
   }
 
@@ -2425,16 +2360,14 @@ 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 :
           MPI_MAX_PROCESSOR_NAME - 1 );
   *resultlen =
-    strlen(name) >
-    MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
+      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;
 }
 
@@ -2639,8 +2550,8 @@ int PMPI_Error_class(int errorcode, int* errorclass) {
 
 
 int PMPI_Initialized(int* flag) {
-  *flag=smpi_process_initialized();
-  return MPI_SUCCESS;
+   *flag=smpi_process_initialized();
+   return MPI_SUCCESS;
 }
 
 /* The topo part of MPI_COMM_WORLD should always be NULL. When other topologies
@@ -2756,431 +2667,431 @@ int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
 
 int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_set_name(MPI_Datatype  datatype, char * name)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_get_name(MPI_Datatype  datatype, char * name, int* len)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 
 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 
 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler* errhandler) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Cancel(MPI_Request* request) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Buffer_attach(void* buffer, int size) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Buffer_detach(void* buffer, int* size) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_free_keyval(int* keyval) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Pcontrol(const int level )
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
 {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_free_keyval(int* keyval) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Keyval_free(int* keyval) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Win_fence( int assert,  MPI_Win win){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Win_free( MPI_Win* win){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Info_create( MPI_Info *info){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Info_set( MPI_Info info, char *key, char *value){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Info_free( MPI_Info *info){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
                             int *num_addresses, int *num_datatypes, int *combiner){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
                            int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
                            MPI_Datatype* array_of_datatypes){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
                             int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
                             int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_create_subarray(int ndims,int *array_of_sizes, int *array_of_subsizes, int *array_of_starts, int order, MPI_Datatype oldtype, MPI_Datatype *newtype){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
                     void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
                     MPI_Comm comm){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Add_error_class( int *errorclass){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Add_error_code(  int errorclass, int *errorcode){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Add_error_string( int errorcode, char *string){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Info_delete(MPI_Info info, char *key){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Grequest_start( MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn, MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Grequest_complete( MPI_Request request){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Open_port( MPI_Info info, char *port_name){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Close_port(char *port_name){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_spawn( char *command, char **argv, int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
                               int* array_of_maxprocs, MPI_Info* array_of_info, int root,
                               MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
   NOT_YET_IMPLEMENTED
-    }
+}
 
 int PMPI_Comm_get_parent( MPI_Comm *parent){
   NOT_YET_IMPLEMENTED
-    }
+}
index 9ba0724..3a015ff 100755 (executable)
@@ -21,7 +21,7 @@ NETWORK_BANDWIDTH="${DEFAULT_NETWORK_BANDWIDTH}"
 NETWORK_LATENCY="${DEFAULT_NETWORK_LATENCY}"
 POWER="${DEFAULT_POWER}"
 
-SIMOPTS="--cfg=maxmin/precision:1e-9 --cfg=network/model:SMPI --cfg=network/TCP_gamma:4194304"
+SIMOPTS="--cfg=maxmin/precision:1e-9 --cfg=surf/precision:1e-9 --cfg=network/model:SMPI --cfg=network/TCP_gamma:4194304"
 
 #usage to print the way this script should be called
 usage () {
@@ -426,10 +426,6 @@ fi
 ${EXEC} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP}
 status=$?
 
-if [ ${status} = 139 ]; then echo "ERROR: A segmentation fault was triggered. 
-A common cause in SimGrid may be the use of a too small stack size for the simulated processes (default 8192 KiB).
-Please see contexts/stack_size parameter , or http://simgrid.org/simgrid/latest/doc/options.html#options_virt_stacksize "; fi
-
 if [ -z "${KEEP}" ] ; then
    if [ -z "${PLATFORM}" ]; then
        rm ${PLATFORMTMP}
index c746e9a..3c6662d 100644 (file)
@@ -17,18 +17,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu,
  * CallBacks *
  *************/
 
-static void parse_cpu_init(sg_platf_host_cbarg_t host){
-  ((CpuCas01ModelPtr)surf_cpu_model_pm)->parseInit(host);
-}
-
-static void cpu_add_traces_cpu(){
-  surf_cpu_model_pm->addTraces();
-}
-
 static void cpu_define_callbacks()
 {
   sg_platf_host_add_cb(parse_cpu_init);
-  sg_platf_postparse_add_cb(cpu_add_traces_cpu);
+  sg_platf_postparse_add_cb(add_traces_cpu);
 }
 
 /*********
@@ -315,7 +307,7 @@ CpuActionPtr CpuCas01::execute(double size)
 CpuActionPtr CpuCas01::sleep(double duration)
 {
   if (duration > 0)
-    duration = MAX(duration, MAXMIN_PRECISION);
+    duration = MAX(duration, sg_surf_precision);
 
   XBT_IN("(%s,%g)", getName(), duration);
   CpuCas01ActionPtr action = new CpuCas01Action(getModel(), 1.0, getState() != SURF_RESOURCE_ON,
index 685cd4c..438f3c2 100644 (file)
@@ -81,7 +81,6 @@ class CpuCas01Action: public CpuAction {
   friend CpuActionPtr CpuCas01::execute(double size);
   friend CpuActionPtr CpuCas01::sleep(double duration);
 public:
-  CpuCas01Action() {};
   CpuCas01Action(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint);
 
   ~CpuCas01Action() {};
index 736b29e..1a08d36 100644 (file)
@@ -10,9 +10,11 @@ XBT_LOG_EXTERNAL_CATEGORY(surf_kernel);
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
                                 "Logging specific to the SURF cpu module");
 
+int autoload_surf_cpu_model = 1;
+void_f_void_t surf_cpu_model_init_preparse = NULL;
+
 CpuModelPtr surf_cpu_model_pm;
 CpuModelPtr surf_cpu_model_vm;
-
 /*************
  * Callbacks *
  *************/
@@ -25,18 +27,38 @@ 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;
+
+void parse_cpu_init(sg_platf_host_cbarg_t host){
+  surf_cpu_model_pm->parseInit(host);
+}
+
+void add_traces_cpu(){
+  surf_cpu_model_pm->addTraces();
+}
 
 /*********
  * Model *
  *********/
+void CpuModel::parseInit(sg_platf_host_cbarg_t host)
+{
+  createResource(host->id,
+        host->power_peak,
+        host->pstate,
+        host->power_scale,
+        host->power_trace,
+        host->core_amount,
+        host->initial_state,
+        host->state_trace,
+        host->properties);
+}
 
 void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
 {
   CpuActionPtr action;
   while ((xbt_heap_size(getActionHeap()) > 0)
-         && (double_equals(xbt_heap_maxkey(getActionHeap()), now))) {
+         && (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) {
     action = static_cast<CpuActionPtr>(static_cast<ActionPtr>(xbt_heap_pop(getActionHeap())));
     XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
 #ifdef HAVE_TRACING
@@ -185,6 +207,11 @@ Cpu::~Cpu(){
     xbt_free(p_constraintCoreId);
 }
 
+double Cpu::getCurrentPowerPeak()
+{
+  return m_powerPeak;
+}
+
 double Cpu::getSpeed(double load)
 {
   return load * m_powerPeak;
@@ -203,8 +230,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 *
@@ -225,7 +253,7 @@ void CpuAction::updateRemainingLazy(double now)
 
   if (m_remains > 0) {
     XBT_CDEBUG(surf_kernel, "Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate);
-    double_update(&(m_remains), m_lastValue * delta);
+    double_update(&(m_remains), m_lastValue * delta, sg_maxmin_precision*sg_surf_precision);
 
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
@@ -309,6 +337,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);
 }
index c72e0f5..b2f4e8a 100644 (file)
@@ -28,31 +28,35 @@ typedef CpuPlugin *CpuPluginPtr;
 /*************
  * Callbacks *
  *************/
-CpuPtr getActionCpu(CpuActionPtr action);
+XBT_PUBLIC(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;
+XBT_PUBLIC_DATA( 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;
+XBT_PUBLIC_DATA( 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;
+XBT_PUBLIC_DATA( 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;
+XBT_PUBLIC_DATA( surf_callback(void, CpuActionPtr, e_surf_action_state_t, e_surf_action_state_t)) cpuActionStateChangedCallbacks;
+
+XBT_PUBLIC(void) parse_cpu_init(sg_platf_host_cbarg_t host);
+
+XBT_PUBLIC(void) add_traces_cpu();
 
 /*********
  * Model *
@@ -62,25 +66,28 @@ extern surf_callback(void, CpuActionPtr) cpuActionStateChangedCallbacks;
  * @brief SURF cpu model interface class
  * @details A model is an object which handle the interactions between its Resources and its Actions
  */
-class CpuModel : public Model {
+XBT_PUBLIC_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
+   *
+   * @param host [TODO]
    */
-  CpuPtr createResource(string name);
+  void parseInit(sg_platf_host_cbarg_t host);
 
-  void setState(e_surf_resource_state_t state);
+  virtual CpuPtr createResource(const char *name, xbt_dynar_t power_peak,
+                      int pstate, double power_scale,
+                          tmgr_trace_t power_trace, int core,
+                          e_surf_resource_state_t state_initial,
+                          tmgr_trace_t state_trace,
+                          xbt_dict_t cpu_properties)=0;
 
   void updateActionsStateLazy(double now, double delta);
   void updateActionsStateFull(double now, double delta);
@@ -96,7 +103,7 @@ public:
 * @brief SURF cpu resource interface class
 * @details A Cpu represent a cpu associated to a workstation
 */
-class Cpu : public Resource {
+XBT_PUBLIC_CLASS Cpu : public Resource {
 public:
   /**
    * @brief Cpu constructor
@@ -105,7 +112,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 +126,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 +144,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 +152,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 +160,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 +168,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 +178,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 getCurrentPowerPeak();
 
 
   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);
@@ -210,17 +217,12 @@ public:
  * @brief SURF Cpu action interface class
  * @details A CpuAction represent the execution of code on a Cpu
  */
-class CpuAction : public Action {
+XBT_PUBLIC_CLASS CpuAction : public Action {
 friend CpuPtr getActionCpu(CpuActionPtr action);
 public:
   /**
    * @brief CpuAction constructor
-   */
-  CpuAction() {};
-
-  /**
-   * @brief CpuAction constructor
-   * 
+   *
    * @param model The CpuModel associated to this CpuAction
    * @param cost [TODO]
    * @param failed [TODO]
@@ -230,7 +232,7 @@ public:
 
   /**
    * @brief CpuAction constructor
-   * 
+   *
    * @param model The CpuModel associated to this CpuAction
    * @param cost [TODO]
    * @param failed [TODO]
@@ -242,7 +244,7 @@ public:
   /**
    * @brief Set the affinity of the current CpuAction
    * @details [TODO]
-   * 
+   *
    * @param cpu [TODO]
    * @param mask [TODO]
    */
index fc07dd5..5c083d5 100644 (file)
@@ -119,7 +119,7 @@ double CpuTiTgmr::integrate(double a, double b)
 
 /**
  * \brief Auxiliary function to calculate the integral between a and b.
- *     It simply calculates the integral at point a and b and returns the difference 
+ *     It simply calculates the integral at point a and b and returns the difference
  *   between them.
  * \param trace    Trace structure
  * \param a        Initial point
@@ -148,7 +148,7 @@ double CpuTiTrace::integrateSimplePoint(double a)
       ("a %f ind %d integral %f ind + 1 %f ind %f time +1 %f time %f",
        a, ind, integral, p_integral[ind + 1], p_integral[ind],
        p_timePoints[ind + 1], p_timePoints[ind]);
-  double_update(&a_aux, p_timePoints[ind]);
+  double_update(&a_aux, p_timePoints[ind], sg_maxmin_precision*sg_surf_precision);
   if (a_aux > 0)
     integral +=
         ((p_integral[ind + 1] -
@@ -257,7 +257,7 @@ double CpuTiTgmr::solveSomewhatSimple(double a, double amount)
  *  It returns the date when the requested amount of flops is available
  * \param trace    Trace structure
  * \param a        Initial point
- * \param amount  Amount of flops 
+ * \param amount  Amount of flops
  * \return The date when amount is available.
 */
 double CpuTiTrace::solveSimple(double a, double amount)
@@ -347,7 +347,7 @@ CpuTiTgmr::CpuTiTgmr(tmgr_trace_t power_trace, double value)
 
 /**
  * \brief Binary search in array.
- *  It returns the first point of the interval in which "a" is. 
+ *  It returns the first point of the interval in which "a" is.
  * \param array    Array
  * \param a        Value to search
  * \param low     Low bound to search in array
@@ -379,18 +379,10 @@ int CpuTiTrace::binarySearch(double *array, double a, int low, int high)
  * CallBacks *
  *************/
 
-static void parse_cpu_ti_init(sg_platf_host_cbarg_t host){
-  ((CpuTiModelPtr)surf_cpu_model_pm)->parseInit(host);
-}
-
-static void add_traces_cpu_ti(){
-  surf_cpu_model_pm->addTraces();
-}
-
 static void cpu_ti_define_callbacks()
 {
-  sg_platf_host_add_cb(parse_cpu_ti_init);
-  sg_platf_postparse_add_cb(add_traces_cpu_ti);
+  sg_platf_host_add_cb(parse_cpu_init);
+  sg_platf_postparse_add_cb(add_traces_cpu);
 }
 
 /*********
@@ -435,20 +427,7 @@ CpuTiModel::~CpuTiModel()
   xbt_heap_free(p_tiActionHeap);
 }
 
-void CpuTiModel::parseInit(sg_platf_host_cbarg_t host)
-{
-  createResource(host->id,
-        host->power_peak,
-        host->pstate,
-        host->power_scale,
-        host->power_trace,
-        host->core_amount,
-        host->initial_state,
-        host->state_trace,
-        host->properties);
-}
-
-CpuTiPtr CpuTiModel::createResource(const char *name,
+CpuPtr CpuTiModel::createResource(const char *name,
                               xbt_dynar_t powerPeak,
                               int pstate,
                            double powerScale,
@@ -571,8 +550,8 @@ CpuTi::CpuTi(CpuTiModelPtr model, const char *name, xbt_dynar_t powerPeak,
   setState(stateInitial);
   m_powerScale = powerScale;
   m_core = core;
-  tmgr_trace_t empty_trace;            
-  s_tmgr_event_t val;          
+  tmgr_trace_t empty_trace;
+  s_tmgr_event_t val;
   xbt_assert(core==1,"Multi-core not handled with this model yet");
   XBT_DEBUG("power scale %f", powerScale);
   p_availTrace = new CpuTiTgmr(powerTrace, powerScale);
@@ -593,7 +572,7 @@ CpuTi::CpuTi(CpuTiModelPtr model, const char *name, xbt_dynar_t powerPeak,
   if (stateTrace)
     p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, static_cast<ResourcePtr>(this));
   if (powerTrace && xbt_dynar_length(powerTrace->s_list.event_list) > 1) {
-    // add a fake trace event if periodicity == 0 
+    // add a fake trace event if periodicity == 0
     xbt_dynar_get_cpy(powerTrace->s_list.event_list,
                       xbt_dynar_length(powerTrace->s_list.event_list) - 1, &val);
     if (val.delta == 0) {
@@ -835,7 +814,7 @@ CpuActionPtr CpuTi::execute(double size)
 CpuActionPtr CpuTi::sleep(double duration)
 {
   if (duration > 0)
-    duration = MAX(duration, MAXMIN_PRECISION);
+    duration = MAX(duration, sg_surf_precision);
 
   XBT_IN("(%s,%g)", getName(), duration);
   CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(getModel()), 1.0, getState() != SURF_RESOURCE_ON, this);
@@ -886,7 +865,7 @@ void CpuTiAction::updateIndexHeap(int i)
 
 void CpuTiAction::setState(e_surf_action_state_t state)
 {
-  Action::setState(state);
+  CpuAction::setState(state);
   xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
 }
 
index b44ff97..1361b0e 100644 (file)
@@ -50,7 +50,7 @@ private:
 };
 
 enum trace_type {
-  
+
   TRACE_FIXED,                /*< Trace fixed, no availability file */
   TRACE_DYNAMIC               /*< Dynamic, availability file disponible */
 };
@@ -86,7 +86,7 @@ public:
   ~CpuTiModel();
 
   void parseInit(sg_platf_host_cbarg_t host);
-  CpuTiPtr createResource(const char *name,  xbt_dynar_t powerPeak,
+  CpuPtr createResource(const char *name,  xbt_dynar_t powerPeak,
                           int pstate, double power_scale,
                           tmgr_trace_t power_trace, int core,
                           e_surf_resource_state_t state_initial,
@@ -121,7 +121,7 @@ public:
        xbt_dict_t properties) ;
   ~CpuTi();
 
-  void updateState(tmgr_trace_event_t event_type, double value, double date);  
+  void updateState(tmgr_trace_event_t event_type, double value, double date);
   void updateActionsFinishTime(double now);
   bool isUsed();
   void printCpuTiModel();
@@ -159,7 +159,6 @@ class CpuTiAction: public CpuAction {
   friend void CpuTi::updateRemainingAmount(double now);//FIXME
 
 public:
-  CpuTiAction() {};
   CpuTiAction(CpuTiModelPtr model, double cost, bool failed,
                                 CpuTiPtr cpu);
 
index 1e9c3f7..2affd8d 100644 (file)
@@ -146,7 +146,7 @@ void bottleneck_solve(lmm_system_t sys)
                  cnst, cnst->remaining, elem->variable,
                  elem->variable->mu);
           double_update(&(cnst->remaining),
-                        elem->value * elem->variable->mu);
+                        elem->value * elem->variable->mu, sg_maxmin_precision);
         } else {
           XBT_DEBUG
               ("\tNon-Shared variable. Update constraint usage of %p (%g) with variable %p by %g",
@@ -158,7 +158,7 @@ void bottleneck_solve(lmm_system_t sys)
         XBT_DEBUG("\tUpdate constraint %p (%g) by %g",
                cnst, cnst->remaining, cnst->usage);
 
-        double_update(&(cnst->remaining), cnst->usage);
+        double_update(&(cnst->remaining), cnst->usage, sg_maxmin_precision);
       }
 
       XBT_DEBUG("\tRemaining for %p : %g", cnst, cnst->remaining);
index c62055b..64fc0ad 100644 (file)
@@ -63,7 +63,7 @@ static int __check_feasible(xbt_swag_t cnst_list, xbt_swag_t var_list,
       tmp += var->value;
     }
 
-    if (double_positive(tmp - cnst->bound)) {
+    if (double_positive(tmp - cnst->bound, sg_maxmin_precision)) {
       if (warn)
         XBT_WARN
             ("The link (%p) is over-used. Expected less than %f and got %f",
@@ -84,7 +84,7 @@ static int __check_feasible(xbt_swag_t cnst_list, xbt_swag_t var_list,
     XBT_DEBUG("Checking feasability for variable (%p): sat = %f mu = %f", var,
            var->value - var->bound, var->mu);
 
-    if (double_positive(var->value - var->bound)) {
+    if (double_positive(var->value - var->bound, sg_maxmin_precision)) {
       if (warn)
         XBT_WARN
             ("The variable (%p) is too large. Expected less than %f and got %f",
@@ -171,7 +171,7 @@ void lagrange_solve(lmm_system_t sys)
    * Lagrange Variables.
    */
   int max_iterations = 100;
-  double epsilon_min_error = MAXMIN_PRECISION;
+  double epsilon_min_error = 0.00001; /* this is the precision on the objective function so it's none of the configurable values and this value is the legacy one */
   double dichotomy_min_error = 1e-14;
   double overall_modification = 1;
 
index cb60858..b40d829 100644 (file)
@@ -21,6 +21,7 @@ typedef struct s_dyn_light {
 } s_dyn_light_t, *dyn_light_t;
 
 XBT_EXPORT_NO_IMPORT(double) sg_maxmin_precision = 0.00001;
+XBT_EXPORT_NO_IMPORT(double) sg_surf_precision   = 0.00001;
 
 static void *lmm_variable_mallocator_new_f(void);
 static void lmm_variable_mallocator_free_f(void *var);
@@ -561,7 +562,7 @@ void lmm_print(lmm_system_t sys)
     }
     XBT_DEBUG("%s", trace_buf);
     trace_buf[0] = '\000';
-    xbt_assert(!double_positive(sum - cnst->bound),
+    xbt_assert(!double_positive(sum - cnst->bound, sg_maxmin_precision),
                 "Incorrect value (%f is not smaller than %f): %g",
                 sum, cnst->bound, sum - cnst->bound);
   }
@@ -573,7 +574,7 @@ void lmm_print(lmm_system_t sys)
     if (var->bound > 0) {
       XBT_DEBUG("'%d'(%f) : %f (<=%f)", var->id_int, var->weight, var->value,
              var->bound);
-      xbt_assert(!double_positive(var->value - var->bound),
+      xbt_assert(!double_positive(var->value - var->bound, sg_maxmin_precision),
                   "Incorrect value (%f is not smaller than %f",
                   var->value, var->bound);
     } else {
@@ -702,10 +703,14 @@ void lmm_solve(lmm_system_t sys)
 
       if (min_bound < 0) {
         var->value = min_usage / var->weight;
+        XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value);
       } else {
-        if (min_bound == var->bound)
+        if (min_bound == var->bound) {
           var->value = var->bound;
+          XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value);
+        }
         else {
+          XBT_DEBUG("Do not consider %p (%d)\n", var, var->id_int);
           xbt_swag_remove(var, var_list);
           continue;
         }
@@ -720,8 +725,8 @@ void lmm_solve(lmm_system_t sys)
         elem = &var->cnsts[i];
         cnst = elem->constraint;
         if (cnst->shared) {
-          double_update(&(cnst->remaining), elem->value * var->value);
-          double_update(&(cnst->usage), elem->value / var->weight);
+          double_update(&(cnst->remaining), elem->value * var->value, sg_maxmin_precision);
+          double_update(&(cnst->usage), elem->value / var->weight, sg_maxmin_precision);
           if(cnst->usage<=0 || cnst->remaining<=0) {
             if (cnst->cnst_light) {
               int index = (cnst->cnst_light-cnst_light_tab);
@@ -742,8 +747,8 @@ void lmm_solve(lmm_system_t sys)
           elem_list = &(cnst->element_set);
           xbt_swag_foreach(_elem, elem_list) {
                elem = (lmm_element_t)_elem;
-            if (elem->variable->weight <= 0 || elem->variable->value > 0)
-              break;
+            if (elem->variable->weight <= 0) break;
+            if (elem->variable->value > 0) continue;
             if (elem->value > 0)
               cnst->usage = MAX(cnst->usage, elem->value / elem->variable->weight);
           }
@@ -906,7 +911,7 @@ XBT_INLINE lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t
 #ifdef HAVE_LATENCY_BOUND_TRACKING
 XBT_INLINE int lmm_is_variable_limited_by_latency(lmm_variable_t var)
 {
-  return (double_equals(var->bound, var->value));
+  return (double_equals(var->bound, var->value, sg_maxmin_precision));
 }
 #endif
 
index b80ddfd..73bc407 100644 (file)
@@ -315,7 +315,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
 {
   NetworkCm02ActionPtr action;
   while ((xbt_heap_size(p_actionHeap) > 0)
-         && (double_equals(xbt_heap_maxkey(p_actionHeap), now))) {
+         && (double_equals(xbt_heap_maxkey(p_actionHeap), now, sg_surf_precision))) {
     action = (NetworkCm02ActionPtr) xbt_heap_pop(p_actionHeap);
     XBT_DEBUG("Something happened to action %p", action);
 #ifdef HAVE_TRACING
@@ -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 *
  **********/
@@ -631,13 +638,13 @@ void NetworkCm02Action::updateRemainingLazy(double now)
 
   if (m_remains > 0) {
     XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate);
-    double_update(&(m_remains), m_lastValue * delta);
+    double_update(&(m_remains), m_lastValue * delta, sg_maxmin_precision*sg_surf_precision);
 
     XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains);
   }
 
   if (m_maxDuration != NO_MAX_DURATION)
-    double_update(&m_maxDuration, delta);
+    double_update(&m_maxDuration, delta, sg_surf_precision);
 
   if (m_remains <= 0 &&
       (lmm_get_variable_weight(getVariable()) > 0)) {
index b4d4048..c31c1c9 100644 (file)
@@ -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());
 };
 
 
index d9f36dd..c331629 100644 (file)
@@ -58,7 +58,7 @@ void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
        action = static_cast<NetworkConstantActionPtr>(&*it);
     if (action->m_latency > 0) {
       if (action->m_latency > delta) {
-        double_update(&(action->m_latency), delta);
+        double_update(&(action->m_latency), delta, sg_surf_precision);
       } else {
         action->m_latency = 0.0;
       }
@@ -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;
 }
 
index 49e4c6d..39195ef 100644 (file)
@@ -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_ */
index 8988357..f85abe1 100644 (file)
@@ -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;
+XBT_PUBLIC_DATA( 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;
+XBT_PUBLIC_DATA( 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;
+XBT_PUBLIC_DATA( 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;
+XBT_PUBLIC_DATA( 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)`
+ */
+XBT_PUBLIC_DATA( 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]
index 4fecb0f..f566367 100644 (file)
@@ -1,7 +1,9 @@
-/* Copyright (c) 2007-2013. The SimGrid Team.
- *
- * This program is free software; you can redistribute it and/or modify it
+/* Copyright (c) 2007-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
+
 #include "network_ns3.hpp"
 #include "surf_private.h"
 #include "simgrid/sg_config.h"
@@ -331,6 +333,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 +430,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 +443,6 @@ NetworkNS3Link::~NetworkNS3Link()
 void NetworkNS3Link::updateState(tmgr_trace_event_t event_type, double value, double date)
 {
 
-}
-double NetworkNS3Link::getLatency()
-{
-
-}
-double NetworkNS3Link::getBandwidth()
-{
-
 }
 
 /**********
index f5389b8..2b28eed 100644 (file)
@@ -1,7 +1,9 @@
 /* Copyright (c) 2004-2014. The SimGrid Team.
- *
- * This program is free software; you can redistribute it and/or modify it
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
+
 #include "network_interface.hpp"
 #include "surf/ns3/ns3_interface.h"
 
@@ -61,8 +63,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;
index e9dea0e..68174da 100644 (file)
@@ -40,7 +40,7 @@ static xbt_dynar_t parse_factor(const char *smpi_coef_string)
 
     radical_elements2 = xbt_str_split(value, ":");
     if (xbt_dynar_length(radical_elements2) != 2)
-      xbt_die("Malformed radical for smpi factor!");
+      surf_parse_error("Malformed radical for smpi factor!");
     fact.factor = atol(xbt_dynar_get_as(radical_elements2, 0, char *));
     fact.value = atof(xbt_dynar_get_as(radical_elements2, 1, char *));
     xbt_dynar_push_as(smpi_factor, s_smpi_factor_t, fact);
index 4c3d591..900f77b 100644 (file)
@@ -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();
index db6b193..8aaf466 100644 (file)
@@ -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()
 
index 993ac0b..4fd94ac 100644 (file)
@@ -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];
 
index 90e14c7..28de019 100644 (file)
@@ -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 *
@@ -98,8 +98,9 @@ xbt_dict_t Storage::parseContent(char *filename)
   FILE *file = NULL;
 
   file = surf_fopen(filename, "r");
-  xbt_assert(file != NULL, "Cannot open file '%s' (path=%s)", filename,
-              xbt_str_join(surf_path, ":"));
+  if (file == NULL)
+    xbt_die("Cannot open file '%s' (path=%s)", filename,
+            xbt_str_join(surf_path, ":"));
 
   char *line = NULL;
   size_t len = 0;
@@ -107,10 +108,9 @@ xbt_dict_t Storage::parseContent(char *filename)
   char path[1024];
   sg_size_t size;
 
-
   while ((read = xbt_getline(&line, &len, file)) != -1) {
     if (read){
-    if(sscanf(line,"%s %llu", path, &size) == 2) {
+      if(sscanf(line,"%s %llu", path, &size) == 2) {
         m_usedSize += size;
         sg_size_t *psize = xbt_new(sg_size_t, 1);
         *psize = size;
@@ -138,14 +138,14 @@ 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()
 {
   /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */
-  /*surf_action_t action = storage_action_execute(storage,0, LS);*/
 
   xbt_dict_t content_dict = xbt_dict_new_homogeneous(NULL);
   xbt_dict_cursor_t cursor = NULL;
@@ -162,23 +162,33 @@ sg_size_t Storage::getSize(){
   return m_size;
 }
 
+sg_size_t Storage::getFreeSize(){
+  return m_size - m_usedSize;
+}
+
+sg_size_t Storage::getUsedSize(){
+  return m_usedSize;
+}
+
 /**********
  * Action *
  **********/
 StorageAction::StorageAction(ModelPtr model, double cost, bool failed,
-                                    StoragePtr storage, e_surf_action_storage_type_t type)
+                             StoragePtr storage, e_surf_action_storage_type_t type)
 : Action(model, cost, failed)
-, m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL)
-{
+, m_type(type), p_storage(storage), p_file(NULL){
+  progress = 0;
 };
 
 StorageAction::StorageAction(ModelPtr model, double cost, bool failed, lmm_variable_t var,
-                                    StoragePtr storage, e_surf_action_storage_type_t type)
+                             StoragePtr storage, e_surf_action_storage_type_t type)
   : Action(model, cost, failed, var)
-  , m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL) {
+  , m_type(type), p_storage(storage), p_file(NULL){
+  progress = 0;
 }
 
 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);
 }
index d70771c..61ef3ab 100644 (file)
@@ -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,34 +176,25 @@ 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
    */
   virtual StorageActionPtr close(surf_file_t fd)=0;
 
-  /**
-   * @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
-   */
-  virtual StorageActionPtr ls(const char *path)=0;
-
   /**
    * @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,35 +203,42 @@ 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
    */
   virtual StorageActionPtr write(surf_file_t fd, sg_size_t size)=0;
 
-  /**
-   * @brief Rename a path
-   * 
-   * @param src The old path
-   * @param dest The new path
-   */
-  virtual void rename(const char *src, const char *dest)=0;
-
   /**
    * @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();
 
+  /**
+   * @brief Get the available size in bytes of the current Storage
+   *
+   * @return The available size in bytes of the current Storage
+   */
+  virtual sg_size_t getFreeSize();
+
+  /**
+   * @brief Get the used size in bytes of the current Storage
+   *
+   * @return The used size in bytes of the current Storage
+   */
+  virtual sg_size_t getUsedSize();
+
+
   xbt_dict_t parseContent(char *filename);
 
   xbt_dynar_t p_writeActions;
@@ -261,8 +259,7 @@ typedef enum {
   WRITE,  /**< Write in a file */
   STAT,   /**< Stat a file */
   OPEN,   /**< Open a file */
-  CLOSE,  /**< Close a file */
-  LS      /**< List directory contents */
+  CLOSE  /**< Close a file */
 } e_surf_action_storage_type_t;
 
 /** @ingroup SURF_storage_interface
@@ -272,12 +269,7 @@ class StorageAction : public Action {
 public:
   /**
    * @brief StorageAction constructor
-   */
-  StorageAction() : m_type(READ) {};//FIXME:REMOVE
-
-  /**
-   * @brief StorageAction constructor
-   * 
+   *
    * @param model The StorageModel associated to this StorageAction
    * @param cost The cost of this  NetworkAction in [TODO]
    * @param failed [description]
@@ -289,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]
@@ -305,7 +297,7 @@ public:
   e_surf_action_storage_type_t m_type;
   StoragePtr p_storage;
   surf_file_t p_file;
-  xbt_dict_t p_lsDict;
+  double progress;
 };
 
 typedef struct s_storage_type {
index c5395d6..d0bc408 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "storage_n11.hpp"
 #include "surf_private.h"
-
+#include <math.h> /*ceil*/
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_storage);
 
 static int storage_selective_update = 0;
@@ -305,17 +305,34 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
      ; it != itend ; it=itNext) {
     ++itNext;
     action = static_cast<StorageActionPtr>(&*it);
+
     if(action->m_type == WRITE)
     {
       // Update the disk usage
-     // Update the file size
-     // For each action of type write
-      double rate = lmm_variable_getvalue(action->getVariable());
-      /* Hack to avoid rounding differences between x86 and x86_64
-       * (note that the next sizes are of type sg_size_t). */
-      long incr = delta * rate + MAXMIN_PRECISION;
+      // Update the file size
+      // For each action of type write
+      double current_progress =
+          delta * lmm_variable_getvalue(action->getVariable());
+      long int incr = current_progress;
+
+      XBT_DEBUG("%s:\n\t progress =  %.2f, current_progress = %.2f, "
+                "incr = %ld, lrint(1) = %ld, lrint(2) = %ld",
+                action->p_file->name,
+                action->progress,  current_progress, incr,
+                lrint(action->progress + current_progress),
+                lrint(action->progress)+ incr);
+
+      /* Take care of rounding error accumulation */
+      if (lrint(action->progress + current_progress) >
+          lrint(action->progress)+ incr)
+        incr++;
+
+      action->progress +=current_progress;
+
       action->p_storage->m_usedSize += incr; // disk usage
-      action->p_file->size += incr; // file size
+      action->p_file->current_position+= incr; // current_position
+      //  which becomes the new file size
+      action->p_file->size = action->p_file->current_position ;
 
       sg_size_t *psize = xbt_new(sg_size_t,1);
       *psize = action->p_file->size;
@@ -361,61 +378,17 @@ StorageN11::StorageN11(StorageModelPtr model, const char* name, xbt_dict_t prope
   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
 }
 
-StorageActionPtr StorageN11::ls(const char* path)
-{
-  StorageActionPtr action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, LS);
-
-  action->p_lsDict = NULL;
-  xbt_dict_t ls_dict = xbt_dict_new_homogeneous(xbt_free);
-
-  char* key;
-  sg_size_t size = 0;
-  xbt_dict_cursor_t cursor = NULL;
-
-  xbt_dynar_t dyn = NULL;
-  char* file = NULL;
-
-  // for each file in the storage content
-  xbt_dict_foreach(p_content,cursor,key,size){
-    // Search if file start with the prefix 'path'
-    if(xbt_str_start_with(key,path)){
-      file = &key[strlen(path)];
-
-      // Split file with '/'
-      dyn = xbt_str_split(file,"/");
-      file = xbt_dynar_get_as(dyn,0,char*);
-
-      // file
-      if(xbt_dynar_length(dyn) == 1){
-        sg_size_t *psize = xbt_new(sg_size_t, 1);
-        *psize=size;
-        xbt_dict_set(ls_dict, file, psize, NULL);
-      }
-      // Directory
-      else
-      {
-        // if directory does not exist yet in the dictionary
-        if(!xbt_dict_get_or_null(ls_dict,file))
-          xbt_dict_set(ls_dict,file,NULL,NULL);
-      }
-      xbt_dynar_free(&dyn);
-    }
-  }
-
-  action->p_lsDict = ls_dict;
-  return action;
-}
-
 StorageActionPtr StorageN11::open(const char* mount, const char* path)
 {
   XBT_DEBUG("\tOpen file '%s'",path);
+
   sg_size_t size, *psize;
   psize = (sg_size_t*) xbt_dict_get_or_null(p_content, path);
   // if file does not exist create an empty file
   if(psize)
     size = *psize;
   else {
-       psize = xbt_new(sg_size_t,1);
+    psize = xbt_new(sg_size_t,1);
     size = 0;
     *psize = size;
     xbt_dict_set(p_content, path, psize, NULL);
@@ -429,6 +402,7 @@ StorageActionPtr StorageN11::open(const char* mount, const char* path)
 
   StorageActionPtr action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, OPEN);
   action->p_file = file;
+
   return action;
 }
 
@@ -456,12 +430,12 @@ StorageActionPtr StorageN11::close(surf_file_t fd)
 
 StorageActionPtr StorageN11::read(surf_file_t fd, sg_size_t size)
 {
-  if(size > fd->size){
-    size = fd->size;
+  if(fd->current_position + size > fd->size){
+    size = fd->size - fd->current_position;
     fd->current_position = fd->size;
   }
   else
-       fd->current_position += size;
+    fd->current_position += size;
 
   StorageActionPtr action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, READ);
   return action;
@@ -474,29 +448,16 @@ StorageActionPtr StorageN11::write(surf_file_t fd, sg_size_t size)
 
   StorageActionPtr action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, WRITE);
   action->p_file = fd;
-  fd->current_position += size;
-  // If the storage is full
+  /* Substract the part of the file that might disappear from the used sized on
+   * the storage element */
+  m_usedSize -= (fd->size - fd->current_position);
+  // If the storage is full before even starting to write
   if(m_usedSize==m_size) {
     action->setState(SURF_ACTION_FAILED);
   }
   return action;
 }
 
-void StorageN11::rename(const char *src, const char *dest)
-{
-  sg_size_t *psize, *new_psize;
-  psize = (sg_size_t*) xbt_dict_get_or_null(p_content,src);
-  new_psize = xbt_new(sg_size_t, 1);
-  *new_psize = *psize;
-  if (psize){// src file exists
-    xbt_dict_remove(p_content, src);
-    xbt_dict_set(p_content, dest, new_psize,NULL);
-    XBT_DEBUG("Change file name from %s to %s, size '%llu'",src, dest, *psize);
-  }
-  else
-    XBT_DEBUG("File %s doesn't exist",src);
-}
-
 /**********
  * Action *
  **********/
@@ -513,15 +474,14 @@ StorageN11Action::StorageN11Action(ModelPtr model, double cost, bool failed, Sto
   case OPEN:
   case CLOSE:
   case STAT:
-  case LS:
     break;
   case READ:
     lmm_expand(model->getMaxminSystem(), storage->p_constraintRead,
-                  getVariable(), 1.0);
+               getVariable(), 1.0);
     break;
   case WRITE:
     lmm_expand(model->getMaxminSystem(), storage->p_constraintWrite,
-                  getVariable(), 1.0);
+               getVariable(), 1.0);
     ActionPtr action = this;
     xbt_dynar_push(storage->p_writeActions, &action);
     ref();
index 93f4f3a..d479002 100644 (file)
@@ -70,7 +70,6 @@ public:
 
 class StorageN11Action : public StorageAction {
 public:
-       StorageN11Action() {}; //FIXME:REMOVE
   StorageN11Action(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type);
   void suspend();
   int unref();
index 9d364aa..6ee28a1 100644 (file)
@@ -360,8 +360,8 @@ xbt_dynar_t surf_workstation_get_attached_storage_list(surf_resource_t workstati
   return get_casted_workstation(workstation)->getAttachedStorageList();
 }
 
-surf_action_t surf_workstation_open(surf_resource_t workstation, const char* mount, const char* path){
-  return get_casted_workstation(workstation)->open(mount, path);
+surf_action_t surf_workstation_open(surf_resource_t workstation, const char* fullpath){
+  return get_casted_workstation(workstation)->open(fullpath);
 }
 
 surf_action_t surf_workstation_close(surf_resource_t workstation, surf_file_t fd){
@@ -372,10 +372,6 @@ int surf_workstation_unlink(surf_resource_t workstation, surf_file_t fd){
   return get_casted_workstation(workstation)->unlink(fd);
 }
 
-surf_action_t surf_workstation_ls(surf_resource_t workstation, const char* mount, const char *path){
-  return get_casted_workstation(workstation)->ls(mount, path);
-}
-
 size_t surf_workstation_get_size(surf_resource_t workstation, surf_file_t fd){
   return get_casted_workstation(workstation)->getSize(fd);
 }
@@ -392,14 +388,6 @@ xbt_dynar_t surf_workstation_get_info(surf_resource_t resource, surf_file_t fd){
   return get_casted_workstation(resource)->getInfo(fd);
 }
 
-sg_size_t surf_workstation_get_free_size(surf_resource_t resource, const char* name){
-  return get_casted_workstation(resource)->getFreeSize(name);
-}
-
-sg_size_t surf_workstation_get_used_size(surf_resource_t resource, const char* name){
-  return get_casted_workstation(resource)->getUsedSize(name);
-}
-
 size_t surf_workstation_file_tell(surf_resource_t workstation, surf_file_t fd){
   return get_casted_workstation(workstation)->fileTell(fd);
 }
@@ -408,6 +396,10 @@ int surf_workstation_file_seek(surf_resource_t workstation, surf_file_t fd, sg_s
   return get_casted_workstation(workstation)->fileSeek(fd, offset, origin);
 }
 
+int surf_workstation_file_move(surf_resource_t workstation, surf_file_t fd, const char* fullpath){
+  return get_casted_workstation(workstation)->fileMove(fd, fullpath);
+}
+
 xbt_dynar_t surf_workstation_get_vms(surf_resource_t resource){
   return get_casted_workstation(resource)->getVms();
 }
@@ -476,12 +468,16 @@ sg_size_t surf_storage_get_size(surf_resource_t resource){
   return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->getSize();
 }
 
-const char* surf_storage_get_host(surf_resource_t resource){
-  return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->p_attach;
+sg_size_t surf_storage_get_free_size(surf_resource_t resource){
+  return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->getFreeSize();
+}
+
+sg_size_t surf_storage_get_used_size(surf_resource_t resource){
+  return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->getUsedSize();
 }
 
-void surf_storage_rename(surf_resource_t resource, const char* src, const char* dest){
-  static_cast<StoragePtr>(surf_storage_resource_priv(resource))->rename(src, dest);
+const char* surf_storage_get_host(surf_resource_t resource){
+  return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->p_attach;
 }
 
 surf_action_t surf_cpu_execute(surf_resource_t cpu, double size){
@@ -561,7 +557,3 @@ double surf_network_action_get_latency_limited(surf_action_t action) {
 surf_file_t surf_storage_action_get_file(surf_action_t action){
   return static_cast<StorageActionPtr>(action)->p_file;
 }
-
-xbt_dict_t surf_storage_action_get_ls_dict(surf_action_t action){
-  return static_cast<StorageActionPtr>(action)->p_lsDict;
-}
index 6be998b..7cf6ef8 100644 (file)
@@ -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
@@ -520,7 +520,7 @@ double Model::shareResourcesLazy(double now)
 {
   ActionPtr action = NULL;
   double min = -1;
-  double value;
+  double share, time_to_completion;
 
   XBT_DEBUG
       ("Before share resources, the size of modified actions set is %zd",
@@ -533,29 +533,30 @@ double Model::shareResourcesLazy(double now)
        p_modifiedSet->size());
 
   while(!p_modifiedSet->empty()) {
-       action = &(p_modifiedSet->front());
-       p_modifiedSet->pop_front();
+    action = &(p_modifiedSet->front());
+    p_modifiedSet->pop_front();
     int max_dur_flag = 0;
 
     if (action->getStateSet() != p_runningActionSet)
       continue;
 
     /* bogus priority, skip it */
-    if (action->getPriority() <= 0)
+    if (action->getPriority() <= 0 || action->getHat()==LATENCY)
       continue;
 
     action->updateRemainingLazy(now);
 
     min = -1;
-    value = lmm_variable_getvalue(action->getVariable());
-    if (value > 0) {
+    time_to_completion = -1;
+    share = lmm_variable_getvalue(action->getVariable());
+
+    if (share > 0) {
       if (action->getRemains() > 0) {
-        value = action->getRemainsNoUpdate() / value;
-        min = now + value;
+        time_to_completion = action->getRemainsNoUpdate() / share;
       } else {
-        value = 0.0;
-        min = now;
+        time_to_completion = 0.0;
       }
+      min = now + time_to_completion; // when the task will complete if nothing changes
     }
 
     if ((action->getMaxDuration() != NO_MAX_DURATION)
@@ -563,12 +564,15 @@ double Model::shareResourcesLazy(double now)
             || action->getStartTime() +
             action->getMaxDuration() < min)) {
       min = action->getStartTime() +
-          action->getMaxDuration();
+          action->getMaxDuration();  // when the task will complete anyway because of the deadline if any
       max_dur_flag = 1;
     }
 
-    XBT_DEBUG("Action(%p) Start %f Finish %f Max_duration %f", action,
-        action->getStartTime(), now + value,
+
+    XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->getVariable()->id_int);
+
+    XBT_DEBUG("Action(%p) Start %f. May finish at %f (got a share of %f). Max_duration %f", action,
+        action->getStartTime(), min, share,
         action->getMaxDuration());
 
     if (min != -1) {
@@ -755,26 +759,29 @@ const char *surf_action_state_names[6] = {
   "SURF_ACTION_NOT_IN_THE_SYSTEM"
 };
 
-Action::Action()
-: m_refcount(1)
-{}
+void Action::initialize(ModelPtr model, double cost, bool failed,
+                        lmm_variable_t var)
+{
+  m_priority = 1.0;
+  m_refcount = 1;
+  m_remains = cost;
+  m_maxDuration = NO_MAX_DURATION;
+  m_finish = -1.0;
+  m_failed = failed;
+  m_start = surf_get_clock();
+  m_cost = cost;
+  p_model = model;
+  p_data = NULL;
+  p_variable = var;
+  m_lastValue = 0;
+  m_lastUpdate = 0;
+  m_suspended = false;
+  m_hat = NOTSET;
+}
 
 Action::Action(ModelPtr model, double cost, bool failed)
- : m_priority(1.0)
- , m_refcount(1)
- , m_remains(cost)
- , m_maxDuration(NO_MAX_DURATION)
- , m_finish(-1.0)
- , m_failed(failed)
- , m_start(surf_get_clock())
- , m_cost(cost)
- , p_model(model)
- , p_data(NULL)
- , p_variable(NULL)
- , m_lastValue(0)
- , m_lastUpdate(0)
- , m_suspended(false)
 {
+  initialize(model, cost, failed);
   #ifdef HAVE_TRACING
     p_category = NULL;
   #endif
@@ -789,21 +796,8 @@ Action::Action(ModelPtr model, double cost, bool failed)
 }
 
 Action::Action(ModelPtr model, double cost, bool failed, lmm_variable_t var)
- : m_priority(1.0)
- , m_refcount(1)
- , m_remains(cost)
- , m_maxDuration(NO_MAX_DURATION)
- , m_finish(-1.0)
- , m_failed(failed)
- , m_start(surf_get_clock())
- , m_cost(cost)
- , p_model(model)
- , p_data(NULL)
- , p_variable(var)
- , m_lastValue(0)
- , m_lastUpdate(0)
- , m_suspended(false)
 {
+  initialize(model, cost, failed, var);
   #ifdef HAVE_TRACING
     p_category = NULL;
   #endif
@@ -872,8 +866,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();
 }
 
@@ -1053,7 +1047,7 @@ void Action::updateRemainingLazy(double now)
 
   if (m_remains > 0) {
     XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate);
-    double_update(&m_remains, m_lastValue * delta);
+    double_update(&m_remains, m_lastValue * delta, sg_surf_precision*sg_maxmin_precision);
 
 #ifdef HAVE_TRACING
     if (getModel() == static_cast<ModelPtr>(surf_cpu_model_pm) && TRACE_is_enabled()) {
@@ -1067,7 +1061,7 @@ void Action::updateRemainingLazy(double now)
   if(getModel() == static_cast<ModelPtr>(surf_network_model))
   {
     if (m_maxDuration != NO_MAX_DURATION)
-      double_update(&m_maxDuration, delta);
+      double_update(&m_maxDuration, delta, sg_surf_precision);
 
     //FIXME: duplicated code
     if ((m_remains <= 0) &&
index 6be1e2c..a636b30 100644 (file)
@@ -74,7 +74,7 @@ typedef Model* ModelPtr;
 
 //class Resource;
 typedef Resource* ResourcePtr;
-                       
+
 //class Action;
 typedef Action* ActionPtr;
 
@@ -102,8 +102,8 @@ enum heap_action_type{
 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail; 
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth; 
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
 
 /*********
@@ -115,58 +115,58 @@ XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
  * @brief SURF model interface class
  * @details A model is an object which handle the interactions between its Resources and its Actions
  */
-class Model {
+XBT_PUBLIC_CLASS Model {
 public:
-  /** 
+  /**
    * @brief Model constructor
-   * 
+   *
    * @param name the name of the model
    */
   Model(const char *name);
 
-  /** 
+  /**
    * @brief Model destructor
    */
   virtual ~Model();
 
   /**
    * @brief Get the name of the current Model
-   * 
+   *
    * @return The name of the current Model
    */
   const char *getName() {return p_name;}
 
   /**
-   * @brief Get the set of [actions](@ref Action) in *ready* state 
-   * 
-   * @return The set of [actions](@ref Action) in *ready* state 
+   * @brief Get the set of [actions](@ref Action) in *ready* state
+   *
+   * @return The set of [actions](@ref Action) in *ready* state
    */
   virtual ActionListPtr getReadyActionSet() {return p_readyActionSet;}
 
   /**
    * @brief Get the set of [actions](@ref Action) in *running* state
-   * 
+   *
    * @return The set of [actions](@ref Action) in *running* state
    */
   virtual ActionListPtr getRunningActionSet() {return p_runningActionSet;}
 
   /**
    * @brief Get the set of [actions](@ref Action) in *failed* state
-   * 
+   *
    * @return The set of [actions](@ref Action) in *failed* state
    */
   virtual ActionListPtr getFailedActionSet() {return p_failedActionSet;}
 
   /**
    * @brief Get the set of [actions](@ref Action) in *done* state
-   * 
+   *
    * @return The set of [actions](@ref Action) in *done* state
    */
   virtual ActionListPtr getDoneActionSet() {return p_doneActionSet;}
 
   /**
    * @brief Get the set of modified [actions](@ref Action)
-   * 
+   *
    * @return The set of modified [actions](@ref Action)
    */
   virtual ActionLmmListPtr getModifiedSet() {return p_modifiedSet;}
@@ -181,7 +181,7 @@ public:
   /**
    * @brief Get the update mechanism of the current Model
    * @see e_UM_t
-   * 
+   *
    * @return [description]
    */
   e_UM_t getUpdateMechanism() {return p_updateMechanism;}
@@ -189,17 +189,17 @@ public:
   /**
    * @brief Get Action heap
    * @details [TODO]
-   * 
+   *
    * @return The Action heap
    */
   xbt_heap_t getActionHeap() {return p_actionHeap;}
 
-  /** 
+  /**
    * @brief share the resources
-   * @details Share the resources between the actions 
-   * 
-   * @param now [TODO]
-   * @return the date of the next action will finish
+   * @details Share the resources between the actions
+   *
+   * @param now The current time of the simulation
+   * @return The delta of time till the next action will finish
    */
   virtual double shareResources(double now);
   virtual double shareResourcesLazy(double now);
@@ -210,10 +210,10 @@ public:
 
   /**
    * @brief Update state of actions
-   * @details [TODO]
-   * 
-   * @param now [TODO]
-   * @param delta [TODO]
+   * @details Update action to the current time
+   *
+   * @param now The current time of the simulation
+   * @param delta The delta of time since the last update
    */
   virtual void updateActionsState(double now, double delta);
   virtual void updateActionsStateLazy(double now, double delta);
@@ -252,25 +252,25 @@ typedef struct {
  * @brief SURF resource interface class
  * @details A resource represent an element of a component (e.g.: a link for the network)
  */
-class Resource {
+XBT_PUBLIC_CLASS Resource {
 public:
-  /** 
+  /**
    * @brief Resource constructor
    */
   Resource();
 
-  /** 
+  /**
    * @brief Resource constructor
-   * 
+   *
    * @param model Model associated to this Resource
    * @param name The name of the Resource
    * @param props Dictionary of properties associated to this Resource
    */
   Resource(ModelPtr model, const char *name, xbt_dict_t props);
 
-  /** 
+  /**
    * @brief Resource constructor
-   * 
+   *
    * @param model Model associated to this Resource
    * @param name The name of the Resource
    * @param props Dictionary of properties associated to this Resource
@@ -278,9 +278,9 @@ public:
    */
   Resource(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint);
 
-  /** 
+  /**
    * @brief Resource constructor
-   * 
+   *
    * @param model Model associated to this Resource
    * @param name The name of the Resource
    * @param props Dictionary of properties associated to this Resource
@@ -291,25 +291,25 @@ public:
   /**
    * @brief Resource destructor
    */
-  virtual ~Resource(); 
+  virtual ~Resource();
 
   /**
    * @brief Get the Model of the current Resource
-   * 
+   *
    * @return The Model of the current Resource
    */
   ModelPtr getModel();
 
   /**
    * @brief Get the name of the current Resource
-   * 
+   *
    * @return The name of the current Resource
    */
   const char *getName();
 
   /**
    * @brief Get the properties of the current Resource
-   * 
+   *
    * @return The properties of the current Resource
    */
   virtual xbt_dict_t getProperties();
@@ -317,7 +317,7 @@ public:
   /**
    * @brief Update the state of the current Resource
    * @details [TODO]
-   * 
+   *
    * @param event_type [TODO]
    * @param value [TODO]
    * @param date [TODO]
@@ -356,7 +356,7 @@ public:
 
   /**
    * @brief Set the [state](\ref e_surf_resource_state_t) of the current Resource
-   * 
+   *
    * @param state The new state of the current Resource
    */
   virtual void setState(e_surf_resource_state_t state);
@@ -372,7 +372,7 @@ private:
 public:
   /**
    * @brief Get the lmm constraint associated to this Resource if it is part of a LMM component
-   * 
+   *
    * @return The lmm constraint associated to this Resource
    */
   lmm_constraint_t getConstraint();
@@ -389,16 +389,18 @@ void surf_action_lmm_update_index_heap(void *action, int i);
  * @brief SURF action interface class
  * @details An action is an event generated by a resource (e.g.: a communication for the network)
  */
-class Action : public actionHook, public actionLmmHook {
-public:
+XBT_PUBLIC_CLASS Action : public actionHook, public actionLmmHook {
+private:
   /**
-   * @brief Action constructor
+   * @brief Common initializations for the constructors
    */
-  Action();
+  void initialize(ModelPtr model, double cost, bool failed,
+                  lmm_variable_t var = NULL);
 
+public:
   /**
    * @brief Action constructor
-   * 
+   *
    * @param model The Model associated to this Action
    * @param cost The cost of the Action
    * @param failed If the action is impossible (e.g.: execute something on a switched off workstation)
@@ -407,7 +409,7 @@ public:
 
   /**
    * @brief Action constructor
-   * 
+   *
    * @param model The Model associated to this Action
    * @param cost The cost of the Action
    * @param failed If the action is impossible (e.g.: execute something on a switched off workstation)
@@ -419,7 +421,7 @@ public:
    * @brief Action destructor
    */
   virtual ~Action();
-  
+
   /**
    * @brief Finish the action
    */
@@ -427,21 +429,21 @@ public:
 
   /**
    * @brief Get the [state](\ref e_surf_action_state_t) of the current Action
-   * 
+   *
    * @return The state of the current Action
    */
   e_surf_action_state_t getState(); /**< get the state*/
 
   /**
    * @brief Set the [state](\ref e_surf_action_state_t) of the current Action
-   * 
+   *
    * @param state The new state of the current Action
    */
   virtual void setState(e_surf_action_state_t state);
 
   /**
    * @brief Get the bound of the current Action
-   * 
+   *
    * @return The bound of the current Action
    */
   double getBound();
@@ -455,84 +457,84 @@ public:
 
   /**
    * @brief Get the start time of the current action
-   * 
+   *
    * @return The start time of the current action
    */
   double getStartTime();
 
   /**
    * @brief Get the finish time of the current action
-   * 
+   *
    * @return The finish time of the current action
    */
   double getFinishTime();
 
   /**
    * @brief Get the data associated to the current action
-   * 
+   *
    * @return The data associated to the current action
    */
   void *getData() {return p_data;}
 
   /**
    * @brief Set the data associated to the current action
-   * 
+   *
    * @param data The new data associated to the current action
    */
   void setData(void* data);
 
   /**
    * @brief Get the maximum duration of the current action
-   * 
+   *
    * @return The maximum duration of the current action
    */
   double getMaxDuration() {return m_maxDuration;}
 
   /**
    * @brief Get the category associated to the current action
-   * 
+   *
    * @return The category associated to the current action
    */
   char *getCategory() {return p_category;}
 
   /**
    * @brief Get the cost of the current action
-   * 
+   *
    * @return The cost of the current action
    */
   double getCost() {return m_cost;}
 
   /**
    * @brief Set the cost of the current action
-   * 
+   *
    * @param cost The new cost of the current action
    */
   void setCost(double cost) {m_cost = cost;}
 
   /**
    * @brief Update the maximum duration of the current action
-   * 
+   *
    * @param delta [TODO]
    */
-  void updateMaxDuration(double delta) {double_update(&m_maxDuration, delta);}
+  void updateMaxDuration(double delta) {double_update(&m_maxDuration, delta,sg_surf_precision);}
 
   /**
    * @brief Update the remaining time of the current action
-   * 
+   *
    * @param delta [TODO]
    */
-  void updateRemains(double delta) {double_update(&m_remains, delta);}
+  void updateRemains(double delta) {double_update(&m_remains, delta, sg_maxmin_precision*sg_surf_precision);}
 
   /**
    * @brief Set the remaining time of the current action
-   * 
+   *
    * @param value The new remaining time of the current action
    */
   void setRemains(double value) {m_remains = value;}
 
   /**
    * @brief Set the finish time of the current action
-   * 
+   *
    * @param value The new Finush time of the current action
    */
   void setFinishTime(double value) {m_finish = value;}
@@ -545,7 +547,7 @@ public:
   /**
    * @brief Remove a reference to the current action
    * @details If the Action has no more reference, we destroy it
-   * 
+   *
    * @return true if the action was destroyed and false if someone still has references on it
    */
   virtual int unref();
@@ -572,21 +574,21 @@ public:
 
   /**
    * @brief Check if the current action is running
-   * 
+   *
    * @return true if the current Action is suspended, false otherwise
    */
   virtual bool isSuspended();
 
   /**
    * @brief Set the maximum duration of the current Action
-   * 
+   *
    * @param duration The new maximum duration of the current Action
    */
   virtual void setMaxDuration(double duration);
 
   /**
    * @brief Set the priority of the current Action
-   * 
+   *
    * @param priority The new priority of the current Action
    */
   virtual void setPriority(double priority);
@@ -594,7 +596,7 @@ public:
 #ifdef HAVE_TRACING
   /**
    * @brief Set the category of the current Action
-   * 
+   *
    * @param category The new category of the current Action
    */
   void setCategory(const char *category);
@@ -602,21 +604,21 @@ public:
 
   /**
    * @brief Get the remaining time of the current action after updating the resource
-   * 
+   *
    * @return The remaining time
    */
   virtual double getRemains();
 
   /**
    * @brief Get the remaining time of the current action without updating the resource
-   * 
+   *
    * @return The remaining time
    */
   double getRemainsNoUpdate();
 
   /**
    * @brief Get the priority of the current Action
-   * 
+   *
    * @return The priority of the current Action
    */
   double getPriority() {return m_priority;};
@@ -624,13 +626,15 @@ public:
   /**
    * @brief Get the state set in which the action is
    * @details [TODO]
-   * 
+   *
    * @return The state set in which the action is
    */
   ActionListPtr getStateSet() {return p_stateSet;};
 
   s_xbt_swag_hookup_t p_stateHookup;
 
+  ModelPtr getModel() {return p_model;}
+
 protected:
   ActionListPtr p_stateSet;
   double m_priority; /**< priority (1.0 by default) */
@@ -639,15 +643,13 @@ protected:
   double m_maxDuration; /*< max_duration (may fluctuate until the task is completed) */
   double m_finish; /**< finish time : this is modified during the run and fluctuates until the task is completed */
 
-  ModelPtr getModel() {return p_model;}
-
 private:
   int resourceUsed(void *resource_id);
 
   /**
    * @brief Share the resources to the actions
    * @details [TODO]
-   * 
+   *
    * @param now [TODO]
    * @return in how much time the next action may terminatedescription]
    */
@@ -656,7 +658,7 @@ private:
   /**
    * @brief Update the current action state
    * @details [TODO]
-   * 
+   *
    * @param now [TODO]
    * @param delta [TODO]
    */
@@ -665,7 +667,7 @@ private:
   /**
    * @brief Update the [TODO]
    * @details [TODO]
-   * 
+   *
    * @param id [TODO]
    * @param event_type [TODO]
    * @param value [TODO]
index 455f3e8..a4bbe30 100644 (file)
 
 #include "simgrid/platf_interface.h"    // platform creation API internal interface
 #include "simgrid/sg_config.h"
+#include "storage_interface.hpp"
 
 #include "surf/surfxml_parse_values.h"
 
+
 /**
  * @ingroup SURF_build_api
  * @brief A library containing all known workstations
@@ -138,7 +140,7 @@ static void parse_S_host_link(sg_platf_host_link_cbarg_t host)
   // If dynar is is greater than edge id and if the host_link is already defined
   if((int)xbt_dynar_length(current_routing->p_linkUpDownList) > info->getId() &&
       xbt_dynar_get_as(current_routing->p_linkUpDownList, info->getId(), void*))
-    xbt_die("Host_link for '%s' is already defined!",host->id);
+       surf_parse_error("Host_link for '%s' is already defined!",host->id);
 
   XBT_DEBUG("Push Host_link for host '%s' to position %d", info->getName(), info->getId());
   xbt_dynar_set_as(current_routing->p_linkUpDownList, info->getId(), s_surf_parsing_link_up_down_t, link_up_down);
@@ -320,7 +322,7 @@ static void routing_parse_trace_connect(sg_platf_trace_connect_cbarg_t trace_con
         xbt_strdup(trace_connect->element), NULL);
     break;
   default:
-    xbt_die("Cannot connect trace %s to %s: kind of trace unknown",
+       surf_parse_error("Cannot connect trace %s to %s: kind of trace unknown",
         trace_connect->trace, trace_connect->element);
     break;
   }
@@ -1239,6 +1241,22 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer)
 //   }
 // }
 
+static void check_disk_attachment()
+{
+  xbt_lib_cursor_t cursor;
+  char *key;
+  void **data;
+  RoutingEdgePtr host_elm;
+  xbt_lib_foreach(storage_lib, cursor, key, data) {
+    if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != NULL) {
+         StoragePtr storage = static_cast<StoragePtr>(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
+         host_elm = sg_routing_edge_by_name_or_null(storage->p_attach);
+         if(!host_elm)
+                 surf_parse_error("Unable to attach storage %s: host %s doesn't exist.", storage->getName(), storage->p_attach);
+    }
+  }
+}
+
 void routing_register_callbacks()
 {
   sg_platf_host_add_cb(parse_S_host);
@@ -1254,6 +1272,7 @@ void routing_register_callbacks()
 
   sg_platf_peer_add_cb(routing_parse_peer);
   sg_platf_postparse_add_cb(routing_parse_postparse);
+  sg_platf_postparse_add_cb(check_disk_attachment);
 
   /* we care about the ASes while parsing the platf. Incredible, isnt it? */
   sg_platf_AS_end_add_cb(routing_AS_end);
index 3650cf8..ac65fee 100644 (file)
@@ -154,7 +154,7 @@ public:
 /** @ingroup SURF_routing_interface
  * @brief The class representing a whole routing platform
  */
-class RoutingPlatf {
+XBT_PUBLIC_CLASS RoutingPlatf {
 public:
   ~RoutingPlatf();
   AsPtr p_root;
diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp
new file mode 100644 (file)
index 0000000..3ceda71
--- /dev/null
@@ -0,0 +1,229 @@
+#include "surf_routing_cluster_fat_tree.hpp"
+#include "xbt/lib.h"
+
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
+#include <iostream>
+#include <fstream>
+
+
+AsClusterFatTree::AsClusterFatTree() : levels(0) {}
+
+AsClusterFatTree::~AsClusterFatTree() {
+  for (unsigned int i = 0 ; i < this->nodes.size() ; i++) {
+    delete this->nodes[i];
+  }
+}
+
+void AsClusterFatTree::getRouteAndLatency(RoutingEdgePtr src,
+                                          RoutingEdgePtr dst,
+                                          sg_platf_route_cbarg_t into,
+                                          double *latency) {
+  // TODO
+}
+
+/* This function makes the assumption that parse_specific_arguments() and
+ * addNodes() have already been called
+ */
+void AsClusterFatTree::create_links(sg_platf_cluster_cbarg_t cluster) {
+
+  if(this->levels == 0) {
+    return;
+  }
+  this->nodesByLevel.resize(this->levels, 0);
+  unsigned int nodesRequired = 0;
+
+
+  for (unsigned int i = 0 ; i < this->levels ; i++) {
+    int nodesInThisLevel = 1;
+      
+    for (unsigned int j = 0 ;  j < i ; j++) {
+      nodesInThisLevel *= this->upperLevelNodesNumber[j];
+    }
+      
+    for (unsigned int j = i+1 ; j < this->levels ; j++) {
+      nodesInThisLevel *= this->lowerLevelNodesNumber[j];
+    }
+
+    this->nodesByLevel[i] = nodesInThisLevel;
+    nodesRequired += nodesInThisLevel;
+  }
+   
+  if(nodesRequired > this->nodes.size()) {
+    surf_parse_error("There is not enough nodes to fit to the described topology."
+                     " Please check your platform description (We need %d nodes, we only got %lu)",
+                     nodesRequired, this->nodes.size());
+    return;
+  }
+
+  // Nodes are totally ordered, by level and then by position, in this->nodes
+  int k = 0;
+  for (unsigned int i = 0 ; i < this->levels ; i++) {
+    for (unsigned int j = 0 ; j < this->nodesByLevel[i] ; j++) {
+      this->nodes[k]->level = i;
+      this->nodes[k]->position = j;
+      if(i != 0) {
+        int position, size;
+        this->getLevelPosition(i - 1, &position, &size); // TODO : check position and size ?
+        /* We create the connexions between this nodes and all its parents
+         */
+        for (unsigned int l = this->upperLevelNodesNumber[i] * j ;
+             l < this->upperLevelNodesNumber[i] * (j + 1) ; l++)
+          this->addLink(cluster, this->nodes[position + l], this->nodes[k]);
+      }
+      k++;
+    }
+  }
+}
+
+void AsClusterFatTree::getLevelPosition(const unsigned  int level, int *position, int *size) {
+  if (level > this->levels - 1) {
+    *position = -1;
+    *size =  -1;
+    return;
+  }
+  int tempPosition = 0;
+
+  for (unsigned int i = 0 ; i < level ; i++) {
+    tempPosition += this->nodesByLevel[i];
+  }
+  *position = tempPosition;
+  *size = this->nodesByLevel[level];
+}
+
+void AsClusterFatTree::addNodes(std::vector<int> const& id) {
+  for (unsigned int  i = 0 ; i < id.size() ; i++) {
+    this->nodes.push_back(new FatTreeNode(id[i]));
+  }
+}
+
+void AsClusterFatTree::addLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *parent,
+                               FatTreeNode *child) {
+  using std::make_pair;
+  if (parent->children.size() == this->nodesByLevel[parent->level] ||
+      child->parents.size()   == this->nodesByLevel[child->level]) {
+    /* NB : This case should never happen, if this private function is not misused,
+     * so should we keep this test, keep it only for debug, throw an exception
+     * or get rid of it ? In all cases, anytime we get in there, code should be
+     * fixed
+     */
+    xbt_die("I've been asked to create a link that could not possibly exist");
+    return;
+  }
+
+  parent->children.push_back(child);
+  child->parents.push_back(parent);
+
+  FatTreeLink *newLink;
+
+  newLink = new FatTreeLink(cluster, parent, child, this->lowerLevelPortsNumber[parent->level]);
+   this->links.insert(make_pair(make_pair(parent->id, child->id), newLink));
+
+  
+
+}
+
+void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t 
+                                                cluster) {
+  std::vector<string> parameters;
+  std::vector<string> tmp;
+  boost::split(parameters, cluster->topo_parameters, boost::is_any_of(";"));
+
+  // TODO : we have to check for zeros and negative numbers, or it might crash
+  if (parameters.size() != 4){
+    surf_parse_error("Fat trees are defined by the levels number and 3 vectors" 
+                     ", see the documentation for more informations");
+    // Well, there's no doc, yet
+  }
+
+  // The first parts of topo_parameters should be the levels number
+  this->levels = std::atoi(tmp[0].c_str()); // stoi() only in C++11...
+  
+  // Then, a l-sized vector standing for the childs number by level
+  boost::split(tmp, parameters[1], boost::is_any_of(","));
+  if(tmp.size() != this->levels) {
+    surf_parse_error("Fat trees are defined by the levels number and 3 vectors" 
+                     ", see the documentation for more informations"); 
+  }
+  for(unsigned int i = 0 ; i < tmp.size() ; i++){
+    this->lowerLevelNodesNumber.push_back(std::atoi(tmp[i].c_str())); 
+  }
+  
+  // Then, a l-sized vector standing for the parents number by level
+  boost::split(tmp, parameters[2], boost::is_any_of(","));
+  if(tmp.size() != this->levels) {
+    surf_parse_error("Fat trees are defined by the levels number and 3 vectors" 
+                     ", see the documentation for more informations"); 
+  }
+  for(unsigned int i = 0 ; i < tmp.size() ; i++){
+    this->upperLevelNodesNumber.push_back(std::atoi(tmp[i].c_str())); 
+  }
+  
+  // Finally, a l-sized vector standing for the ports number with the lower level
+  boost::split(tmp, parameters[3], boost::is_any_of(","));
+  if(tmp.size() != this->levels) {
+    surf_parse_error("Fat trees are defined by the levels number and 3 vectors" 
+                     ", see the documentation for more informations"); 
+    
+  }
+  for(unsigned int i = 0 ; i < tmp.size() ; i++){
+    this->lowerLevelPortsNumber.push_back(std::atoi(tmp[i].c_str())); 
+  }
+}
+
+
+void AsClusterFatTree::generateDotFile(const string& filename) const {
+  ofstream file;
+  /* Maybe should we get directly a char*, as open takes strings only beginning
+   * with C++11...
+   */
+  file.open(filename.c_str(), ios::out | ios::trunc); 
+  
+  if(file.is_open()) {
+    // That could also be greatly clarified with C++11
+    std::map<std::pair<int,int>,FatTreeLink*>::const_iterator iter;
+    file << "graph AsClusterFatTree {\n";
+    for (iter = this->links.begin() ; iter != this->links.end() ; iter++ ) {
+      for (unsigned int j = 0 ; j < iter->second->ports ; j++) {
+        file << iter->second->source->id
+             << " -- "
+             << iter->second->destination->id
+             << ";\n";
+      }
+    }
+    file << "}";
+    file.close();
+  }
+  else {
+    std::cerr << "Unable to open file " << filename << std::endl;
+    return;
+  }
+}
+
+FatTreeNode::FatTreeNode(int id, int level, int position) : id(id),
+                                                            level(level),
+                                                            position(position){}
+
+FatTreeLink::FatTreeLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *source,
+                         FatTreeNode *destination,
+                         unsigned int ports) : ports(ports), source(source),
+                                               destination(destination) {
+  s_sg_platf_link_cbarg_t linkTemplate;
+  linkTemplate.bandwidth = cluster->bw;
+  linkTemplate.latency = cluster->lat;
+  linkTemplate.state = SURF_RESOURCE_ON;
+  linkTemplate.policy = cluster->sharing_policy; // Maybe should we do sthg with that ?
+
+  for(unsigned int i = 0 ; i < ports ; i++) {
+    NetworkLink* link;
+    linkTemplate.id = bprintf("link_from_%d_to_%d_%d_UP", source->id, destination->id, i);
+    sg_platf_new_link(&linkTemplate);
+    link = (NetworkLink*) xbt_lib_get_or_null(link_lib, linkTemplate.id, SURF_LINK_LEVEL);
+    this->linksUp.push_back(link); // check link?
+    linkTemplate.id = bprintf("link_from_%d_to_%d_%d_DOWN", source->id, destination->id, i);
+    sg_platf_new_link(&linkTemplate);
+    link = (NetworkLink*) xbt_lib_get_or_null(link_lib, linkTemplate.id, SURF_LINK_LEVEL);
+    this->linksDown.push_back(link); // check link ?
+  }
+}
diff --git a/src/surf/surf_routing_cluster_fat_tree.hpp b/src/surf/surf_routing_cluster_fat_tree.hpp
new file mode 100644 (file)
index 0000000..62f9354
--- /dev/null
@@ -0,0 +1,87 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "surf_routing_cluster.hpp"
+
+#ifndef SURF_ROUTING_CLUSTER_FAT_TREE_HPP_
+#define SURF_ROUTING_CLUSTER_FAT_TREE_HPP_
+
+
+/* The class AsClusterFatTree describes PGFT, as introduced by Eitan Zahavi
+ * in "D-Mod-K Routing Providing Non-Blocking Traffic for Shift Permutations
+ * on Real Life Fat Trees" (2010). RLFT are PGFT with some restrictions to 
+ * address real world constraints, which are not currently enforced (but it 
+ * should certainly be checked for)
+ */
+
+/* TODO : limiter link ? Loopback?
+ *
+ */
+
+class FatTreeNode {
+public:
+  int id; // ID as given by the user, should be unique
+  int level; // The 0th level represents the leafs of the PGFT
+  int position; // Position in the level
+  
+  /* We can see the sizes sum of the two following vectors as the device 
+   * ports number. If we use the notations used in Zahavi's paper, 
+   * children.size() = m_level and parents.size() = w_(level+1)
+   * 
+   */
+  std::vector<FatTreeNode*> children;  // m, apply from lvl 0 to levels - 1 
+  std::vector<FatTreeNode*> parents; // w, apply from lvl 1 to levels
+  FatTreeNode(int id, int level=-1, int position=-1);
+};
+
+class FatTreeLink {
+public:
+  FatTreeLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *source,
+              FatTreeNode *destination, unsigned int ports = 0);
+  unsigned int ports;
+  /* Links are dependant of the chosen network model, but must implement 
+   * NetworkLink
+   */
+   std::vector<NetworkLink*> linksUp; // From source to destination
+  std::vector<NetworkLink*> linksDown; // From destination to source
+  /* As it is symetric, it might as well be first / second instead
+   * of source / destination
+   */
+  FatTreeNode *source; 
+  FatTreeNode *destination;
+};
+
+class AsClusterFatTree : public AsCluster {
+public:
+  AsClusterFatTree();
+  ~AsClusterFatTree();
+  virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst,
+                                  sg_platf_route_cbarg_t into,
+                                  double *latency);
+  // virtual void getRouteAndLatency(const int src, const int dst,
+  //                                 std::vector<NetworkLink> *route,
+  //                                 double *latency) const;
+  virtual void create_links(sg_platf_cluster_cbarg_t cluster);
+  void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster);
+  void addNodes(std::vector<int> const& id);
+  void generateDotFile(const string& filename = "fatTree.dot") const;
+
+protected:
+  //description of a PGFT (TODO : better doc)
+  unsigned int levels;
+  std::vector<int> lowerLevelNodesNumber; // number of children by node
+  std::vector<int> upperLevelNodesNumber; // number of parents by node
+  std::vector<int> lowerLevelPortsNumber; // ports between each level l and l-1
+  
+  std::vector<FatTreeNode*> nodes;
+  std::map<std::pair<int,int>, FatTreeLink*> links;
+  std::vector<unsigned int> nodesByLevel;
+
+  void addLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *parent,
+               FatTreeNode *child);
+  void getLevelPosition(const unsigned int level, int *position, int *size);
+};
+#endif
index 48a3ae2..805dd10 100644 (file)
@@ -475,9 +475,9 @@ void AsDijkstra::parseRoute(sg_platf_route_cbarg_t route)
         route->gw_src->getName(), dst, route->gw_dst->getName());
     as_route = 1;
     if(route->gw_dst->getRcType() == SURF_NETWORK_ELEMENT_NULL)
-      xbt_die("The gw_dst '%s' does not exist!",route->gw_dst->getName());
+      surf_parse_error("The gw_dst '%s' does not exist!",route->gw_dst->getName());
     if(route->gw_src->getRcType() == SURF_NETWORK_ELEMENT_NULL)
-      xbt_die("The gw_src '%s' does not exist!",route->gw_src->getName());
+      surf_parse_error("The gw_src '%s' does not exist!",route->gw_src->getName());
   }
 
   RoutingEdgePtr src_net_elm, dst_net_elm;
index f116c4e..18d3c9e 100644 (file)
@@ -177,9 +177,9 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route)
     XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src,
         route->gw_src->getName(), dst, route->gw_dst->getName());
     if(route->gw_dst->getRcType() == SURF_NETWORK_ELEMENT_NULL)
-      xbt_die("The dst_gateway '%s' does not exist!",route->gw_dst->getName());
+      surf_parse_error("The dst_gateway '%s' does not exist!",route->gw_dst->getName());
     if(route->gw_src->getRcType() == SURF_NETWORK_ELEMENT_NULL)
-      xbt_die("The src_gateway '%s' does not exist!",route->gw_src->getName());
+      surf_parse_error("The src_gateway '%s' does not exist!",route->gw_src->getName());
   }
 
   if(TO_FLOYD_LINK(src_net_elm->getId(), dst_net_elm->getId()))
index 79c2a4b..d00fdb8 100644 (file)
@@ -217,11 +217,11 @@ void AsFull::parseRoute(sg_platf_route_cbarg_t route)
       XBT_DEBUG("Load ASroute from \"%s\" to \"%s\"", src, dst);
       if (!route->gw_src ||
           route->gw_src->getRcType() == SURF_NETWORK_ELEMENT_NULL)
-        xbt_die("The src_gateway \"%s\" does not exist!",
+       surf_parse_error("The src_gateway \"%s\" does not exist!",
                 route->gw_src ? route->gw_src->getName() : "(null)");
       if (!route->gw_dst ||
           route->gw_dst->getRcType() == SURF_NETWORK_ELEMENT_NULL)
-        xbt_die("The dst_gateway \"%s\" does not exist!",
+       surf_parse_error("The dst_gateway \"%s\" does not exist!",
                 route->gw_dst ? route->gw_dst->getName() : "(null)");
       XBT_DEBUG("ASroute goes from \"%s\" to \"%s\"",
                 route->gw_src->getName(), route->gw_dst->getName());
index 198b745..2c93389 100644 (file)
@@ -119,6 +119,6 @@ void parse_platform_file(const char *file)
   /* Stop the flex parser */
   surf_parse_close();
   if (parse_status)
-    xbt_die("Parse error in %s", file);
+    surf_parse_error("Parse error in %s", file);
 }
 
index 71718e3..70f949c 100644 (file)
@@ -9,6 +9,8 @@
 #include "cpu_cas01.hpp"
 #include "simgrid/sg_config.h"
 
+#include "network_interface.hpp"
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_workstation, surf,
                                 "Logging specific to the SURF workstation module");
 
@@ -20,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 *
@@ -110,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(){
@@ -191,20 +194,57 @@ xbt_dynar_t Workstation::getAttachedStorageList()
   void **data;
   xbt_dynar_t result = xbt_dynar_new(sizeof(void*), NULL);
   xbt_lib_foreach(storage_lib, cursor, key, data) {
-         if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != NULL) {
-           StoragePtr storage = static_cast<StoragePtr>(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
-           if(!strcmp((const char*)storage->p_attach,this->getName())){
-             xbt_dynar_push_as(result, void *,(void *)static_cast<ResourcePtr>(storage)->getName());
-           }
+    if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != NULL) {
+         StoragePtr storage = static_cast<StoragePtr>(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
+         if(!strcmp((const char*)storage->p_attach,this->getName())){
+           xbt_dynar_push_as(result, void *,(void *)static_cast<ResourcePtr>(storage)->getName());
          }
+       }
   }
   return result;
 }
 
-ActionPtr Workstation::open(const char* mount, const char* path) {
-  StoragePtr st = findStorageOnMountList(mount);
-  XBT_DEBUG("OPEN on disk '%s'", st->getName());
-  return st->open(mount, path);
+ActionPtr Workstation::open(const char* fullpath) {
+
+  StoragePtr st = NULL;
+  s_mount_t mnt;
+  unsigned int cursor;
+  size_t longest_prefix_length = 0;
+  char *path = NULL;
+  char *file_mount_name = NULL;
+  char *mount_name = NULL;
+
+  XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath, getName());
+  xbt_dynar_foreach(p_storage,cursor,mnt)
+  {
+    XBT_DEBUG("See '%s'",mnt.name);
+    file_mount_name = (char *) xbt_malloc ((strlen(mnt.name)+1));
+    strncpy(file_mount_name,fullpath,strlen(mnt.name)+1);
+    file_mount_name[strlen(mnt.name)] = '\0';
+
+    if(!strcmp(file_mount_name,mnt.name) && strlen(mnt.name)>longest_prefix_length)
+    {/* The current mount name is found in the full path and is bigger than the previous*/
+      longest_prefix_length = strlen(mnt.name);
+      st = static_cast<StoragePtr>(mnt.storage);
+    }
+    free(file_mount_name);
+  }
+  if(longest_prefix_length>0)
+  { /* Mount point found, split fullpath into mount_name and path+filename*/
+       path = (char *) xbt_malloc ((strlen(fullpath)-longest_prefix_length+1));
+       mount_name = (char *) xbt_malloc ((longest_prefix_length+1));
+       strncpy(mount_name, fullpath, longest_prefix_length+1);
+       strncpy(path, fullpath+longest_prefix_length, strlen(fullpath)-longest_prefix_length+1);
+       path[strlen(fullpath)-longest_prefix_length] = '\0';
+       mount_name[longest_prefix_length] = '\0';
+  }
+  else
+    xbt_die("Can't find mount point for '%s' on '%s'", fullpath, getName());
+
+  ActionPtr action = st->open((const char*)mount_name, (const char*)path);
+  free((char*)path);
+  free((char*)mount_name);
+  return action;
 }
 
 ActionPtr Workstation::close(surf_file_t fd) {
@@ -228,15 +268,15 @@ ActionPtr Workstation::write(surf_file_t fd, sg_size_t size) {
 int Workstation::unlink(surf_file_t fd) {
   if (!fd){
     XBT_WARN("No such file descriptor. Impossible to unlink");
-    return 0;
+    return -1;
   } else {
-//    XBT_INFO("%s %zu", fd->storage, fd->size);
+
     StoragePtr st = findStorageOnMountList(fd->mount);
     /* Check if the file is on this storage */
     if (!xbt_dict_get_or_null(st->p_content, fd->name)){
       XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
           st->getName());
-      return 0;
+      return -1;
     } else {
       XBT_DEBUG("UNLINK on disk '%s'",st->getName());
       st->m_usedSize -= fd->size;
@@ -244,20 +284,14 @@ int Workstation::unlink(surf_file_t fd) {
       // Remove the file from storage
       xbt_dict_remove(st->p_content, fd->name);
 
-      free(fd->name);
-      free(fd->mount);
+      xbt_free(fd->name);
+      xbt_free(fd->mount);
       xbt_free(fd);
-      return 1;
+      return 0;
     }
   }
 }
 
-ActionPtr Workstation::ls(const char* mount, const char *path){
-  XBT_DEBUG("LS on mount '%s' and file '%s'", mount, path);
-  StoragePtr st = findStorageOnMountList(mount);
-  return st->ls(path);
-}
-
 sg_size_t Workstation::getSize(surf_file_t fd){
   return fd->size;
 }
@@ -285,31 +319,47 @@ int Workstation::fileSeek(surf_file_t fd, sg_size_t offset, int origin){
 
   switch (origin) {
   case SEEK_SET:
-    fd->current_position = 0;
-       return MSG_OK;
+    fd->current_position = offset;
+    return 0;
   case SEEK_CUR:
-       if(offset > fd->size)
-         offset = fd->size;
-       fd->current_position = offset;
-       return MSG_OK;
+    fd->current_position += offset;
+    return 0;
   case SEEK_END:
-       fd->current_position = fd->size;
-       return MSG_OK;
+    fd->current_position = fd->size + offset;
+    return 0;
   default:
-       return MSG_TASK_CANCELED;
+    return -1;
   }
 }
 
-sg_size_t Workstation::getFreeSize(const char* name)
-{
-  StoragePtr st = findStorageOnMountList(name);
-  return st->m_size - st->m_usedSize;
-}
-
-sg_size_t Workstation::getUsedSize(const char* name)
-{
-  StoragePtr st = findStorageOnMountList(name);
-  return st->m_usedSize;
+int Workstation::fileMove(surf_file_t fd, const char* fullpath){
+  /* Check if the new full path is on the same mount point */
+  if(!strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) {
+    sg_size_t *psize, *new_psize;
+    psize = (sg_size_t*)
+        xbt_dict_get_or_null(findStorageOnMountList(fd->mount)->p_content,
+                             fd->name);
+    new_psize = xbt_new(sg_size_t, 1);
+    *new_psize = *psize;
+    if (psize){// src file exists
+      xbt_dict_remove(findStorageOnMountList(fd->mount)->p_content, fd->name);
+      char *path = (char *) xbt_malloc ((strlen(fullpath)-strlen(fd->mount)+1));;
+      strncpy(path, fullpath+strlen(fd->mount),
+              strlen(fullpath)-strlen(fd->mount)+1);
+      xbt_dict_set(findStorageOnMountList(fd->mount)->p_content, path,
+                   new_psize,NULL);
+      XBT_DEBUG("Move file from %s to %s, size '%llu'",fd->name, fullpath, *psize);
+      free(path);
+      return 0;
+    } else {
+      XBT_WARN("File %s doesn't exist", fd->name);
+      return -1;
+    }
+  } else {
+    XBT_WARN("New full path %s is not on the same mount point: %s. Action has been canceled.",
+             fullpath, fd->mount);
+    return -1;
+  }
 }
 
 xbt_dynar_t Workstation::getVms()
@@ -345,6 +395,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);
 }
index 3357edb..0d50aff 100644 (file)
@@ -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,17 +257,16 @@ public:
 
   /**
    * @brief Open a file
-   * 
-   * @param mount The mount point
-   * @param path The path to the file
-   * 
+   *
+   * @param fullpath The full path to the file
+   *
    * @return The StorageAction corresponding to the opening
    */
-  virtual ActionPtr open(const char* mount, const char* path);
+  virtual ActionPtr open(const char* fullpath);
 
   /**
    * @brief Close a file
-   * 
+   *
    * @param fd The file descriptor to close
    * @return The StorageAction corresponding to the closing
    */
@@ -276,25 +275,15 @@ public:
   /**
    * @brief Unlink a file
    * @details [long description]
-   * 
+   *
    * @param fd [description]
    * @return [description]
    */
   virtual int unlink(surf_file_t fd);
 
-  /**
-   * @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
-   */
-  virtual ActionPtr ls(const char* mount, const char *path);
-
   /**
    * @brief Get the size in bytes of the file
-   * 
+   *
    * @param fd The file descriptor to read
    * @return The size in bytes of the file
    */
@@ -302,7 +291,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
@@ -311,7 +300,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
@@ -326,7 +315,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
    */
@@ -334,32 +323,16 @@ 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 
-   * 
-   * @param name The mount point
-   * @return The amount of availble space in bytes
-   */
-  virtual sg_size_t getFreeSize(const char* name);
-
-  /**
-   * @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
-   */
-  virtual sg_size_t getUsedSize(const char* name);
-
-  /**
-   * @brief Set the position indictator assiociated with the file descriptor to a new position
+   * @brief Set the position indicator associated 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
@@ -370,6 +343,17 @@ public:
    */
   virtual int fileSeek(surf_file_t fd, sg_size_t offset, int origin);
 
+  /**
+   * @brief Move a file to another location on the *same mount point*.
+   * @details [long description]
+   *
+   * @param fd The file descriptor
+   * @param fullpath The new full path
+   * @return MSG_OK if successful, MSG_TASK_CANCELED and a warning if the new
+   * full path is not on the same mount point
+   */
+  virtual int fileMove(surf_file_t fd, const char* fullpath);
+
   xbt_dynar_t p_storage;
   RoutingEdgePtr p_netElm;
   CpuPtr p_cpu;
@@ -377,7 +361,7 @@ public:
 
   /**
    * @brief Get the list of virtual machines on the current Workstation
-   * 
+   *
    * @return The list of VMs
    */
   xbt_dynar_t getVms();
@@ -386,7 +370,7 @@ public:
   /**
    * @brief [brief description]
    * @details [long description]
-   * 
+   *
    * @param params [description]
    */
   void getParams(ws_params_t params);
@@ -394,7 +378,7 @@ public:
   /**
    * @brief [brief description]
    * @details [long description]
-   * 
+   *
    * @param params [description]
    */
   void setParams(ws_params_t params);
@@ -412,7 +396,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]
@@ -422,7 +406,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]
index f44c1a1..a2b4ac6 100644 (file)
@@ -85,10 +85,10 @@ void WorkstationL07Model::updateActionsState(double /*now*/, double delta)
     deltap = delta;
     if (action->m_latency > 0) {
       if (action->m_latency > deltap) {
-        double_update(&(action->m_latency), deltap);
+        double_update(&(action->m_latency), deltap, sg_surf_precision);
         deltap = 0.0;
       } else {
-        double_update(&(deltap), action->m_latency);
+        double_update(&(deltap), action->m_latency, sg_surf_precision);
         action->m_latency = 0.0;
       }
       if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) {
@@ -287,19 +287,21 @@ xbt_dynar_t WorkstationL07Model::getRoute(WorkstationPtr src, WorkstationPtr dst
   return route;
 }
 
-ResourcePtr CpuL07Model::createResource(const char *name, double power_scale,
-                               double power_initial,
-                               tmgr_trace_t power_trace,
-                               e_surf_resource_state_t state_initial,
-                               tmgr_trace_t state_trace,
-                               xbt_dict_t cpu_properties)
+CpuPtr CpuL07Model::createResource(const char *name,  xbt_dynar_t powerPeak,
+                          int pstate, double power_scale,
+                          tmgr_trace_t power_trace, int core,
+                          e_surf_resource_state_t state_initial,
+                          tmgr_trace_t state_trace,
+                          xbt_dict_t cpu_properties)
 {
+  double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
+
   xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
               "Host '%s' declared several times in the platform file.",
               name);
 
   CpuL07Ptr cpu = new CpuL07(this, name, cpu_properties,
-                                    power_scale, power_initial, power_trace,state_initial, state_trace);
+                                    power_initial, power_scale, power_trace,state_initial, state_trace);
 
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
 
@@ -357,7 +359,7 @@ void WorkstationL07Model::addTraces()
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
-    host->p_power.event = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
+    host->p_powerEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
   }
 
   /* Connect traces relative to network */
@@ -425,21 +427,19 @@ double WorkstationL07::getConsumedEnergy()
 }
 
 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props,
-                  double power_scale,
-                      double power_initial, tmgr_trace_t power_trace,
+                  double power_initial,
+                      double power_scale, tmgr_trace_t power_trace,
                       e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
  : Cpu(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale),
-          1, 0, 0)
+          1, power_initial, power_scale)
 {
-  p_power.scale = power_scale;
-  xbt_assert(p_power.scale > 0, "Power has to be >0");
+  xbt_assert(m_powerScale > 0, "Power has to be >0");
 
-  m_powerCurrent = power_initial;
   if (power_trace)
-    p_power.event = tmgr_history_add_trace(history, power_trace, 0.0, 0,
+    p_powerEvent = tmgr_history_add_trace(history, power_trace, 0.0, 0,
                                            static_cast<ResourcePtr>(this));
   else
-    p_power.event = NULL;
+    p_powerEvent = NULL;
 
   setState(state_initial);
   if (state_trace)
@@ -480,11 +480,11 @@ bool LinkL07::isUsed(){
 
 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
   XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value);
-  if (event_type == p_power.event) {
-       m_powerCurrent = value;
-    lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_powerCurrent * p_power.scale);
+  if (event_type == p_powerEvent) {
+         m_powerScale = value;
+    lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_powerPeak * m_powerScale);
     if (tmgr_trace_event_free(event_type))
-      p_power.event = NULL;
+      p_powerEvent = NULL;
   } else if (event_type == p_stateEvent) {
     if (value > 0)
       setState(SURF_RESOURCE_ON);
@@ -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) {
@@ -537,16 +528,6 @@ e_surf_resource_state_t WorkstationL07::getState()
   return p_cpu->getState();
 }
 
-double CpuL07::getSpeed(double load)
-{
-  return load * p_power.scale;
-}
-
-double CpuL07::getAvailableSpeed()
-{
-  return m_powerCurrent;
-}
-
 ActionPtr WorkstationL07::execute(double size)
 {
   void **workstation_list = xbt_new0(void *, 1);
@@ -582,11 +563,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());
@@ -738,21 +739,6 @@ static void ptask_parse_workstation_init(sg_platf_host_cbarg_t host)
       host->properties);
 }
 
-static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host)
-{
-  double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
-  static_cast<CpuL07ModelPtr>(surf_cpu_model_pm)->createResource(
-      host->id,
-      power_peak,
-      host->power_scale,
-      host->power_trace,
-      host->initial_state,
-      host->state_trace,
-      host->properties);
-}
-
-
-
 static void ptask_parse_link_init(sg_platf_link_cbarg_t link)
 {
   if (link->policy == SURF_LINK_FULLDUPLEX) {
@@ -802,7 +788,7 @@ static void ptask_add_traces(){
 
 static void ptask_define_callbacks()
 {
-  sg_platf_host_add_cb(ptask_parse_cpu_init);
+  sg_platf_host_add_cb(parse_cpu_init);
   sg_platf_host_add_cb(ptask_parse_workstation_init);
   sg_platf_link_add_cb(ptask_parse_link_init);
   sg_platf_postparse_add_cb(ptask_add_traces);
index 360a851..aea13ee 100644 (file)
@@ -75,6 +75,12 @@ public:
                                  e_surf_resource_state_t state_initial,
                                  tmgr_trace_t state_trace,
                                  xbt_dict_t cpu_properties);
+  CpuPtr createResource(const char *name,  xbt_dynar_t powerPeak,
+                          int pstate, double power_scale,
+                          tmgr_trace_t power_trace, int core,
+                          e_surf_resource_state_t state_initial,
+                          tmgr_trace_t state_trace,
+                          xbt_dict_t cpu_properties);
   void addTraces() {DIE_IMPOSSIBLE;};
 
   WorkstationL07ModelPtr p_workstationModel;
@@ -120,10 +126,9 @@ public:
 };
 
 class CpuL07 : public Cpu {
-public:
-  s_surf_metric_t p_power;
+  friend void WorkstationL07Model::addTraces();
   tmgr_trace_event_t p_stateEvent;
-
+  tmgr_trace_event_t p_powerEvent;
 public:
   CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties,
                 double power_scale,
@@ -132,8 +137,6 @@ public:
   bool isUsed();
   //bool isUsed() {DIE_IMPOSSIBLE;};
   void updateState(tmgr_trace_event_t event_type, double value, double date);
-  double getSpeed(double load);
-  double getAvailableSpeed();
   CpuActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};
   CpuActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
 
@@ -142,8 +145,6 @@ public:
   int getNbPstates() {THROW_UNIMPLEMENTED;};
   void setPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
   double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
-
-  double m_powerCurrent;
 };
 
 class LinkL07 : public NetworkLink {
@@ -164,6 +165,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;
index 3731048..b32ec96 100644 (file)
@@ -13,6 +13,7 @@
 #include "xbt/module.h"         /* xbt_binary_name */
 #include "xbt_modinter.h"       /* backtrace initialization headers */
 #ifdef HAVE_MC
+#define UNW_LOCAL_ONLY
 #include <libunwind.h>
 #endif
 /* end of "useless" inclusions */
index 24d7ec4..4a65fcd 100644 (file)
@@ -623,7 +623,9 @@ static void xbt_log_connect_categories(void)
   XBT_LOG_CONNECT(mc_checkpoint);
   XBT_LOG_CONNECT(mc_compare);
   XBT_LOG_CONNECT(mc_dpor);
+  XBT_LOG_CONNECT(mc_dwarf);
   XBT_LOG_CONNECT(mc_global);
+  XBT_LOG_CONNECT(mc_hash);
   XBT_LOG_CONNECT(mc_liveness);
   XBT_LOG_CONNECT(mc_memory);
   XBT_LOG_CONNECT(mc_memory_map);
index 322d818..ca48a1e 100644 (file)
@@ -1,8 +1,4 @@
-/* Free a block of memory allocated by `mmalloc'.
-   Copyright 1990, 1991, 1992 Free Software Foundation
-
-   Written May 1989 by Mike Haertel.
-   Heavily modified Mar 1992 by Fred Fish.  (fnf@cygnus.com) */
+/* Free a block of memory allocated by `mmalloc'. */
 
 /* Copyright (c) 2010-2014. The SimGrid Team.
  * All rights reserved.                                                     */
@@ -10,6 +6,11 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+/* Copyright 1990, 1991, 1992 Free Software Foundation
+
+   Written May 1989 by Mike Haertel.
+   Heavily modified Mar 1992 by Fred Fish.  (fnf@cygnus.com) */
+
 #include "mmprivate.h"
 #include "xbt/ex.h"
 #include "mc/mc.h"
index 074dec3..33de568 100644 (file)
@@ -4,14 +4,14 @@
    behavior.  It should also still be possible to build the library
    as a standard library with multiple objects. */
 
-/* Copyright 1996, 2000 Free Software Foundation  */
-
 /* Copyright (c) 2010, 2012-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+/* Copyright 1996, 2000 Free Software Foundation  */
+
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>             /* Prototypes for lseek, sbrk (maybe) */
 #endif
index 2762185..af5bd88 100644 (file)
@@ -11,6 +11,7 @@
 #include "mc/mc.h"
 #include "xbt/mmalloc.h"
 #include "mc/datatypes.h"
+#include "mc/mc_private.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mm_diff, xbt,
                                 "Logging specific to mm_diff in mmalloc");
@@ -132,12 +133,24 @@ static int compare_backtrace(int b1, int f1, int b2, int f2){
 
 typedef char* type_name;
 
-__thread void *s_heap = NULL, *heapbase1 = NULL, *heapbase2 = NULL;
-__thread malloc_info *heapinfo1 = NULL, *heapinfo2 = NULL;
-__thread size_t heaplimit = 0, heapsize1 = 0, heapsize2 = 0;
-__thread xbt_dynar_t to_ignore1 = NULL, to_ignore2 = NULL;
-__thread heap_area_t **equals_to1, **equals_to2;
-__thread type_name **types1, **types2;
+struct s_mm_diff {
+  void *s_heap, *heapbase1, *heapbase2;
+  malloc_info *heapinfo1, *heapinfo2;
+  size_t heaplimit;
+  // Number of blocks in the heaps:
+  size_t heapsize1, heapsize2;
+  xbt_dynar_t to_ignore1, to_ignore2;
+  s_heap_area_t *equals_to1, *equals_to2;
+  dw_type_t *types1, *types2;
+  size_t available;
+};
+
+#define equals_to1_(i,j) equals_to1[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
+#define equals_to2_(i,j) equals_to2[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
+#define types1_(i,j) types1[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
+#define types2_(i,j) types2[ MAX_FRAGMENT_PER_BLOCK*(i) + (j)]
+
+__thread struct s_mm_diff* mm_diff_info = NULL;
 
 /*********************************** Free functions ************************************/
 
@@ -157,11 +170,11 @@ static void heap_area_free(heap_area_t area){
 
 /************************************************************************************/
 
-static heap_area_t new_heap_area(int block, int fragment){
-  heap_area_t area = NULL;
-  area = xbt_new0(s_heap_area_t, 1);
-  area->block = block;
-  area->fragment = fragment;
+static s_heap_area_t make_heap_area(int block, int fragment){
+  s_heap_area_t area;
+  area.valid = 1;
+  area.block = block;
+  area.fragment = fragment;
   return area;
 }
 
@@ -242,131 +255,108 @@ static int is_block_stack(int block){
   return 0;
 }
 
-static void match_equals(xbt_dynar_t list){
+static void match_equals(struct s_mm_diff *state, xbt_dynar_t list){
 
   unsigned int cursor = 0;
   heap_area_pair_t current_pair;
-  heap_area_t previous_area;
 
   xbt_dynar_foreach(list, cursor, current_pair){
 
     if(current_pair->fragment1 != -1){
 
-      if(equals_to1[current_pair->block1][current_pair->fragment1] != NULL){
-        previous_area = equals_to1[current_pair->block1][current_pair->fragment1];
-        heap_area_free(equals_to2[previous_area->block][previous_area->fragment]);
-        equals_to2[previous_area->block][previous_area->fragment] = NULL;
-        heap_area_free(previous_area);
-      }
-      if(equals_to2[current_pair->block2][current_pair->fragment2] != NULL){
-        previous_area = equals_to2[current_pair->block2][current_pair->fragment2];
-        heap_area_free(equals_to1[previous_area->block][previous_area->fragment]);
-        equals_to1[previous_area->block][previous_area->fragment] = NULL;
-        heap_area_free(previous_area);
-      }
-
-      equals_to1[current_pair->block1][current_pair->fragment1] = new_heap_area(current_pair->block2, current_pair->fragment2);
-      equals_to2[current_pair->block2][current_pair->fragment2] = new_heap_area(current_pair->block1, current_pair->fragment1);
+      state->equals_to1_(current_pair->block1,current_pair->fragment1) = make_heap_area(current_pair->block2, current_pair->fragment2);
+      state->equals_to2_(current_pair->block2,current_pair->fragment2) = make_heap_area(current_pair->block1, current_pair->fragment1);
       
     }else{
 
-      if(equals_to1[current_pair->block1][0] != NULL){
-        previous_area = equals_to1[current_pair->block1][0];
-        heap_area_free(equals_to2[previous_area->block][0]);
-        equals_to2[previous_area->block][0] = NULL;
-        heap_area_free(previous_area);
-      }
-      if(equals_to2[current_pair->block2][0] != NULL){
-        previous_area = equals_to2[current_pair->block2][0];
-        heap_area_free(equals_to1[previous_area->block][0]);
-        equals_to1[previous_area->block][0] = NULL;
-        heap_area_free(previous_area);
-      }
-
-      equals_to1[current_pair->block1][0] = new_heap_area(current_pair->block2, current_pair->fragment2);
-      equals_to2[current_pair->block2][0] = new_heap_area(current_pair->block1, current_pair->fragment1);
+      state->equals_to1_(current_pair->block1,0) = make_heap_area(current_pair->block2, current_pair->fragment2);
+      state->equals_to2_(current_pair->block2,0) = make_heap_area(current_pair->block1, current_pair->fragment1);
 
     }
 
   }
 }
 
-static int equal_blocks(int b1, int b2){
+/** Check whether two blocks are known to be matching
+ *
+ *  @param state  State used
+ *  @param b1     Block of state 1
+ *  @param b2     Block of state 2
+ *  @return       if the blocks are known to be matching
+ */
+static int equal_blocks(struct s_mm_diff *state, int b1, int b2){
   
-  if(equals_to1[b1][0]->block == b2 && equals_to2[b2][0]->block == b1)
+  if(state->equals_to1_(b1,0).block == b2 && state->equals_to2_(b2,0).block == b1)
     return 1;
 
   return 0;
 }
 
-static int equal_fragments(int b1, int f1, int b2, int f2){
+/** Check whether two fragments are known to be matching
+ *
+ *  @param state  State used
+ *  @param b1     Block of state 1
+ *  @param f1     Fragment of state 1
+ *  @param b2     Block of state 2
+ *  @param f2     Fragment of state 2
+ *  @return       if the fragments are known to be matching
+ */
+static int equal_fragments(struct s_mm_diff *state, int b1, int f1, int b2, int f2){
   
-  if(equals_to1[b1][f1]->block == b2 && equals_to1[b1][f1]->fragment == f2 && equals_to2[b2][f2]->block == b1 && equals_to2[b2][f2]->fragment == f1)
+  if(state->equals_to1_(b1,f1).block == b2
+    && state->equals_to1_(b1,f1).fragment == f2
+    && state->equals_to2_(b2,f2).block == b1
+    && state->equals_to2_(b2,f2).fragment == f1)
     return 1;
 
   return 0;
 }
 
 int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1, xbt_dynar_t i2){
+  if(mm_diff_info==NULL) {
+    mm_diff_info = xbt_new0(struct s_mm_diff, 1);
+    mm_diff_info->equals_to1 = NULL;
+    mm_diff_info->equals_to2 = NULL;
+    mm_diff_info->types1 = NULL;
+    mm_diff_info->types2 = NULL;
+  }
+  struct s_mm_diff *state = mm_diff_info;
 
-  if((((struct mdesc *)heap1)->heaplimit != ((struct mdesc *)heap2)->heaplimit) || ((((struct mdesc *)heap1)->heapsize != ((struct mdesc *)heap2)->heapsize) ))
+  if((((struct mdesc *)heap1)->heaplimit != ((struct mdesc *)heap2)->heaplimit)
+    || ((((struct mdesc *)heap1)->heapsize != ((struct mdesc *)heap2)->heapsize) ))
     return -1;
 
-  int i, j;
-
-  heaplimit = ((struct mdesc *)heap1)->heaplimit;
+  state->heaplimit = ((struct mdesc *)heap1)->heaplimit;
 
-  s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize();
+  state->s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - xbt_pagesize;
 
-  heapbase1 = (char *)heap1 + BLOCKSIZE;
-  heapbase2 = (char *)heap2 + BLOCKSIZE;
+  state->heapbase1 = (char *)heap1 + BLOCKSIZE;
+  state->heapbase2 = (char *)heap2 + BLOCKSIZE;
 
-  heapinfo1 = (malloc_info *)((char *)heap1 + ((uintptr_t)((char *)((struct mdesc *)heap1)->heapinfo - (char *)s_heap)));
-  heapinfo2 = (malloc_info *)((char *)heap2 + ((uintptr_t)((char *)((struct mdesc *)heap2)->heapinfo - (char *)s_heap)));
+  state->heapinfo1 = (malloc_info *)((char *)heap1 + ((uintptr_t)((char *)((struct mdesc *)heap1)->heapinfo - (char *)state->s_heap)));
+  state->heapinfo2 = (malloc_info *)((char *)heap2 + ((uintptr_t)((char *)((struct mdesc *)heap2)->heapinfo - (char *)state->s_heap)));
 
-  heapsize1 = heap1->heapsize;
-  heapsize2 = heap2->heapsize;
+  state->heapsize1 = heap1->heapsize;
+  state->heapsize2 = heap2->heapsize;
 
-  to_ignore1 = i1;
-  to_ignore2 = i2;
+  state->to_ignore1 = i1;
+  state-> to_ignore2 = i2;
 
-  equals_to1 = malloc(heaplimit * sizeof(heap_area_t *));
-  types1 = malloc(heaplimit * sizeof(type_name *));
-  for(i=0; i<=heaplimit; i++){
-    equals_to1[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(heap_area_t));
-    types1[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(type_name));
-    for(j=0; j<MAX_FRAGMENT_PER_BLOCK; j++){
-      equals_to1[i][j] = NULL;
-      types1[i][j] = NULL;
-    }      
+  if(state->heaplimit > state->available) {
+    state->equals_to1 = realloc(state->equals_to1, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
+    state->types1 = realloc(state->types1, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
+    state->equals_to2 = realloc(state->equals_to2, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
+    state->types2 = realloc(state->types2, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
+    state->available = state->heaplimit;
   }
 
-  equals_to2 = malloc(heaplimit * sizeof(heap_area_t *));
-  types2 = malloc(heaplimit * sizeof(type_name *));
-  for(i=0; i<=heaplimit; i++){
-    equals_to2[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(heap_area_t));
-    types2[i] = malloc(MAX_FRAGMENT_PER_BLOCK * sizeof(type_name));
-    for(j=0; j<MAX_FRAGMENT_PER_BLOCK; j++){
-      equals_to2[i][j] = NULL;
-      types2[i][j] = NULL;
-    }
-  }
+  memset(state->equals_to1, 0, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
+  memset(state->equals_to2, 0, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(s_heap_area_t));
+  memset(state->types1, 0, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
+  memset(state->types2, 0, state->heaplimit * MAX_FRAGMENT_PER_BLOCK * sizeof(type_name *));
 
   if(MC_is_active()){
-    MC_ignore_global_variable("heaplimit");
-    MC_ignore_global_variable("s_heap");
-    MC_ignore_global_variable("heapbase1");
-    MC_ignore_global_variable("heapbase2");
-    MC_ignore_global_variable("heapinfo1");
-    MC_ignore_global_variable("heapinfo2");
-    MC_ignore_global_variable("heapsize1");
-    MC_ignore_global_variable("heapsize2");
-    MC_ignore_global_variable("to_ignore1");
-    MC_ignore_global_variable("to_ignore2");
-    MC_ignore_global_variable("equals_to1");
-    MC_ignore_global_variable("equals_to2");
-    MC_ignore_global_variable("types1");
-    MC_ignore_global_variable("types2");
+    MC_ignore_global_variable("mm_diff_info");
   }
 
   return 0;
@@ -375,40 +365,11 @@ int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1,
 
 void reset_heap_information(){
 
-  size_t i = 0, j;
-
-  for(i=0; i<=heaplimit; i++){
-    for(j=0; j<MAX_FRAGMENT_PER_BLOCK;j++){
-      heap_area_free(equals_to1[i][j]);
-      equals_to1[i][j] = NULL;
-      heap_area_free(equals_to2[i][j]);
-      equals_to2[i][j] = NULL;
-      xbt_free(types1[i][j]);
-      types1[i][j] = NULL;
-      xbt_free(types2[i][j]);
-      types2[i][j] = NULL;
-    }
-    free(equals_to1[i]);
-    free(equals_to2[i]);
-    free(types1[i]);
-    free(types2[i]);
-  }
-
-  free(equals_to1);
-  free(equals_to2);
-  free(types1);
-  free(types2);
-
-  s_heap = NULL, heapbase1 = NULL, heapbase2 = NULL;
-  heapinfo1 = NULL, heapinfo2 = NULL;
-  heaplimit = 0, heapsize1 = 0, heapsize2 = 0;
-  to_ignore1 = NULL, to_ignore2 = NULL;
-  equals_to1 = NULL, equals_to2 = NULL;
-  types1 = NULL, types2 = NULL;
-
 }
 
-int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_types, xbt_dict_t other_types){
+int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_mheap_t heap1, xbt_mheap_t heap2){
+
+  struct s_mm_diff *state = mm_diff_info;
 
   if(heap1 == NULL && heap2 == NULL){
     XBT_DEBUG("Malloc descriptors null");
@@ -428,27 +389,27 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
 
   i1 = 1;
 
-  while(i1 <= heaplimit){
+  while(i1 <= state->heaplimit){
 
-    if(heapinfo1[i1].type == -1){ /* Free block */
+    if(state->heapinfo1[i1].type == -1){ /* Free block */
       i1++;
       continue;
     }
 
-    addr_block1 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
+    addr_block1 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase));
 
-    if(heapinfo1[i1].type == 0){  /* Large block */
+    if(state->heapinfo1[i1].type == 0){  /* Large block */
       
       if(is_stack(addr_block1)){
-        for(k=0; k < heapinfo1[i1].busy_block.size; k++)
-          equals_to1[i1+k][0] = new_heap_area(i1, -1);
-        for(k=0; k < heapinfo2[i1].busy_block.size; k++)
-          equals_to2[i1+k][0] = new_heap_area(i1, -1);
-        i1 += heapinfo1[i1].busy_block.size;
+        for(k=0; k < state->heapinfo1[i1].busy_block.size; k++)
+          state->equals_to1_(i1+k,0) = make_heap_area(i1, -1);
+        for(k=0; k < state->heapinfo2[i1].busy_block.size; k++)
+          state->equals_to2_(i1+k,0) = make_heap_area(i1, -1);
+        i1 += state->heapinfo1[i1].busy_block.size;
         continue;
       }
 
-      if(equals_to1[i1][0] != NULL){
+      if(state->equals_to1_(i1,0).valid){
         i1++;
         continue;
       }
@@ -458,21 +419,21 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
       res_compare = 0;
   
       /* Try first to associate to same block in the other heap */
-      if(heapinfo2[i1].type == heapinfo1[i1].type){
+      if(state->heapinfo2[i1].type == state->heapinfo1[i1].type){
 
-        if(equals_to2[i1][0] == NULL){
+        if(state->equals_to2_(i1,0).valid == 0){
 
-          addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
+          addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase));
         
-          res_compare = compare_heap_area(addr_block1, addr_block2, NULL, all_types, other_types, NULL, 0);
+          res_compare = compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2, NULL, NULL, 0);
         
           if(res_compare != 1){
-            for(k=1; k < heapinfo2[i1].busy_block.size; k++)
-              equals_to2[i1+k][0] = new_heap_area(i1, -1);
-            for(k=1; k < heapinfo1[i1].busy_block.size; k++)
-              equals_to1[i1+k][0] = new_heap_area(i1, -1);
+            for(k=1; k < state->heapinfo2[i1].busy_block.size; k++)
+              state->equals_to2_(i1+k,0) = make_heap_area(i1, -1);
+            for(k=1; k < state->heapinfo1[i1].busy_block.size; k++)
+              state->equals_to1_(i1+k,0) = make_heap_area(i1, -1);
             equal = 1;
-            i1 += heapinfo1[i1].busy_block.size;
+            i1 += state->heapinfo1[i1].busy_block.size;
           }
         
           xbt_dynar_reset(previous);
@@ -481,34 +442,34 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
         
       }
 
-      while(i2 <= heaplimit && !equal){
+      while(i2 <= state->heaplimit && !equal){
 
-        addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));        
+        addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase));
            
         if(i2 == i1){
           i2++;
           continue;
         }
 
-        if(heapinfo2[i2].type != 0){
+        if(state->heapinfo2[i2].type != 0){
           i2++;
           continue;
         }
     
-        if(equals_to2[i2][0] != NULL){  
+        if(state->equals_to2_(i2,0).valid){
           i2++;
           continue;
         }
           
-        res_compare = compare_heap_area(addr_block1, addr_block2, NULL, all_types, other_types, NULL, 0);
+        res_compare = compare_heap_area(addr_block1, addr_block2, snapshot1, snapshot2, NULL, NULL, 0);
         
         if(res_compare != 1 ){
-          for(k=1; k < heapinfo2[i2].busy_block.size; k++)
-            equals_to2[i2+k][0] = new_heap_area(i1, -1);
-          for(k=1; k < heapinfo1[i1].busy_block.size; k++)
-            equals_to1[i1+k][0] = new_heap_area(i2, -1);
+          for(k=1; k < state->heapinfo2[i2].busy_block.size; k++)
+            state->equals_to2_(i2+k,0) = make_heap_area(i1, -1);
+          for(k=1; k < state->heapinfo1[i1].busy_block.size; k++)
+            state->equals_to1_(i1+k,0) = make_heap_area(i2, -1);
           equal = 1;
-          i1 += heapinfo1[i1].busy_block.size;
+          i1 += state->heapinfo1[i1].busy_block.size;
         }
 
         xbt_dynar_reset(previous);
@@ -518,36 +479,36 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
       }
 
       if(!equal){
-        XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, heapinfo1[i1].busy_block.busy_size, addr_block1);
-        i1 = heaplimit + 1;
+        XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, state->heapinfo1[i1].busy_block.busy_size, addr_block1);
+        i1 = state->heaplimit + 1;
         nb_diff1++;
           //i1++;
       }
       
     }else{ /* Fragmented block */
 
-      for(j1=0; j1 < (size_t) (BLOCKSIZE >> heapinfo1[i1].type); j1++){
+      for(j1=0; j1 < (size_t) (BLOCKSIZE >> state->heapinfo1[i1].type); j1++){
 
-        if(heapinfo1[i1].busy_frag.frag_size[j1] == -1) /* Free fragment */
+        if(state->heapinfo1[i1].busy_frag.frag_size[j1] == -1) /* Free fragment */
           continue;
 
-        if(equals_to1[i1][j1] != NULL)
+        if(state->equals_to1_(i1,j1).valid)
           continue;
 
-        addr_frag1 = (void*) ((char *)addr_block1 + (j1 << heapinfo1[i1].type));
+        addr_frag1 = (void*) ((char *)addr_block1 + (j1 << state->heapinfo1[i1].type));
 
         i2 = 1;
         equal = 0;
         
         /* Try first to associate to same fragment in the other heap */
-        if(heapinfo2[i1].type == heapinfo1[i1].type){
+        if(state->heapinfo2[i1].type == state->heapinfo1[i1].type){
 
-          if(equals_to2[i1][j1] == NULL){
+          if(state->equals_to2_(i1,j1).valid == 0){
 
-            addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
-            addr_frag2 = (void*) ((char *)addr_block2 + (j1 << ((xbt_mheap_t)s_heap)->heapinfo[i1].type));
+            addr_block2 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase));
+            addr_frag2 = (void*) ((char *)addr_block2 + (j1 << ((xbt_mheap_t)state->s_heap)->heapinfo[i1].type));
 
-            res_compare = compare_heap_area(addr_frag1, addr_frag2, NULL, all_types, other_types, NULL, 0);
+            res_compare = compare_heap_area(addr_frag1, addr_frag2, snapshot1, snapshot2, NULL, NULL, 0);
 
             if(res_compare !=  1)
               equal = 1;
@@ -558,25 +519,25 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
 
         }
 
-        while(i2 <= heaplimit && !equal){
+        while(i2 <= state->heaplimit && !equal){
 
-          if(heapinfo2[i2].type <= 0){
+          if(state->heapinfo2[i2].type <= 0){
             i2++;
             continue;
           }
 
-          for(j2=0; j2 < (size_t) (BLOCKSIZE >> heapinfo2[i2].type); j2++){
+          for(j2=0; j2 < (size_t) (BLOCKSIZE >> state->heapinfo2[i2].type); j2++){
 
             if(i2 == i1 && j2 == j1)
               continue;
            
-            if(equals_to2[i2][j2] != NULL)
+            if(state->equals_to2_(i2,j2).valid)
               continue;
                           
-            addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
-            addr_frag2 = (void*) ((char *)addr_block2 + (j2 <<((xbt_mheap_t)s_heap)->heapinfo[i2].type));
+            addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase));
+            addr_frag2 = (void*) ((char *)addr_block2 + (j2 <<((xbt_mheap_t)state->s_heap)->heapinfo[i2].type));
 
-            res_compare = compare_heap_area(addr_frag1, addr_frag2, NULL, all_types, other_types, NULL, 0);
+            res_compare = compare_heap_area(addr_frag1, addr_frag2, snapshot2, snapshot2, NULL, NULL, 0);
             
             if(res_compare != 1){
               equal = 1;
@@ -593,9 +554,9 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
         }
 
         if(!equal){
-          XBT_DEBUG("Block %zu, fragment %zu not found (size_used = %zd, address = %p)\n", i1, j1, heapinfo1[i1].busy_frag.frag_size[j1], addr_frag1);
-          i2 = heaplimit + 1;
-          i1 = heaplimit + 1;
+          XBT_DEBUG("Block %zu, fragment %zu not found (size_used = %zd, address = %p)\n", i1, j1, state->heapinfo1[i1].busy_frag.frag_size[j1], addr_frag1);
+          i2 = state->heaplimit + 1;
+          i1 = state->heaplimit + 1;
           nb_diff1++;
           break;
         }
@@ -612,14 +573,14 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
   size_t i = 1, j = 0;
   void *real_addr_frag1 = NULL, *real_addr_block1 = NULL, *real_addr_block2 = NULL, *real_addr_frag2 = NULL;
  
-  while(i<=heaplimit){
-    if(heapinfo1[i].type == 0){
-      if(i1 == heaplimit){
-        if(heapinfo1[i].busy_block.busy_size > 0){
-          if(equals_to1[i][0] == NULL){            
+  while(i<=state->heaplimit){
+    if(state->heapinfo1[i].type == 0){
+      if(i1 == state->heaplimit){
+        if(state->heapinfo1[i].busy_block.busy_size > 0){
+          if(state->equals_to1_(i,0).valid == 0){
             if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
-              addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
-              XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block1, heapinfo1[i].busy_block.busy_size);
+              addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)state->heapbase1));
+              XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block1, state->heapinfo1[i].busy_block.busy_size);
               //mmalloc_backtrace_block_display((void*)heapinfo1, i);
             }
             nb_diff1++;
@@ -627,17 +588,17 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
         }
       }
     }
-    if(heapinfo1[i].type > 0){
-      addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
-      real_addr_block1 =  ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)((struct mdesc *)s_heap)->heapbase));
-      for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo1[i].type); j++){
-        if(i1== heaplimit){
-          if(heapinfo1[i].busy_frag.frag_size[j] > 0){
-            if(equals_to1[i][j] == NULL){
+    if(state->heapinfo1[i].type > 0){
+      addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)state->heapbase1));
+      real_addr_block1 =  ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)((struct mdesc *)state->s_heap)->heapbase));
+      for(j=0; j < (size_t) (BLOCKSIZE >> state->heapinfo1[i].type); j++){
+        if(i1== state->heaplimit){
+          if(state->heapinfo1[i].busy_frag.frag_size[j] > 0){
+            if(state->equals_to1_(i,j).valid == 0){
               if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
-                addr_frag1 = (void*) ((char *)addr_block1 + (j << heapinfo1[i].type));
-                real_addr_frag1 = (void*) ((char *)real_addr_block1 + (j << ((struct mdesc *)s_heap)->heapinfo[i].type));
-                XBT_DEBUG("Block %zu, Fragment %zu (%p - %p) not found (size used = %zd)", i, j, addr_frag1, real_addr_frag1, heapinfo1[i].busy_frag.frag_size[j]);
+                addr_frag1 = (void*) ((char *)addr_block1 + (j << state->heapinfo1[i].type));
+                real_addr_frag1 = (void*) ((char *)real_addr_block1 + (j << ((struct mdesc *)state->s_heap)->heapinfo[i].type));
+                XBT_DEBUG("Block %zu, Fragment %zu (%p - %p) not found (size used = %zd)", i, j, addr_frag1, real_addr_frag1, state->heapinfo1[i].busy_frag.frag_size[j]);
                 //mmalloc_backtrace_fragment_display((void*)heapinfo1, i, j);
               }
               nb_diff1++;
@@ -649,19 +610,19 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
     i++; 
   }
 
-  if(i1 == heaplimit)
+  if(i1 == state->heaplimit)
     XBT_DEBUG("Number of blocks/fragments not found in heap1 : %d", nb_diff1);
 
   i = 1;
 
-  while(i<=heaplimit){
-    if(heapinfo2[i].type == 0){
-      if(i1 == heaplimit){
-        if(heapinfo2[i].busy_block.busy_size > 0){
-          if(equals_to2[i][0] == NULL){
+  while(i<=state->heaplimit){
+    if(state->heapinfo2[i].type == 0){
+      if(i1 == state->heaplimit){
+        if(state->heapinfo2[i].busy_block.busy_size > 0){
+          if(state->equals_to2_(i,0).valid == 0){
             if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
-              addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
-              XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block2, heapinfo2[i].busy_block.busy_size);
+              addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)state->heapbase2));
+              XBT_DEBUG("Block %zu (%p) not found (size used = %zu)", i, addr_block2, state->heapinfo2[i].busy_block.busy_size);
               //mmalloc_backtrace_block_display((void*)heapinfo2, i);
             }
             nb_diff2++;
@@ -669,17 +630,17 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
         }
       }
     }
-    if(heapinfo2[i].type > 0){
-      addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
-      real_addr_block2 =  ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)((struct mdesc *)s_heap)->heapbase));
-      for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo2[i].type); j++){
-        if(i1 == heaplimit){
-          if(heapinfo2[i].busy_frag.frag_size[j] > 0){
-            if(equals_to2[i][j] == NULL){
+    if(state->heapinfo2[i].type > 0){
+      addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)state->heapbase2));
+      real_addr_block2 =  ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)((struct mdesc *)state->s_heap)->heapbase));
+      for(j=0; j < (size_t) (BLOCKSIZE >> state->heapinfo2[i].type); j++){
+        if(i1 == state->heaplimit){
+          if(state->heapinfo2[i].busy_frag.frag_size[j] > 0){
+            if(state->equals_to2_(i,j).valid == 0){
               if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){
-                addr_frag2 = (void*) ((char *)addr_block2 + (j << heapinfo2[i].type));
-                real_addr_frag2 = (void*) ((char *)real_addr_block2 + (j << ((struct mdesc *)s_heap)->heapinfo[i].type));
-                XBT_DEBUG( "Block %zu, Fragment %zu (%p - %p) not found (size used = %zd)", i, j, addr_frag2, real_addr_frag2, heapinfo2[i].busy_frag.frag_size[j]);
+                addr_frag2 = (void*) ((char *)addr_block2 + (j << state->heapinfo2[i].type));
+                real_addr_frag2 = (void*) ((char *)real_addr_block2 + (j << ((struct mdesc *)state->s_heap)->heapinfo[i].type));
+                XBT_DEBUG( "Block %zu, Fragment %zu (%p - %p) not found (size used = %zd)", i, j, addr_frag2, real_addr_frag2, state->heapinfo2[i].busy_frag.frag_size[j]);
                 //mmalloc_backtrace_fragment_display((void*)heapinfo2, i, j);
               }
               nb_diff2++;
@@ -691,7 +652,7 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
     i++; 
   }
 
-  if(i1 == heaplimit)
+  if(i1 == state->heaplimit)
     XBT_DEBUG("Number of blocks/fragments not found in heap2 : %d", nb_diff2);
 
   xbt_dynar_free(&previous);
@@ -700,17 +661,31 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dict_t all_ty
   return ((nb_diff1 > 0) || (nb_diff2 > 0));
 }
 
-static int compare_heap_area_without_type(void *real_area1, void *real_area2, void *area1, void *area2, xbt_dynar_t previous, xbt_dict_t all_types, xbt_dict_t other_types, int size, int check_ignore){
+/**
+ *
+ * @param state
+ * @param real_area1     Process address for state 1
+ * @param real_area2     Process address for state 2
+ * @param area1          Snapshot address for state 1
+ * @param area2          Snapshot address for state 2
+ * @param snapshot1      Snapshot of state 1
+ * @param snapshot2      Snapshot of state 2
+ * @param previous
+ * @param size
+ * @param check_ignore
+ */
+static int compare_heap_area_without_type(struct s_mm_diff *state, void *real_area1, void *real_area2, void *area1, void *area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_dynar_t previous, int size, int check_ignore){
 
   int i = 0;
   void *addr_pointed1, *addr_pointed2;
-  int pointer_align, ignore1, ignore2, res_compare;
+  int pointer_align, res_compare;
+  ssize_t ignore1, ignore2;
 
   while(i<size){
 
     if(check_ignore > 0){
-      if((ignore1 = heap_comparison_ignore_size(to_ignore1, (char *)real_area1 + i)) != -1){
-        if((ignore2 = heap_comparison_ignore_size(to_ignore2, (char *)real_area2 + i))  == ignore1){
+      if((ignore1 = heap_comparison_ignore_size(state->to_ignore1, (char *)real_area1 + i)) != -1){
+        if((ignore2 = heap_comparison_ignore_size(state->to_ignore2, (char *)real_area2 + i))  == ignore1){
           if(ignore1 == 0){
             check_ignore--;
             return 0;
@@ -732,9 +707,9 @@ static int compare_heap_area_without_type(void *real_area1, void *real_area2, vo
       if(addr_pointed1 > maestro_stack_start && addr_pointed1 < maestro_stack_end && addr_pointed2 > maestro_stack_start && addr_pointed2 < maestro_stack_end){
         i = pointer_align + sizeof(void *);
         continue;
-      }else if((addr_pointed1 > s_heap) && ((char *)addr_pointed1 < (char *)s_heap + STD_HEAP_SIZE) 
-               && (addr_pointed2 > s_heap) && ((char *)addr_pointed2 < (char *)s_heap + STD_HEAP_SIZE)){
-        res_compare = compare_heap_area(addr_pointed1, addr_pointed2, previous, all_types, other_types, NULL, 0); 
+      }else if((addr_pointed1 > state->s_heap) && ((char *)addr_pointed1 < (char *)state->s_heap + STD_HEAP_SIZE)
+               && (addr_pointed2 > state->s_heap) && ((char *)addr_pointed2 < (char *)state->s_heap + STD_HEAP_SIZE)){
+        res_compare = compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, NULL, 0);
         if(res_compare == 1){
           return res_compare;
         }
@@ -754,103 +729,113 @@ static int compare_heap_area_without_type(void *real_area1, void *real_area2, vo
  
 }
 
-
-static int compare_heap_area_with_type(void *real_area1, void *real_area2, void *area1, void *area2, 
-                                       xbt_dynar_t previous, xbt_dict_t all_types, xbt_dict_t other_types, char *type_id, 
+/**
+ *
+ * @param state
+ * @param real_area1     Process address for state 1
+ * @param real_area2     Process address for state 2
+ * @param area1          Snapshot address for state 1
+ * @param area2          Snapshot address for state 2
+ * @param snapshot1      Snapshot of state 1
+ * @param snapshot2      Snapshot of state 2
+ * @param previous
+ * @param type_id
+ * @param area_size      either a byte_size or an elements_count (?)
+ * @param check_ignore
+ * @param pointer_level
+ * @return               0 (same), 1 (different), -1 (unknown)
+ */
+static int compare_heap_area_with_type(struct s_mm_diff *state, void *real_area1, void *real_area2, void *area1, void *area2,
+                                       mc_snapshot_t snapshot1, mc_snapshot_t snapshot2,
+                                       xbt_dynar_t previous, dw_type_t type,
                                        int area_size, int check_ignore, int pointer_level){
 
   if(is_stack(real_area1) && is_stack(real_area2))
     return 0;
 
-  size_t ignore1, ignore2;
+  ssize_t ignore1, ignore2;
 
-  if((check_ignore > 0) && ((ignore1 = heap_comparison_ignore_size(to_ignore1, real_area1)) > 0) && ((ignore2 = heap_comparison_ignore_size(to_ignore2, real_area2))  == ignore1)){
+  if((check_ignore > 0) && ((ignore1 = heap_comparison_ignore_size(state->to_ignore1, real_area1)) > 0) && ((ignore2 = heap_comparison_ignore_size(state->to_ignore2, real_area2))  == ignore1)){
     return 0;
   }
   
-  dw_type_t type = xbt_dict_get_or_null(all_types, type_id);
   dw_type_t subtype, subsubtype;
-  int res, elm_size, i, switch_types = 0;
+  int res, elm_size, i;
   unsigned int cursor = 0;
   dw_type_t member;
   void *addr_pointed1, *addr_pointed2;;
-  char *type_desc;
 
   switch(type->type){
-  case e_dw_base_type:
-    if(strcmp(type->name, "char") == 0){ /* String, hence random (arbitrary ?) size */
+  case DW_TAG_unspecified_type:
+    return 1;
+
+  case DW_TAG_base_type:
+    if(type->name!=NULL && strcmp(type->name, "char") == 0){ /* String, hence random (arbitrary ?) size */
       if(real_area1 == real_area2)
         return -1;
       else
         return (memcmp(area1, area2, area_size) != 0);
     }else{
-      if(area_size != -1 && type->size != area_size)
+      if(area_size != -1 && type->byte_size != area_size)
         return -1;
       else{
-        return  (memcmp(area1, area2, type->size) != 0);
+        return  (memcmp(area1, area2, type->byte_size) != 0);
       }
     }
     break;
-  case e_dw_enumeration_type:
-    if(area_size != -1 && type->size != area_size)
+  case DW_TAG_enumeration_type:
+    if(area_size != -1 && type->byte_size != area_size)
       return -1;
     else
-      return (memcmp(area1, area2, type->size) != 0);
+      return (memcmp(area1, area2, type->byte_size) != 0);
     break;
-  case e_dw_typedef:
-    return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->dw_type_id, area_size, check_ignore, pointer_level);
+  case DW_TAG_typedef:
+  case DW_TAG_const_type:
+  case DW_TAG_volatile_type:
+    return compare_heap_area_with_type(state, real_area1, real_area2, area1, area2, snapshot1, snapshot2, previous, type->subtype, area_size, check_ignore, pointer_level);
     break;
-  case e_dw_const_type:
-    return 0;
-    break;
-  case e_dw_array_type:
-    subtype = xbt_dict_get_or_null(all_types, type->dw_type_id);
+  case DW_TAG_array_type:
+    subtype = type->subtype;
     switch(subtype->type){
-    case e_dw_base_type:
-    case e_dw_enumeration_type:
-    case e_dw_pointer_type:
-    case e_dw_structure_type:
-    case e_dw_union_type:
-      if(subtype->size == 0){ /*declaration of the type, need the complete description */
-        type_desc = get_type_description(all_types, subtype->name);
-        if(type_desc){
-          subtype = xbt_dict_get_or_null(all_types, type_desc);
-        }else{
-          subtype = xbt_dict_get_or_null(other_types, get_type_description(other_types, subtype->name));
-          switch_types = 1;
-        }
-      }
-      elm_size = subtype->size;
+    case DW_TAG_unspecified_type:
+      return 1;
+
+    case DW_TAG_base_type:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_pointer_type:
+    case DW_TAG_reference_type:
+    case DW_TAG_rvalue_reference_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_class_type:
+    case DW_TAG_union_type:
+      if(subtype->full_type)
+        subtype = subtype->full_type;
+      elm_size = subtype->byte_size;
       break;
-    case e_dw_typedef:
-    case e_dw_volatile_type:
-      subsubtype = xbt_dict_get_or_null(all_types, subtype->dw_type_id);
-      if(subsubtype->size == 0){ /*declaration of the type, need the complete description */
-        type_desc = get_type_description(all_types, subsubtype->name);
-        if(type_desc){
-          subsubtype = xbt_dict_get_or_null(all_types, type_desc);
-        }else{
-          subsubtype = xbt_dict_get_or_null(other_types, get_type_description(other_types, subtype->name));
-          switch_types = 1;
-        }
-      }
-      elm_size = subsubtype->size;
+    // TODO, just remove the type indirection?
+    case DW_TAG_const_type:
+    case DW_TAG_typedef:
+    case DW_TAG_volatile_type:
+      subsubtype = subtype->subtype;
+      if(subsubtype->full_type)
+        subsubtype = subsubtype->full_type;
+      elm_size = subsubtype->byte_size;
       break;
     default : 
       return 0;
       break;
     }
-    for(i=0; i<type->size; i++){ 
-      if(switch_types)
-        res = compare_heap_area_with_type((char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), previous, other_types, all_types, type->dw_type_id, type->size, check_ignore, pointer_level);
-      else
-        res = compare_heap_area_with_type((char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), previous, all_types, other_types, type->dw_type_id, type->size, check_ignore, pointer_level);
+    for(i=0; i<type->element_count; i++){
+      // TODO, add support for variable stride (DW_AT_byte_stride)
+      res = compare_heap_area_with_type(state, (char *)real_area1 + (i*elm_size), (char *)real_area2 + (i*elm_size), (char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), snapshot1, snapshot2, previous, type->subtype, subtype->byte_size, check_ignore, pointer_level);
       if(res == 1)
         return res;
     }
     break;
-  case e_dw_pointer_type:
-    if(type->dw_type_id && ((dw_type_t)xbt_dict_get_or_null(all_types, type->dw_type_id))->type == e_dw_subroutine_type){
+  case DW_TAG_reference_type:
+  case DW_TAG_rvalue_reference_type:
+  case DW_TAG_pointer_type:
+    if(type->subtype && type->subtype->type == DW_TAG_subroutine_type){
       addr_pointed1 = *((void **)(area1)); 
       addr_pointed2 = *((void **)(area2));
       return (addr_pointed1 != addr_pointed2);;
@@ -860,8 +845,8 @@ static int compare_heap_area_with_type(void *real_area1, void *real_area2, void
         for(i=0; i<(area_size/sizeof(void *)); i++){ 
           addr_pointed1 = *((void **)((char *)area1 + (i*sizeof(void *)))); 
           addr_pointed2 = *((void **)((char *)area2 + (i*sizeof(void *)))); 
-          if(addr_pointed1 > s_heap && (char *)addr_pointed1 < (char*) s_heap + STD_HEAP_SIZE && addr_pointed2 > s_heap && (char *)addr_pointed2 < (char*) s_heap + STD_HEAP_SIZE)
-            res =  compare_heap_area(addr_pointed1, addr_pointed2, previous, all_types, other_types, type->dw_type_id, pointer_level); 
+          if(addr_pointed1 > state->s_heap && (char *)addr_pointed1 < (char*) state->s_heap + STD_HEAP_SIZE && addr_pointed2 > state->s_heap && (char *)addr_pointed2 < (char*) state->s_heap + STD_HEAP_SIZE)
+            res =  compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, type->subtype, pointer_level);
           else
             res =  (addr_pointed1 != addr_pointed2);
           if(res == 1)
@@ -870,30 +855,21 @@ static int compare_heap_area_with_type(void *real_area1, void *real_area2, void
       }else{
         addr_pointed1 = *((void **)(area1)); 
         addr_pointed2 = *((void **)(area2));
-        if(addr_pointed1 > s_heap && (char *)addr_pointed1 < (char*) s_heap + STD_HEAP_SIZE && addr_pointed2 > s_heap && (char *)addr_pointed2 < (char*) s_heap + STD_HEAP_SIZE)
-          return compare_heap_area(addr_pointed1, addr_pointed2, previous, all_types, other_types, type->dw_type_id, pointer_level); 
+        if(addr_pointed1 > state->s_heap && (char *)addr_pointed1 < (char*) state->s_heap + STD_HEAP_SIZE && addr_pointed2 > state->s_heap && (char *)addr_pointed2 < (char*) state->s_heap + STD_HEAP_SIZE)
+          return compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, previous, type->subtype, pointer_level);
         else
           return  (addr_pointed1 != addr_pointed2);
       }
     }
     break;
-  case e_dw_structure_type:
-    if(type->size == 0){ /*declaration of the structure, need the complete description */
-      type_desc = get_type_description(all_types, type->name);
-      if(type_desc){
-        type = xbt_dict_get_or_null(all_types, type_desc);
-      }else{
-        type = xbt_dict_get_or_null(other_types, get_type_description(other_types, type->name));
-        switch_types = 1;
-      }
-    }
-    if(area_size != -1 && type->size != area_size){
-      if(area_size>type->size && area_size%type->size == 0){
-        for(i=0; i<(area_size/type->size); i++){ 
-          if(switch_types)
-            res = compare_heap_area_with_type((char *)real_area1 + (i*type->size), (char *)real_area2 + (i*type->size), (char *)area1 + (i*type->size), (char *)area2 + (i*type->size), previous, other_types, all_types, type_id, -1, check_ignore, 0); 
-          else
-            res = compare_heap_area_with_type((char *)real_area1 + (i*type->size), (char *)real_area2 + (i*type->size), (char *)area1 + (i*type->size), (char *)area2 + (i*type->size), previous, all_types, other_types, type_id, -1, check_ignore, 0); 
+  case DW_TAG_structure_type:
+  case DW_TAG_class_type:
+    if(type->full_type)
+      type = type->full_type;
+    if(area_size != -1 && type->byte_size != area_size){
+      if(area_size>type->byte_size && area_size%type->byte_size == 0){
+        for(i=0; i<(area_size/type->byte_size); i++){
+          res = compare_heap_area_with_type(state, (char *)real_area1 + (i*type->byte_size), (char *)real_area2 + (i*type->byte_size), (char *)area1 + (i*type->byte_size), (char *)area2 + (i*type->byte_size), snapshot1, snapshot2, previous, type, -1, check_ignore, 0);
           if(res == 1)
             return res;
         }
@@ -902,22 +878,21 @@ static int compare_heap_area_with_type(void *real_area1, void *real_area2, void
       }
     }else{
       cursor = 0;
-      xbt_dynar_foreach(type->members, cursor, member){ 
-        if(switch_types)
-          res = compare_heap_area_with_type((char *)real_area1 + member->offset, (char *)real_area2 + member->offset, (char *)area1 + member->offset, (char *)area2 + member->offset, previous, other_types, all_types, member->dw_type_id, -1, check_ignore, 0);
-        else
-          res = compare_heap_area_with_type((char *)real_area1 + member->offset, (char *)real_area2 + member->offset, (char *)area1 + member->offset, (char *)area2 + member->offset, previous, all_types, other_types, member->dw_type_id, -1, check_ignore, 0);  
+      xbt_dynar_foreach(type->members, cursor, member){
+        // TODO, optimize this? (for the offset case)
+        char* real_member1 = mc_member_resolve(real_area1, type, member, snapshot1);
+        char* real_member2 = mc_member_resolve(real_area2, type, member, snapshot2);
+        char* member1 = mc_translate_address((uintptr_t)real_member1, snapshot1);
+        char* member2 = mc_translate_address((uintptr_t)real_member2, snapshot2);
+        res = compare_heap_area_with_type(state, real_member1, real_member2, member1, member2, snapshot1, snapshot2, previous, member->subtype, -1, check_ignore, 0);
         if(res == 1){
           return res;
         }
       }
     }
     break;
-  case e_dw_union_type:
-    return compare_heap_area_without_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->size, check_ignore);
-    break;
-  case e_dw_volatile_type:
-    return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->dw_type_id, area_size, check_ignore, pointer_level);
+  case DW_TAG_union_type:
+    return compare_heap_area_without_type(state, real_area1, real_area2, area1, area2, snapshot1, snapshot2, previous, type->byte_size, check_ignore);
     break;
   default:
     break;
@@ -927,46 +902,48 @@ static int compare_heap_area_with_type(void *real_area1, void *real_area2, void
 
 }
 
-static char* get_offset_type(char* type_id, int offset, xbt_dict_t all_types, xbt_dict_t other_types, int area_size, int *switch_type){
-  dw_type_t type = xbt_dict_get_or_null(all_types, type_id);
-  if(type == NULL){
-    type = xbt_dict_get_or_null(other_types, type_id);
-    *switch_type = 1;
-  }
-  char* type_desc;
+/** Infer the type of a part of the block from the type of the block
+ *
+ * TODO, handle DW_TAG_array_type as well as arrays of the object ((*p)[5], p[5])
+ *
+ * TODO, handle subfields ((*p).bar.foo, (*p)[5].bar…)
+ *
+ * @param  type_id            DWARF type ID of the root address
+ * @param  area_size
+ * @return                    DWARF type ID for given offset
+ */
+static dw_type_t get_offset_type(void* real_base_address, dw_type_t type, int offset, int area_size, mc_snapshot_t snapshot){
+
+  // Beginning of the block, the infered variable type if the type of the block:
+  if(offset==0)
+    return type;
+
   switch(type->type){
-  case e_dw_structure_type :
-    if(type->size == 0){ /*declaration of the structure, need the complete description */
-      if(*switch_type == 0){
-        type_desc = get_type_description(all_types, type->name);
-        if(type_desc){
-          type = xbt_dict_get_or_null(all_types, type_desc);
-        }else{
-          type = xbt_dict_get_or_null(other_types, get_type_description(other_types, type->name));
-          *switch_type = 1;
-        }
-      }else{
-        type_desc = get_type_description(other_types, type->name);
-        if(type_desc){
-          type = xbt_dict_get_or_null(other_types, type_desc);
-        }else{
-          type = xbt_dict_get_or_null(all_types, get_type_description(other_types, type->name));
-          *switch_type = 0;
-        }
-      }
+  case DW_TAG_structure_type :
+  case DW_TAG_class_type:
+    if(type->full_type)
+      type = type->full_type;
     
-    }
-    if(area_size != -1 && type->size != area_size){
-      if(area_size>type->size && area_size%type->size == 0)
-        return type_id;
+    if(area_size != -1 && type->byte_size != area_size){
+      if(area_size>type->byte_size && area_size%type->byte_size == 0)
+        return type;
       else
         return NULL;
     }else{
       unsigned int cursor = 0;
       dw_type_t member;
       xbt_dynar_foreach(type->members, cursor, member){ 
-        if(member->offset == offset)
-          return member->dw_type_id;
+
+        if(!member->location.size) {
+          // We have the offset, use it directly (shortcut):
+          if(member->offset == offset)
+            return member->subtype;
+        } else {
+          char* real_member = mc_member_resolve(real_base_address, type, member, snapshot);
+          if(real_member - (char*)real_base_address == offset)
+            return member->subtype;
+        }
+
       }
       return NULL;
     }
@@ -978,7 +955,20 @@ static char* get_offset_type(char* type_id, int offset, xbt_dict_t all_types, xb
   }
 }
 
-int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t all_types, xbt_dict_t other_types, char *type_id, int pointer_level){
+/**
+ *
+ * @param area1          Process address for state 1
+ * @param area2          Process address for state 2
+ * @param snapshot1      Snapshot of state 1
+ * @param snapshot2      Snapshot of state 2
+ * @param previous       Pairs of blocks already compared on the current path (or NULL)
+ * @param type_id        Type of variable
+ * @param pointer_level
+ * @return 0 (same), 1 (different), -1
+ */
+int compare_heap_area(void *area1, void* area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_dynar_t previous, dw_type_t type, int pointer_level){
+
+  struct s_mm_diff* state = mm_diff_info;
 
   int res_compare;
   ssize_t block1, frag1, block2, frag2;
@@ -987,13 +977,10 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
 
   void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2, *real_addr_block1, *real_addr_block2,  *real_addr_frag1, *real_addr_frag2;
   void *area1_to_compare, *area2_to_compare;
-  dw_type_t type = NULL;
-  char *type_desc;
   int type_size = -1;
   int offset1 =0, offset2 = 0;
   int new_size1 = -1, new_size2 = -1;
-  char *new_type_id1 = NULL, *new_type_id2 = NULL;
-  int switch_type = 0;
+  dw_type_t new_type1 = NULL, new_type2 = NULL;
 
   int match_pairs = 0;
 
@@ -1002,64 +989,70 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
     match_pairs = 1;
   }
 
-  block1 = ((char*)area1 - (char*)((xbt_mheap_t)s_heap)->heapbase) / BLOCKSIZE + 1;
-  block2 = ((char*)area2 - (char*)((xbt_mheap_t)s_heap)->heapbase) / BLOCKSIZE + 1;
+  // Get block number:
+  block1 = ((char*)area1 - (char*)((xbt_mheap_t)state->s_heap)->heapbase) / BLOCKSIZE + 1;
+  block2 = ((char*)area2 - (char*)((xbt_mheap_t)state->s_heap)->heapbase) / BLOCKSIZE + 1;
 
+  // If either block is a stack block:
   if(is_block_stack((int)block1) && is_block_stack((int)block2)){
     add_heap_area_pair(previous, block1, -1, block2, -1);
     if(match_pairs){
-      match_equals(previous);
+      match_equals(state, previous);
       xbt_dynar_free(&previous);
     }
     return 0;
   }
 
-  if(((char *)area1 < (char*)((xbt_mheap_t)s_heap)->heapbase)  || (block1 > heapsize1) || (block1 < 1) || ((char *)area2 < (char*)((xbt_mheap_t)s_heap)->heapbase) || (block2 > heapsize2) || (block2 < 1)){
+  // If either block is not in the expected area of memory:
+  if(((char *)area1 < (char*)((xbt_mheap_t)state->s_heap)->heapbase)  || (block1 > state->heapsize1) || (block1 < 1)
+    || ((char *)area2 < (char*)((xbt_mheap_t)state->s_heap)->heapbase) || (block2 > state->heapsize2) || (block2 < 1)){
     if(match_pairs){
       xbt_dynar_free(&previous);
     }
     return 1;
   }
 
-  addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)heapbase1));
-  addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)heapbase2));
+  // Snapshot address of the block:
+  addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)state->heapbase1));
+  addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)state->heapbase2));
 
-  real_addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
-  real_addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)s_heap)->heapbase));
+  // Process address of the block:
+  real_addr_block1 = ((void*) (((ADDR2UINT(block1)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase));
+  real_addr_block2 = ((void*) (((ADDR2UINT(block2)) - 1) * BLOCKSIZE + (char*)((xbt_mheap_t)state->s_heap)->heapbase));
 
-  if(type_id){
-    type = xbt_dict_get_or_null(all_types, type_id);
-    if(type->size == 0){
-      if(type->dw_type_id == NULL){
-        type_desc = get_type_description(all_types, type->name);
-        if(type_desc)
-          type = xbt_dict_get_or_null(all_types, type_desc);
-        else
-          type = xbt_dict_get_or_null(other_types, get_type_description(other_types, type->name));
-      }else{
-        type = xbt_dict_get_or_null(all_types, type->dw_type_id);
-      }
-    }
-    if((type->type == e_dw_pointer_type) || ((type->type == e_dw_base_type) && (!strcmp(type->name, "char"))))
+  if(type){
+
+    if(type->full_type)
+      type = type->full_type;
+
+    // This assume that for "boring" types (volatile ...) byte_size is absent:
+    while(type->byte_size == 0 && type->subtype!=NULL)
+      type = type->subtype;
+
+    // Find type_size:
+    if((type->type == DW_TAG_pointer_type) || ((type->type == DW_TAG_base_type) && type->name!=NULL && (!strcmp(type->name, "char"))))
       type_size = -1;
     else
-      type_size = type->size;
+      type_size = type->byte_size;
+
   }
   
-  if((heapinfo1[block1].type == -1) && (heapinfo2[block2].type == -1)){  /* Free block */
+  if((state->heapinfo1[block1].type == -1) && (state->heapinfo2[block2].type == -1)){  /* Free block */
 
     if(match_pairs){
-      match_equals(previous);
+      match_equals(state, previous);
       xbt_dynar_free(&previous);
     }
     return 0;
 
-  }else if((heapinfo1[block1].type == 0) && (heapinfo2[block2].type == 0)){ /* Complete block */ 
+  }else if((state->heapinfo1[block1].type == 0) && (state->heapinfo2[block2].type == 0)){ /* Complete block */
     
-    if(equals_to1[block1][0] != NULL && equals_to2[block2][0] != NULL){
-      if(equal_blocks(block1, block2)){
+    // TODO, lookup variable type from block type as done for fragmented blocks
+
+    if(state->equals_to1_(block1,0).valid && state->equals_to2_(block2,0).valid){
+      if(equal_blocks(state, block1, block2)){
         if(match_pairs){
-          match_equals(previous);
+          match_equals(state, previous);
           xbt_dynar_free(&previous);
         }
         return 0;
@@ -1067,23 +1060,25 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
     }
 
     if(type_size != -1){
-      if(type_size != heapinfo1[block1].busy_block.busy_size && type_size != heapinfo2[block2].busy_block.busy_size && !strcmp(type->name, "s_smx_context")){
+      if(type_size != state->heapinfo1[block1].busy_block.busy_size
+        && type_size != state->heapinfo2[block2].busy_block.busy_size
+        && type->name!=NULL && !strcmp(type->name, "s_smx_context")){
         if(match_pairs){
-          match_equals(previous);
+          match_equals(state, previous);
           xbt_dynar_free(&previous);
         }
         return -1;
       }
     }
 
-    if(heapinfo1[block1].busy_block.size != heapinfo2[block2].busy_block.size){
+    if(state->heapinfo1[block1].busy_block.size != state->heapinfo2[block2].busy_block.size){
       if(match_pairs){
         xbt_dynar_free(&previous);
       }
       return 1;
     }
 
-    if(heapinfo1[block1].busy_block.busy_size != heapinfo2[block2].busy_block.busy_size){
+    if(state->heapinfo1[block1].busy_block.busy_size != state->heapinfo2[block2].busy_block.busy_size){
       if(match_pairs){
         xbt_dynar_free(&previous);
       }
@@ -1092,24 +1087,26 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
 
     if(!add_heap_area_pair(previous, block1, -1, block2, -1)){
       if(match_pairs){
-        match_equals(previous);
+        match_equals(state, previous);
         xbt_dynar_free(&previous);
       }
       return 0;
     }
  
-    size = heapinfo1[block1].busy_block.busy_size;
+    size = state->heapinfo1[block1].busy_block.busy_size;
     
-    if(type_id != NULL){
-      xbt_free(types1[block1][0]);
-      xbt_free(types2[block2][0]);
-      types1[block1][0] = strdup(type_id);
-      types2[block2][0] = strdup(type_id);
+    // Remember (basic) type inference.
+    // The current data structure only allows us to do this for the whole block.
+    if (type != NULL && area1==real_addr_block1) {
+      state->types1_(block1,0) = type;
+    }
+    if (type != NULL && area2==real_addr_block2) {
+      state->types2_(block2,0) = type;
     }
 
     if(size <= 0){
       if(match_pairs){
-        match_equals(previous);
+        match_equals(state, previous);
         xbt_dynar_free(&previous);
       }
       return 0;
@@ -1121,51 +1118,57 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
     area1_to_compare = addr_block1;
     area2_to_compare = addr_block2;
 
-    if((heapinfo1[block1].busy_block.ignore > 0) && (heapinfo2[block2].busy_block.ignore == heapinfo1[block1].busy_block.ignore))
-      check_ignore = heapinfo1[block1].busy_block.ignore;
+    if((state->heapinfo1[block1].busy_block.ignore > 0) && (state->heapinfo2[block2].busy_block.ignore == state->heapinfo1[block1].busy_block.ignore))
+      check_ignore = state->heapinfo1[block1].busy_block.ignore;
       
-  }else if((heapinfo1[block1].type > 0) && (heapinfo2[block2].type > 0)){ /* Fragmented block */
+  }else if((state->heapinfo1[block1].type > 0) && (state->heapinfo2[block2].type > 0)){ /* Fragmented block */
 
-    frag1 = ((uintptr_t) (ADDR2UINT (area1) % (BLOCKSIZE))) >> heapinfo1[block1].type;
-    frag2 = ((uintptr_t) (ADDR2UINT (area2) % (BLOCKSIZE))) >> heapinfo2[block2].type;
+    // Fragment number:
+    frag1 = ((uintptr_t) (ADDR2UINT (area1) % (BLOCKSIZE))) >> state->heapinfo1[block1].type;
+    frag2 = ((uintptr_t) (ADDR2UINT (area2) % (BLOCKSIZE))) >> state->heapinfo2[block2].type;
 
-    addr_frag1 = (void*) ((char *)addr_block1 + (frag1 << heapinfo1[block1].type));
-    addr_frag2 = (void*) ((char *)addr_block2 + (frag2 << heapinfo2[block2].type));
+    // Snapshot address of the fragment:
+    addr_frag1 = (void*) ((char *)addr_block1 + (frag1 << state->heapinfo1[block1].type));
+    addr_frag2 = (void*) ((char *)addr_block2 + (frag2 << state->heapinfo2[block2].type));
 
-    real_addr_frag1 = (void*) ((char *)real_addr_block1 + (frag1 << ((xbt_mheap_t)s_heap)->heapinfo[block1].type));
-    real_addr_frag2 = (void*) ((char *)real_addr_block2 + (frag2 << ((xbt_mheap_t)s_heap)->heapinfo[block2].type));
+    // Process address of the fragment:
+    real_addr_frag1 = (void*) ((char *)real_addr_block1 + (frag1 << ((xbt_mheap_t)state->s_heap)->heapinfo[block1].type));
+    real_addr_frag2 = (void*) ((char *)real_addr_block2 + (frag2 << ((xbt_mheap_t)state->s_heap)->heapinfo[block2].type));
 
+    // Check the size of the fragments against the size of the type:
     if(type_size != -1){
-      if(heapinfo1[block1].busy_frag.frag_size[frag1] == -1 || heapinfo2[block2].busy_frag.frag_size[frag2] == -1){
+      if(state->heapinfo1[block1].busy_frag.frag_size[frag1] == -1 || state->heapinfo2[block2].busy_frag.frag_size[frag2] == -1){
         if(match_pairs){
-          match_equals(previous);
+          match_equals(state, previous);
           xbt_dynar_free(&previous);
         }
         return -1;
       }
-      if(type_size != heapinfo1[block1].busy_frag.frag_size[frag1] || type_size !=  heapinfo2[block2].busy_frag.frag_size[frag2]){
+      if(type_size != state->heapinfo1[block1].busy_frag.frag_size[frag1]|| type_size !=  state->heapinfo2[block2].busy_frag.frag_size[frag2]){
         if(match_pairs){
-          match_equals(previous);
+          match_equals(state, previous);
           xbt_dynar_free(&previous);
         }
         return -1;
       }
     }
 
-    if(equals_to1[block1][frag1] != NULL && equals_to2[block2][frag2] != NULL){
-      if(equal_fragments(block1, frag1, block2, frag2)){
+    // Check if the blocks are already matched together:
+    if(state->equals_to1_(block1,frag1).valid && state->equals_to2_(block2,frag2).valid){
+      if(equal_fragments(state, block1, frag1, block2, frag2)){
         if(match_pairs){
-          match_equals(previous);
+          match_equals(state, previous);
           xbt_dynar_free(&previous);
         }
         return 0;
       }
     }
 
-    if(heapinfo1[block1].busy_frag.frag_size[frag1] != heapinfo2[block2].busy_frag.frag_size[frag2]){
+    // Compare the size of both fragments:
+    if(state->heapinfo1[block1].busy_frag.frag_size[frag1] != state->heapinfo2[block2].busy_frag.frag_size[frag2]){
       if(type_size == -1){
          if(match_pairs){
-          match_equals(previous);
+          match_equals(state, previous);
           xbt_dynar_free(&previous);
         }
         return -1;
@@ -1177,58 +1180,62 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
       }
     }
       
-    size = heapinfo1[block1].busy_frag.frag_size[frag1];
+    // Size of the fragment:
+    size = state->heapinfo1[block1].busy_frag.frag_size[frag1];
 
-    if(type_id != NULL){
-      xbt_free(types1[block1][frag1]);
-      xbt_free(types2[block2][frag2]);
-      types1[block1][frag1] = strdup(type_id);
-      types2[block2][frag2] = strdup(type_id);
+    // Remember (basic) type inference.
+    // The current data structure only allows us to do this for the whole block.
+    if(type != NULL && area1==real_addr_frag1){
+      state->types1_(block1,frag1) = type;
+    }
+    if(type != NULL && area2==real_addr_frag2) {
+      state->types2_(block2,frag2) = type;
     }
 
-    if(real_addr_frag1 != area1 || real_addr_frag2 != area2){
+    // The type of the variable is already known:
+    if(type) {
+      new_type1 = type;
+      new_type2 = type;
+    }
+
+    // Type inference from the block type.
+    else if(state->types1_(block1,frag1) != NULL || state->types2_(block2,frag2) != NULL) {
+
       offset1 = (char *)area1 - (char *)real_addr_frag1;
       offset2 = (char *)area2 - (char *)real_addr_frag2;
-      if(types1[block1][frag1] != NULL && types2[block2][frag2] != NULL){
-        new_type_id1 = get_offset_type(types1[block1][frag1], offset1, all_types, other_types, size, &switch_type);
-        new_type_id2 = get_offset_type(types2[block2][frag2], offset1, all_types, other_types, size, &switch_type);
-      }else if(types1[block1][frag1] != NULL){
-        new_type_id1 = get_offset_type(types1[block1][frag1], offset1, all_types, other_types, size, &switch_type);
-        new_type_id2 = get_offset_type(types1[block1][frag1], offset2, all_types, other_types, size, &switch_type);       
-      }else if(types2[block2][frag2] != NULL){
-        new_type_id1 = get_offset_type(types2[block2][frag2], offset1, all_types, other_types, size, &switch_type);
-        new_type_id2 = get_offset_type(types2[block2][frag2], offset2, all_types, other_types, size, &switch_type);
+
+      if(state->types1_(block1,frag1) != NULL && state->types2_(block2,frag2) != NULL){
+        new_type1 = get_offset_type(real_addr_frag1, state->types1_(block1,frag1), offset1, size, snapshot1);
+        new_type2 = get_offset_type(real_addr_frag2, state->types2_(block2,frag2), offset1, size, snapshot2);
+      }else if(state->types1_(block1,frag1) != NULL){
+        new_type1 = get_offset_type(real_addr_frag1, state->types1_(block1,frag1), offset1, size, snapshot1);
+        new_type2 = get_offset_type(real_addr_frag2, state->types1_(block1,frag1), offset2, size, snapshot2);
+      }else if(state->types2_(block2,frag2) != NULL){
+        new_type1 = get_offset_type(real_addr_frag1, state->types2_(block2,frag2), offset1, size, snapshot1);
+        new_type2 = get_offset_type(real_addr_frag2, state->types2_(block2,frag2), offset2, size, snapshot2);
       }else{
         if(match_pairs){
-          match_equals(previous);
+          match_equals(state, previous);
           xbt_dynar_free(&previous);
         }
         return -1;
       }   
 
-      if(new_type_id1 !=  NULL && new_type_id2 !=  NULL && !strcmp(new_type_id1, new_type_id2)){
-        if(switch_type){
-          type = xbt_dict_get_or_null(other_types, new_type_id1);
-          while(type->size == 0 && type->dw_type_id != NULL)
-            type = xbt_dict_get_or_null(other_types, type->dw_type_id);
-          new_size1 = type->size;
-          type = xbt_dict_get_or_null(other_types, new_type_id2);
-          while(type->size == 0 && type->dw_type_id != NULL)
-            type = xbt_dict_get_or_null(other_types, type->dw_type_id);
-          new_size2 = type->size;
-        }else{
-          type = xbt_dict_get_or_null(all_types, new_type_id1);
-          while(type->size == 0 && type->dw_type_id != NULL)
-            type = xbt_dict_get_or_null(all_types, type->dw_type_id);
-          new_size1 = type->size;
-          type = xbt_dict_get_or_null(all_types, new_type_id2);
-          while(type->size == 0 && type->dw_type_id != NULL)
-            type = xbt_dict_get_or_null(all_types, type->dw_type_id);
-          new_size2 = type->size;
-        }
+      if(new_type1 !=  NULL && new_type2 !=  NULL && new_type1!=new_type2){
+
+          type = new_type1;
+          while(type->byte_size == 0 && type->subtype != NULL)
+            type = type->subtype;
+          new_size1 = type->byte_size;
+
+          type = new_type2;
+          while(type->byte_size == 0 && type->subtype != NULL)
+            type = type->subtype;
+          new_size2 = type->byte_size;
+
       }else{
         if(match_pairs){
-          match_equals(previous);
+          match_equals(state, previous);
           xbt_dynar_free(&previous);
         }
         return -1;
@@ -1239,14 +1246,14 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
     area2_to_compare = (char *)addr_frag2 + offset2;
     
     if(new_size1 > 0 && new_size1 == new_size2){
-      type_id = new_type_id1;
+      type = new_type1;
       size = new_size1;
     }
 
     if(offset1 == 0 && offset2 == 0){
       if(!add_heap_area_pair(previous, block1, frag1, block2, frag2)){
         if(match_pairs){
-          match_equals(previous);
+          match_equals(state, previous);
           xbt_dynar_free(&previous);
         }
         return 0;
@@ -1255,14 +1262,14 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
 
     if(size <= 0){
       if(match_pairs){
-        match_equals(previous);
+        match_equals(state, previous);
         xbt_dynar_free(&previous);
       }
       return 0;
     }
       
-    if((heapinfo1[block1].busy_frag.ignore[frag1] > 0) && ( heapinfo2[block2].busy_frag.ignore[frag2] == heapinfo1[block1].busy_frag.ignore[frag1]))
-      check_ignore = heapinfo1[block1].busy_frag.ignore[frag1];
+    if((state->heapinfo1[block1].busy_frag.ignore[frag1] > 0) && ( state->heapinfo2[block2].busy_frag.ignore[frag2] == state->heapinfo1[block1].busy_frag.ignore[frag1]))
+      check_ignore = state->heapinfo1[block1].busy_frag.ignore[frag1];
     
   }else{
 
@@ -1275,30 +1282,19 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
   
 
   /* Start comparison*/
-  if(type_id != NULL){
-    if(switch_type)
-      res_compare = compare_heap_area_with_type(area1, area2, area1_to_compare, area2_to_compare, previous, other_types, all_types, type_id, size, check_ignore, pointer_level);
-    else
-      res_compare = compare_heap_area_with_type(area1, area2, area1_to_compare, area2_to_compare, previous, all_types, other_types, type_id, size, check_ignore, pointer_level);
-    if(res_compare == 1){
-      if(match_pairs)
-        xbt_dynar_free(&previous);
-      return res_compare;
-    }
+  if(type){
+    res_compare = compare_heap_area_with_type(state, area1, area2, area1_to_compare, area2_to_compare, snapshot1, snapshot2, previous, type, size, check_ignore, pointer_level);
   }else{
-    if(switch_type)
-      res_compare = compare_heap_area_without_type(area1, area2, area1_to_compare, area2_to_compare, previous, other_types, all_types, size, check_ignore);
-    else
-      res_compare = compare_heap_area_without_type(area1, area2, area1_to_compare, area2_to_compare, previous, all_types, other_types, size, check_ignore);
-    if(res_compare == 1){
-      if(match_pairs)
-        xbt_dynar_free(&previous);
-      return res_compare;
-    }
+    res_compare = compare_heap_area_without_type(state, area1, area2, area1_to_compare, area2_to_compare, snapshot1, snapshot2, previous, size, check_ignore);
+  }
+  if(res_compare == 1){
+    if(match_pairs)
+      xbt_dynar_free(&previous);
+    return res_compare;
   }
 
   if(match_pairs){
-    match_equals(previous);
+    match_equals(state, previous);
     xbt_dynar_free(&previous);
   }
 
@@ -1308,20 +1304,22 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
 /*********************************************** Miscellaneous ***************************************************/
 /****************************************************************************************************************/
 
+// Not used:
+static int get_pointed_area_size(void *area, int heap){
 
-int get_pointed_area_size(void *area, int heap){
+  struct s_mm_diff *state = mm_diff_info;
 
   int block, frag;
   malloc_info *heapinfo;
 
   if(heap == 1)
-    heapinfo = heapinfo1;
+    heapinfo = state->heapinfo1;
   else
-    heapinfo = heapinfo2;
+    heapinfo = state->heapinfo2;
 
-  block = ((char*)area - (char*)((xbt_mheap_t)s_heap)->heapbase) / BLOCKSIZE + 1;
+  block = ((char*)area - (char*)((xbt_mheap_t)state->s_heap)->heapbase) / BLOCKSIZE + 1;
 
-  if(((char *)area < (char*)((xbt_mheap_t)s_heap)->heapbase)  || (block > heapsize1) || (block < 1))
+  if(((char *)area < (char*)((xbt_mheap_t)state->s_heap)->heapbase)  || (block > state->heapsize1) || (block < 1))
     return -1;
 
   if(heapinfo[block].type == -1){ /* Free block */
@@ -1335,14 +1333,15 @@ int get_pointed_area_size(void *area, int heap){
 
 }
 
-char *get_type_description(xbt_dict_t types, char *type_name){
+// Not used:
+char *get_type_description(mc_object_info_t info, char *type_name){
 
   xbt_dict_cursor_t dict_cursor;
   char *type_origin;
   dw_type_t type;
 
-  xbt_dict_foreach(types, dict_cursor, type_origin, type){
-    if(type->name && (strcmp(type->name, type_name) == 0) && type->size > 0){
+  xbt_dict_foreach(info->types, dict_cursor, type_origin, type){
+    if(type->name && (strcmp(type->name, type_name) == 0) && type->byte_size > 0){
       xbt_dict_cursor_free(&dict_cursor);
       return type_origin;
     }
@@ -1357,8 +1356,11 @@ char *get_type_description(xbt_dict_t types, char *type_name){
 #define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
 #endif
 
+// Not used:
 int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){
 
+  struct s_mm_diff *state = mm_diff_info;
+
   if(heap1 == NULL && heap1 == NULL){
     XBT_DEBUG("Malloc descriptors null");
     return 0;
@@ -1370,18 +1372,18 @@ int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){
   }
 
   /* Heap information */
-  heaplimit = ((struct mdesc *)heap1)->heaplimit;
+  state->heaplimit = ((struct mdesc *)heap1)->heaplimit;
 
-  s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - getpagesize();
+  state->s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - xbt_pagesize;
 
-  heapbase1 = (char *)heap1 + BLOCKSIZE;
-  heapbase2 = (char *)heap2 + BLOCKSIZE;
+  state->heapbase1 = (char *)heap1 + BLOCKSIZE;
+  state->heapbase2 = (char *)heap2 + BLOCKSIZE;
 
-  heapinfo1 = (malloc_info *)((char *)heap1 + ((uintptr_t)((char *)heap1->heapinfo - (char *)s_heap)));
-  heapinfo2 = (malloc_info *)((char *)heap2 + ((uintptr_t)((char *)heap2->heapinfo - (char *)s_heap)));
+  state->heapinfo1 = (malloc_info *)((char *)heap1 + ((uintptr_t)((char *)heap1->heapinfo - (char *)state->s_heap)));
+  state->heapinfo2 = (malloc_info *)((char *)heap2 + ((uintptr_t)((char *)heap2->heapinfo - (char *)state->s_heap)));
 
-  heapsize1 = heap1->heapsize;
-  heapsize2 = heap2->heapsize;
+  state->heapsize1 = heap1->heapsize;
+  state->heapsize2 = heap2->heapsize;
 
   /* Start comparison */
   size_t i, j, k;
@@ -1393,30 +1395,30 @@ int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){
 
   i = 1;
 
-  while(i <= heaplimit){
+  while(i <= state->heaplimit){
 
-    addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1));
-    addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2));
+    addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)state->heapbase1));
+    addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)state->heapbase2));
 
-    if(heapinfo1[i].type != heapinfo2[i].type){
+    if(state->heapinfo1[i].type != state->heapinfo2[i].type){
   
       distance += BLOCKSIZE;
-      XBT_DEBUG("Different type of blocks (%zu) : %d - %d -> distance = %d", i, heapinfo1[i].type, heapinfo2[i].type, distance);
+      XBT_DEBUG("Different type of blocks (%zu) : %d - %d -> distance = %d", i, state->heapinfo1[i].type, state->heapinfo2[i].type, distance);
       i++;
     
     }else{
 
-      if(heapinfo1[i].type == -1){ /* Free block */
+      if(state->heapinfo1[i].type == -1){ /* Free block */
         i++;
         continue;
       }
 
-      if(heapinfo1[i].type == 0){ /* Large block */
+      if(state->heapinfo1[i].type == 0){ /* Large block */
        
-        if(heapinfo1[i].busy_block.size != heapinfo2[i].busy_block.size){
-          distance += BLOCKSIZE * max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
-          i += max(heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size);
-          XBT_DEBUG("Different larger of cluster at block %zu : %zu - %zu -> distance = %d", i, heapinfo1[i].busy_block.size, heapinfo2[i].busy_block.size, distance);
+        if(state->heapinfo1[i].busy_block.size != state->heapinfo2[i].busy_block.size){
+          distance += BLOCKSIZE * max(state->heapinfo1[i].busy_block.size, state->heapinfo2[i].busy_block.size);
+          i += max(state->heapinfo1[i].busy_block.size, state->heapinfo2[i].busy_block.size);
+          XBT_DEBUG("Different larger of cluster at block %zu : %zu - %zu -> distance = %d", i, state->heapinfo1[i].busy_block.size, state->heapinfo2[i].busy_block.size, distance);
           continue;
         }
 
@@ -1430,7 +1432,7 @@ int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){
         k = 0;
 
         //while(k < (heapinfo1[i].busy_block.busy_size)){
-        while(k < heapinfo1[i].busy_block.size * BLOCKSIZE){
+        while(k < state->heapinfo1[i].busy_block.size * BLOCKSIZE){
           if(memcmp((char *)addr_block1 + k, (char *)addr_block2 + k, 1) != 0){
             distance ++;
           }
@@ -1441,12 +1443,12 @@ int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){
 
       }else { /* Fragmented block */
 
-        for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo1[i].type); j++){
+        for(j=0; j < (size_t) (BLOCKSIZE >> state->heapinfo1[i].type); j++){
 
-          addr_frag1 = (void*) ((char *)addr_block1 + (j << heapinfo1[i].type));
-          addr_frag2 = (void*) ((char *)addr_block2 + (j << heapinfo2[i].type));
+          addr_frag1 = (void*) ((char *)addr_block1 + (j << state->heapinfo1[i].type));
+          addr_frag2 = (void*) ((char *)addr_block2 + (j << state->heapinfo2[i].type));
 
-          if(heapinfo1[i].busy_frag.frag_size[j] == 0 && heapinfo2[i].busy_frag.frag_size[j] == 0){
+          if(state->heapinfo1[i].busy_frag.frag_size[j] == 0 && state->heapinfo2[i].busy_frag.frag_size[j] == 0){
             continue;
           }
           
@@ -1460,7 +1462,7 @@ int mmalloc_linear_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){
           k=0;
 
           //while(k < max(heapinfo1[i].busy_frag.frag_size[j], heapinfo2[i].busy_frag.frag_size[j])){
-          while(k < (BLOCKSIZE / (BLOCKSIZE >> heapinfo1[i].type))){
+          while(k < (BLOCKSIZE / (BLOCKSIZE >> state->heapinfo1[i].type))){
             if(memcmp((char *)addr_frag1 + k, (char *)addr_frag2 + k, 1) != 0){
               distance ++;
             }
index 7984ad0..0073245 100644 (file)
@@ -7,6 +7,7 @@
 /* Redefine the classical malloc/free/realloc functions so that they fit well in the mmalloc framework */
 
 #include "mmprivate.h"
+#include "xbt_modinter.h"
 #include "internal_config.h"
 #include <math.h>
 
index 7cfde64..8ee23eb 100644 (file)
@@ -1,5 +1,12 @@
-/* Initialization for access to a mmap'd malloc managed region.
-   Copyright 1992, 2000 Free Software Foundation, Inc.
+/* Initialization for access to a mmap'd malloc managed region. */
+
+/* Copyright (c) 2012-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+/* Copyright 1992, 2000 Free Software Foundation, Inc.
 
    Contributed by Fred Fish at Cygnus Support.   fnf@cygnus.com
 
    not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/* Copyright (c) 2012-2014. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
 #include <sys/types.h>
 #include <fcntl.h>              /* After sys/types.h, at least for dpx/2.  */
 #include <sys/stat.h>
@@ -323,7 +324,7 @@ void *mmalloc_preinit(void)
 {
   int res;
   if (__mmalloc_default_mdp == NULL) {
-    unsigned long mask = ~((unsigned long)getpagesize() - 1);
+    unsigned long mask = ~((unsigned long)xbt_pagesize - 1);
     void *addr = (void*)(((unsigned long)sbrk(0) + HEAP_OFFSET) & mask);
     __mmalloc_default_mdp = xbt_mheap_new(-1, addr);
     /* Fixme? only the default mdp in protected against forks */
index 2fb4338..7376ca6 100644 (file)
@@ -1,8 +1,4 @@
-/* Memory allocator `malloc'.
-   Copyright 1990, 1991, 1992 Free Software Foundation
-
-   Written May 1989 by Mike Haertel.
-   Heavily modified Mar 1992 by Fred Fish for mmap'd version. */
+/* Memory allocator `malloc'. */
 
 /* Copyright (c) 2010-2014. The SimGrid Team.
  * All rights reserved.                                                     */
@@ -10,6 +6,11 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+/* Copyright 1990, 1991, 1992 Free Software Foundation
+
+   Written May 1989 by Mike Haertel.
+   Heavily modified Mar 1992 by Fred Fish for mmap'd version. */
+
 #include <string.h>             /* Prototypes for memcpy, memmove, memset, etc */
 #include <stdio.h>
 #include "mmprivate.h"
index 5ad7cd3..9fbf7a9 100644 (file)
@@ -1,7 +1,4 @@
-/* Support for an sbrk-like function that uses mmap.
-   Copyright 1992, 2000 Free Software Foundation, Inc.
-
-   Contributed by Fred Fish at Cygnus Support.   fnf@cygnus.com */
+/* Support for an sbrk-like function that uses mmap. */
 
 /* Copyright (c) 2010-2014. The SimGrid Team.
  * All rights reserved.                                                     */
@@ -9,9 +6,9 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef MAP_ANONYMOUS
-#define MAP_ANONYMOUS MAP_ANON
-#endif
+/* Copyright 1992, 2000 Free Software Foundation, Inc.
+
+   Contributed by Fred Fish at Cygnus Support.   fnf@cygnus.com */
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>             /* Prototypes for lseek */
 #include <stdio.h>
 #include <fcntl.h>
 #include <sys/mman.h>
+#include <sys/wait.h>
 
 #include "mmprivate.h"
 
-/* Cache the pagesize for the current host machine.  Note that if the host
-   does not readily provide a getpagesize() function, we need to emulate it
-   elsewhere, not clutter up this file with lots of kluges to try to figure
-   it out. */
-
-static size_t pagesize;
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
 
-#define PAGE_ALIGN(addr) (void*) (((long)(addr) + pagesize - 1) & \
-                                  ~(pagesize - 1))
+#define PAGE_ALIGN(addr) (void*) (((long)(addr) + xbt_pagesize - 1) &   \
+                                  ~((long)xbt_pagesize - 1))
 
 /* Return MAP_PRIVATE if MDP represents /dev/zero.  Otherwise, return
    MAP_SHARED.  */
@@ -65,8 +60,6 @@ void *mmorecore(struct mdesc *mdp, ssize_t size)
   char buf = 0;                 /* Single byte to write to extend mapped file */
 
 //  fprintf(stderr,"increase %p by %u\n",mdp,size);
-  if (pagesize == 0)
-    pagesize = getpagesize();
 
   if (size == 0) {
     /* Just return the current "break" value. */
index 370f84b..37e4ea7 100644 (file)
@@ -1,8 +1,4 @@
-/* Declarations for `mmalloc' and friends.
-   Copyright 1990, 1991, 1992 Free Software Foundation
-
-   Written May 1989 by Mike Haertel.
-   Heavily modified Mar 1992 by Fred Fish. (fnf@cygnus.com) */
+/* Declarations for `mmalloc' and friends. */
 
 /* Copyright (c) 2010-2014. The SimGrid Team.
  * All rights reserved.                                                     */
@@ -10,6 +6,11 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+/* Copyright 1990, 1991, 1992 Free Software Foundation
+
+   Written May 1989 by Mike Haertel.
+   Heavily modified Mar 1992 by Fred Fish. (fnf@cygnus.com) */
+
 #ifndef __MMPRIVATE_H
 #define __MMPRIVATE_H 1
 
@@ -109,6 +110,7 @@ struct mstats
 };
 
 typedef struct s_heap_area{
+  int valid;
   int block;
   int fragment;
 }s_heap_area_t, *heap_area_t;
index 03bc80b..1a6d100 100644 (file)
@@ -1,6 +1,4 @@
-/* Change the size of a block allocated by `mmalloc'.
-   Copyright 1990, 1991 Free Software Foundation
-   Written May 1989 by Mike Haertel. */
+/* Change the size of a block allocated by `mmalloc'. */
 
 /* Copyright (c) 2010-2014. The SimGrid Team.
  * All rights reserved.                                                     */
@@ -8,6 +6,9 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+/* Copyright 1990, 1991 Free Software Foundation
+   Written May 1989 by Mike Haertel. */
+
 #include <string.h>             /* Prototypes for memcpy, memmove, memset, etc */
 #include <stdlib.h> /* abort */
 
index 560b06c..d218feb 100644 (file)
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-/*\r
- *      win32-ucontext: Unix ucontext_t operations on Windows platforms\r
- *      Copyright(C) 2007 Panagiotis E. Hadjidoukas\r
- *\r
- *      Contact Email: phadjido@cs.uoi.gr, xdoukas@ceid.upatras.gr\r
- *\r
- *      win32-ucontext is free software; you can redistribute it and/or\r
- *      modify it under the terms of the GNU Lesser General Public\r
- *      License as published by the Free Software Foundation; either\r
- *      version 2 of the License, or (at your option) any later version.\r
- *\r
- *      win32-ucontext is distributed in the hope that it will be useful,\r
- *      but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
- *      Lesser General Public License for more details.\r
- *\r
- *      You should have received a copy of the GNU Lesser General Public\r
- *      License along with SimGrid in the file LICENSE-LGPL-2.1;\r
- *      if not, write to the Free Software Foundation, Inc.,\r
- *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA\r
- */  \r
-    \r
-#include "win32_ucontext.h"\r
-\r
-int getcontext(ucontext_t * ucp) \r
-{\r
-  int ret;\r
-  \r
-      /* Retrieve the full machine context */ \r
-      ucp->uc_mcontext.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS;\r
-  ret = GetThreadContext(GetCurrentThread(), &ucp->uc_mcontext);\r
-  return (ret == 0) ? -1 : 0;\r
-}\r
-\r
-int setcontext(const ucontext_t * ucp) \r
-{\r
-  int ret;\r
-  \r
-      /* Restore the full machine context (already set) */ \r
-      ret = SetThreadContext(GetCurrentThread(), &ucp->uc_mcontext);\r
-  return (ret == 0) ? -1 : 0;\r
-}\r
-\r
-int makecontext(ucontext_t * ucp, void (*func) (), int argc, ...) \r
-{\r
-  int i;\r
-  va_list ap;\r
-  char *sp;\r
-\r
-   /* Stack grows down */\r
-      sp = (char *) (size_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size;\r
-  \r
-      /* Reserve stack space for the arguments (maximum possible: argc*(8 bytes per argument)) */ \r
-      sp -= argc * sizeof(void*);\r
-  if (sp < (char *) ucp->uc_stack.ss_sp) {\r
-    \r
-        /* errno = ENOMEM; */ \r
-        return -1;\r
-  }\r
-  \r
-      /* Set the instruction and the stack pointer */\r
-  #ifdef _I_X86_\r
-  ucp->uc_mcontext.Eip = (DWORD) func;\r
-  ucp->uc_mcontext.Esp = (DWORD) sp - sizeof(void*);\r
-  #endif\r
-  #ifdef _IA64_\r
-  #  error "_IA64_"\r
-  #endif\r
-  #ifdef _AMD64_\r
-  ucp->uc_mcontext.Rip = (DWORD64) func;\r
-  ucp->uc_mcontext.Rsp = (DWORD64) sp - sizeof(void*);\r
-  #endif\r
-\r
-      /* Save/Restore the full machine context */ \r
-      ucp->uc_mcontext.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS;\r
-  \r
-      /* Copy the arguments */ \r
-      va_start(ap, argc);\r
-  for (i = 0; i < argc; i++) {\r
-    memcpy(sp, ap, sizeof(void*));\r
-    ap += sizeof(void*);\r
-    sp += sizeof(void*);\r
-  }\r
-  va_end(ap);\r
-  return 0;\r
-}\r
-\r
-int swapcontext(ucontext_t * oucp, const ucontext_t * ucp) \r
-{\r
-  int ret;\r
-  if ((oucp == NULL) || (ucp == NULL)) {\r
-    \r
-        /*errno = EINVAL; */ \r
-        return -1;\r
-  }\r
-  ret = getcontext(oucp);\r
-  if (ret == 0) {\r
-    ret = setcontext(ucp);\r
-  }\r
-  return ret;\r
-}\r
-\r
+/*
+ *      win32-ucontext: Unix ucontext_t operations on Windows platforms
+ *      Copyright(C) 2007 Panagiotis E. Hadjidoukas
+ *
+ *      Contact Email: phadjido@cs.uoi.gr, xdoukas@ceid.upatras.gr
+ *
+ *      win32-ucontext is free software; you can redistribute it and/or
+ *      modify it under the terms of the GNU Lesser General Public
+ *      License as published by the Free Software Foundation; either
+ *      version 2 of the License, or (at your option) any later version.
+ *
+ *      win32-ucontext is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *      Lesser General Public License for more details.
+ *
+ *      You should have received a copy of the GNU Lesser General Public
+ *      License along with SimGrid in the file LICENSE-LGPL-2.1;
+ *      if not, write to the Free Software Foundation, Inc.,
+ *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */  
+    
+#include "xbt/win32_ucontext.h"
+
+int getcontext(ucontext_t * ucp) 
+{
+  int ret;
+  
+      /* Retrieve the full machine context */ 
+      ucp->uc_mcontext.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS;
+  ret = GetThreadContext(GetCurrentThread(), &ucp->uc_mcontext);
+  return (ret == 0) ? -1 : 0;
+}
+
+int setcontext(const ucontext_t * ucp) 
+{
+  int ret;
+  
+      /* Restore the full machine context (already set) */ 
+      ret = SetThreadContext(GetCurrentThread(), &ucp->uc_mcontext);
+  return (ret == 0) ? -1 : 0;
+}
+
+int makecontext(ucontext_t * ucp, void (*func) (), int argc, ...) 
+{
+  int i;
+  va_list ap;
+  char *sp;
+
+   /* Stack grows down */
+      sp = (char *) (size_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size;
+  
+      /* Reserve stack space for the arguments (maximum possible: argc*(8 bytes per argument)) */ 
+      sp -= argc * sizeof(void*);
+  if (sp < (char *) ucp->uc_stack.ss_sp) {
+    
+        /* errno = ENOMEM; */ 
+        return -1;
+  }
+  
+      /* Set the instruction and the stack pointer */
+  #ifdef _I_X86_
+  ucp->uc_mcontext.Eip = (DWORD) func;
+  ucp->uc_mcontext.Esp = (DWORD) sp - sizeof(void*);
+  #elif defined _IA64_
+  #  error "_IA64_"
+  #elif defined _AMD64_
+  ucp->uc_mcontext.Rip = (DWORD64) func;
+  ucp->uc_mcontext.Rsp = (DWORD64) sp - sizeof(void*);
+  #else
+  #error "No architecture defined for Windows build. need either _AMD64_ or _I_X86_"
+  #endif
+
+      /* Save/Restore the full machine context */ 
+      ucp->uc_mcontext.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS;
+  
+      /* Copy the arguments */ 
+      va_start(ap, argc);
+  for (i = 0; i < argc; i++) {
+    memcpy(sp, ap, sizeof(void*));
+    ap += sizeof(void*);
+    sp += sizeof(void*);
+  }
+  va_end(ap);
+  return 0;
+}
+
+int swapcontext(ucontext_t * oucp, const ucontext_t * ucp) 
+{
+  int ret;
+  if ((oucp == NULL) || (ucp == NULL)) {
+    
+        /*errno = EINVAL; */ 
+        return -1;
+  }
+  ret = getcontext(oucp);
+  if (ret == 0) {
+    ret = setcontext(ucp);
+  }
+  return ret;
+}
+
index 26e8dd1..615ad8d 100644 (file)
@@ -9,7 +9,7 @@
 #include "xbt/misc.h"
 #include "simgrid_config.h"     /* _XBT_WIN32 */
 #include "internal_config.h"    /* MMALLOC_WANT_OVERRIDE_LEGACY */
-
+#include "portable.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/dynar.h"
@@ -22,6 +22,9 @@
 #include "simgrid/sg_config.h"
 
 #include <stdio.h>
+#ifdef _XBT_WIN32
+#include <signal.h>
+#endif
 
 XBT_LOG_NEW_CATEGORY(xbt, "All XBT categories (simgrid toolbox)");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module, xbt, "module handling");
@@ -35,6 +38,8 @@ xbt_dynar_t xbt_cmdline = NULL; /* all we got in argv */
 int xbt_initialized = 0;
 int _sg_do_clean_atexit = 1;
 
+int xbt_pagesize;
+
 /* Declare xbt_preinit and xbt_postexit as constructor/destructor of the library.
  * This is crude and rather compiler-specific, unfortunately.
  */
@@ -83,7 +88,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
 
 static void xbt_preinit(void) {
   unsigned int seed = 2147483647;
-
+#ifndef WIN32
+  xbt_pagesize = sysconf(_SC_PAGESIZE);
+#else
+  SYSTEM_INFO si;
+  GetSystemInfo(&si);
+  xbt_pagesize = si.dwPageSize;
+#endif
 #ifdef MMALLOC_WANT_OVERRIDE_LEGACY
   mmalloc_preinit();
 #endif
@@ -148,13 +159,31 @@ void xbt_exit()
 
 /* these two functions belong to xbt/sysdep.h, which have no corresponding .c file */
 /** @brief like free, but you can be sure that it is a function  */
-XBT_PUBLIC(void) xbt_free_f(void *p)
+void xbt_free_f(void *p)
 {
   free(p);
 }
 
 /** @brief should be given a pointer to pointer, and frees the second one */
-XBT_PUBLIC(void) xbt_free_ref(void *d)
+void xbt_free_ref(void *d)
 {
   free(*(void **) d);
 }
+
+/** @brief Kill the program in silence */
+void xbt_abort(void)
+{
+#ifdef COVERAGE
+  /* Call __gcov_flush on abort when compiling with coverage options. */
+  extern void __gcov_flush(void);
+  __gcov_flush();
+#endif
+#ifdef _XBT_WIN32
+  /* It was said *in silence*.  We don't want to see the error message printed
+   * by the Microsoft's implementation of abort(). */
+  raise(SIGABRT);
+  signal(SIGABRT, SIG_DFL);
+  raise(SIGABRT);
+#endif
+  abort();
+}
index ff9d996..c9dd691 100644 (file)
@@ -54,10 +54,9 @@ static xbt_os_thread_t main_thread = NULL;
 static pthread_key_t xbt_self_thread_key;
 static int thread_mod_inited = 0;
 
-/* attribute structure to handle pthread stack size changing */
+/* defaults attribute for pthreads */
 //FIXME: find where to put this
-static pthread_attr_t attr;
-static int thread_attr_inited = 0;
+static pthread_attr_t thread_attr;
 
 /* frees the xbt_os_thread_t corresponding to the current thread */
 static void xbt_os_thread_free_thread_data(xbt_os_thread_t thread)
@@ -105,11 +104,12 @@ void xbt_os_thread_mod_preinit(void)
   if ((errcode = pthread_setspecific(xbt_self_thread_key, main_thread)))
     THROWF(system_error, errcode,
            "pthread_setspecific failed for xbt_self_thread_key");
-
   
   __xbt_running_ctx_fetch = _os_thread_get_running_ctx;
   __xbt_ex_terminate = _os_thread_ex_terminate;
 
+  pthread_attr_init(&thread_attr);
+
   thread_mod_inited = 1;
 
 #ifndef HAVE_SEM_INIT
@@ -182,7 +182,7 @@ xbt_os_thread_t xbt_os_thread_create(const char *name,
   XBT_RUNNING_CTX_INITIALIZE(res_thread->running_ctx);
   res_thread->extra_data = extra_data;
   
-  if ((errcode = pthread_create(&(res_thread->t), thread_attr_inited!=0? &attr: NULL,
+  if ((errcode = pthread_create(&(res_thread->t), &thread_attr,
                                 wrapper_start_routine, res_thread)))
     THROWF(system_error, errcode,
            "pthread_create failed: %s", strerror(errcode));
@@ -195,35 +195,51 @@ xbt_os_thread_t xbt_os_thread_create(const char *name,
 
 void xbt_os_thread_setstacksize(int stack_size)
 {
+  size_t alignment[] = {
+    xbt_pagesize,
+#ifdef PTHREAD_STACK_MIN
+    PTHREAD_STACK_MIN,
+#endif
+    0
+  };
   size_t sz;
   int res;
+  int i;
 
   if (stack_size < 0)
     xbt_die("stack size %d is negative, maybe it exceeds MAX_INT?", stack_size);
 
   sz = stack_size;
-  pthread_attr_init(&attr);
-  res = pthread_attr_setstacksize(&attr, sz);
+  res = pthread_attr_setstacksize(&thread_attr, sz);
 
-#ifdef PTHREAD_STACK_MIN
-  if (res == EINVAL) {
-    /* Invalid size, try again with a multiple of PTHREAD_STACK_MIN. */
-    size_t rem = sz % PTHREAD_STACK_MIN;
+  for (i = 0; res == EINVAL && alignment[i] > 0; i++) {
+    /* Invalid size, try again with next multiple of alignment[i]. */
+    size_t rem = sz % alignment[i];
     if (rem != 0 || sz == 0) {
-      size_t sz2 = sz - rem + PTHREAD_STACK_MIN;
-      XBT_DEBUG("pthread_attr_setstacksize failed for %#zx, try again with %#zx",
+      size_t sz2 = sz - rem + alignment[i];
+      XBT_DEBUG("pthread_attr_setstacksize failed for %zd, try again with %zd",
                 sz, sz2);
       sz = sz2;
-      res = pthread_attr_setstacksize(&attr, sz);
+      res = pthread_attr_setstacksize(&thread_attr, sz);
     }
   }
-#endif
 
   if (res == EINVAL)
-    XBT_WARN("invalid stack size (maybe too big): %#zx", sz);
+    XBT_WARN("invalid stack size (maybe too big): %zd", sz);
   else if (res != 0)
-    XBT_WARN("unknown error %d in pthread stacksize setting: %#zx", res, sz);
-  thread_attr_inited = 1;
+    XBT_WARN("unknown error %d in pthread stacksize setting: %zd", res, sz);
+}
+
+void xbt_os_thread_setguardsize(int guard_size)
+{
+#ifdef WIN32
+  THROW_UNIMPLEMENTED; //pthread_attr_setguardsize is not implemented in pthread.h on windows
+#else
+  size_t sz = guard_size;
+  int res = pthread_attr_setguardsize(&thread_attr, sz);
+  if (res)
+    XBT_WARN("pthread_attr_setguardsize failed (%d) for size: %zd", res, sz);
+#endif
 }
 
 const char *xbt_os_thread_name(xbt_os_thread_t t)
@@ -754,6 +770,11 @@ void xbt_os_thread_setstacksize(int size)
   stack_size = size;
 }
 
+void xbt_os_thread_setguardsize(int size)
+{
+  XBT_WARN("xbt_os_thread_setguardsize is not implemented (%d)", size);
+}
+
 const char *xbt_os_thread_name(xbt_os_thread_t t)
 {
   return t->name;
index f9eae05..6290cd9 100644 (file)
@@ -1,16 +1,17 @@
 /* xbt_sha.c - SHA1 hash function */
 
+/* Copyright (c) 2008-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 /* Initial version part of iksemel (XML parser for Jabber)
  *   Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>. All right reserved.
  *   Distributed under LGPL v2.1, February 1999.
  */
 
 /* Later adapted to fit into SimGrid. Distributed under LGPL v2.1, Feb 1999.*/
-/* Copyright (c) 2008-2014. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/sysdep.h"
 #include "xbt/hash.h"
diff --git a/teshsuite/bug-17132/CMakeLists.txt b/teshsuite/bug-17132/CMakeLists.txt
new file mode 100644 (file)
index 0000000..87b5a82
--- /dev/null
@@ -0,0 +1,39 @@
+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}")
+
+  include_directories("${CMAKE_HOME_DIRECTORY}/include/smpi")
+  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
+    ${CMAKE_CURRENT_SOURCE_DIR}/bug-17132-surf-debug.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 (file)
index 0000000..22e35b9
--- /dev/null
@@ -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-surf-debug.tesh b/teshsuite/bug-17132/bug-17132-surf-debug.tesh
new file mode 100644 (file)
index 0000000..9256883
--- /dev/null
@@ -0,0 +1,2 @@
+! output ignore
+$ ../../smpi_script/bin/smpirun -np 16 -platform ${srcdir:=.}/small_platform.xml -hostfile ${srcdir:=.}/hostfile.txt ./bug-17132 --cfg=smpi/cpu_threshold:-1 --log=surf.thres:debug
diff --git a/teshsuite/bug-17132/bug-17132.c b/teshsuite/bug-17132/bug-17132.c
new file mode 100644 (file)
index 0000000..9cd6985
--- /dev/null
@@ -0,0 +1,53 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "xbt/log.h"
+#include <stdio.h>
+#include <mpi.h>
+
+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);
+
+  int rank;
+  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+  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);
+
+  if(rank==0) {
+    printf("Walltime = %g\n",MPI_Wtime());
+  }
+
+  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 (file)
index 0000000..a73b210
--- /dev/null
@@ -0,0 +1,9 @@
+$ ../../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 'surf/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)
+> Walltime = 0.00212779
diff --git a/teshsuite/bug-17132/hostfile.txt b/teshsuite/bug-17132/hostfile.txt
new file mode 100644 (file)
index 0000000..994b3e2
--- /dev/null
@@ -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 (file)
index 0000000..a2b420d
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version='3'>
+ <AS id='AS0' routing='Full'>
+
+  <host id='host1' power='1.0'/>
+  <host id='host2' power='1.0'/>
+  <link id='link' bandwidth='1e+10' latency='1e-09'/>
+
+  <route src='host1' dst='host2' symmetrical="YES">
+       <link_ctn id='link'/>
+  </route>
+
+ </AS>
+</platform>
index fa5f5ea..d352f27 100644 (file)
@@ -12,7 +12,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 void storage_info(msg_host_t host);
 void display_storage_properties(msg_storage_t storage);
 int hsm_put(const char *remote_host, const char *src, const char *dest);
-sg_size_t write_local_file(char *dest, sg_size_t file_size);
+sg_size_t write_local_file(const char *dest, sg_size_t file_size);
 sg_size_t read_local_file(const char *src);
 void dump_storage_by_name(char *name);
 void display_storage_content(msg_storage_t storage);
@@ -36,13 +36,14 @@ void storage_info(msg_host_t host)
   {
     XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name);
 
-    sg_size_t free_size = MSG_storage_get_free_size(mount_name);
-    sg_size_t used_size = MSG_storage_get_used_size(mount_name);
+    storage = MSG_storage_get_by_name(storage_name);
+
+    sg_size_t free_size = MSG_storage_get_free_size(storage);
+    sg_size_t used_size = MSG_storage_get_used_size(storage);
 
     XBT_INFO("\t\tFree size: %llu bytes", free_size);
     XBT_INFO("\t\tUsed size: %llu bytes", used_size);
 
-    storage = MSG_storage_get_by_name(storage_name);
     display_storage_properties(storage);
     dump_storage_by_name(storage_name);
   }
@@ -76,10 +77,10 @@ int hsm_put(const char *remote_host, const char *src, const char *dest){
   return 1;
 }
 
-sg_size_t write_local_file(char *dest, sg_size_t file_size)
+sg_size_t write_local_file(const char *dest, sg_size_t file_size)
 {
   sg_size_t written;
-  msg_file_t file = MSG_file_open("/sd1",dest, NULL);
+  msg_file_t file = MSG_file_open(dest, NULL);
   written = MSG_file_write(file, file_size);
   XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1",written, file_size, MSG_host_get_name(MSG_host_self()));
   MSG_file_close(file);
@@ -89,7 +90,7 @@ sg_size_t write_local_file(char *dest, sg_size_t file_size)
 sg_size_t read_local_file(const char *src)
 {
   sg_size_t read, file_size;
-  msg_file_t file = MSG_file_open("/sd1",src, NULL);
+  msg_file_t file = MSG_file_open(src, NULL);
   file_size = MSG_file_get_size(file);
 
   read = MSG_file_read(file, file_size);
@@ -140,9 +141,9 @@ void get_set_storage_data(const char *storage_name){
 
 int client(int argc, char *argv[])
 {
-  hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx","./scratch/toto.cxx");
-  hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml","./scratch/titi.xml");
-  hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/Slave.cxx","./scratch/tata.cxx");
+  hsm_put("server","/sd1/doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx","/sd2/scratch/toto.cxx");
+  hsm_put("server","/sd1/doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml","/sd2/scratch/titi.xml");
+  hsm_put("server","/sd1/doc/simgrid/examples/cxx/autoDestination/Slave.cxx","/sd2/scratch/tata.cxx");
 
   msg_task_t finalize = MSG_task_create("finalize", 0, 0, NULL);
   MSG_task_send(finalize, "server");
index 210727f..3c3c5a6 100644 (file)
@@ -7,10 +7,10 @@ $ msg/storage/storage_basic --cfg=path:${srcdir:=.} ${srcdir:=.}/msg/storage/pla
 > [  0.000000] (1:server@server)               'usage' -> 'File system'
 > [  0.000000] (1:server@server) *** Dump a storage element ***
 > [  0.000000] (1:server@server) Print the content of the storage element: sdisk1
-> [  0.000000] (1:server@server)       ./doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml size: 10 bytes
-> [  0.000000] (1:server@server)       ./doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx size: 10 bytes
-> [  0.000000] (1:server@server)       ./doc/simgrid/examples/cxx/autoDestination/Master.cxx size: 10 bytes
-> [  0.000000] (1:server@server)       ./doc/simgrid/examples/cxx/basic/FinalizeTask.cxx size: 10 bytes
+> [  0.000000] (1:server@server)       /doc/simgrid/examples/cxx/autoDestination/Master.cxx size: 10 bytes
+> [  0.000000] (1:server@server)       /doc/simgrid/examples/cxx/basic/FinalizeTask.cxx size: 10 bytes
+> [  0.000000] (1:server@server)       /doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx size: 10 bytes
+> [  0.000000] (1:server@server)       /doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml size: 10 bytes
 > [  0.000000] (1:server@server)       Storage name: sdisk2, mount name: /sd2
 > [  0.000000] (1:server@server)               Free size: 805306367980 bytes
 > [  0.000000] (1:server@server)               Used size: 20 bytes
@@ -18,16 +18,16 @@ $ msg/storage/storage_basic --cfg=path:${srcdir:=.} ${srcdir:=.}/msg/storage/pla
 > [  0.000000] (1:server@server)               'usage' -> 'Cache'
 > [  0.000000] (1:server@server) *** Dump a storage element ***
 > [  0.000000] (1:server@server) Print the content of the storage element: sdisk2
-> [  0.000000] (1:server@server)       ./doc/simgrid/examples/cxx/basic/Slave.cxx size: 10 bytes
-> [  0.000000] (1:server@server)       ./doc/simgrid/examples/cxx/basic/Main.cxx size: 10 bytes
+> [  0.000000] (1:server@server)       /doc/simgrid/examples/cxx/basic/Main.cxx size: 10 bytes
+> [  0.000000] (1:server@server)       /doc/simgrid/examples/cxx/basic/Slave.cxx size: 10 bytes
 > [  0.000000] (1:server@server) Server waiting for transfers ...
-> [  0.005000] (2:client@client) client has read 500001 on ./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx
+> [  0.005000] (2:client@client) client has read 500001 on /sd1/doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx
 > [  0.005000] (2:client@client) client sends 500001 to server
 > [  0.026647] (1:server@server) 500001 bytes on 500001 bytes have been written by server on /sd1
-> [  0.417980] (2:client@client) client has read 800000 on ./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml
+> [  0.417980] (2:client@client) client has read 800000 on /sd1/doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml
 > [  0.417980] (2:client@client) client sends 800000 to server
 > [  0.452225] (1:server@server) 800000 bytes on 800000 bytes have been written by server on /sd1
-> [  1.283559] (2:client@client) client has read 45800000 on ./doc/simgrid/examples/cxx/autoDestination/Slave.cxx
+> [  1.283559] (2:client@client) client has read 45800000 on /sd1/doc/simgrid/examples/cxx/autoDestination/Slave.cxx
 > [  1.283559] (2:client@client) client sends 45800000 to server
 > [  3.207494] (1:server@server) 45800000 bytes on 45800000 bytes have been written by server on /sd1
 > [  3.208145] (2:client@client) *** GET/SET DATA for storage element: cdisk ***
@@ -35,27 +35,26 @@ $ msg/storage/storage_basic --cfg=path:${srcdir:=.} ${srcdir:=.}/msg/storage/pla
 > [  3.208145] (2:client@client)       Set and get data: 'Some data'
 > [  3.208145] (1:server@server) *** Storage info on server ***
 > [  3.208145] (1:server@server)       Storage name: sdisk1, mount name: /sd1
-> [  3.208145] (1:server@server)               Free size: 322075447159 bytes
-> [  3.208145] (1:server@server)               Used size: 47100041 bytes
+> [  3.208145] (1:server@server)               Free size: 322122547160 bytes
+> [  3.208145] (1:server@server)               Used size: 40 bytes
 > [  3.208145] (1:server@server)       Properties of mounted storage: sdisk1
 > [  3.208145] (1:server@server)               'usage' -> 'File system'
 > [  3.208145] (1:server@server) *** Dump a storage element ***
 > [  3.208145] (1:server@server) Print the content of the storage element: sdisk1
-> [  3.208145] (1:server@server)       ./scratch/titi.xml size: 800000 bytes
-> [  3.208145] (1:server@server)       ./doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml size: 10 bytes
-> [  3.208145] (1:server@server)       ./scratch/tata.cxx size: 45800000 bytes
-> [  3.208145] (1:server@server)       ./doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx size: 10 bytes
-> [  3.208145] (1:server@server)       ./scratch/toto.cxx size: 500001 bytes
-> [  3.208145] (1:server@server)       ./doc/simgrid/examples/cxx/autoDestination/Master.cxx size: 10 bytes
-> [  3.208145] (1:server@server)       ./doc/simgrid/examples/cxx/basic/FinalizeTask.cxx size: 10 bytes
+> [  3.208145] (1:server@server)       /doc/simgrid/examples/cxx/autoDestination/Master.cxx size: 10 bytes
+> [  3.208145] (1:server@server)       /doc/simgrid/examples/cxx/basic/FinalizeTask.cxx size: 10 bytes
+> [  3.208145] (1:server@server)       /doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx size: 10 bytes
+> [  3.208145] (1:server@server)       /doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml size: 10 bytes
 > [  3.208145] (1:server@server)       Storage name: sdisk2, mount name: /sd2
-> [  3.208145] (1:server@server)               Free size: 805306367980 bytes
-> [  3.208145] (1:server@server)               Used size: 20 bytes
+> [  3.208145] (1:server@server)               Free size: 805259267979 bytes
+> [  3.208145] (1:server@server)               Used size: 47100021 bytes
 > [  3.208145] (1:server@server)       Properties of mounted storage: sdisk2
 > [  3.208145] (1:server@server)               'usage' -> 'Cache'
 > [  3.208145] (1:server@server) *** Dump a storage element ***
 > [  3.208145] (1:server@server) Print the content of the storage element: sdisk2
-> [  3.208145] (1:server@server)       ./doc/simgrid/examples/cxx/basic/Slave.cxx size: 10 bytes
-> [  3.208145] (1:server@server)       ./doc/simgrid/examples/cxx/basic/Main.cxx size: 10 bytes
+> [  3.208145] (1:server@server)       /scratch/titi.xml size: 800000 bytes
+> [  3.208145] (1:server@server)       /scratch/tata.cxx size: 45800000 bytes
+> [  3.208145] (1:server@server)       /doc/simgrid/examples/cxx/basic/Main.cxx size: 10 bytes
+> [  3.208145] (1:server@server)       /scratch/toto.cxx size: 500001 bytes
+> [  3.208145] (1:server@server)       /doc/simgrid/examples/cxx/basic/Slave.cxx size: 10 bytes
 > [  3.208145] (0:@) Simulated time: 3.20814
-
index 1c5713f..e495e7e 100644 (file)
@@ -1,5 +1,5 @@
-./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx 500001        
-./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml 800000          
-./doc/simgrid/examples/cxx/autoDestination/Main.cxx 75000000      
-./doc/simgrid/examples/cxx/autoDestination/Slave.cxx 45800000     
-./doc/simgrid/examples/cxx/autoDestination/BasicTask.cxx 400000         
+/doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx 500001         
+/doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml 800000           
+/doc/simgrid/examples/cxx/autoDestination/Main.cxx 75000000       
+/doc/simgrid/examples/cxx/autoDestination/Slave.cxx 45800000      
+/doc/simgrid/examples/cxx/autoDestination/BasicTask.cxx 400000          
index 34cb554..f2adbfb 100644 (file)
@@ -1,4 +1,4 @@
-./doc/simgrid/examples/cxx/autoDestination/Master.cxx 10          
-./doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml 10   
-./doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx 10       
-./doc/simgrid/examples/cxx/basic/FinalizeTask.cxx 10         
+/doc/simgrid/examples/cxx/autoDestination/Master.cxx 10           
+/doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml 10   
+/doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx 10        
+/doc/simgrid/examples/cxx/basic/FinalizeTask.cxx 10          
index 06ed884..e1497a0 100644 (file)
@@ -1,2 +1,2 @@
-./doc/simgrid/examples/cxx/basic/Main.cxx 10
-./doc/simgrid/examples/cxx/basic/Slave.cxx 10   
\ No newline at end of file
+/doc/simgrid/examples/cxx/basic/Main.cxx 10
+/doc/simgrid/examples/cxx/basic/Slave.cxx 10   
\ No newline at end of file
index 320a0c1..d65ba9f 100644 (file)
@@ -38,6 +38,7 @@ set(tesh_files
   ${CMAKE_CURRENT_SOURCE_DIR}/get_full_link.tesh
   ${CMAKE_CURRENT_SOURCE_DIR}/bogus_two_hosts_asymetric.tesh
   ${CMAKE_CURRENT_SOURCE_DIR}/bogus_missing_gateway.tesh
+  ${CMAKE_CURRENT_SOURCE_DIR}/bogus_disk_attachment.tesh
   PARENT_SCOPE
   )
 set(xml_files
@@ -48,6 +49,7 @@ set(xml_files
   ${CMAKE_CURRENT_SOURCE_DIR}/four_hosts_floyd.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/two_hosts_multi_hop.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/one_cluster_file.xml
+  ${CMAKE_CURRENT_SOURCE_DIR}/one_cluster_multicore.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/one_cluster_foreach.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/one_cluster_fullduplex.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/one_cluster_one_host_random.xml
@@ -88,6 +90,7 @@ set(xml_files
   ${CMAKE_CURRENT_SOURCE_DIR}/clusterA.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/clusterB.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/Dijkstra.xml
+  ${CMAKE_CURRENT_SOURCE_DIR}/bogus_disk_attachment.xml
   PARENT_SCOPE
   )
 set(teshsuite_src
diff --git a/teshsuite/simdag/platforms/bogus_disk_attachment.tesh b/teshsuite/simdag/platforms/bogus_disk_attachment.tesh
new file mode 100644 (file)
index 0000000..02e5e4a
--- /dev/null
@@ -0,0 +1,4 @@
+! expect signal SIGABRT
+$ ${bindir:=.}/flatifier bogus_disk_attachment.xml "--log=root.fmt:[%10.6r]%e[%i:%P@%h]%e%m%n"
+> [  0.000000] [0:@] surf_workstation_model_init_ptask_L07
+> [  0.000000] [0:@] Parse error at bogus_disk_attachment.xml:26: Unable to attach storage cdisk: host plouf doesn't exist.
diff --git a/teshsuite/simdag/platforms/bogus_disk_attachment.xml b/teshsuite/simdag/platforms/bogus_disk_attachment.xml
new file mode 100644 (file)
index 0000000..c5ca5dc
--- /dev/null
@@ -0,0 +1,26 @@
+
+<!-- THIS FILE IS INVALID.
+
+It declares a storage attached to a nonexistant host (plouf)
+See bogus_disk_attachment.tesh -->
+
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+
+<platform version="3">
+       <AS id="AS0" routing="Full">
+               <!-- STORAGE TYPES -->
+               <storage_type id="single_HDD" model="SSD" size="4000">
+                       <model_prop id="Bwrite" value="30000000" /> <!-- 30Mo/s -->
+                       <model_prop id="Bread" value="100000000" /> <!-- 100Mo/s -->
+                       <model_prop id="Bconnection" value="150000000" /> <!-- 150Mo/s -->
+               </storage_type>
+               
+               <storage id="cdisk" typeId="single_HDD"  attach="plouf" />
+
+               <!-- HOSTS -->
+               <host id="client" power="1000000000">
+                       <mount storageId="cdisk" name="/sd1" />
+               </host>
+       </AS>
+</platform>
\ No newline at end of file
index b475902..128b9b7 100644 (file)
@@ -116,7 +116,7 @@ int main(int argc, char **argv)
   if (parse_cmdline(&timings, &downgrade, &platformFile, argc, argv) || !platformFile) {
     xbt_die("Invalid command line arguments: expected [--timings|--downgrade] platformFile");
   }
+
   XBT_DEBUG("%d,%d,%s", timings, downgrade, platformFile);
 
   if (downgrade) {
@@ -147,6 +147,9 @@ int main(int argc, char **argv)
           SD_workstation_get_name(hosts[i]),
           SD_workstation_get_power(hosts[i]));
       props = SD_workstation_get_properties(hosts[i]);
+      if (SD_workstation_get_cores(hosts[i])>1) {
+        printf(" cores=\"%d\"", SD_workstation_get_cores(hosts[i]));
+      }
       if (props && !xbt_dict_is_empty(props)) {
         printf(">\n");
         xbt_dict_foreach(props, cursor, key, data) {
index 873b810..fe5f803 100644 (file)
@@ -137,6 +137,140 @@ $ ${bindir:=.}/flatifier$EXEEXT one_cluster.xml "--log=root.fmt:[%10.6r]%e[%i:%P
 > </AS>
 > </platform>
 
+$ ${bindir:=.}/flatifier$EXEEXT one_cluster_multicore.xml "--log=root.fmt:[%10.6r]%e[%i:%P@%h]%e%m%n"
+> [  0.000000] [0:@] surf_workstation_model_init_ptask_L07
+> <?xml version='1.0'?>
+> <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+> <platform version="3">
+> <AS id="AS0" routing="Full">
+>   <host id="bob0.hamburger.edu" power="1000000000 core="6"/>
+>   <host id="bob2.hamburger.edu" power="1000000000 core="6""/>
+>   <host id="bob3.hamburger.edu" power="1000000000 core="6""/>
+>   <host id="bob4.hamburger.edu" power="1000000000 core="6""/>
+>   <host id="bob6.hamburger.edu" power="1000000000 core="6""/>
+>   <router id="bobbob_cluster_router.hamburger.edu"/>
+>   <link id="__loopback__" bandwidth="498000000" latency="0.000015000" sharing_policy="FATPIPE"/>
+>   <link id="bob_cluster_link_0_DOWN" bandwidth="125000000" latency="0.000050000"/>
+>   <link id="bob_cluster_link_0_UP" bandwidth="125000000" latency="0.000050000"/>
+>   <link id="bob_cluster_link_2_DOWN" bandwidth="125000000" latency="0.000050000"/>
+>   <link id="bob_cluster_link_2_UP" bandwidth="125000000" latency="0.000050000"/>
+>   <link id="bob_cluster_link_3_DOWN" bandwidth="125000000" latency="0.000050000"/>
+>   <link id="bob_cluster_link_3_UP" bandwidth="125000000" latency="0.000050000"/>
+>   <link id="bob_cluster_link_4_DOWN" bandwidth="125000000" latency="0.000050000"/>
+>   <link id="bob_cluster_link_4_UP" bandwidth="125000000" latency="0.000050000"/>
+>   <link id="bob_cluster_link_6_DOWN" bandwidth="125000000" latency="0.000050000"/>
+>   <link id="bob_cluster_link_6_UP" bandwidth="125000000" latency="0.000050000"/>
+>   <route src="bob3.hamburger.edu" dst="bob3.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_3_UP"/><link_ctn id="bob_cluster_link_3_DOWN"/>
+>   </route>
+>   <route src="bob3.hamburger.edu" dst="bob0.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_3_UP"/><link_ctn id="bob_cluster_link_0_DOWN"/>
+>   </route>
+>   <route src="bob3.hamburger.edu" dst="bob2.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_3_UP"/><link_ctn id="bob_cluster_link_2_DOWN"/>
+>   </route>
+>   <route src="bob3.hamburger.edu" dst="bob4.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_3_UP"/><link_ctn id="bob_cluster_link_4_DOWN"/>
+>   </route>
+>   <route src="bob3.hamburger.edu" dst="bob6.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_3_UP"/><link_ctn id="bob_cluster_link_6_DOWN"/>
+>   </route>
+>   <route src="bob3.hamburger.edu" dst="bobbob_cluster_router.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_3_UP"/>
+>   </route>
+>   <route src="bob0.hamburger.edu" dst="bob3.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_0_UP"/><link_ctn id="bob_cluster_link_3_DOWN"/>
+>   </route>
+>   <route src="bob0.hamburger.edu" dst="bob0.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_0_UP"/><link_ctn id="bob_cluster_link_0_DOWN"/>
+>   </route>
+>   <route src="bob0.hamburger.edu" dst="bob2.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_0_UP"/><link_ctn id="bob_cluster_link_2_DOWN"/>
+>   </route>
+>   <route src="bob0.hamburger.edu" dst="bob4.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_0_UP"/><link_ctn id="bob_cluster_link_4_DOWN"/>
+>   </route>
+>   <route src="bob0.hamburger.edu" dst="bob6.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_0_UP"/><link_ctn id="bob_cluster_link_6_DOWN"/>
+>   </route>
+>   <route src="bob0.hamburger.edu" dst="bobbob_cluster_router.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_0_UP"/>
+>   </route>
+>   <route src="bob2.hamburger.edu" dst="bob3.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_2_UP"/><link_ctn id="bob_cluster_link_3_DOWN"/>
+>   </route>
+>   <route src="bob2.hamburger.edu" dst="bob0.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_2_UP"/><link_ctn id="bob_cluster_link_0_DOWN"/>
+>   </route>
+>   <route src="bob2.hamburger.edu" dst="bob2.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_2_UP"/><link_ctn id="bob_cluster_link_2_DOWN"/>
+>   </route>
+>   <route src="bob2.hamburger.edu" dst="bob4.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_2_UP"/><link_ctn id="bob_cluster_link_4_DOWN"/>
+>   </route>
+>   <route src="bob2.hamburger.edu" dst="bob6.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_2_UP"/><link_ctn id="bob_cluster_link_6_DOWN"/>
+>   </route>
+>   <route src="bob2.hamburger.edu" dst="bobbob_cluster_router.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_2_UP"/>
+>   </route>
+>   <route src="bob4.hamburger.edu" dst="bob3.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_4_UP"/><link_ctn id="bob_cluster_link_3_DOWN"/>
+>   </route>
+>   <route src="bob4.hamburger.edu" dst="bob0.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_4_UP"/><link_ctn id="bob_cluster_link_0_DOWN"/>
+>   </route>
+>   <route src="bob4.hamburger.edu" dst="bob2.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_4_UP"/><link_ctn id="bob_cluster_link_2_DOWN"/>
+>   </route>
+>   <route src="bob4.hamburger.edu" dst="bob4.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_4_UP"/><link_ctn id="bob_cluster_link_4_DOWN"/>
+>   </route>
+>   <route src="bob4.hamburger.edu" dst="bob6.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_4_UP"/><link_ctn id="bob_cluster_link_6_DOWN"/>
+>   </route>
+>   <route src="bob4.hamburger.edu" dst="bobbob_cluster_router.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_4_UP"/>
+>   </route>
+>   <route src="bob6.hamburger.edu" dst="bob3.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_6_UP"/><link_ctn id="bob_cluster_link_3_DOWN"/>
+>   </route>
+>   <route src="bob6.hamburger.edu" dst="bob0.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_6_UP"/><link_ctn id="bob_cluster_link_0_DOWN"/>
+>   </route>
+>   <route src="bob6.hamburger.edu" dst="bob2.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_6_UP"/><link_ctn id="bob_cluster_link_2_DOWN"/>
+>   </route>
+>   <route src="bob6.hamburger.edu" dst="bob4.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_6_UP"/><link_ctn id="bob_cluster_link_4_DOWN"/>
+>   </route>
+>   <route src="bob6.hamburger.edu" dst="bob6.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_6_UP"/><link_ctn id="bob_cluster_link_6_DOWN"/>
+>   </route>
+>   <route src="bob6.hamburger.edu" dst="bobbob_cluster_router.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_6_UP"/>
+>   </route>
+>   <route src="bobbob_cluster_router.hamburger.edu" dst="bobbob_cluster_router.hamburger.edu">
+>   
+>   </route>
+>   <route src="bobbob_cluster_router.hamburger.edu" dst="bob3.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_3_DOWN"/>
+>   </route>
+>   <route src="bobbob_cluster_router.hamburger.edu" dst="bob0.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_0_DOWN"/>
+>   </route>
+>   <route src="bobbob_cluster_router.hamburger.edu" dst="bob2.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_2_DOWN"/>
+>   </route>
+>   <route src="bobbob_cluster_router.hamburger.edu" dst="bob4.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_4_DOWN"/>
+>   </route>
+>   <route src="bobbob_cluster_router.hamburger.edu" dst="bob6.hamburger.edu">
+>   <link_ctn id="bob_cluster_link_6_DOWN"/>
+>   </route>
+> </AS>
+> </platform>
+
 $ ${bindir:=.}/flatifier$EXEEXT one_host_availability.xml "--log=root.fmt:[%10.6r]%e[%i:%P@%h]%e%m%n"
 > [  0.000000] [0:@] surf_workstation_model_init_ptask_L07
 > <?xml version='1.0'?>
diff --git a/teshsuite/simdag/platforms/one_cluster_multicore.xml b/teshsuite/simdag/platforms/one_cluster_multicore.xml
new file mode 100644 (file)
index 0000000..884ec32
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+<AS id="AS0" routing="Full">
+  <cluster id="bob_cluster" prefix="bob" suffix=".hamburger.edu"
+   radical="0,2-4,6" power="1Gf" core="6" bw="125MBps" lat="50us"/>
+</AS>
+</platform>
index 4c78962..8a22a1a 100644 (file)
@@ -5,20 +5,26 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
 add_executable(check_defaults check_defaults.c)
 target_link_libraries(check_defaults simgrid)
 
+add_executable(stack_overflow stack_overflow.c)
+target_link_libraries(stack_overflow simgrid)
+
 set(tesh_files
   ${tesh_files}
   ${CMAKE_CURRENT_SOURCE_DIR}/factory_raw.tesh
   ${CMAKE_CURRENT_SOURCE_DIR}/factory_thread.tesh
   ${CMAKE_CURRENT_SOURCE_DIR}/factory_ucontext.tesh
+  ${CMAKE_CURRENT_SOURCE_DIR}/stack_overflow.tesh
   PARENT_SCOPE
   )
 set(xml_files
   ${xml_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/stack_overflow.xml
   PARENT_SCOPE
   )
 set(teshsuite_src
   ${teshsuite_src}
   ${CMAKE_CURRENT_SOURCE_DIR}/check_defaults.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/stack_overflow.c
   PARENT_SCOPE
   )
 set(bin_files
diff --git a/teshsuite/simix/stack_overflow.c b/teshsuite/simix/stack_overflow.c
new file mode 100644 (file)
index 0000000..0ae6ffa
--- /dev/null
@@ -0,0 +1,58 @@
+/* stack_overflow -- simple program generating a stack overflow          */
+
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "simgrid/platf.h"
+#include "simgrid/simix.h"
+#include "surf/surfxml_parse.h"
+#include "xbt/log.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "my log messages");
+
+static unsigned collatz(unsigned c0, unsigned n)
+{
+  unsigned x;
+  if (n == 0) {
+    x = c0;
+  } else {
+    x = collatz(c0, n - 1);
+    if (x % 2 == 0)
+      x = x / 2;
+    else
+      x = 3 * x + 1;
+  }
+  return x;
+}
+
+static int master(int argc, char *argv[])
+{
+  XBT_INFO("Launching our nice bugged recursive function...");
+  unsigned i = 1;
+  do {
+    i *= 2;
+    unsigned res = collatz(i, i);
+    XBT_VERB("collatz(%u, %u) returned %u", i, i, res);
+  } while (i <= 0x80000000u);
+  return 0;
+}
+
+int main(int argc, char *argv[])
+{
+  SIMIX_global_init(&argc, argv);
+
+  if (argc != 2) {
+    printf("Usage: %s platform_and_deployment.xml\n", argv[0]);
+    exit(EXIT_FAILURE);
+  }
+
+  SIMIX_function_register("master", master);
+  SIMIX_create_environment(argv[1]);
+  SIMIX_launch_application(argv[1]);
+  SIMIX_run();
+
+  return 0;
+}
diff --git a/teshsuite/simix/stack_overflow.tesh b/teshsuite/simix/stack_overflow.tesh
new file mode 100644 (file)
index 0000000..a0df41e
--- /dev/null
@@ -0,0 +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 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/teshsuite/simix/stack_overflow.xml b/teshsuite/simix/stack_overflow.xml
new file mode 100644 (file)
index 0000000..8ac632a
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+
+  <!-- The hosts -->
+  <AS  id="AS0"  routing="Full">
+   <host id="Tremblay" power="98.095Mf"/>
+  </AS>
+
+  <!-- The master process (with some arguments) -->
+  <process host="Tremblay" function="master">
+  </process>
+
+</platform>
index 33e4cd7..759f177 100644 (file)
@@ -17,6 +17,7 @@ $ ../../smpi_script/bin/smpirun -trace-ti --cfg=tracing/filename:out_in_ti.txt -
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi/format' to 'TI'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi/computing' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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 'tracing/filename' to 'out_in_ti.txt'
@@ -52,6 +53,7 @@ $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.:critical -trace-t
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi/format' to 'TI'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi/computing' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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 'tracing/filename' to 'out_ti.txt'
@@ -60,7 +62,7 @@ $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.:critical -trace-t
 > [Jupiter:1:(0) 0.016798] [smpi_replay/INFO] Simulation time 0.016798
 
 ! output sort
-$ find ./out_ti.txt_files -type f -exec cat {} \;
+$ sh -c "cat ./out_ti.txt_files/*"
 > 0 init
 > 0 send 1 1 1
 > 0 recv 1 1 1
@@ -83,7 +85,7 @@ $ find ./out_ti.txt_files -type f -exec cat {} \;
 > 3 finalize
 
 ! output sort
-$ find ./out_in_ti.txt_files -type f -exec cat {} \;
+$ sh -c "cat ./out_in_ti.txt_files/*"
 > 0 init
 > 0 send 1 1 1
 > 0 recv 1 1 1
@@ -127,6 +129,7 @@ $ ../../smpi_script/bin/smpirun -trace-ti --cfg=tracing/filename:out_in_ti.txt -
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi/format' to 'TI'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi/computing' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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 'tracing/filename' to 'out_in_ti.txt'
@@ -162,6 +165,7 @@ $ ../../smpi_script/bin/smpirun -ext smpi_replay --log=replay.:critical -trace-t
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi/format' to 'TI'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/smpi/computing' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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 'tracing/filename' to 'out_ti.txt'
index ec96371..e13e40c 100644 (file)
@@ -4,7 +4,7 @@
 
 ! timeout 20
 p Test allreduce
-$ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../../examples/msg/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ./allreduce_coll 300000 --log=smpi_kernel.thres:warning
+$ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../../examples/msg/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ./allreduce_coll 30000 --log=smpi_kernel.thres:warning
 > You requested to use 16 processes, but there is only 5 processes in your hostfile...
 > [rank 0] -> Tremblay
 > [rank 1] -> Jupiter
index 7b5430e..352f56c 100644 (file)
@@ -7,6 +7,7 @@ $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform $
 > [rank 1] -> Jupiter
 > [rank 2] -> Fafard
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
@@ -21,6 +22,7 @@ $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform $
 > [rank 3] -> Ginette
 > [rank 4] -> Bourassa
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
@@ -43,6 +45,7 @@ $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform $
 > [rank 10] -> Tremblay
 > [rank 11] -> Jupiter
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
index 99e1111..b5f789e 100644 (file)
@@ -4,6 +4,7 @@ p Test hvector
 $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../../examples/msg/small_platform.xml -np 2 ./hvector_test -q --log=smpi_kernel.thres:warning
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
 > [rank 0] -> Tremblay
index c5e6f8d..f8777fb 100644 (file)
@@ -4,6 +4,7 @@ p Test indexed
 $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../../examples/msg/small_platform.xml -np 2 ./indexed_test -q --log=smpi_kernel.thres:warning
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
 > [rank 0] -> Tremblay
index f8b8f8e..153598d 100644 (file)
@@ -40,6 +40,7 @@ set(txt_files
   ${CMAKE_CURRENT_SOURCE_DIR}/hostfile
   ${CMAKE_CURRENT_SOURCE_DIR}/checktests
   ${CMAKE_CURRENT_SOURCE_DIR}/util/mtest.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/util/mtest_manual.c
   ${CMAKE_CURRENT_SOURCE_DIR}/f77/testlist
   ${CMAKE_CURRENT_SOURCE_DIR}/f90/testlist
   ${CMAKE_CURRENT_SOURCE_DIR}/include/mpitestconf.h
@@ -59,8 +60,10 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
 include_directories("${CMAKE_HOME_DIRECTORY}/include/smpi")
 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/")
 
-#C version
+#C version - use automatic privatization if mmap is supported, manual through SMPI macros if not
+if(HAVE_MMAP)
 add_library(mtest_c STATIC util/mtest.c)
-
-
+else()
+add_library(mtest_c STATIC util/mtest_manual.c)
+endif()
 
index ece1e25..9ebf1f7 100644 (file)
@@ -20,7 +20,7 @@ int main(int argc, char *argv[])
     /* a random non-zero sized buffer */
 #define NELEM (10)
     buf = malloc(NELEM*sizeof(int));
-    assert(buf);
+    assert(buf!=NULL);
 
     for (i = 0; i < NELEM; i++) {
         buf[i] = wrank * NELEM + i;
index d6fd63c..5844207 100644 (file)
@@ -534,7 +534,7 @@ static int pack_and_check_expected(MPI_Datatype type, const char *name,
     err = MPI_Pack_size(type_size/sizeof(int), MPI_INT, MPI_COMM_SELF, &pack_size);
     check_err(MPI_Pack_size);
     pack_buf = malloc(pack_size);
-    assert(pack_buf);
+    assert(pack_buf!=NULL);
 
     pos = 0;
     err = MPI_Pack(&sendbuf[0], type_size/sizeof(int), MPI_INT, pack_buf, pack_size, &pos, MPI_COMM_SELF);
index b19b1e7..efd6c06 100644 (file)
@@ -9,11 +9,14 @@ C
       integer cin(*), cout(*)
       integer count, datatype
       integer i
-      
-!      if (datatype .ne. MPI_INTEGER) then
-!         write(6,*) 'Invalid datatype ',datatype,' passed to user_op()'
-!         return
-!      endif
+
+      if (.false.) then
+         if (datatype .ne. MPI_INTEGER) then
+            write(6,*) 'Invalid datatype ',datatype,
+     &           ' passed to user_op()'
+            return
+         endif
+      endif
 
       do i=1, count
          cout(i) = cin(i) + cout(i)
index 5d4714b..e7cc14a 100644 (file)
@@ -16,12 +16,12 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite AND SMPI_F2C)
   add_executable(allpairf allpairf.f)
 #  add_executable(greqf greqf.f dummyf.f)
   #add_executable(mprobef mprobef.f)
-#  add_executable(statusesf statusesf.f)
+  add_executable(statusesf statusesf.f)
 
   target_link_libraries(allpairf simgrid mtest_f77)
 #  target_link_libraries(greqf simgrid mtest_f77)
   #target_link_libraries(mprobef simgrid mtest_f77)
-#  target_link_libraries(statusesf simgrid mtest_f77)
+  target_link_libraries(statusesf simgrid mtest_f77)
 
 endif()
 
index 3385b9d..fe7ad6b 100644 (file)
@@ -1,4 +1,4 @@
-#statusesf 1
+statusesf 1
 #greqf 1
 allpairf 2
-#mprobef 2 mpiversion=3.0
+mprobef 2 mpiversion=3.0
index f1a137c..2c54d76 100644 (file)
@@ -15,8 +15,6 @@ C       about out-of-order statements
         logical dbgflag
         integer wrank
         common /mtest/ dbgflag, wrank
-        integer myindex
-        common /grr/ myindex
 
         call MPI_Initialized( flag, ierr )
         if (.not. flag) then
@@ -24,7 +22,6 @@ C       about out-of-order statements
         endif
 
         dbgflag = .false.
-        myindex = 0
         call MPI_Comm_rank( MPI_COMM_WORLD, wrank, ierr )
         end
 C
@@ -56,8 +53,12 @@ C A simple get intracomm for now
         integer comm, min_size, size, rank
         logical qsmaller
         integer myindex
-        common /grr/ myindex 
+        save myindex
+        data myindex /0/
 
+        if (.false.) then
+           qsmaller = qsmaller
+        endif
         comm = MPI_COMM_NULL
         if (myindex .eq. 0) then
            comm = MPI_COMM_WORLD
@@ -75,7 +76,6 @@ C A simple get intracomm for now
         endif
         myindex = mod( myindex, 4 ) + 1
         MTestGetIntracomm = comm .ne. MPI_COMM_NULL
-        qsmaller=.true.
         end
 C
         subroutine MTestFreeComm( comm )
index 2230ac2..496d178 100644 (file)
       integer count, datatype
       integer i
       
-!      if (datatype .ne. MPI_INTEGER) then
-!         write(6,*) 'Invalid datatype ',datatype,' passed to user_op()'
-!         return
-!      endif
+      if (.false.) then
+         if (datatype .ne. MPI_INTEGER) then
+            write(6,*) 'Invalid datatype ',datatype,' passed to user_op()'
+            return
+         endif
+      endif
 
       do i=1, count
          cout(i) = cin(i) + cout(i)
index 5367f99..123a623 100644 (file)
@@ -23,7 +23,7 @@
       call mpi_comm_rank( MPI_COMM_WORLD, rank, ierr )
       if (size .lt. 2) then
          print *, "Must have at least 2 processes"
-         call MPI_Abort( 1, MPI_COMM_WORLD, ierr )
+         call MPI_Abort( MPI_COMM_WORLD, 1, ierr )
          stop
       endif
 
index 71e9735..8227ef0 100644 (file)
@@ -44,7 +44,7 @@
       call mpi_comm_size(MPI_COMM_WORLD, size, ierr )
       if (size .lt. 2) then
          print *, "Must have at least 2 processes"
-         call MPI_Abort( 1, MPI_COMM_WORLD, ierr )
+         call MPI_Abort( MPI_COMM_WORLD, 1, ierr )
          stop
       endif
 
index 51a0fcb..9275e6a 100644 (file)
@@ -11,11 +11,11 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite AND SMPI_F90)
   set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
   include_directories("${CMAKE_HOME_DIRECTORY}/include/smpi")
 
-#  add_executable(allpairf90 allpairf90.f90)
+  add_executable(allpairf90 allpairf90.f90)
 #  add_executable(greqf90 greqf90.f90 dummyf90.f90)
 #  add_executable(mprobef90 mprobef90.f90)
   add_executable(statusesf90 statusesf90.f90)
-#  target_link_libraries(allpairf90 simgrid mtest_f90)
+  target_link_libraries(allpairf90 simgrid mtest_f90)
 #  target_link_libraries(greqf90 simgrid mtest_f90)
 #  target_link_libraries(mprobef90 simgrid mtest_f90)
   target_link_libraries(statusesf90 simgrid mtest_f90)
index 70f5c51..92251df 100644 (file)
@@ -21,6 +21,7 @@
       call MTest_Init( ierr )
 
       do while ( mtestGetIntraComm( comm, 2, .false. ) )
+
          call test_pair_send( comm, errs )
          call test_pair_ssend( comm, errs )
          !call test_pair_rsend( comm, errs )
index b39a1a0..920fba2 100644 (file)
@@ -1,5 +1,5 @@
 # This file generated by f77tof90
 statusesf90 1
 #greqf90 1
-#allpairf90 2
+allpairf90 2
 mprobef90 2 mpiversion=3.0
index 8e44792..bb12b29 100644 (file)
            endif
         endif
         end
-
-module array
-        integer, dimension(:), allocatable :: myindex
-end module
-
 !
 ! A simple get intracomm for now
         logical function MTestGetIntracomm( comm, min_size, qsmaller )
-        use array
         use mpi
-
         integer ierr
         integer comm, min_size, size, rank
         logical qsmaller
+        integer myindex
+        save myindex
+        data myindex /0/
 
-        integer status
-        call mpi_comm_size( MPI_COMM_WORLD, size, ierr )
-        
-        if(.not. allocated(myindex)) then
-            allocate(myindex(size), STAT=status)
-            call mpi_comm_rank( MPI_COMM_WORLD, rank, ierr )
-            myindex(rank+1)=0
+        if (.false.) then
+           qsmaller = qsmaller
         endif
-
-        !data myindex /0/
-        
-        
-
-        if (myindex(rank+1) .eq. 0) then
+        comm = MPI_COMM_NULL
+        if (myindex .eq. 0) then
            comm = MPI_COMM_WORLD
-        else if (myindex(rank+1) .eq. 1) then
+        else if (myindex .eq. 1) then
            call mpi_comm_dup( MPI_COMM_WORLD, comm, ierr )
-        else if (myindex(rank+1) .eq. 2) then
+        else if (myindex .eq. 2) then
            call mpi_comm_size( MPI_COMM_WORLD, size, ierr )
            call mpi_comm_rank( MPI_COMM_WORLD, rank, ierr )
            call mpi_comm_split( MPI_COMM_WORLD, 0, size - rank, comm,  &
       &                                 ierr )
         else
-           if (min_size .eq. 1 .and. myindex(rank+1) .eq. 3) then
+           if (min_size .eq. 1 .and. myindex .eq. 3) then
               comm = MPI_COMM_SELF
            endif
         endif
-        myindex(rank+1) = mod( myindex(rank+1), 4 ) + 1
+        myindex = mod( myindex, 4 ) + 1
         MTestGetIntracomm = comm .ne. MPI_COMM_NULL
-        qsmaller=.true.
         end
 !
         subroutine MTestFreeComm( comm )
index e922072..e75d17b 100644 (file)
@@ -7,7 +7,6 @@
 #include "mpi.h"
 #include "mpitestconf.h"
 #include "mpitest.h"
-#include "smpi_cocci.h"
 #if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
 #include <stdio.h>
 #endif
@@ -49,13 +48,13 @@ static void MTestResourceSummary( FILE * );
 /* Here is where we could put the includes and definitions to enable
    memory testing */
 
-SMPI_VARINIT_GLOBAL_AND_SET(dbgflag, int, 0); /* Flag used for debugging */
-SMPI_VARINIT_GLOBAL_AND_SET(wrank, int, -1);  /* World rank */
-SMPI_VARINIT_GLOBAL_AND_SET(verbose, int, 0); /* Message level (0 is none) */
-SMPI_VARINIT_GLOBAL_AND_SET(returnWithVal, int, 0); /* Allow programs to return
-                                  with a non-zero if there was an error (may
-                                  cause problems with some runtime systems) */
-SMPI_VARINIT_GLOBAL_AND_SET(usageOutput, int, 0); /* */
+static int dbgflag = 0;         /* Flag used for debugging */
+static int wrank = -1;          /* World rank */
+static int verbose = 0;         /* Message level (0 is none) */
+static int returnWithVal = 0;   /* Allow programs to return with a non-zero 
+                                  if there was an error (may cause problems
+                                  with some runtime systems) */
+static int usageOutput = 0;     /* */
 
 /* Provide backward portability to MPI 1 */
 #ifndef MPI_VERSION
@@ -99,8 +98,8 @@ void MTest_Init_thread( int *argc, char ***argv, int required, int *provided )
     }
     /* Check for debugging control */
     if (getenv( "MPITEST_DEBUG" )) {
-       SMPI_VARGET_GLOBAL(dbgflag) = 1;
-       MPI_Comm_rank( MPI_COMM_WORLD, &SMPI_VARGET_GLOBAL(wrank) );
+       dbgflag = 1;
+       MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
     }
 
     /* Check for verbose control */
@@ -116,7 +115,7 @@ void MTest_Init_thread( int *argc, char ***argv, int required, int *provided )
        }
        else {
            if (val >= 0) {
-               SMPI_VARGET_GLOBAL(verbose) = val;
+               verbose = val;
            }
            else {
                fprintf( stderr, "Warning: %s not valid for MPITEST_VERBOSE\n", 
@@ -132,13 +131,13 @@ void MTest_Init_thread( int *argc, char ***argv, int required, int *provided )
            strcmp( envval, "YES" ) == 0 ||
            strcmp( envval, "true" ) == 0 ||
            strcmp( envval, "TRUE" ) == 0) {
-           SMPI_VARGET_GLOBAL(returnWithVal) = 1;
+           returnWithVal = 1;
        }
        else if (strcmp( envval, "no" ) == 0 ||
            strcmp( envval, "NO" ) == 0 ||
            strcmp( envval, "false" ) == 0 ||
            strcmp( envval, "FALSE" ) == 0) {
-           SMPI_VARGET_GLOBAL(returnWithVal) = 0;
+           returnWithVal = 0;
        }
        else {
            fprintf( stderr, 
@@ -150,7 +149,7 @@ void MTest_Init_thread( int *argc, char ***argv, int required, int *provided )
     
     /* Print rusage data if set */
     if (getenv( "MPITEST_RUSAGE" )) {
-       SMPI_VARGET_GLOBAL(usageOutput) = 1;
+       usageOutput = 1;
     }
 }
 /* 
@@ -220,7 +219,7 @@ void MTest_Finalize( int errs )
        fflush( stdout );
     }
     
-    if (SMPI_VARGET_GLOBAL(usageOutput))
+    if (usageOutput) 
        MTestResourceSummary( stdout );
 
 
@@ -233,7 +232,7 @@ void MTest_Finalize( int errs )
  */
 int MTestReturnValue( int errors )
 {
-    if (SMPI_VARGET_GLOBAL(returnWithVal)) return errors ? 1 : 0;
+    if (returnWithVal) return errors ? 1 : 0;
     return 0;
 }
 /* ------------------------------------------------------------------------ */
@@ -278,7 +277,7 @@ void MTestSleep( int sec )
  *    Indexed  - Indexed datatype.  Only for a count of 1 instance of the 
  *               datatype
  */
-SMPI_VARINIT_GLOBAL_AND_SET(datatype_index, int, 0);
+static int datatype_index = 0;
 
 /* ------------------------------------------------------------------------ */
 /* Datatype routines for contiguous datatypes                               */
@@ -637,7 +636,7 @@ int MTestGetDatatypes( MTestDatatype *sendtype, MTestDatatype *recvtype,
     recvtype->count      = count;
     /* Use datatype_index to choose a datatype to use.  If at the end of the
        list, return 0 */
-    switch (SMPI_VARGET_GLOBAL(datatype_index)) {
+    switch (datatype_index) {
     case 0:
        sendtype->datatype = MPI_INT;
        sendtype->isBasic  = 1;
@@ -859,7 +858,7 @@ int MTestGetDatatypes( MTestDatatype *sendtype, MTestDatatype *recvtype,
        break;
 #endif
     default:
-       SMPI_VARGET_GLOBAL(datatype_index) = -1;
+       datatype_index = -1;
     }
 
     if (!sendtype->InitBuf) {
@@ -870,29 +869,29 @@ int MTestGetDatatypes( MTestDatatype *sendtype, MTestDatatype *recvtype,
        sendtype->CheckBuf = MTestTypeContigCheckbuf;
        recvtype->CheckBuf = MTestTypeContigCheckbuf;
     }
-    SMPI_VARGET_GLOBAL(datatype_index)++;
+    datatype_index++;
 
-    if (SMPI_VARGET_GLOBAL(dbgflag) && SMPI_VARGET_GLOBAL(datatype_index) > 0) {
+    if (dbgflag && datatype_index > 0) {
        int typesize;
-       fprintf( stderr, "%d: sendtype is %s\n", SMPI_VARGET_GLOBAL(wrank), MTestGetDatatypeName( sendtype ) );
+       fprintf( stderr, "%d: sendtype is %s\n", wrank, MTestGetDatatypeName( sendtype ) );
        merr = MPI_Type_size( sendtype->datatype, &typesize );
        if (merr) MTestPrintError( merr );
-       fprintf( stderr, "%d: sendtype size = %d\n", SMPI_VARGET_GLOBAL(wrank), typesize );
-       fprintf( stderr, "%d: recvtype is %s\n", SMPI_VARGET_GLOBAL(wrank), MTestGetDatatypeName( recvtype ) );
+       fprintf( stderr, "%d: sendtype size = %d\n", wrank, typesize );
+       fprintf( stderr, "%d: recvtype is %s\n", wrank, MTestGetDatatypeName( recvtype ) );
        merr = MPI_Type_size( recvtype->datatype, &typesize );
        if (merr) MTestPrintError( merr );
-       fprintf( stderr, "%d: recvtype size = %d\n", SMPI_VARGET_GLOBAL(wrank), typesize );
+       fprintf( stderr, "%d: recvtype size = %d\n", wrank, typesize );
        fflush( stderr );
        
     }
-    else if (SMPI_VARGET_GLOBAL(verbose) && SMPI_VARGET_GLOBAL(datatype_index) > 0) {
+    else if (verbose && datatype_index > 0) {
        printf( "Get new datatypes: send = %s, recv = %s\n", 
                MTestGetDatatypeName( sendtype ), 
                MTestGetDatatypeName( recvtype ) );
        fflush( stdout );
     }
 
-    return SMPI_VARGET_GLOBAL(datatype_index);
+    return datatype_index;
 }
 
 /* Reset the datatype index (start from the initial data type.
@@ -901,13 +900,13 @@ int MTestGetDatatypes( MTestDatatype *sendtype, MTestDatatype *recvtype,
 */
 void MTestResetDatatypes( void )
 {
-    SMPI_VARGET_GLOBAL(datatype_index) = 0;
+    datatype_index = 0;
 }
 /* Return the index of the current datatype.  This is rarely needed and
    is provided mostly to enable debugging of the MTest package itself */
 int MTestGetDatatypeIndex( void )
 {
-    return SMPI_VARGET_GLOBAL(datatype_index);
+    return datatype_index;
 }
 
 /* Free the storage associated with a datatype */
@@ -954,15 +953,14 @@ int MTestCheckRecv( MPI_Status *status, MTestDatatype *recvtype )
    simplify the use of the routine */
 const char *MTestGetDatatypeName( MTestDatatype *dtype )
 {
-    typedef char name_type[4][MPI_MAX_OBJECT_NAME];
-    SMPI_VARINIT_STATIC(name, name_type);
-    SMPI_VARINIT_STATIC_AND_SET(sp, int, 0);
+    static char name[4][MPI_MAX_OBJECT_NAME];
+    static int sp=0;
     int rlen, merr;
 
-    if (SMPI_VARGET_STATIC(sp) >= 4) SMPI_VARGET_STATIC(sp) = 0;
-    merr = MPI_Type_get_name( dtype->datatype, SMPI_VARGET_STATIC(name)[SMPI_VARGET_STATIC(sp)], &rlen );
+    if (sp >= 4) sp = 0;
+    merr = MPI_Type_get_name( dtype->datatype, name[sp], &rlen );
     if (merr) MTestPrintError( merr );
-    return (const char *)SMPI_VARGET_STATIC(name)[SMPI_VARGET_STATIC(sp)++];
+    return (const char *)name[sp++];
 }
 /* ----------------------------------------------------------------------- */
 
@@ -973,10 +971,10 @@ const char *MTestGetDatatypeName( MTestDatatype *dtype )
  * that return value as well.
  * 
  */
-SMPI_VARINIT_GLOBAL_AND_SET(interCommIdx, int, 0);
-SMPI_VARINIT_GLOBAL_AND_SET(intraCommIdx, int, 0);
-SMPI_VARINIT_GLOBAL_AND_SET(intraCommName, const char *, 0);
-SMPI_VARINIT_GLOBAL_AND_SET(interCommName, const char *, 0);
+static int interCommIdx = 0;
+static int intraCommIdx = 0;
+static const char *intraCommName = 0;
+static const char *interCommName = 0;
 
 /* 
  * Get an intracommunicator with at least min_size members.  If "allowSmaller"
@@ -994,18 +992,18 @@ int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
        MPI_COMM_NULL is always considered large enough */
     while (!done) {
        isBasic = 0;
-       SMPI_VARGET_GLOBAL(intraCommName) = "";
-       switch (SMPI_VARGET_GLOBAL(intraCommIdx)) {
+       intraCommName = "";
+       switch (intraCommIdx) {
        case 0:
            *comm = MPI_COMM_WORLD;
            isBasic = 1;
-           SMPI_VARGET_GLOBAL(intraCommName) = "MPI_COMM_WORLD";
+           intraCommName = "MPI_COMM_WORLD";
            break;
        case 1:
            /* dup of world */
            merr = MPI_Comm_dup(MPI_COMM_WORLD, comm );
            if (merr) MTestPrintError( merr );
-           SMPI_VARGET_GLOBAL(intraCommName) = "Dup of MPI_COMM_WORLD";
+           intraCommName = "Dup of MPI_COMM_WORLD";
            break;
        case 2:
            /* reverse ranks */
@@ -1015,7 +1013,7 @@ int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
            if (merr) MTestPrintError( merr );
            merr = MPI_Comm_split( MPI_COMM_WORLD, 0, size-rank, comm );
            if (merr) MTestPrintError( merr );
-           SMPI_VARGET_GLOBAL(intraCommName) = "Rank reverse of MPI_COMM_WORLD";
+           intraCommName = "Rank reverse of MPI_COMM_WORLD";
            break;
        case 3:
            /* subset of world, with reversed ranks */
@@ -1026,12 +1024,12 @@ int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
            merr = MPI_Comm_split( MPI_COMM_WORLD, ((rank < size/2) ? 1 : MPI_UNDEFINED),
                                   size-rank, comm );
            if (merr) MTestPrintError( merr );
-           SMPI_VARGET_GLOBAL(intraCommName) = "Rank reverse of half of MPI_COMM_WORLD";
+           intraCommName = "Rank reverse of half of MPI_COMM_WORLD";
            break;
        case 4:
            *comm = MPI_COMM_SELF;
            isBasic = 1;
-           SMPI_VARGET_GLOBAL(intraCommName) = "MPI_COMM_SELF";
+           intraCommName = "MPI_COMM_SELF";
            break;
 
            /* These next cases are communicators that include some
@@ -1044,7 +1042,7 @@ int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
            int newsize;
            merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
            if (merr) MTestPrintError( merr );
-           newsize = size - (SMPI_VARGET_GLOBAL(intraCommIdx) - 4);
+           newsize = size - (intraCommIdx - 4);
            
            if (allowSmaller && newsize >= min_size) {
                merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
@@ -1058,13 +1056,13 @@ int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
                    *comm = MPI_COMM_NULL;
                }
                else {
-                   SMPI_VARGET_GLOBAL(intraCommName) = "Split of WORLD";
+                   intraCommName = "Split of WORLD";
                }
            }
            else {
                /* Act like default */
                *comm = MPI_COMM_NULL;
-               SMPI_VARGET_GLOBAL(intraCommIdx) = -1;
+               intraCommIdx = -1;
            }
        }
        break;
@@ -1072,7 +1070,7 @@ int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
            /* Other ideas: dup of self, cart comm, graph comm */
        default:
            *comm = MPI_COMM_NULL;
-           SMPI_VARGET_GLOBAL(intraCommIdx) = -1;
+           intraCommIdx = -1;
            break;
        }
 
@@ -1083,7 +1081,7 @@ int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
                done = 1;
        }
         else {
-            SMPI_VARGET_GLOBAL(intraCommName) = "MPI_COMM_NULL";
+            intraCommName = "MPI_COMM_NULL";
             isBasic = 1;
             done = 1;
         }
@@ -1094,7 +1092,7 @@ done2=done;
         /* Advance the comm index whether we are done or not, otherwise we could
          * spin forever trying to allocate a too-small communicator over and
          * over again. */
-        SMPI_VARGET_GLOBAL(intraCommIdx)++;
+        intraCommIdx++;
 
         if (!done && !isBasic && *comm != MPI_COMM_NULL) {
             /* avoid leaking communicators */
@@ -1103,7 +1101,7 @@ done2=done;
         }
     }
 
-    return SMPI_VARGET_GLOBAL(intraCommIdx);
+    return intraCommIdx;
 }
 
 /* 
@@ -1117,7 +1115,7 @@ int MTestGetIntracomm( MPI_Comm *comm, int min_size )
 /* Return the name of an intra communicator */
 const char *MTestGetIntracommName( void )
 {
-    return SMPI_VARGET_GLOBAL(intraCommName);
+    return intraCommName;
 }
 
 /* 
@@ -1138,9 +1136,9 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
     while (!done) {
         *comm = MPI_COMM_NULL;
         *isLeftGroup = 0;
-        SMPI_VARGET_GLOBAL(interCommName) = "MPI_COMM_NULL";
+        interCommName = "MPI_COMM_NULL";
 
-       switch (SMPI_VARGET_GLOBAL(interCommIdx)) {
+       switch (interCommIdx) {
        case 0:
            /* Split comm world in half */
            merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
@@ -1166,7 +1164,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
                merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader,
                                             12345, comm );
                if (merr) MTestPrintError( merr );
-               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD";
+               interCommName = "Intercomm by splitting MPI_COMM_WORLD";
            }
            else 
                *comm = MPI_COMM_NULL;
@@ -1196,7 +1194,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
                merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, 
                                             rleader, 12346, comm );
                if (merr) MTestPrintError( merr );
-               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD into 1, rest";
+               interCommName = "Intercomm by splitting MPI_COMM_WORLD into 1, rest";
            }
            else
                *comm = MPI_COMM_NULL;
@@ -1227,7 +1225,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
                merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, 
                                             rleader, 12347, comm );
                if (merr) MTestPrintError( merr );
-               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD into 2, rest";
+               interCommName = "Intercomm by splitting MPI_COMM_WORLD into 2, rest";
            }
            else 
                *comm = MPI_COMM_NULL;
@@ -1266,7 +1264,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
                mcomm = *comm;
                merr = MPI_Comm_dup(mcomm, comm);
                if (merr) MTestPrintError( merr );
-               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD then dup'ing";
+               interCommName = "Intercomm by splitting MPI_COMM_WORLD then dup'ing";
            }
            else 
                *comm = MPI_COMM_NULL;
@@ -1308,7 +1306,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
                /* this split is effectively a dup but tests the split code paths */
                merr = MPI_Comm_split(mcomm, 0, rank, comm);
                if (merr) MTestPrintError( merr );
-               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD then then splitting again";
+               interCommName = "Intercomm by splitting MPI_COMM_WORLD then then splitting again";
            }
            else
                *comm = MPI_COMM_NULL;
@@ -1345,7 +1343,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
                     merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader, 12345, comm );
                     if (merr) MTestPrintError( merr );
                 }
-                SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD (discarding rank 0 in the left group) then MPI_Intercomm_create'ing";
+                interCommName = "Intercomm by splitting MPI_COMM_WORLD (discarding rank 0 in the left group) then MPI_Intercomm_create'ing";
             }
             else {
                 *comm = MPI_COMM_NULL;
@@ -1398,7 +1396,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
                 merr = MPI_Group_free(&newgroup);
                 if (merr) MTestPrintError( merr );
 
-                SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD then discarding 0 ranks with MPI_Comm_create";
+                interCommName = "Intercomm by splitting MPI_COMM_WORLD then discarding 0 ranks with MPI_Comm_create";
             }
             else {
                 *comm = MPI_COMM_NULL;
@@ -1407,7 +1405,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
 
        default:
            *comm = MPI_COMM_NULL;
-           SMPI_VARGET_GLOBAL(interCommIdx) = -1;
+           interCommIdx = -1;
            break;
        }
 
@@ -1419,7 +1417,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
            if (size + remsize >= min_size) done = 1;
        }
        else {
-           SMPI_VARGET_GLOBAL(interCommName) = "MPI_COMM_NULL";
+           interCommName = "MPI_COMM_NULL";
            done = 1;
         }
 
@@ -1429,7 +1427,7 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
         /* Advance the comm index whether we are done or not, otherwise we could
          * spin forever trying to allocate a too-small communicator over and
          * over again. */
-        SMPI_VARGET_GLOBAL(interCommIdx)++;
+        interCommIdx++;
 
         if (!done && *comm != MPI_COMM_NULL) {
             /* avoid leaking communicators */
@@ -1448,12 +1446,12 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
         }
     }
 
-    return SMPI_VARGET_GLOBAL(interCommIdx);
+    return interCommIdx;
 }
 /* Return the name of an intercommunicator */
 const char *MTestGetIntercommName( void )
 {
-    return SMPI_VARGET_GLOBAL(interCommName);
+    return interCommName;
 }
 
 /* Get a communicator of a given minimum size.  Both intra and inter 
@@ -1461,19 +1459,19 @@ const char *MTestGetIntercommName( void )
 int MTestGetComm( MPI_Comm *comm, int min_size )
 {
     int idx=0;
-    SMPI_VARINIT_STATIC_AND_SET(getinter, int, 0);
+    static int getinter = 0;
 
-    if (!SMPI_VARGET_STATIC(getinter)) {
+    if (!getinter) {
        idx = MTestGetIntracomm( comm, min_size );
        if (idx == 0) {
-           SMPI_VARGET_STATIC(getinter) = 1;
+           getinter = 1;
        }
     }
-    if (SMPI_VARGET_STATIC(getinter)) {
+    if (getinter) {
        int isLeft;
        idx = MTestGetIntercomm( comm, &isLeft, min_size );
        if (idx == 0) {
-           SMPI_VARGET_STATIC(getinter) = 0;
+           getinter = 0;
        }
     }
 
@@ -1523,7 +1521,7 @@ void MTestPrintfMsg( int level, const char format[], ... )
 {
     va_list list;
 
-    if (SMPI_VARGET_GLOBAL(verbose) && level >= SMPI_VARGET_GLOBAL(verbose)) {
+    if (verbose && level >= verbose) {
        va_start(list,format);
        vprintf( format, list );
        va_end(list);
@@ -1543,20 +1541,20 @@ static void MTestResourceSummary( FILE *fp )
 {
 #ifdef HAVE_GETRUSAGE
     struct rusage ru;
-    SMPI_VARINIT_STATIC_AND_SET(pfThreshold, int, -2);
+    static int pfThreshold = -2;
     int doOutput = 1;
     if (getrusage( RUSAGE_SELF, &ru ) == 0) {
        /* There is an option to generate output only when a resource
           exceeds a threshold.  To date, only page faults supported. */
-       if (SMPI_VARGET_STATIC(pfThreshold) == -2) {
+       if (pfThreshold == -2) {
            char *p = getenv("MPITEST_RUSAGE_PF");
-           SMPI_VARGET_STATIC(pfThreshold) = -1;
+           pfThreshold = -1;
            if (p) {
-               SMPI_VARGET_STATIC(pfThreshold) = strtol( p, 0, 0 );
+               pfThreshold = strtol( p, 0, 0 );
            }
        }
-       if (SMPI_VARGET_STATIC(pfThreshold) > 0) {
-           doOutput = ru.ru_minflt > SMPI_VARGET_STATIC(pfThreshold);
+       if (pfThreshold > 0) {
+           doOutput = ru.ru_minflt > pfThreshold;
        }
        if (doOutput) {
            /* Cast values to long in case some system has defined them
@@ -1584,48 +1582,47 @@ static void MTestResourceSummary( FILE *fp )
 /*
  * Create MPI Windows
  */
-SMPI_VARINIT_GLOBAL_AND_SET(win_index, int, 0);
-SMPI_VARINIT_GLOBAL(winName, const char *);
+static int win_index = 0;
+static const char *winName;
 /* Use an attribute to remember the type of memory allocation (static,
    malloc, or MPI_Alloc_mem) */
-SMPI_VARINIT_GLOBAL_AND_SET(mem_keyval, int, MPI_KEYVAL_INVALID);
+static int mem_keyval = MPI_KEYVAL_INVALID;
 int MTestGetWin( MPI_Win *win, int mustBePassive )
 {
-    typedef char actbuf_type[1024];
-    SMPI_VARINIT_STATIC(actbuf, actbuf_type);
-    SMPI_VARINIT_STATIC(pasbuf, char *);
+    static char actbuf[1024];
+    static char *pasbuf;
     char        *buf;
     int         n, rank, merr;
     MPI_Info    info;
 
-    if (SMPI_VARGET_GLOBAL(mem_keyval) == MPI_KEYVAL_INVALID) {
+    if (mem_keyval == MPI_KEYVAL_INVALID) {
        /* Create the keyval */
        merr = MPI_Win_create_keyval( MPI_WIN_NULL_COPY_FN, 
                                      MPI_WIN_NULL_DELETE_FN, 
-                                     &SMPI_VARGET_GLOBAL(mem_keyval), 0 );
+                                     &mem_keyval, 0 );
        if (merr) MTestPrintError( merr );
 
     }
 
-    switch (SMPI_VARGET_GLOBAL(win_index)) {
+    switch (win_index) {
     case 0:
        /* Active target window */
-       merr = MPI_Win_create( SMPI_VARGET_STATIC(actbuf), 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD,
+       merr = MPI_Win_create( actbuf, 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD, 
                               win );
        if (merr) MTestPrintError( merr );
-       SMPI_VARGET_GLOBAL(winName) = "active-window";
-       merr = MPI_Win_set_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), (void *)0 );
+       winName = "active-window";
+       merr = MPI_Win_set_attr( *win, mem_keyval, (void *)0 );
        if (merr) MTestPrintError( merr );
        break;
     case 1:
        /* Passive target window */
-       merr = MPI_Alloc_mem( 1024, MPI_INFO_NULL, &SMPI_VARGET_STATIC(pasbuf) );
+       merr = MPI_Alloc_mem( 1024, MPI_INFO_NULL, &pasbuf );
        if (merr) MTestPrintError( merr );
-       merr = MPI_Win_create( SMPI_VARGET_STATIC(pasbuf), 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD,
+       merr = MPI_Win_create( pasbuf, 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD, 
                               win );
        if (merr) MTestPrintError( merr );
-       SMPI_VARGET_GLOBAL(winName) = "passive-window";
-       merr = MPI_Win_set_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), (void *)2 );
+       winName = "passive-window";
+       merr = MPI_Win_set_attr( *win, mem_keyval, (void *)2 );
        if (merr) MTestPrintError( merr );
        break;
     case 2:
@@ -1640,8 +1637,8 @@ int MTestGetWin( MPI_Win *win, int mustBePassive )
        merr = MPI_Win_create( buf, n, 1, MPI_INFO_NULL, MPI_COMM_WORLD, 
                               win );
        if (merr) MTestPrintError( merr );
-       SMPI_VARGET_GLOBAL(winName) = "active-all-different-win";
-       merr = MPI_Win_set_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), (void *)1 );
+       winName = "active-all-different-win";
+       merr = MPI_Win_set_attr( *win, mem_keyval, (void *)1 );
        if (merr) MTestPrintError( merr );
        break;
     case 3:
@@ -1661,20 +1658,20 @@ int MTestGetWin( MPI_Win *win, int mustBePassive )
        if (merr) MTestPrintError( merr );
        merr = MPI_Info_free( &info );
        if (merr) MTestPrintError( merr );
-       SMPI_VARGET_GLOBAL(winName) = "active-nolocks-all-different-win";
-       merr = MPI_Win_set_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), (void *)1 );
+       winName = "active-nolocks-all-different-win";
+       merr = MPI_Win_set_attr( *win, mem_keyval, (void *)1 );
        if (merr) MTestPrintError( merr );
        break;
     default:
-       SMPI_VARGET_GLOBAL(win_index) = -1;
+       win_index = -1;
     }
-    SMPI_VARGET_GLOBAL(win_index)++;
-    return SMPI_VARGET_GLOBAL(win_index);
+    win_index++;
+    return win_index;
 }
 /* Return a pointer to the name associated with a window object */
 const char *MTestGetWinName( void )
 {
-    return SMPI_VARGET_GLOBAL(winName);
+    return winName;
 }
 /* Free the storage associated with a window object */
 void MTestFreeWin( MPI_Win *win )
@@ -1689,7 +1686,7 @@ void MTestFreeWin( MPI_Win *win )
     }
     if (addr) {
        void *val;
-       merr = MPI_Win_get_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), &val, &flag );
+       merr = MPI_Win_get_attr( *win, mem_keyval, &val, &flag );
        if (merr) MTestPrintError( merr );
        if (flag) {
            if (val == (void *)1) {
@@ -1707,8 +1704,8 @@ void MTestFreeWin( MPI_Win *win )
 }
 static void MTestRMACleanup( void )
 {
-    if (SMPI_VARGET_GLOBAL(mem_keyval) != MPI_KEYVAL_INVALID) {
-       MPI_Win_free_keyval( &SMPI_VARGET_GLOBAL(mem_keyval) );
+    if (mem_keyval != MPI_KEYVAL_INVALID) {
+       MPI_Win_free_keyval( &mem_keyval );
     }
 }
 #else 
diff --git a/teshsuite/smpi/mpich3-test/util/mtest_manual.c b/teshsuite/smpi/mpich3-test/util/mtest_manual.c
new file mode 100644 (file)
index 0000000..e922072
--- /dev/null
@@ -0,0 +1,1716 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ *  (C) 2001 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include "mpitestconf.h"
+#include "mpitest.h"
+#include "smpi_cocci.h"
+#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
+#include <stdio.h>
+#endif
+#if defined(HAVE_STDLIB_H) || defined(STDC_HEADERS)
+#include <stdlib.h>
+#endif
+#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
+#include <string.h>
+#endif
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+/* The following two includes permit the collection of resource usage
+   data in the tests
+ */
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+#include <errno.h>
+
+
+/*
+ * Utility routines for writing MPI tests.
+ *
+ * We check the return codes on all MPI routines (other than INIT)
+ * to allow the program that uses these routines to select MPI_ERRORS_RETURN
+ * as the error handler.  We do *not* set MPI_ERRORS_RETURN because
+ * the code that makes use of these routines may not check return
+ * codes.
+ * 
+ */
+
+static void MTestRMACleanup( void );
+static void MTestResourceSummary( FILE * );
+
+/* Here is where we could put the includes and definitions to enable
+   memory testing */
+
+SMPI_VARINIT_GLOBAL_AND_SET(dbgflag, int, 0); /* Flag used for debugging */
+SMPI_VARINIT_GLOBAL_AND_SET(wrank, int, -1);  /* World rank */
+SMPI_VARINIT_GLOBAL_AND_SET(verbose, int, 0); /* Message level (0 is none) */
+SMPI_VARINIT_GLOBAL_AND_SET(returnWithVal, int, 0); /* Allow programs to return
+                                  with a non-zero if there was an error (may
+                                  cause problems with some runtime systems) */
+SMPI_VARINIT_GLOBAL_AND_SET(usageOutput, int, 0); /* */
+
+/* Provide backward portability to MPI 1 */
+#ifndef MPI_VERSION
+#define MPI_VERSION 1
+#endif
+#if MPI_VERSION < 2
+#define MPI_THREAD_SINGLE 0
+#endif
+
+/* 
+ * Initialize and Finalize MTest
+ */
+
+/*
+   Initialize MTest, initializing MPI if necessary.  
+
+ Environment Variables:
++ MPITEST_DEBUG - If set (to any value), turns on debugging output
+. MPITEST_THREADLEVEL_DEFAULT - If set, use as the default "provided"
+                                level of thread support.  Applies to 
+                                MTest_Init but not MTest_Init_thread.
+- MPITEST_VERBOSE - If set to a numeric value, turns on that level of
+  verbose output.  This is used by the routine 'MTestPrintfMsg'
+
+*/
+void MTest_Init_thread( int *argc, char ***argv, int required, int *provided )
+{
+    int flag;
+    char *envval = 0;
+
+    MPI_Initialized( &flag );
+    if (!flag) {
+       /* Permit an MPI that claims only MPI 1 but includes the 
+          MPI_Init_thread routine (e.g., IBM MPI) */
+#if MPI_VERSION >= 2 || defined(HAVE_MPI_INIT_THREAD)
+       MPI_Init_thread( argc, argv, required, provided );
+#else
+       MPI_Init( argc, argv );
+       *provided = -1;
+#endif
+    }
+    /* Check for debugging control */
+    if (getenv( "MPITEST_DEBUG" )) {
+       SMPI_VARGET_GLOBAL(dbgflag) = 1;
+       MPI_Comm_rank( MPI_COMM_WORLD, &SMPI_VARGET_GLOBAL(wrank) );
+    }
+
+    /* Check for verbose control */
+    envval = getenv( "MPITEST_VERBOSE" );
+    if (envval) {
+       char *s;
+       long val = strtol( envval, &s, 0 );
+       if (s == envval) {
+           /* This is the error case for strtol */
+           fprintf( stderr, "Warning: %s not valid for MPITEST_VERBOSE\n", 
+                    envval );
+           fflush( stderr );
+       }
+       else {
+           if (val >= 0) {
+               SMPI_VARGET_GLOBAL(verbose) = val;
+           }
+           else {
+               fprintf( stderr, "Warning: %s not valid for MPITEST_VERBOSE\n", 
+                        envval );
+               fflush( stderr );
+           }
+       }
+    }
+    /* Check for option to return success/failure in the return value of main */
+    envval = getenv( "MPITEST_RETURN_WITH_CODE" );
+    if (envval) {
+       if (strcmp( envval, "yes" ) == 0 ||
+           strcmp( envval, "YES" ) == 0 ||
+           strcmp( envval, "true" ) == 0 ||
+           strcmp( envval, "TRUE" ) == 0) {
+           SMPI_VARGET_GLOBAL(returnWithVal) = 1;
+       }
+       else if (strcmp( envval, "no" ) == 0 ||
+           strcmp( envval, "NO" ) == 0 ||
+           strcmp( envval, "false" ) == 0 ||
+           strcmp( envval, "FALSE" ) == 0) {
+           SMPI_VARGET_GLOBAL(returnWithVal) = 0;
+       }
+       else {
+           fprintf( stderr, 
+                    "Warning: %s not valid for MPITEST_RETURN_WITH_CODE\n", 
+                    envval );
+           fflush( stderr );
+       }
+    }
+    
+    /* Print rusage data if set */
+    if (getenv( "MPITEST_RUSAGE" )) {
+       SMPI_VARGET_GLOBAL(usageOutput) = 1;
+    }
+}
+/* 
+ * Initialize the tests, using an MPI-1 style init.  Supports 
+ * MTEST_THREADLEVEL_DEFAULT to test with user-specified thread level
+ */
+void MTest_Init( int *argc, char ***argv )
+{
+    int provided;
+#if MPI_VERSION >= 2 || defined(HAVE_MPI_INIT_THREAD)
+    const char *str = 0;
+    int        threadLevel;
+
+    threadLevel = MPI_THREAD_SINGLE;
+    str = getenv( "MTEST_THREADLEVEL_DEFAULT" );
+    if (!str) str = getenv( "MPITEST_THREADLEVEL_DEFAULT" );
+    if (str && *str) {
+       if (strcmp(str,"MULTIPLE") == 0 || strcmp(str,"multiple") == 0) {
+           threadLevel = MPI_THREAD_MULTIPLE;
+       }
+       else if (strcmp(str,"SERIALIZED") == 0 || 
+                strcmp(str,"serialized") == 0) {
+           threadLevel = MPI_THREAD_SERIALIZED;
+       }
+       else if (strcmp(str,"FUNNELED") == 0 || strcmp(str,"funneled") == 0) {
+           threadLevel = MPI_THREAD_FUNNELED;
+       }
+       else if (strcmp(str,"SINGLE") == 0 || strcmp(str,"single") == 0) {
+           threadLevel = MPI_THREAD_SINGLE;
+       }
+       else {
+           fprintf( stderr, "Unrecognized thread level %s\n", str );
+           /* Use exit since MPI_Init/Init_thread has not been called. */
+           exit(1);
+       }
+    }
+    MTest_Init_thread( argc, argv, threadLevel, &provided );
+#else
+    /* If the MPI_VERSION is 1, there is no MPI_THREAD_xxx defined */
+    MTest_Init_thread( argc, argv, 0, &provided );
+#endif    
+}
+
+/*
+  Finalize MTest.  errs is the number of errors on the calling process; 
+  this routine will write the total number of errors over all of MPI_COMM_WORLD
+  to the process with rank zero, or " No Errors".
+  It does *not* finalize MPI.
+ */
+void MTest_Finalize( int errs )
+{
+    int rank, toterrs, merr;
+
+    merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+    if (merr) MTestPrintError( merr );
+
+    merr = MPI_Reduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, 
+                     0, MPI_COMM_WORLD );
+    if (merr) MTestPrintError( merr );
+    if (rank == 0) {
+       if (toterrs) {
+           printf( " Found %d errors\n", toterrs );
+       }
+       else {
+           printf( " No Errors\n" );
+       }
+       fflush( stdout );
+    }
+    
+    if (SMPI_VARGET_GLOBAL(usageOutput))
+       MTestResourceSummary( stdout );
+
+
+    /* Clean up any persistent objects that we allocated */
+    MTestRMACleanup();
+}
+/* ------------------------------------------------------------------------ */
+/* This routine may be used instead of "return 0;" at the end of main; 
+   it allows the program to use the return value to signal success or failure. 
+ */
+int MTestReturnValue( int errors )
+{
+    if (SMPI_VARGET_GLOBAL(returnWithVal)) return errors ? 1 : 0;
+    return 0;
+}
+/* ------------------------------------------------------------------------ */
+
+/*
+ * Miscellaneous utilities, particularly to eliminate OS dependencies
+ * from the tests.
+ * MTestSleep( seconds )
+ */
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+void MTestSleep( int sec )
+{
+    Sleep( 1000 * sec );
+}
+#else
+#include <unistd.h>
+void MTestSleep( int sec )
+{
+    sleep( sec );
+}
+#endif
+
+/*
+ * Datatypes
+ *
+ * Eventually, this could read a description of a file.  For now, we hard 
+ * code the choices.
+ *
+ * Each kind of datatype has the following functions:
+ *    MTestTypeXXXInit     - Initialize a send buffer for that type
+ *    MTestTypeXXXInitRecv - Initialize a receive buffer for that type
+ *    MTestTypeXXXFree     - Free any buffers associate with that type
+ *    MTestTypeXXXCheckbuf - Check that the buffer contains the expected data
+ * These routines work with (nearly) any datatype that is of type XXX, 
+ * allowing the test codes to create a variety of contiguous, vector, and
+ * indexed types, then test them by calling these routines.
+ *
+ * Available types (for the XXX) are
+ *    Contig   - Simple contiguous buffers
+ *    Vector   - Simple strided "vector" type
+ *    Indexed  - Indexed datatype.  Only for a count of 1 instance of the 
+ *               datatype
+ */
+SMPI_VARINIT_GLOBAL_AND_SET(datatype_index, int, 0);
+
+/* ------------------------------------------------------------------------ */
+/* Datatype routines for contiguous datatypes                               */
+/* ------------------------------------------------------------------------ */
+/* 
+ * Setup contiguous buffers of n copies of a datatype.
+ */
+static void *MTestTypeContigInit( MTestDatatype *mtype )
+{
+    MPI_Aint size;
+    int merr;
+
+    if (mtype->count > 0) {
+       signed char *p;
+       int  i, totsize;
+       merr = MPI_Type_extent( mtype->datatype, &size );
+       if (merr) MTestPrintError( merr );
+       totsize = size * mtype->count;
+       if (!mtype->buf) {
+           mtype->buf = (void *) malloc( totsize );
+       }
+       p = (signed char *)(mtype->buf);
+       if (!p) {
+           /* Error - out of memory */
+           MTestError( "Out of memory in type buffer init" );
+       }
+       for (i=0; i<totsize; i++) {
+           p[i] = 0xff ^ (i & 0xff);
+       }
+    }
+    else {
+       if (mtype->buf) {
+           free( mtype->buf );
+       }
+       mtype->buf = 0;
+    }
+    return mtype->buf;
+}
+
+/* 
+ * Setup contiguous buffers of n copies of a datatype.  Initialize for
+ * reception (e.g., set initial data to detect failure)
+ */
+static void *MTestTypeContigInitRecv( MTestDatatype *mtype )
+{
+    MPI_Aint size;
+    int      merr;
+
+    if (mtype->count > 0) {
+       signed char *p;
+       int  i, totsize;
+       merr = MPI_Type_extent( mtype->datatype, &size );
+       if (merr) MTestPrintError( merr );
+       totsize = size * mtype->count;
+       if (!mtype->buf) {
+           mtype->buf = (void *) malloc( totsize );
+       }
+       p = (signed char *)(mtype->buf);
+       if (!p) {
+           /* Error - out of memory */
+           MTestError( "Out of memory in type buffer init" );
+       }
+       for (i=0; i<totsize; i++) {
+           p[i] = 0xff;
+       }
+    }
+    else {
+       if (mtype->buf) {
+           free( mtype->buf );
+       }
+       mtype->buf = 0;
+    }
+    return mtype->buf;
+}
+static void *MTestTypeContigFree( MTestDatatype *mtype )
+{
+    if (mtype->buf) {
+       free( mtype->buf );
+       mtype->buf = 0;
+    }
+    return 0;
+}
+static int MTestTypeContigCheckbuf( MTestDatatype *mtype )
+{
+    unsigned char *p;
+    unsigned char expected;
+    int  i, totsize, err = 0, merr;
+    MPI_Aint size;
+
+    p = (unsigned char *)mtype->buf;
+    if (p) {
+       merr = MPI_Type_extent( mtype->datatype, &size );
+       if (merr) MTestPrintError( merr );
+       totsize = size * mtype->count;
+       for (i=0; i<totsize; i++) {
+           expected = (0xff ^ (i & 0xff));
+           if (p[i] != expected) {
+               err++;
+               if (mtype->printErrors && err < 10) {
+                   printf( "Data expected = %x but got p[%d] = %x\n",
+                           expected, i, p[i] );
+                   fflush( stdout );
+               }
+           }
+       }
+    }
+    return err;
+}
+
+/* ------------------------------------------------------------------------ */
+/* Datatype routines for vector datatypes                                   */
+/* ------------------------------------------------------------------------ */
+
+static void *MTestTypeVectorInit( MTestDatatype *mtype )
+{
+    MPI_Aint size;
+    int      merr;
+
+    if (mtype->count > 0) {
+       unsigned char *p;
+       int  i, j, k, nc, totsize;
+
+       merr = MPI_Type_extent( mtype->datatype, &size );
+       if (merr) MTestPrintError( merr );
+       totsize    = mtype->count * size;
+       if (!mtype->buf) {
+           mtype->buf = (void *) malloc( totsize );
+       }
+       p          = (unsigned char *)(mtype->buf);
+       if (!p) {
+           /* Error - out of memory */
+           MTestError( "Out of memory in type buffer init" );
+       }
+
+       /* First, set to -1 */
+       for (i=0; i<totsize; i++) p[i] = 0xff;
+
+       /* Now, set the actual elements to the successive values.
+          To do this, we need to run 3 loops */
+       nc = 0;
+       /* count is usually one for a vector type */
+       for (k=0; k<mtype->count; k++) {
+           /* For each element (block) */
+           for (i=0; i<mtype->nelm; i++) {
+               /* For each value */
+               for (j=0; j<mtype->blksize; j++) {
+                   p[j] = (0xff ^ (nc & 0xff));
+                   nc++;
+               }
+               p += mtype->stride;
+           }
+       }
+    }
+    else {
+       mtype->buf = 0;
+    }
+    return mtype->buf;
+}
+
+static void *MTestTypeVectorFree( MTestDatatype *mtype )
+{
+    if (mtype->buf) {
+       free( mtype->buf );
+       mtype->buf = 0;
+    }
+    return 0;
+}
+
+/* ------------------------------------------------------------------------ */
+/* Datatype routines for indexed block datatypes                            */
+/* ------------------------------------------------------------------------ */
+
+/* 
+ * Setup a buffer for one copy of an indexed datatype. 
+ */
+static void *MTestTypeIndexedInit( MTestDatatype *mtype )
+{
+    MPI_Aint totsize;
+    int      merr;
+    
+    if (mtype->count > 1) {
+       MTestError( "This datatype is supported only for a single count" );
+    }
+    if (mtype->count == 1) {
+       signed char *p;
+       int  i, k, offset, j;
+
+       /* Allocate the send/recv buffer */
+       merr = MPI_Type_extent( mtype->datatype, &totsize );
+       if (merr) MTestPrintError( merr );
+       if (!mtype->buf) {
+           mtype->buf = (void *) malloc( totsize );
+       }
+       p = (signed char *)(mtype->buf);
+       if (!p) {
+           MTestError( "Out of memory in type buffer init\n" );
+       }
+       /* Initialize the elements */
+       /* First, set to -1 */
+       for (i=0; i<totsize; i++) p[i] = 0xff;
+
+       /* Now, set the actual elements to the successive values.
+          We require that the base type is a contiguous type */
+       k = 0;
+       for (i=0; i<mtype->nelm; i++) {
+           int b;
+           /* Compute the offset: */
+           offset = mtype->displs[i] * mtype->basesize;
+           /* For each element in the block */
+           for (b=0; b<mtype->index[i]; b++) {
+               for (j=0; j<mtype->basesize; j++) {
+                   p[offset+j] = 0xff ^ (k++ & 0xff);
+               }
+               offset += mtype->basesize;
+           }
+       }
+    }
+    else {
+       /* count == 0 */
+       if (mtype->buf) {
+           free( mtype->buf );
+       }
+       mtype->buf = 0;
+    }
+    return mtype->buf;
+}
+
+/* 
+ * Setup indexed buffers for 1 copy of a datatype.  Initialize for
+ * reception (e.g., set initial data to detect failure)
+ */
+static void *MTestTypeIndexedInitRecv( MTestDatatype *mtype )
+{
+    MPI_Aint totsize;
+    int      merr;
+
+    if (mtype->count > 1) {
+       MTestError( "This datatype is supported only for a single count" );
+    }
+    if (mtype->count == 1) {
+       signed char *p;
+       int  i;
+       merr = MPI_Type_extent( mtype->datatype, &totsize );
+       if (merr) MTestPrintError( merr );
+       if (!mtype->buf) {
+           mtype->buf = (void *) malloc( totsize );
+       }
+       p = (signed char *)(mtype->buf);
+       if (!p) {
+           /* Error - out of memory */
+           MTestError( "Out of memory in type buffer init\n" );
+       }
+       for (i=0; i<totsize; i++) {
+           p[i] = 0xff;
+       }
+    }
+    else {
+       /* count == 0 */
+       if (mtype->buf) {
+           free( mtype->buf );
+       }
+       mtype->buf = 0;
+    }
+    return mtype->buf;
+}
+
+static void *MTestTypeIndexedFree( MTestDatatype *mtype )
+{
+    if (mtype->buf) {
+       free( mtype->buf );
+       free( mtype->displs );
+       free( mtype->index );
+       mtype->buf    = 0;
+       mtype->displs = 0;
+       mtype->index  = 0;
+    }
+    return 0;
+}
+
+static int MTestTypeIndexedCheckbuf( MTestDatatype *mtype )
+{
+    unsigned char *p;
+    unsigned char expected;
+    int  i, err = 0, merr;
+    MPI_Aint totsize;
+
+    p = (unsigned char *)mtype->buf;
+    if (p) {
+       int j, k, offset;
+       merr = MPI_Type_extent( mtype->datatype, &totsize );
+       if (merr) MTestPrintError( merr );
+       
+       k = 0;
+       for (i=0; i<mtype->nelm; i++) {
+           int b;
+           /* Compute the offset: */
+           offset = mtype->displs[i] * mtype->basesize;
+           for (b=0; b<mtype->index[i]; b++) {
+               for (j=0; j<mtype->basesize; j++) {
+                   expected = (0xff ^ (k & 0xff));
+                   if (p[offset+j] != expected) {
+                       err++;
+                       if (mtype->printErrors && err < 10) {
+                           printf( "Data expected = %x but got p[%d,%d] = %x\n",
+                                   expected, i,j, p[offset+j] );
+                           fflush( stdout );
+                       }
+                   }
+                   k++;
+               }
+               offset += mtype->basesize;
+           }
+       }
+    }
+    return err;
+}
+
+
+/* ------------------------------------------------------------------------ */
+/* Routines to select a datatype and associated buffer create/fill/check    */
+/* routines                                                                 */
+/* ------------------------------------------------------------------------ */
+
+/* 
+   Create a range of datatypes with a given count elements.
+   This uses a selection of types, rather than an exhaustive collection.
+   It allocates both send and receive types so that they can have the same
+   type signature (collection of basic types) but different type maps (layouts
+   in memory) 
+ */
+int MTestGetDatatypes( MTestDatatype *sendtype, MTestDatatype *recvtype,
+                      int count )
+{
+    int merr;
+    int i;
+
+    sendtype->InitBuf    = 0;
+    sendtype->FreeBuf    = 0;
+    sendtype->CheckBuf   = 0;
+    sendtype->datatype   = 0;
+    sendtype->isBasic    = 0;
+    sendtype->printErrors = 0;
+    recvtype->InitBuf    = 0;
+    recvtype->FreeBuf    = 0;
+
+    recvtype->CheckBuf   = 0;
+    recvtype->datatype   = 0;
+    recvtype->isBasic    = 0;
+    recvtype->printErrors = 0;
+
+    sendtype->buf        = 0;
+    recvtype->buf        = 0;
+
+    /* Set the defaults for the message lengths */
+    sendtype->count      = count;
+    recvtype->count      = count;
+    /* Use datatype_index to choose a datatype to use.  If at the end of the
+       list, return 0 */
+    switch (SMPI_VARGET_GLOBAL(datatype_index)) {
+    case 0:
+       sendtype->datatype = MPI_INT;
+       sendtype->isBasic  = 1;
+       recvtype->datatype = MPI_INT;
+       recvtype->isBasic  = 1;
+       break;
+    case 1:
+       sendtype->datatype = MPI_DOUBLE;
+       sendtype->isBasic  = 1;
+       recvtype->datatype = MPI_DOUBLE;
+       recvtype->isBasic  = 1;
+       break;
+    case 2:
+       sendtype->datatype = MPI_FLOAT_INT;
+       sendtype->isBasic  = 1;
+       recvtype->datatype = MPI_FLOAT_INT;
+       recvtype->isBasic  = 1;
+       break;
+    case 3:
+       merr = MPI_Type_dup( MPI_INT, &sendtype->datatype );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Type_set_name( sendtype->datatype,
+                                  (char*)"dup of MPI_INT" );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Type_dup( MPI_INT, &recvtype->datatype );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Type_set_name( recvtype->datatype,
+                                  (char*)"dup of MPI_INT" );
+       if (merr) MTestPrintError( merr );
+       /* dup'ed types are already committed if the original type 
+          was committed (MPI-2, section 8.8) */
+       break;
+    case 4:
+       /* vector send type and contiguous receive type */
+       /* These sizes are in bytes (see the VectorInit code) */
+       sendtype->stride   = 3 * sizeof(int);
+       sendtype->blksize  = sizeof(int);
+       sendtype->nelm     = recvtype->count;
+
+       merr = MPI_Type_vector( recvtype->count, 1, 3, MPI_INT, 
+                               &sendtype->datatype );
+       if (merr) MTestPrintError( merr );
+        merr = MPI_Type_commit( &sendtype->datatype );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Type_set_name( sendtype->datatype,
+                                  (char*)"int-vector" );
+       if (merr) MTestPrintError( merr );
+       sendtype->count    = 1;
+       recvtype->datatype = MPI_INT;
+       recvtype->isBasic  = 1;
+       sendtype->InitBuf  = MTestTypeVectorInit;
+       recvtype->InitBuf  = MTestTypeContigInitRecv;
+       sendtype->FreeBuf  = MTestTypeVectorFree;
+       recvtype->FreeBuf  = MTestTypeContigFree;
+       sendtype->CheckBuf = 0;
+       recvtype->CheckBuf = MTestTypeContigCheckbuf;
+       break;
+
+    case 5:
+       /* Indexed send using many small blocks and contig receive */
+       sendtype->blksize  = sizeof(int);
+       sendtype->nelm     = recvtype->count;
+       sendtype->basesize = sizeof(int);
+       sendtype->displs   = (int *)malloc( sendtype->nelm * sizeof(int) );
+       sendtype->index    = (int *)malloc( sendtype->nelm * sizeof(int) );
+       if (!sendtype->displs || !sendtype->index) {
+           MTestError( "Out of memory in type init\n" );
+       }
+       /* Make the sizes larger (4 ints) to help push the total
+          size to over 256k in some cases, as the MPICH code as of
+          10/1/06 used large internal buffers for packing non-contiguous
+          messages */
+       for (i=0; i<sendtype->nelm; i++) {
+           sendtype->index[i]   = 4;
+           sendtype->displs[i]  = 5*i;
+       }
+       merr = MPI_Type_indexed( sendtype->nelm,
+                                sendtype->index, sendtype->displs, 
+                                MPI_INT, &sendtype->datatype );
+       if (merr) MTestPrintError( merr );
+        merr = MPI_Type_commit( &sendtype->datatype );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Type_set_name( sendtype->datatype,
+                                  (char*)"int-indexed(4-int)" );
+       if (merr) MTestPrintError( merr );
+       sendtype->count    = 1;
+       sendtype->InitBuf  = MTestTypeIndexedInit;
+       sendtype->FreeBuf  = MTestTypeIndexedFree;
+       sendtype->CheckBuf = 0;
+
+       recvtype->datatype = MPI_INT;
+       recvtype->isBasic  = 1;
+       recvtype->count    = count * 4;
+       recvtype->InitBuf  = MTestTypeContigInitRecv;
+       recvtype->FreeBuf  = MTestTypeContigFree;
+       recvtype->CheckBuf = MTestTypeContigCheckbuf;
+       break;
+
+    case 6:
+       /* Indexed send using 2 large blocks and contig receive */
+       sendtype->blksize  = sizeof(int);
+       sendtype->nelm     = 2;
+       sendtype->basesize = sizeof(int);
+       sendtype->displs   = (int *)malloc( sendtype->nelm * sizeof(int) );
+       sendtype->index    = (int *)malloc( sendtype->nelm * sizeof(int) );
+       if (!sendtype->displs || !sendtype->index) {
+           MTestError( "Out of memory in type init\n" );
+       }
+       /* index -> block size */
+       sendtype->index[0]   = (recvtype->count + 1) / 2;
+       sendtype->displs[0]  = 0;
+       sendtype->index[1]   = recvtype->count - sendtype->index[0];
+       sendtype->displs[1]  = sendtype->index[0] + 1; 
+       /* There is a deliberate gap here */
+
+       merr = MPI_Type_indexed( sendtype->nelm,
+                                sendtype->index, sendtype->displs, 
+                                MPI_INT, &sendtype->datatype );
+       if (merr) MTestPrintError( merr );
+        merr = MPI_Type_commit( &sendtype->datatype );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Type_set_name( sendtype->datatype,
+                                  (char*)"int-indexed(2 blocks)" );
+       if (merr) MTestPrintError( merr );
+       sendtype->count    = 1;
+       sendtype->InitBuf  = MTestTypeIndexedInit;
+       sendtype->FreeBuf  = MTestTypeIndexedFree;
+       sendtype->CheckBuf = 0;
+
+       recvtype->datatype = MPI_INT;
+       recvtype->isBasic  = 1;
+       recvtype->count    = sendtype->index[0] + sendtype->index[1];
+       recvtype->InitBuf  = MTestTypeContigInitRecv;
+       recvtype->FreeBuf  = MTestTypeContigFree;
+       recvtype->CheckBuf = MTestTypeContigCheckbuf;
+       break;
+
+    case 7:
+       /* Indexed receive using many small blocks and contig send */
+       recvtype->blksize  = sizeof(int);
+       recvtype->nelm     = recvtype->count;
+       recvtype->basesize = sizeof(int);
+       recvtype->displs   = (int *)malloc( recvtype->nelm * sizeof(int) );
+       recvtype->index    = (int *)malloc( recvtype->nelm * sizeof(int) );
+       if (!recvtype->displs || !recvtype->index) {
+           MTestError( "Out of memory in type recv init\n" );
+       }
+       /* Make the sizes larger (4 ints) to help push the total
+          size to over 256k in some cases, as the MPICH code as of
+          10/1/06 used large internal buffers for packing non-contiguous
+          messages */
+       /* Note that there are gaps in the indexed type */
+       for (i=0; i<recvtype->nelm; i++) {
+           recvtype->index[i]   = 4;
+           recvtype->displs[i]  = 5*i;
+       }
+       merr = MPI_Type_indexed( recvtype->nelm,
+                                recvtype->index, recvtype->displs, 
+                                MPI_INT, &recvtype->datatype );
+       if (merr) MTestPrintError( merr );
+        merr = MPI_Type_commit( &recvtype->datatype );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Type_set_name( recvtype->datatype,
+                                  (char*)"recv-int-indexed(4-int)" );
+       if (merr) MTestPrintError( merr );
+       recvtype->count    = 1;
+       recvtype->InitBuf  = MTestTypeIndexedInitRecv;
+       recvtype->FreeBuf  = MTestTypeIndexedFree;
+       recvtype->CheckBuf = MTestTypeIndexedCheckbuf;
+
+       sendtype->datatype = MPI_INT;
+       sendtype->isBasic  = 1;
+       sendtype->count    = count * 4;
+       sendtype->InitBuf  = MTestTypeContigInit;
+       sendtype->FreeBuf  = MTestTypeContigFree;
+       sendtype->CheckBuf = 0;
+       break;
+
+       /* Less commonly used but still simple types */
+    case 8:
+       sendtype->datatype = MPI_SHORT;
+       sendtype->isBasic  = 1;
+       recvtype->datatype = MPI_SHORT;
+       recvtype->isBasic  = 1;
+       break;
+    case 9:
+       sendtype->datatype = MPI_LONG;
+       sendtype->isBasic  = 1;
+       recvtype->datatype = MPI_LONG;
+       recvtype->isBasic  = 1;
+       break;
+    case 10:
+       sendtype->datatype = MPI_CHAR;
+       sendtype->isBasic  = 1;
+       recvtype->datatype = MPI_CHAR;
+       recvtype->isBasic  = 1;
+       break;
+    case 11:
+       sendtype->datatype = MPI_UINT64_T;
+       sendtype->isBasic  = 1;
+       recvtype->datatype = MPI_UINT64_T;
+       recvtype->isBasic  = 1;
+       break;
+    case 12:
+       sendtype->datatype = MPI_FLOAT;
+       sendtype->isBasic  = 1;
+       recvtype->datatype = MPI_FLOAT;
+       recvtype->isBasic  = 1;
+       break;
+
+#ifndef USE_STRICT_MPI
+       /* MPI_BYTE may only be used with MPI_BYTE in strict MPI */
+    case 13:
+       sendtype->datatype = MPI_INT;
+       sendtype->isBasic  = 1;
+       recvtype->datatype = MPI_BYTE;
+       recvtype->isBasic  = 1;
+       recvtype->count    *= sizeof(int);
+       break;
+#endif
+    default:
+       SMPI_VARGET_GLOBAL(datatype_index) = -1;
+    }
+
+    if (!sendtype->InitBuf) {
+       sendtype->InitBuf  = MTestTypeContigInit;
+       recvtype->InitBuf  = MTestTypeContigInitRecv;
+       sendtype->FreeBuf  = MTestTypeContigFree;
+       recvtype->FreeBuf  = MTestTypeContigFree;
+       sendtype->CheckBuf = MTestTypeContigCheckbuf;
+       recvtype->CheckBuf = MTestTypeContigCheckbuf;
+    }
+    SMPI_VARGET_GLOBAL(datatype_index)++;
+
+    if (SMPI_VARGET_GLOBAL(dbgflag) && SMPI_VARGET_GLOBAL(datatype_index) > 0) {
+       int typesize;
+       fprintf( stderr, "%d: sendtype is %s\n", SMPI_VARGET_GLOBAL(wrank), MTestGetDatatypeName( sendtype ) );
+       merr = MPI_Type_size( sendtype->datatype, &typesize );
+       if (merr) MTestPrintError( merr );
+       fprintf( stderr, "%d: sendtype size = %d\n", SMPI_VARGET_GLOBAL(wrank), typesize );
+       fprintf( stderr, "%d: recvtype is %s\n", SMPI_VARGET_GLOBAL(wrank), MTestGetDatatypeName( recvtype ) );
+       merr = MPI_Type_size( recvtype->datatype, &typesize );
+       if (merr) MTestPrintError( merr );
+       fprintf( stderr, "%d: recvtype size = %d\n", SMPI_VARGET_GLOBAL(wrank), typesize );
+       fflush( stderr );
+       
+    }
+    else if (SMPI_VARGET_GLOBAL(verbose) && SMPI_VARGET_GLOBAL(datatype_index) > 0) {
+       printf( "Get new datatypes: send = %s, recv = %s\n", 
+               MTestGetDatatypeName( sendtype ), 
+               MTestGetDatatypeName( recvtype ) );
+       fflush( stdout );
+    }
+
+    return SMPI_VARGET_GLOBAL(datatype_index);
+}
+
+/* Reset the datatype index (start from the initial data type.
+   Note: This routine is rarely needed; MTestGetDatatypes automatically
+   starts over after the last available datatype is used.
+*/
+void MTestResetDatatypes( void )
+{
+    SMPI_VARGET_GLOBAL(datatype_index) = 0;
+}
+/* Return the index of the current datatype.  This is rarely needed and
+   is provided mostly to enable debugging of the MTest package itself */
+int MTestGetDatatypeIndex( void )
+{
+    return SMPI_VARGET_GLOBAL(datatype_index);
+}
+
+/* Free the storage associated with a datatype */
+void MTestFreeDatatype( MTestDatatype *mtype )
+{
+    int merr;
+    /* Invoke a datatype-specific free function to handle
+       both the datatype and the send/receive buffers */
+    if (mtype->FreeBuf) {
+       (mtype->FreeBuf)( mtype );
+    }
+    /* Free the datatype itself if it was created */
+    if (!mtype->isBasic) {
+       merr = MPI_Type_free( &mtype->datatype );
+       if (merr) MTestPrintError( merr );
+    }
+}
+
+/* Check that a message was received correctly.  Returns the number of
+   errors detected.  Status may be NULL or MPI_STATUS_IGNORE */
+int MTestCheckRecv( MPI_Status *status, MTestDatatype *recvtype )
+{
+    int count;
+    int errs = 0, merr;
+
+    if (status && status != MPI_STATUS_IGNORE) {
+       merr = MPI_Get_count( status, recvtype->datatype, &count );
+       if (merr) MTestPrintError( merr );
+       
+       /* Check count against expected count */
+       if (count != recvtype->count) {
+           errs ++;
+       }
+    }
+
+    /* Check received data */
+    if (!errs && recvtype->CheckBuf( recvtype )) {
+       errs++;
+    }
+    return errs;
+}
+
+/* This next routine uses a circular buffer of static name arrays just to
+   simplify the use of the routine */
+const char *MTestGetDatatypeName( MTestDatatype *dtype )
+{
+    typedef char name_type[4][MPI_MAX_OBJECT_NAME];
+    SMPI_VARINIT_STATIC(name, name_type);
+    SMPI_VARINIT_STATIC_AND_SET(sp, int, 0);
+    int rlen, merr;
+
+    if (SMPI_VARGET_STATIC(sp) >= 4) SMPI_VARGET_STATIC(sp) = 0;
+    merr = MPI_Type_get_name( dtype->datatype, SMPI_VARGET_STATIC(name)[SMPI_VARGET_STATIC(sp)], &rlen );
+    if (merr) MTestPrintError( merr );
+    return (const char *)SMPI_VARGET_STATIC(name)[SMPI_VARGET_STATIC(sp)++];
+}
+/* ----------------------------------------------------------------------- */
+
+/* 
+ * Create communicators.  Use separate routines for inter and intra
+ * communicators (there is a routine to give both)
+ * Note that the routines may return MPI_COMM_NULL, so code should test for
+ * that return value as well.
+ * 
+ */
+SMPI_VARINIT_GLOBAL_AND_SET(interCommIdx, int, 0);
+SMPI_VARINIT_GLOBAL_AND_SET(intraCommIdx, int, 0);
+SMPI_VARINIT_GLOBAL_AND_SET(intraCommName, const char *, 0);
+SMPI_VARINIT_GLOBAL_AND_SET(interCommName, const char *, 0);
+
+/* 
+ * Get an intracommunicator with at least min_size members.  If "allowSmaller"
+ * is true, allow the communicator to be smaller than MPI_COMM_WORLD and
+ * for this routine to return MPI_COMM_NULL for some values.  Returns 0 if
+ * no more communicators are available.
+ */
+int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
+{
+    int size, rank, merr;
+    int done2, done=0;
+    int isBasic = 0;
+
+    /* The while loop allows us to skip communicators that are too small.
+       MPI_COMM_NULL is always considered large enough */
+    while (!done) {
+       isBasic = 0;
+       SMPI_VARGET_GLOBAL(intraCommName) = "";
+       switch (SMPI_VARGET_GLOBAL(intraCommIdx)) {
+       case 0:
+           *comm = MPI_COMM_WORLD;
+           isBasic = 1;
+           SMPI_VARGET_GLOBAL(intraCommName) = "MPI_COMM_WORLD";
+           break;
+       case 1:
+           /* dup of world */
+           merr = MPI_Comm_dup(MPI_COMM_WORLD, comm );
+           if (merr) MTestPrintError( merr );
+           SMPI_VARGET_GLOBAL(intraCommName) = "Dup of MPI_COMM_WORLD";
+           break;
+       case 2:
+           /* reverse ranks */
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_split( MPI_COMM_WORLD, 0, size-rank, comm );
+           if (merr) MTestPrintError( merr );
+           SMPI_VARGET_GLOBAL(intraCommName) = "Rank reverse of MPI_COMM_WORLD";
+           break;
+       case 3:
+           /* subset of world, with reversed ranks */
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_split( MPI_COMM_WORLD, ((rank < size/2) ? 1 : MPI_UNDEFINED),
+                                  size-rank, comm );
+           if (merr) MTestPrintError( merr );
+           SMPI_VARGET_GLOBAL(intraCommName) = "Rank reverse of half of MPI_COMM_WORLD";
+           break;
+       case 4:
+           *comm = MPI_COMM_SELF;
+           isBasic = 1;
+           SMPI_VARGET_GLOBAL(intraCommName) = "MPI_COMM_SELF";
+           break;
+
+           /* These next cases are communicators that include some
+              but not all of the processes */
+       case 5:
+       case 6:
+       case 7:
+       case 8:
+       {
+           int newsize;
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           newsize = size - (SMPI_VARGET_GLOBAL(intraCommIdx) - 4);
+           
+           if (allowSmaller && newsize >= min_size) {
+               merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+               if (merr) MTestPrintError( merr );
+               merr = MPI_Comm_split( MPI_COMM_WORLD, rank < newsize, rank, 
+                                      comm );
+               if (merr) MTestPrintError( merr );
+               if (rank >= newsize) {
+                   merr = MPI_Comm_free( comm );
+                   if (merr) MTestPrintError( merr );
+                   *comm = MPI_COMM_NULL;
+               }
+               else {
+                   SMPI_VARGET_GLOBAL(intraCommName) = "Split of WORLD";
+               }
+           }
+           else {
+               /* Act like default */
+               *comm = MPI_COMM_NULL;
+               SMPI_VARGET_GLOBAL(intraCommIdx) = -1;
+           }
+       }
+       break;
+           
+           /* Other ideas: dup of self, cart comm, graph comm */
+       default:
+           *comm = MPI_COMM_NULL;
+           SMPI_VARGET_GLOBAL(intraCommIdx) = -1;
+           break;
+       }
+
+       if (*comm != MPI_COMM_NULL) {
+           merr = MPI_Comm_size( *comm, &size );
+           if (merr) MTestPrintError( merr );
+           if (size >= min_size)
+               done = 1;
+       }
+        else {
+            SMPI_VARGET_GLOBAL(intraCommName) = "MPI_COMM_NULL";
+            isBasic = 1;
+            done = 1;
+        }
+done2=done;
+        /* we are only done if all processes are done */
+        MPI_Allreduce(&done2, &done, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);
+
+        /* Advance the comm index whether we are done or not, otherwise we could
+         * spin forever trying to allocate a too-small communicator over and
+         * over again. */
+        SMPI_VARGET_GLOBAL(intraCommIdx)++;
+
+        if (!done && !isBasic && *comm != MPI_COMM_NULL) {
+            /* avoid leaking communicators */
+            merr = MPI_Comm_free(comm);
+            if (merr) MTestPrintError(merr);
+        }
+    }
+
+    return SMPI_VARGET_GLOBAL(intraCommIdx);
+}
+
+/* 
+ * Get an intracommunicator with at least min_size members.
+ */
+int MTestGetIntracomm( MPI_Comm *comm, int min_size ) 
+{
+    return MTestGetIntracommGeneral( comm, min_size, 0 );
+}
+
+/* Return the name of an intra communicator */
+const char *MTestGetIntracommName( void )
+{
+    return SMPI_VARGET_GLOBAL(intraCommName);
+}
+
+/* 
+ * Return an intercomm; set isLeftGroup to 1 if the calling process is 
+ * a member of the "left" group.
+ */
+int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
+{
+    int size, rank, remsize, merr;
+    int done=0;
+    MPI_Comm mcomm  = MPI_COMM_NULL;
+    MPI_Comm mcomm2 = MPI_COMM_NULL;
+    int rleader;
+
+    /* The while loop allows us to skip communicators that are too small.
+       MPI_COMM_NULL is always considered large enough.  The size is
+       the sum of the sizes of the local and remote groups */
+    while (!done) {
+        *comm = MPI_COMM_NULL;
+        *isLeftGroup = 0;
+        SMPI_VARGET_GLOBAL(interCommName) = "MPI_COMM_NULL";
+
+       switch (SMPI_VARGET_GLOBAL(interCommIdx)) {
+       case 0:
+           /* Split comm world in half */
+           merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           if (size > 1) {
+               merr = MPI_Comm_split( MPI_COMM_WORLD, (rank < size/2), rank, 
+                                      &mcomm );
+               if (merr) MTestPrintError( merr );
+               if (rank == 0) {
+                   rleader = size/2;
+               }
+               else if (rank == size/2) {
+                   rleader = 0;
+               }
+               else {
+                   /* Remote leader is signficant only for the processes
+                      designated local leaders */
+                   rleader = -1;
+               }
+               *isLeftGroup = rank < size/2;
+               merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader,
+                                            12345, comm );
+               if (merr) MTestPrintError( merr );
+               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD";
+           }
+           else 
+               *comm = MPI_COMM_NULL;
+           break;
+       case 1:
+           /* Split comm world in to 1 and the rest */
+           merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           if (size > 1) {
+               merr = MPI_Comm_split( MPI_COMM_WORLD, rank == 0, rank, 
+                                      &mcomm );
+               if (merr) MTestPrintError( merr );
+               if (rank == 0) {
+                   rleader = 1;
+               }
+               else if (rank == 1) {
+                   rleader = 0;
+               }
+               else {
+                   /* Remote leader is signficant only for the processes
+                      designated local leaders */
+                   rleader = -1;
+               }
+               *isLeftGroup = rank == 0;
+               merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, 
+                                            rleader, 12346, comm );
+               if (merr) MTestPrintError( merr );
+               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD into 1, rest";
+           }
+           else
+               *comm = MPI_COMM_NULL;
+           break;
+
+       case 2:
+           /* Split comm world in to 2 and the rest */
+           merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           if (size > 3) {
+               merr = MPI_Comm_split( MPI_COMM_WORLD, rank < 2, rank, 
+                                      &mcomm );
+               if (merr) MTestPrintError( merr );
+               if (rank == 0) {
+                   rleader = 2;
+               }
+               else if (rank == 2) {
+                   rleader = 0;
+               }
+               else {
+                   /* Remote leader is signficant only for the processes
+                      designated local leaders */
+                   rleader = -1;
+               }
+               *isLeftGroup = rank < 2;
+               merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, 
+                                            rleader, 12347, comm );
+               if (merr) MTestPrintError( merr );
+               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD into 2, rest";
+           }
+           else 
+               *comm = MPI_COMM_NULL;
+           break;
+
+       case 3:
+           /* Split comm world in half, then dup */
+           merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           if (size > 1) {
+               merr = MPI_Comm_split( MPI_COMM_WORLD, (rank < size/2), rank, 
+                                      &mcomm );
+               if (merr) MTestPrintError( merr );
+               if (rank == 0) {
+                   rleader = size/2;
+               }
+               else if (rank == size/2) {
+                   rleader = 0;
+               }
+               else {
+                   /* Remote leader is signficant only for the processes
+                      designated local leaders */
+                   rleader = -1;
+               }
+               *isLeftGroup = rank < size/2;
+               merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader,
+                                            12345, comm );
+               if (merr) MTestPrintError( merr );
+                /* avoid leaking after assignment below */
+               merr = MPI_Comm_free( &mcomm );
+               if (merr) MTestPrintError( merr );
+
+               /* now dup, some bugs only occur for dup's of intercomms */
+               mcomm = *comm;
+               merr = MPI_Comm_dup(mcomm, comm);
+               if (merr) MTestPrintError( merr );
+               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD then dup'ing";
+           }
+           else 
+               *comm = MPI_COMM_NULL;
+           break;
+
+       case 4:
+           /* Split comm world in half, form intercomm, then split that intercomm */
+           merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           if (size > 1) {
+               merr = MPI_Comm_split( MPI_COMM_WORLD, (rank < size/2), rank, 
+                                      &mcomm );
+               if (merr) MTestPrintError( merr );
+               if (rank == 0) {
+                   rleader = size/2;
+               }
+               else if (rank == size/2) {
+                   rleader = 0;
+               }
+               else {
+                   /* Remote leader is signficant only for the processes
+                      designated local leaders */
+                   rleader = -1;
+               }
+               *isLeftGroup = rank < size/2;
+               merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader,
+                                            12345, comm );
+               if (merr) MTestPrintError( merr );
+                /* avoid leaking after assignment below */
+               merr = MPI_Comm_free( &mcomm );
+               if (merr) MTestPrintError( merr );
+
+               /* now split, some bugs only occur for splits of intercomms */
+               mcomm = *comm;
+               rank = MPI_Comm_rank(mcomm, &rank);
+               if (merr) MTestPrintError( merr );
+               /* this split is effectively a dup but tests the split code paths */
+               merr = MPI_Comm_split(mcomm, 0, rank, comm);
+               if (merr) MTestPrintError( merr );
+               SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD then then splitting again";
+           }
+           else
+               *comm = MPI_COMM_NULL;
+           break;
+
+       case 5:
+            /* split comm world in half discarding rank 0 on the "left"
+             * communicator, then form them into an intercommunicator */
+           merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           if (size >= 4) {
+                int color = (rank < size/2 ? 0 : 1);
+                if (rank == 0)
+                    color = MPI_UNDEFINED;
+
+               merr = MPI_Comm_split( MPI_COMM_WORLD, color, rank, &mcomm );
+               if (merr) MTestPrintError( merr );
+
+               if (rank == 1) {
+                   rleader = size/2;
+               }
+               else if (rank == (size/2)) {
+                   rleader = 1;
+               }
+               else {
+                   /* Remote leader is signficant only for the processes
+                      designated local leaders */
+                   rleader = -1;
+               }
+               *isLeftGroup = rank < size/2;
+                if (rank != 0) { /* 0's mcomm is MPI_COMM_NULL */
+                    merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader, 12345, comm );
+                    if (merr) MTestPrintError( merr );
+                }
+                SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD (discarding rank 0 in the left group) then MPI_Intercomm_create'ing";
+            }
+            else {
+                *comm = MPI_COMM_NULL;
+            }
+            break;
+
+        case 6:
+            /* Split comm world in half then form them into an
+             * intercommunicator.  Then discard rank 0 from each group of the
+             * intercomm via MPI_Comm_create. */
+           merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
+           if (merr) MTestPrintError( merr );
+           if (size >= 4) {
+                MPI_Group oldgroup, newgroup;
+                int ranks[1];
+                int color = (rank < size/2 ? 0 : 1);
+
+               merr = MPI_Comm_split( MPI_COMM_WORLD, color, rank, &mcomm );
+               if (merr) MTestPrintError( merr );
+
+               if (rank == 0) {
+                   rleader = size/2;
+               }
+               else if (rank == (size/2)) {
+                   rleader = 0;
+               }
+               else {
+                   /* Remote leader is signficant only for the processes
+                      designated local leaders */
+                   rleader = -1;
+               }
+               *isLeftGroup = rank < size/2;
+                merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader, 12345, &mcomm2 );
+                if (merr) MTestPrintError( merr );
+
+                /* We have an intercomm between the two halves of comm world. Now create
+                 * a new intercomm that removes rank 0 on each side. */
+                merr = MPI_Comm_group(mcomm2, &oldgroup);
+                if (merr) MTestPrintError( merr );
+                ranks[0] = 0;
+                merr = MPI_Group_excl(oldgroup, 1, ranks, &newgroup);
+                if (merr) MTestPrintError( merr );
+                merr = MPI_Comm_create(mcomm2, newgroup, comm);
+                if (merr) MTestPrintError( merr );
+
+                merr = MPI_Group_free(&oldgroup);
+                if (merr) MTestPrintError( merr );
+                merr = MPI_Group_free(&newgroup);
+                if (merr) MTestPrintError( merr );
+
+                SMPI_VARGET_GLOBAL(interCommName) = "Intercomm by splitting MPI_COMM_WORLD then discarding 0 ranks with MPI_Comm_create";
+            }
+            else {
+                *comm = MPI_COMM_NULL;
+            }
+            break;
+
+       default:
+           *comm = MPI_COMM_NULL;
+           SMPI_VARGET_GLOBAL(interCommIdx) = -1;
+           break;
+       }
+
+       if (*comm != MPI_COMM_NULL) {
+           merr = MPI_Comm_size( *comm, &size );
+           if (merr) MTestPrintError( merr );
+           merr = MPI_Comm_remote_size( *comm, &remsize );
+           if (merr) MTestPrintError( merr );
+           if (size + remsize >= min_size) done = 1;
+       }
+       else {
+           SMPI_VARGET_GLOBAL(interCommName) = "MPI_COMM_NULL";
+           done = 1;
+        }
+
+        /* we are only done if all processes are done */
+        MPI_Allreduce(MPI_IN_PLACE, &done, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);
+
+        /* Advance the comm index whether we are done or not, otherwise we could
+         * spin forever trying to allocate a too-small communicator over and
+         * over again. */
+        SMPI_VARGET_GLOBAL(interCommIdx)++;
+
+        if (!done && *comm != MPI_COMM_NULL) {
+            /* avoid leaking communicators */
+            merr = MPI_Comm_free(comm);
+            if (merr) MTestPrintError(merr);
+        }
+
+        /* cleanup for common temp objects */
+        if (mcomm != MPI_COMM_NULL) {
+            merr = MPI_Comm_free(&mcomm);
+            if (merr) MTestPrintError( merr );
+        }
+        if (mcomm2 != MPI_COMM_NULL) {
+            merr = MPI_Comm_free(&mcomm2);
+            if (merr) MTestPrintError( merr );
+        }
+    }
+
+    return SMPI_VARGET_GLOBAL(interCommIdx);
+}
+/* Return the name of an intercommunicator */
+const char *MTestGetIntercommName( void )
+{
+    return SMPI_VARGET_GLOBAL(interCommName);
+}
+
+/* Get a communicator of a given minimum size.  Both intra and inter 
+   communicators are provided */
+int MTestGetComm( MPI_Comm *comm, int min_size )
+{
+    int idx=0;
+    SMPI_VARINIT_STATIC_AND_SET(getinter, int, 0);
+
+    if (!SMPI_VARGET_STATIC(getinter)) {
+       idx = MTestGetIntracomm( comm, min_size );
+       if (idx == 0) {
+           SMPI_VARGET_STATIC(getinter) = 1;
+       }
+    }
+    if (SMPI_VARGET_STATIC(getinter)) {
+       int isLeft;
+       idx = MTestGetIntercomm( comm, &isLeft, min_size );
+       if (idx == 0) {
+           SMPI_VARGET_STATIC(getinter) = 0;
+       }
+    }
+
+    return idx;
+}
+
+/* Free a communicator.  It may be called with a predefined communicator
+ or MPI_COMM_NULL */
+void MTestFreeComm( MPI_Comm *comm )
+{
+    int merr;
+    if (*comm != MPI_COMM_WORLD &&
+       *comm != MPI_COMM_SELF &&
+       *comm != MPI_COMM_NULL) {
+       merr = MPI_Comm_free( comm );
+       if (merr) MTestPrintError( merr );
+    }
+}
+
+/* ------------------------------------------------------------------------ */
+void MTestPrintError( int errcode )
+{
+    int errclass, slen;
+    char string[MPI_MAX_ERROR_STRING];
+    
+    MPI_Error_class( errcode, &errclass );
+    MPI_Error_string( errcode, string, &slen );
+    printf( "Error class %d (%s)\n", errclass, string );
+    fflush( stdout );
+}
+void MTestPrintErrorMsg( const char msg[], int errcode )
+{
+    int errclass, slen;
+    char string[MPI_MAX_ERROR_STRING];
+    
+    MPI_Error_class( errcode, &errclass );
+    MPI_Error_string( errcode, string, &slen );
+    printf( "%s: Error class %d (%s)\n", msg, errclass, string ); 
+    fflush( stdout );
+}
+/* ------------------------------------------------------------------------ */
+/* 
+ If verbose output is selected and the level is at least that of the
+ value of the verbose flag, then perform printf( format, ... );
+ */
+void MTestPrintfMsg( int level, const char format[], ... )
+{
+    va_list list;
+
+    if (SMPI_VARGET_GLOBAL(verbose) && level >= SMPI_VARGET_GLOBAL(verbose)) {
+       va_start(list,format);
+       vprintf( format, list );
+       va_end(list);
+       fflush(stdout);
+    }
+}
+/* Fatal error.  Report and exit */
+void MTestError( const char *msg )
+{
+    fprintf( stderr, "%s\n", msg );
+    fflush( stderr );
+    MPI_Abort( MPI_COMM_WORLD, 1 );
+    exit(1);
+}
+/* ------------------------------------------------------------------------ */
+static void MTestResourceSummary( FILE *fp )
+{
+#ifdef HAVE_GETRUSAGE
+    struct rusage ru;
+    SMPI_VARINIT_STATIC_AND_SET(pfThreshold, int, -2);
+    int doOutput = 1;
+    if (getrusage( RUSAGE_SELF, &ru ) == 0) {
+       /* There is an option to generate output only when a resource
+          exceeds a threshold.  To date, only page faults supported. */
+       if (SMPI_VARGET_STATIC(pfThreshold) == -2) {
+           char *p = getenv("MPITEST_RUSAGE_PF");
+           SMPI_VARGET_STATIC(pfThreshold) = -1;
+           if (p) {
+               SMPI_VARGET_STATIC(pfThreshold) = strtol( p, 0, 0 );
+           }
+       }
+       if (SMPI_VARGET_STATIC(pfThreshold) > 0) {
+           doOutput = ru.ru_minflt > SMPI_VARGET_STATIC(pfThreshold);
+       }
+       if (doOutput) {
+           /* Cast values to long in case some system has defined them
+              as another integer type */
+           fprintf( fp, "RUSAGE: max resident set = %ldKB\n", 
+                    (long)ru.ru_maxrss );
+           fprintf( fp, "RUSAGE: page faults = %ld : %ld\n", 
+                    (long)ru.ru_minflt, (long)ru.ru_majflt );
+           /* Not every Unix provides useful information for the xxrss fields */
+           fprintf( fp, "RUSAGE: memory in text/data/stack = %ld : %ld : %ld\n", 
+                    (long)ru.ru_ixrss, (long)ru.ru_idrss, (long)ru.ru_isrss );
+           fprintf( fp, "RUSAGE: I/O in and out = %ld : %ld\n", 
+                    (long)ru.ru_inblock, (long)ru.ru_oublock );
+           fprintf( fp, "RUSAGE: context switch = %ld : %ld\n", 
+                    (long)ru.ru_nvcsw, (long)ru.ru_nivcsw );
+       }
+    }
+    else {
+       fprintf( fp, "RUSAGE: return error %d\n", errno );
+    }
+#endif
+}
+/* ------------------------------------------------------------------------ */
+#ifdef HAVE_MPI_WIN_CREATE
+/*
+ * Create MPI Windows
+ */
+SMPI_VARINIT_GLOBAL_AND_SET(win_index, int, 0);
+SMPI_VARINIT_GLOBAL(winName, const char *);
+/* Use an attribute to remember the type of memory allocation (static,
+   malloc, or MPI_Alloc_mem) */
+SMPI_VARINIT_GLOBAL_AND_SET(mem_keyval, int, MPI_KEYVAL_INVALID);
+int MTestGetWin( MPI_Win *win, int mustBePassive )
+{
+    typedef char actbuf_type[1024];
+    SMPI_VARINIT_STATIC(actbuf, actbuf_type);
+    SMPI_VARINIT_STATIC(pasbuf, char *);
+    char        *buf;
+    int         n, rank, merr;
+    MPI_Info    info;
+
+    if (SMPI_VARGET_GLOBAL(mem_keyval) == MPI_KEYVAL_INVALID) {
+       /* Create the keyval */
+       merr = MPI_Win_create_keyval( MPI_WIN_NULL_COPY_FN, 
+                                     MPI_WIN_NULL_DELETE_FN, 
+                                     &SMPI_VARGET_GLOBAL(mem_keyval), 0 );
+       if (merr) MTestPrintError( merr );
+
+    }
+
+    switch (SMPI_VARGET_GLOBAL(win_index)) {
+    case 0:
+       /* Active target window */
+       merr = MPI_Win_create( SMPI_VARGET_STATIC(actbuf), 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD,
+                              win );
+       if (merr) MTestPrintError( merr );
+       SMPI_VARGET_GLOBAL(winName) = "active-window";
+       merr = MPI_Win_set_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), (void *)0 );
+       if (merr) MTestPrintError( merr );
+       break;
+    case 1:
+       /* Passive target window */
+       merr = MPI_Alloc_mem( 1024, MPI_INFO_NULL, &SMPI_VARGET_STATIC(pasbuf) );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Win_create( SMPI_VARGET_STATIC(pasbuf), 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD,
+                              win );
+       if (merr) MTestPrintError( merr );
+       SMPI_VARGET_GLOBAL(winName) = "passive-window";
+       merr = MPI_Win_set_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), (void *)2 );
+       if (merr) MTestPrintError( merr );
+       break;
+    case 2:
+       /* Active target; all windows different sizes */
+       merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+       if (merr) MTestPrintError( merr );
+       n = rank * 64;
+       if (n) 
+           buf = (char *)malloc( n );
+       else
+           buf = 0;
+       merr = MPI_Win_create( buf, n, 1, MPI_INFO_NULL, MPI_COMM_WORLD, 
+                              win );
+       if (merr) MTestPrintError( merr );
+       SMPI_VARGET_GLOBAL(winName) = "active-all-different-win";
+       merr = MPI_Win_set_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), (void *)1 );
+       if (merr) MTestPrintError( merr );
+       break;
+    case 3:
+       /* Active target, no locks set */
+       merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+       if (merr) MTestPrintError( merr );
+       n = rank * 64;
+       if (n) 
+           buf = (char *)malloc( n );
+       else
+           buf = 0;
+       merr = MPI_Info_create( &info );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Info_set( info, (char*)"nolocks", (char*)"true" );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Win_create( buf, n, 1, info, MPI_COMM_WORLD, win );
+       if (merr) MTestPrintError( merr );
+       merr = MPI_Info_free( &info );
+       if (merr) MTestPrintError( merr );
+       SMPI_VARGET_GLOBAL(winName) = "active-nolocks-all-different-win";
+       merr = MPI_Win_set_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), (void *)1 );
+       if (merr) MTestPrintError( merr );
+       break;
+    default:
+       SMPI_VARGET_GLOBAL(win_index) = -1;
+    }
+    SMPI_VARGET_GLOBAL(win_index)++;
+    return SMPI_VARGET_GLOBAL(win_index);
+}
+/* Return a pointer to the name associated with a window object */
+const char *MTestGetWinName( void )
+{
+    return SMPI_VARGET_GLOBAL(winName);
+}
+/* Free the storage associated with a window object */
+void MTestFreeWin( MPI_Win *win )
+{
+    void *addr;
+    int  flag, merr;
+
+    merr = MPI_Win_get_attr( *win, MPI_WIN_BASE, &addr, &flag );
+    if (merr) MTestPrintError( merr );
+    if (!flag) {
+       MTestError( "Could not get WIN_BASE from window" );
+    }
+    if (addr) {
+       void *val;
+       merr = MPI_Win_get_attr( *win, SMPI_VARGET_GLOBAL(mem_keyval), &val, &flag );
+       if (merr) MTestPrintError( merr );
+       if (flag) {
+           if (val == (void *)1) {
+               free( addr );
+           }
+           else if (val == (void *)2) {
+               merr = MPI_Free_mem( addr );
+               if (merr) MTestPrintError( merr );
+           }
+           /* if val == (void *)0, then static data that must not be freed */
+       }
+    }
+    merr = MPI_Win_free(win);
+    if (merr) MTestPrintError( merr );
+}
+static void MTestRMACleanup( void )
+{
+    if (SMPI_VARGET_GLOBAL(mem_keyval) != MPI_KEYVAL_INVALID) {
+       MPI_Win_free_keyval( &SMPI_VARGET_GLOBAL(mem_keyval) );
+    }
+}
+#else 
+static void MTestRMACleanup( void ) {}
+#endif
index 9b88c7b..a67ee17 100644 (file)
@@ -4,6 +4,7 @@ p Test dsend
 $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../../examples/msg/small_platform.xml -np 2 ./dsend -q --log=smpi_kernel.thres:warning
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
 > [Jupiter:1:(0) 0.000000] [dsend/INFO] rank 1: data exchanged
@@ -22,6 +23,7 @@ $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform $
 > == pivot=2 : pingpong [2] <--> [3]
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] About to send 1st message '99' to process [1] 
index a191088..1d3e74c 100644 (file)
@@ -8,6 +8,7 @@ $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform $
 > [rank 1] -> Jupiter
 > [rank 2] -> Fafard
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
@@ -31,6 +32,7 @@ $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform $
 > [rank 3] -> Ginette
 > [rank 4] -> Bourassa
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
@@ -64,6 +66,7 @@ $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform $
 > [rank 10] -> Tremblay
 > [rank 11] -> Jupiter
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
index 3d78abb..64d932a 100644 (file)
@@ -5,6 +5,7 @@ p Test compute
 $ ../../smpi_script/bin/smpirun -platform ${srcdir:=.}/../../examples/msg/small_platform_with_routers.xml -hostfile ${srcdir:=.}/hostfile -np 4 ./shared  --log=smpi_kernel.thres:warning
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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] After change, the value in the shared buffer is: 16053117601147974045
index c6e05db..ebeb8c6 100644 (file)
@@ -6,6 +6,7 @@ $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform $
 > Process 1 got -2 (-2?) and 8.000000 (8.0?), tab (should be all 0): 0 0 0 0 0 0 
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
 > [rank 0] -> Tremblay
index ddd03a0..e9a31a6 100644 (file)
@@ -4,6 +4,7 @@ p Test vector
 $ ../../smpi_script/bin/smpirun -map -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../../examples/msg/small_platform.xml -np 2 ./vector_test -q --log=smpi_kernel.thres:warning
 > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'surf/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'
 > [rank 0] -> Tremblay
index a09704d..b9a074c 100644 (file)
@@ -27,7 +27,7 @@ int main(int argc, char**argv)
   xbt_init(&argc,argv);
 
   XBT_INFO("Allocating a new heap");
-  unsigned long mask = ~((unsigned long)getpagesize() - 1);
+  unsigned long mask = ~((unsigned long)xbt_pagesize - 1);
   void *addr = (void*)(((unsigned long)sbrk(0) + BUFFSIZE) & mask);
   heapA = xbt_mheap_new(-1, addr);
   if (heapA == NULL) {
diff --git a/testsuite/mc/CMakeLists.txt b/testsuite/mc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..df0bc0b
--- /dev/null
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 2.6)
+
+if(HAVE_MC)
+  set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
+  add_executable(dwarf dwarf.c)
+  target_link_libraries(dwarf simgrid)
+
+  add_executable(dwarf-expression dwarf_expression.c)
+  target_link_libraries(dwarf-expression simgrid)
+endif()
+
+set(testsuite_src
+  ${testsuite_src}
+  ${CMAKE_CURRENT_SOURCE_DIR}/dwarf.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/dwarf_expression.c
+  PARENT_SCOPE
+  )
diff --git a/testsuite/mc/dwarf.c b/testsuite/mc/dwarf.c
new file mode 100644 (file)
index 0000000..50d8ad4
--- /dev/null
@@ -0,0 +1,148 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+
+#include <string.h>
+#include <assert.h>
+
+#include <xbt.h>
+#include <mc/mc.h>
+
+#include "../../src/include/mc/datatypes.h"
+#include "../../src/mc/mc_private.h"
+
+int test_some_array[4][5][6];
+struct some_struct { int first; int second[4][5]; } test_some_struct;
+
+static dw_type_t find_type_by_name(mc_object_info_t info, const char* name) {
+  xbt_dict_cursor_t cursor = NULL;
+  char *key;
+  dw_type_t type;
+  xbt_dict_foreach(info->types, cursor, key, type) {
+    if(!strcmp(name, type->name))
+      return type;
+  }
+
+  return NULL;
+}
+
+static dw_variable_t find_global_variable_by_name(mc_object_info_t info, const char* name) {
+  unsigned int cursor = 0;
+  dw_variable_t variable;
+  xbt_dynar_foreach(info->global_variables, cursor, variable){
+    if(!strcmp(name, variable->name))
+      return variable;
+  }
+
+  return NULL;
+}
+
+static dw_frame_t find_function_by_name(mc_object_info_t info, const char* name) {
+  xbt_dict_cursor_t cursor = 0;
+  dw_frame_t subprogram;
+  char* key;
+  xbt_dict_foreach(info->subprograms, cursor, key, subprogram){
+    if(!strcmp(name, subprogram->name))
+      return subprogram;
+  }
+
+  return NULL;
+}
+
+static dw_variable_t find_local_variable(dw_frame_t frame, const char* argument_name) {
+  unsigned int cursor = 0;
+  dw_variable_t variable;
+  xbt_dynar_foreach(frame->variables, cursor, variable){
+    if(!strcmp(argument_name, variable->name))
+      return variable;
+  }
+
+  return NULL;
+}
+
+static void test_local_variable(mc_object_info_t info, const char* function, const char* variable, void* address, unw_cursor_t* cursor) {
+  dw_frame_t subprogram = find_function_by_name(info, function);
+  assert(subprogram);
+  // TODO, Lookup frame by IP and test against name instead
+
+  dw_variable_t var = find_local_variable(subprogram, variable);
+  assert(var);
+
+  void* frame_base = mc_find_frame_base(subprogram, info, cursor);
+  xbt_assert((void*)mc_dwarf_resolve_locations(&var->locations, info, cursor, frame_base, NULL) == address,
+    "Bad resolution of local variable %s of %s", variable, function);
+
+}
+
+static dw_variable_t test_global_variable(mc_object_info_t info, const char* name, void* address, long byte_size) {
+  dw_variable_t variable = find_global_variable_by_name(info, name);
+  xbt_assert(variable, "Global variable %s was not found", name);
+  xbt_assert(!strcmp(variable->name, name), "Name mismatch for %s", name);
+  xbt_assert(variable->global, "Variable %s is not global", name);
+  xbt_assert(variable->address == address,
+      "Address mismatch for %s : %p expected but %p found", name, address, variable->address);
+
+  dw_type_t type = xbt_dict_get_or_null(mc_binary_info->types, variable->type_origin);
+  xbt_assert(type!=NULL, "Missing type for %s", name);
+  xbt_assert(type->byte_size = byte_size, "Byte size mismatch for %s", name);
+  return variable;
+}
+
+static dw_type_t find_member(mc_object_info_t info, const char* name, dw_type_t type) {
+  unsigned int cursor = 0;
+  dw_type_t member;
+  xbt_dynar_foreach(type->members, cursor, member){
+    if(!strcmp(name,member->name))
+      return member;
+  }
+  return NULL;
+}
+
+int some_local_variable = 0;
+
+typedef struct foo {int i;} s_foo;
+
+static void test_type_by_name(s_foo my_foo) {
+  assert(xbt_dict_get_or_null(mc_binary_info->full_types_by_name, "struct foo"));
+}
+
+int main(int argc, char** argv) {
+
+  // xbt_init(&argc, argv);
+  SIMIX_global_init(&argc, argv);
+  MC_memory_init();
+  MC_init();
+
+  dw_variable_t var;
+  dw_type_t type;
+
+  var = test_global_variable(mc_binary_info, "some_local_variable", &some_local_variable, sizeof(int));
+
+  var = test_global_variable(mc_binary_info, "test_some_array", &test_some_array, sizeof(test_some_array));
+  type = xbt_dict_get_or_null(mc_binary_info->types, var->type_origin);
+  xbt_assert(type->element_count == 6*5*4, "element_count mismatch in test_some_array : %i / %i", type->element_count, 6*5*4);
+
+  var = test_global_variable(mc_binary_info, "test_some_struct", &test_some_struct, sizeof(test_some_struct));
+  type = xbt_dict_get_or_null(mc_binary_info->types, var->type_origin);
+  assert(find_member(mc_binary_info, "first", type)->offset == 0);
+  assert(find_member(mc_binary_info, "second", type)->offset
+      == ((const char*)&test_some_struct.second) - (const char*)&test_some_struct);
+
+  unw_context_t context;
+  unw_cursor_t cursor;
+  unw_getcontext(&context);
+  unw_init_local(&cursor, &context);
+
+  test_local_variable(mc_binary_info, "main", "argc", &argc, &cursor);
+
+  s_foo my_foo;
+  test_type_by_name(my_foo);
+
+  _exit(0);
+}
diff --git a/testsuite/mc/dwarf_expression.c b/testsuite/mc/dwarf_expression.c
new file mode 100644 (file)
index 0000000..905f88a
--- /dev/null
@@ -0,0 +1,147 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+
+#include <string.h>
+#include <assert.h>
+#include <stdlib.h>
+
+#include "../src/mc/mc_private.h"
+
+static
+uintptr_t eval_binary_operation(mc_expression_state_t state, int op, uintptr_t a, uintptr_t b) {
+  state->stack_size = 0;
+
+  Dwarf_Op ops[15];
+  ops[0].atom = DW_OP_const8u;
+  ops[0].number = a;
+  ops[1].atom = DW_OP_const8u;
+  ops[1].number = b;
+  ops[2].atom = op;
+
+  assert(mc_dwarf_execute_expression(3, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size==1);
+  return state->stack[state->stack_size - 1];
+}
+
+static
+void basic_test(mc_expression_state_t state) {
+  Dwarf_Op ops[60];
+
+  uintptr_t a = rand();
+  uintptr_t b = rand();
+
+  ops[0].atom = DW_OP_drop;
+  assert(mc_dwarf_execute_expression(1, ops, state) == MC_EXPRESSION_E_STACK_UNDERFLOW);
+
+  ops[0].atom = DW_OP_lit21;
+  assert(mc_dwarf_execute_expression(1, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size==1);
+  assert(state->stack[state->stack_size-1]==21);
+
+  ops[0].atom = DW_OP_const8u;
+  ops[0].number = a;
+  assert(mc_dwarf_execute_expression(1, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size==2);
+  assert(state->stack[state->stack_size-1] == a);
+
+  ops[0].atom = DW_OP_drop;
+  ops[1].atom = DW_OP_drop;
+  assert(mc_dwarf_execute_expression(2, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size==0);
+
+  ops[0].atom = DW_OP_lit21;
+  ops[1].atom = DW_OP_plus_uconst;
+  ops[1].number = a;
+  assert(mc_dwarf_execute_expression(2, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size==1);
+  assert(state->stack[state->stack_size-1]== a + 21);
+
+  state->stack_size = 0;
+  ops[0].atom = DW_OP_const8u;
+  ops[0].number = a;
+  ops[1].atom = DW_OP_dup;
+  ops[2].atom = DW_OP_plus;
+  assert(mc_dwarf_execute_expression(3, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size==1);
+  assert(state->stack[state->stack_size-1]== a + a);
+
+  state->stack_size = 0;
+  ops[0].atom = DW_OP_const8u;
+  ops[0].number = a;
+  ops[1].atom = DW_OP_const8u;
+  ops[1].number = b;
+  ops[2].atom = DW_OP_over;
+  assert(mc_dwarf_execute_expression(3, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size==3);
+  assert(state->stack[state->stack_size-1]== a);
+  assert(state->stack[state->stack_size-2]== b);
+  assert(state->stack[state->stack_size-3]== a);
+
+  state->stack_size = 0;
+  ops[0].atom = DW_OP_const8u;
+  ops[0].number = a;
+  ops[1].atom = DW_OP_const8u;
+  ops[1].number = b;
+  ops[2].atom = DW_OP_swap;
+  assert(mc_dwarf_execute_expression(3, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size=2);
+  assert(state->stack[state->stack_size-1]== a);
+  assert(state->stack[state->stack_size-2]== b);
+}
+
+static
+void test_deref(mc_expression_state_t state) {
+  uintptr_t foo = 42;
+
+  Dwarf_Op ops[60];
+  ops[0].atom = DW_OP_const8u;
+  ops[0].number = (uintptr_t) &foo;
+  ops[1].atom = DW_OP_deref;
+  state->stack_size = 0;
+
+  assert(mc_dwarf_execute_expression(2, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size==1);
+  assert(state->stack[state->stack_size-1] == foo);
+}
+
+int main(int argc, char** argv) {
+  s_mc_expression_state_t state;
+  memset(&state, 0, sizeof(s_mc_expression_state_t));
+
+  basic_test(&state);
+
+  for(int i=0; i!=100; ++i) {
+    uintptr_t a = rand();
+    uintptr_t b = rand();
+    assert(eval_binary_operation(&state, DW_OP_plus, a, b) == (a + b));
+  }
+
+  for(int i=0; i!=100; ++i) {
+    uintptr_t a = rand();
+    uintptr_t b = rand();
+    assert(eval_binary_operation(&state, DW_OP_or, a, b) == (a | b));
+  }
+
+  for(int i=0; i!=100; ++i) {
+    uintptr_t a = rand();
+    uintptr_t b = rand();
+    assert(eval_binary_operation(&state, DW_OP_and, a, b) == (a & b));
+  }
+
+  for(int i=0; i!=100; ++i) {
+    uintptr_t a = rand();
+    uintptr_t b = rand();
+    assert(eval_binary_operation(&state, DW_OP_xor, a, b) == (a ^ b));
+  }
+
+  test_deref(&state);
+
+  return 0;
+}
index 3d88670..060ed25 100644 (file)
@@ -173,7 +173,7 @@ void test1(method_t method)
     max_deviation =
         MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
 
-    if (max_deviation > MAXMIN_PRECISION) {
+    if (max_deviation > 0.00001) { // Legacy value used in lagrange.c
       XBT_WARN("Max Deviation from optimal solution : %g", max_deviation);
       XBT_WARN("Found x = %1.20f", x);
       XBT_WARN("Deviation from optimal solution (R_1 = %g): %1.20f", x,
@@ -208,7 +208,7 @@ void test1(method_t method)
     max_deviation =
         MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
 
-    if (max_deviation > MAXMIN_PRECISION) {
+    if (max_deviation > 0.00001) { // Legacy value used in lagrange.c
       XBT_WARN("Max Deviation from optimal solution : %g", max_deviation);
       XBT_WARN("Found x = %1.20f", x);
       XBT_WARN("Deviation from optimal solution (R_1 = %g): %1.20f", x,
index ae1ccd2..129ab69 100644 (file)
@@ -3,7 +3,9 @@ cmake_minimum_required(VERSION 2.6)
 set(bin_files
   ${bin_files}
   ${CMAKE_CURRENT_SOURCE_DIR}/fix-paje-trace.sh
+  ${CMAKE_CURRENT_SOURCE_DIR}/generate.sh
   ${CMAKE_CURRENT_SOURCE_DIR}/indent
+  ${CMAKE_CURRENT_SOURCE_DIR}/normalize-pointers.py
   ${CMAKE_CURRENT_SOURCE_DIR}/platf_route_rulebased2full.py
   ${CMAKE_CURRENT_SOURCE_DIR}/sg_unit_extractor.pl
   ${CMAKE_CURRENT_SOURCE_DIR}/sg_xml_unit_converter.py
index 8baa979..1082e69 100644 (file)
@@ -33,7 +33,6 @@
 + src/simix/simix_network\.tla
 
 + src/smpi/BUGS
-+ src/smpi/colls/allreduce-rab-reduce-scatter\.c
 + src/smpi/colls/alltoall-bruck\.c
 + src/smpi/fixsrc\.pl
 + src/smpi/myprintloc\.cocci
@@ -46,7 +45,6 @@
 + tools/check_dist_archive
 + tools/check_dist_archive\.exclude
 + tools/generate-multi-jar\.py
-+ tools/normalize-pointers\.py
 + tools/update_copyright_header
 
 + tools/spell/.*
diff --git a/tools/generate.sh b/tools/generate.sh
new file mode 100755 (executable)
index 0000000..5f39fdd
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+# Generate files from a given dwarf.h
+
+cat "$1" | grep DW_TAG_ | sed 's/.*\(DW_TAG_[^ ]*\) = \(0x[0-9a-f]*\).*/case \2: return "\1";/' > src/mc/mc_dwarf_tagnames.h
+cat "$1" | grep DW_AT_ | sed 's/.*\(DW_AT_[^ ]*\) = \(0x[0-9a-f]*\).*/case \2: return "\1";/' >  src/mc/mc_dwarf_attrnames.h
index bf02a75..5298b49 100644 (file)
@@ -28,9 +28,11 @@ an error showing the diff (see OUTPUT below).
 Command line arguments
 ----------------------
 Tesh accepts several command line arguments:
-  --cd some/directory: ask tesh to switch the working directory before
-                       launching the tests
-  --setenv var=value: set a specific environment variable
+  --cd some/directory : ask tesh to switch the working directory before
+                        launching the tests
+  --setenv var=value  : set a specific environment variable
+  --cfg arg           : add parameter --cfg=arg to each command line
+  --enable-coverage   : ignore output lines starting with "profiling:"
 
 IO orders
 ---------
index 359d2a5..1029d89 100644 (file)
@@ -43,7 +43,7 @@ $ cd temp_testdir_background
 < }
 $ mkfile delayed_cat.c
 
-$ gcc -Wall -o delayed_cat delayed_cat.c
+$ cc -Wall -o delayed_cat delayed_cat.c
 
 & ./delayed_cat
 > TOTO
index 3efe2c3..ff9c3d5 100644 (file)
@@ -13,7 +13,7 @@ $ cd temp_testdir-bg-set-signal
 < }
 $ mkfile segfault.c
 
-$ gcc -o segfault segfault.c
+$ cc -o segfault segfault.c
 ! expect signal SIGSEGV
 & ./segfault
 $ sleep 1
index ea794f1..f9d21a2 100644 (file)
@@ -12,7 +12,7 @@ $ cd temp_testdir-catch-return
 < }
 $ mkfile return1.c
 
-$ gcc -o return1 return1.c
+$ cc -o return1 return1.c
 
 ! expect return 41
 < $ ./return1
index 5c7b45f..64d37e8 100644 (file)
@@ -13,7 +13,7 @@ $ cd temp_testdir-catch-signal
 < }
 $ mkfile segfault.c
 
-$ gcc -o segfault segfault.c
+$ cc -o segfault segfault.c
 
 ! expect return 15
 < $ ./segfault
index ff0dd17..679234d 100644 (file)
@@ -12,7 +12,7 @@ $ cd temp_testdir-set-return
 < }
 $ mkfile return1.c
 
-$ gcc -o return1 return1.c
+$ cc -o return1 return1.c
 
 ! expect return 1
 $ ./return1
index 43f105e..314b7f0 100644 (file)
@@ -13,7 +13,7 @@ $ cd temp_testdir-set-signal
 < }
 $ mkfile segfault.c
 
-$ gcc -o segfault segfault.c
+$ cc -o segfault segfault.c
 ! expect signal SIGSEGV
 $ ./segfault
 $ cd ..
index 72d5566..632fd8b 100644 (file)
@@ -21,7 +21,7 @@ $ cd temp_testdir-setenv
 < }
 $ mkfile getenv.c
 
-$ gcc -o getenv getenv.c -g
+$ cc -o getenv getenv.c -g
 
 ! setenv tesh_test_toto=blah
 $ ./getenv
index 817110f..769c0c2 100644 (file)
@@ -8,9 +8,11 @@ tesh \- testing shell
 .SH DESCRIPTION
 This is the TESH tool. It constitutes a testing shell, ie a sort of shell specialized to run tests. The list of actions to take is parsed from files files called testsuite.
 .SH OPTIONS
-  --cd some/directory: ask tesh to switch the working directory before
-                       launching the tests
-  --setenv var=value: set a specific environment variable
+  --cd some/directory : ask tesh to switch the working directory before
+                        launching the tests
+  --setenv var=value  : set a specific environment variable
+  --cfg arg           : add parameter --cfg=arg to each command line
+  --enable-coverage   : ignore output lines starting with "profiling:"
 .SH TESH FILE SYNTAX
 Here is the syntax of these files:
 
index e05fd5e..e8aac13 100644 (file)
@@ -20,7 +20,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(tesh, "TEst SHell utility");
 int timeout_value = 5;          /* child timeout value */
 int sort_len = 19;              /* length of the prefix to sort */
 char *option;
-int coverage = 0;        /* whether the code coverage is enable */
+int coverage = 0;        /* whether the code coverage is enabled */
 
 rctx_t rctx;
 const char *testsuite_name;