From: Martin Quinson Date: Thu, 20 Oct 2011 08:27:04 +0000 (+0200) Subject: Merge stuff again. Damn, I should pull before changing stuff X-Git-Tag: exp_20120216~558 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0213e3927d6ac21f3089d8a2d60f3603c8cbac43?hp=f783ed4680c6862a1b7543237e89d1221334bae0 Merge stuff again. Damn, I should pull before changing stuff --- diff --git a/CMakeLists.txt b/CMakeLists.txt index db45e7ee91..f136823f55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 2.6) if(WIN32) SET(CMAKE_RC_COMPILER "windres") endif(WIN32) -project(simgrid CXX C) +project(SimGrid CXX C) + set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE) set(CMAKE_CXX_FLAGS "" CACHE TYPE INTERNAL FORCE) set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE) @@ -13,10 +14,11 @@ set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE) # 3.5.9{1,2} -> beta{1,2} # 3.5.9{3,4,5} -> rc{1,2,3} # 3.6.{0,1,2} -> release 3.6, 3.6.1, 3.6.2 +# 3.7.0 set(SIMGRID_VERSION_MAJOR "3") -set(SIMGRID_VERSION_MINOR "6") -set(SIMGRID_VERSION_PATCH "2") +set(SIMGRID_VERSION_MINOR "7") +set(SIMGRID_VERSION_PATCH "0") if(${SIMGRID_VERSION_PATCH} EQUAL "0") set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}") diff --git a/NEWS b/NEWS index d24f363fba..275c32ffc8 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ - - + _____ _ __ ___(_) ___ _ __ |___ /|___ | +\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ / / + \ V / __/ | \__ \ | (_) | | | | ___) | / / + \_/ \___|_| |___/_|\___/|_| |_| |____(_)_/ + + (still to be done) _ _____ __ ____ __ _____ _ __ ___(_) ___ _ __ |___ / / /_ |___ \ \ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \| '_ \ __) | diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index 06b05c27da..ebbcaf4233 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -137,6 +137,7 @@ ADD_TEST(msg-masterslave-forwarder-thread ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OP ADD_TEST(msg-masterslave-failure-thread ${CMAKE_BINARY_DIR}/bin/tesh ${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_failure.tesh) ADD_TEST(msg-masterslave-bypass-thread ${CMAKE_BINARY_DIR}/bin/tesh ${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_bypass.tesh) ADD_TEST(msg-masterslave-mailbox-thread ${CMAKE_BINARY_DIR}/bin/tesh ${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_mailbox.tesh) +ADD_TEST(msg-masterslave-kill-thread ${CMAKE_BINARY_DIR}/bin/tesh ${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_kill.tesh) if(HAVE_UCONTEXT_H) ADD_TEST(msg-sendrecv-CLM03-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/sendrecv/sendrecv_CLM03.tesh) @@ -148,6 +149,7 @@ if(HAVE_UCONTEXT_H) ADD_TEST(msg-masterslave-failure-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_failure.tesh) ADD_TEST(msg-masterslave-bypass-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_bypass.tesh) ADD_TEST(msg-masterslave-mailbox-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_mailbox.tesh) + ADD_TEST(msg-masterslave-kill-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_kill.tesh) endif(HAVE_UCONTEXT_H) if(HAVE_RAWCTX) @@ -160,6 +162,7 @@ if(HAVE_RAWCTX) ADD_TEST(msg-masterslave-failure-raw ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_failure.tesh) ADD_TEST(msg-masterslave-bypass-raw ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_bypass.tesh) ADD_TEST(msg-masterslave-mailbox-raw ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_mailbox.tesh) + ADD_TEST(msg-masterslave-kill-raw ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_kill.tesh) endif(HAVE_RAWCTX) if (enable_pcre) @@ -378,10 +381,12 @@ ENDIF(HAVE_TRACING) # Lua examples if(HAVE_LUA) +ADD_TEST(lua-duplicated-globals ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd ${CMAKE_HOME_DIRECTORY}/examples/lua/state_cloner duplicated_globals.tesh) ADD_TEST(lua-masterslave ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd ${CMAKE_HOME_DIRECTORY}/examples/lua/masterslave master_slave.tesh) ADD_TEST(lua-mult-matrix ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd ${CMAKE_HOME_DIRECTORY}/examples/lua/multi_matrix mult_matrix.tesh) ADD_TEST(lua-masterslave-bypass ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd ${CMAKE_HOME_DIRECTORY}/examples/lua/console master_slave_bypass.tesh) ADD_TEST(lua-msg-masterslave-console ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd ${CMAKE_BINARY_DIR}/examples/msg/masterslave --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave ${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave/masterslave_console.tesh) +set_tests_properties(lua-duplicated-globals PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/examples/lua/?.so") set_tests_properties(lua-masterslave PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/examples/lua/?.so") set_tests_properties(lua-mult-matrix PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/examples/lua/?.so") set_tests_properties(lua-masterslave-bypass PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/examples/lua/?.so") diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index 57c7461e45..1f422e1332 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -294,14 +294,14 @@ IF(CMAKE_CROSSCOMPILING) ENDIF(WIN32) ELSE(CMAKE_CROSSCOMPILING) try_run(RUN_mcsc_VAR COMPILE_mcsc_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c COMPILE_DEFINITIONS "${mcsc_flags}" OUTPUT_VARIABLE var_compil ) - if(EXISTS "${simgrid_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR) - file(READ "${simgrid_BINARY_DIR}/conftestval" mcsc) + if(EXISTS "${PROJECT_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR) + file(READ "${PROJECT_BINARY_DIR}/conftestval" mcsc) STRING(REPLACE "\n" "" mcsc "${mcsc}") if(mcsc) set(mcsc "yes") @@ -309,9 +309,9 @@ ELSE(CMAKE_CROSSCOMPILING) else(mcsc) set(mcsc "no") endif(mcsc) - else(EXISTS "${simgrid_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR) + else(EXISTS "${PROJECT_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR) set(mcsc "no") - endif(EXISTS "${simgrid_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR) + endif(EXISTS "${PROJECT_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR) ENDIF(CMAKE_CROSSCOMPILING) if(mcsc MATCHES "no" AND pthread) @@ -372,7 +372,7 @@ endif(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/) IF(NOT CMAKE_CROSSCOMPILING) # Check architecture signature begin try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_ARCH.c RUN_OUTPUT_VARIABLE var1 ) @@ -483,7 +483,7 @@ endif(GRAS_THISARCH MATCHES "none") # Check architecture signature end try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_CHECK_STRUCT_COMPACTION.c RUN_OUTPUT_VARIABLE var2 ) @@ -494,7 +494,7 @@ endforeach(var_tmp ${var2}) # Check for [SIZEOF_MAX] try_run(RUN_SM_VAR COMPILE_SM_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_max_size.c RUN_OUTPUT_VARIABLE var3 ) @@ -520,11 +520,11 @@ if(HAVE_MAKECONTEXT OR WIN32) endif(WIN32 AND __GNUC__) try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stacksetup.c COMPILE_DEFINITIONS "${makecontext_CPPFLAGS} ${makecontext_CPPFLAGS_2}" ) - file(READ ${simgrid_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE) + file(READ ${PROJECT_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE) string(REPLACE "\n" "" MAKECONTEXT_ADDR_SIZE "${MAKECONTEXT_ADDR_SIZE}") string(REGEX MATCH ;^.*,;MAKECONTEXT_ADDR "${MAKECONTEXT_ADDR_SIZE}") string(REGEX MATCH ;,.*$; MAKECONTEXT_SIZE "${MAKECONTEXT_ADDR_SIZE}") @@ -540,10 +540,10 @@ endif(HAVE_MAKECONTEXT OR WIN32) ### check for stackgrowth if (NOT CMAKE_CROSSCOMPILING) try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stackgrowth.c ) -file(READ "${simgrid_BINARY_DIR}/conftestval" stack) +file(READ "${PROJECT_BINARY_DIR}/conftestval" stack) if(stack MATCHES "down") set(PTH_STACKGROWTH "-1") endif(stack MATCHES "down") @@ -565,7 +565,7 @@ endif(NOT CMAKE_CROSSCOMPILING) #AC_PRINTF_NULL try_run(RUN_PRINTF_NULL_VAR COMPILE_PRINTF_NULL_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_printf_null.c ) @@ -618,7 +618,7 @@ foreach(fct ${diff_va}) }" ) try_compile(COMPILE_VA_NULL_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c ) if(COMPILE_VA_NULL_VAR) @@ -676,7 +676,7 @@ endforeach(fct ${diff_va}) #-------------------------------------------------------------------------------------------------- ### check for getline try_compile(COMPILE_RESULT_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_getline.c ) @@ -700,7 +700,7 @@ if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32) #set(PREFER_PORTABLE_SNPRINTF 1) else(CMAKE_CROSSCOMPILING) try_run(RUN_SNPRINTF_FUNC_VAR COMPILE_SNPRINTF_FUNC_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_snprintf.c ) endif(CMAKE_CROSSCOMPILING) @@ -710,7 +710,7 @@ if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32) set(PREFER_PORTABLE_VSNPRINTF 1) else(CMAKE_CROSSCOMPILING) try_run(RUN_VSNPRINTF_FUNC_VAR COMPILE_VSNPRINTF_FUNC_VAR - ${simgrid_BINARY_DIR} + ${PROJECT_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_vsnprintf.c ) endif(CMAKE_CROSSCOMPILING) diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index c43b79afd2..95636b9d95 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -322,6 +322,8 @@ set(LUA_SRC src/bindings/lua/simgrid_lua.c src/bindings/lua/lua_stub_generator.c src/bindings/lua/lua_console.c + src/bindings/lua/lua_utils.c + src/bindings/lua/lua_state_cloner.c ) set(TRACING_SRC diff --git a/buildtools/Cmake/Distrib.cmake b/buildtools/Cmake/Distrib.cmake index f32234915a..3f0730849f 100644 --- a/buildtools/Cmake/Distrib.cmake +++ b/buildtools/Cmake/Distrib.cmake @@ -170,11 +170,11 @@ endif(HAVE_LUA) add_custom_target(dist-dir COMMENT "Generating the distribution directory" - COMMAND test -e simgrid-${release_version}/ && chmod -R a+w simgrid-${release_version}/ || true - COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/ - COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version} - COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/doc/html/ - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_HOME_DIRECTORY}/doc/html/ simgrid-${release_version}/doc/html/ + COMMAND test -e ${PROJECT_NAME}-${release_version}/ && chmod -R a+w ${PROJECT_NAME}-${release_version}/ || true + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version} + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/doc/html/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_HOME_DIRECTORY}/doc/html/ ${PROJECT_NAME}-${release_version}/doc/html/ ) add_dependencies(dist-dir simgrid_documentation) add_dependencies(dist-dir maintainer_files) @@ -192,19 +192,19 @@ foreach(file ${source_to_pack}) set(dirs_in_tarball "${dirs_in_tarball};${file_location};") add_custom_command( TARGET dist-dir - COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/${file_location}/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/${file_location}/ ) endif(NOT OPERATION) # Actually copy the file add_custom_command( TARGET dist-dir - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} simgrid-${release_version}/${file_location}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${PROJECT_NAME}-${release_version}/${file_location}/ ) add_custom_command( TARGET dist-dir - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Makefile.default simgrid-${release_version}/Makefile + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Makefile.default ${PROJECT_NAME}-${release_version}/Makefile ) endforeach(file ${source_to_pack}) @@ -213,14 +213,14 @@ endforeach(file ${source_to_pack}) ###################################### add_custom_target(dist - DEPENDS ${CMAKE_BINARY_DIR}/simgrid-${release_version}.tar.gz + DEPENDS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz ) add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/simgrid-${release_version}.tar.gz + OUTPUT ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz COMMENT "Compressing the archive from the distribution directory" - COMMAND ${CMAKE_COMMAND} -E tar cf simgrid-${release_version}.tar simgrid-${release_version}/ - COMMAND gzip -9v simgrid-${release_version}.tar - COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/ + COMMAND ${CMAKE_COMMAND} -E tar cf ${PROJECT_NAME}-${release_version}.tar ${PROJECT_NAME}-${release_version}/ + COMMAND gzip -9v ${PROJECT_NAME}-${release_version}.tar + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/ ) add_dependencies(dist dist-dir) @@ -231,44 +231,44 @@ add_dependencies(dist dist-dir) # Allow to test the "make dist" add_custom_target(distcheck COMMAND ${CMAKE_COMMAND} -E echo "XXX remove old copy" - COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}.cpy COMMAND ${CMAKE_COMMAND} -E echo "XXX copy again the source tree" - COMMAND ${CMAKE_COMMAND} -E copy_directory simgrid-${release_version}/ simgrid-${release_version}.cpy + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_NAME}-${release_version}/ ${PROJECT_NAME}-${release_version}.cpy COMMAND ${CMAKE_COMMAND} -E echo "XXX create build and install subtrees" - COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_build - COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_inst + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/_build + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/_inst # This stupid cmake creates a directory in source, killing the purpose of the chmod # (tricking around) COMMAND ${CMAKE_COMMAND} -E echo "XXX change the modes of directories" - COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/CMakeFiles - COMMAND chmod -R a-w simgrid-${release_version}/ # FIXME: we should pass without commenting that line - COMMAND chmod -R a+w simgrid-${release_version}/_build - COMMAND chmod -R a+w simgrid-${release_version}/_inst - COMMAND chmod -R a+w simgrid-${release_version}/CMakeFiles + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/CMakeFiles + COMMAND chmod -R a-w ${PROJECT_NAME}-${release_version}/ # FIXME: we should pass without commenting that line + COMMAND chmod -R a+w ${PROJECT_NAME}-${release_version}/_build + COMMAND chmod -R a+w ${PROJECT_NAME}-${release_version}/_inst + COMMAND chmod -R a+w ${PROJECT_NAME}-${release_version}/CMakeFiles COMMAND ${CMAKE_COMMAND} -E echo "XXX Configure" - COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ${CMAKE_COMMAND} build .. -DCMAKE_INSTALL_PREFIX=../_inst -Wno-dev -Denable_doc=OFF -# COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make dist-dir + COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_NAME}-${release_version}/_build ${CMAKE_COMMAND} build .. -DCMAKE_INSTALL_PREFIX=../_inst -Wno-dev -Denable_doc=OFF +# COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_NAME}-${release_version}/_build make dist-dir COMMAND ${CMAKE_COMMAND} -E echo "XXX Build" - COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make VERBOSE=1 + COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_NAME}-${release_version}/_build make VERBOSE=1 # This fails, unfortunately, because GRAS is broken for now - COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ctest -j5 --output-on-failure + COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_NAME}-${release_version}/_build ctest -j5 --output-on-failure COMMAND ${CMAKE_COMMAND} -E echo "XXX Check that cleaning works" - COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make clean + COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_NAME}-${release_version}/_build make clean COMMAND ${CMAKE_COMMAND} -E echo "XXX Display what is remaining after make clean" - COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ls -lR + COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_NAME}-${release_version}/_build ls -lR COMMAND ${CMAKE_COMMAND} -E echo "XXX Remove _build and _inst directories" - COMMAND chmod a+w simgrid-${release_version}/ - COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_build - COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_inst + COMMAND chmod a+w ${PROJECT_NAME}-${release_version}/ + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/_build + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/_inst COMMAND ${CMAKE_COMMAND} -E echo "XXX The output of the diff follows" - COMMAND diff -ruN simgrid-${release_version}.cpy simgrid-${release_version} + COMMAND diff -ruN ${PROJECT_NAME}-${release_version}.cpy ${PROJECT_NAME}-${release_version} COMMAND ${CMAKE_COMMAND} -E echo "XXX end of the diff, random cleanups now" - COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy - COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}.cpy + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version} ) add_dependencies(distcheck dist-dir) diff --git a/buildtools/Cmake/PrintArgs.cmake b/buildtools/Cmake/PrintArgs.cmake index 2ed1608ef6..5b9912fee5 100644 --- a/buildtools/Cmake/PrintArgs.cmake +++ b/buildtools/Cmake/PrintArgs.cmake @@ -111,9 +111,9 @@ message(" Smpi dependencies : ${SMPI_DEP}") message("") message(" INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") -exec_program("${CMAKE_COMMAND} -E make_directory ${simgrid_BINARY_DIR}/Testing/Notes/" OUTPUT_VARIABLE OKIDOKI) -file(WRITE ${simgrid_BINARY_DIR}/Testing/Notes/Build "SVN version : ${SVN_VERSION}\n") -file(APPEND ${simgrid_BINARY_DIR}/Testing/Notes/Build "Release : simgrid-${release_version}\n") -file(APPEND ${simgrid_BINARY_DIR}/Testing/Notes/Build "Pipol user : $ENV{PIPOL_USER}\n") -file(APPEND ${simgrid_BINARY_DIR}/Testing/Notes/Build "Pipol image : $ENV{PIPOL_IMAGE}\n") +exec_program("${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/Testing/Notes/" OUTPUT_VARIABLE OKIDOKI) +file(WRITE ${PROJECT_BINARY_DIR}/Testing/Notes/Build "SVN version : ${SVN_VERSION}\n") +file(APPEND ${PROJECT_BINARY_DIR}/Testing/Notes/Build "Release : simgrid-${release_version}\n") +file(APPEND ${PROJECT_BINARY_DIR}/Testing/Notes/Build "Pipol user : $ENV{PIPOL_USER}\n") +file(APPEND ${PROJECT_BINARY_DIR}/Testing/Notes/Build "Pipol image : $ENV{PIPOL_IMAGE}\n") diff --git a/doc/index.doc b/doc/index.doc index c12eb383a0..9a2d9b8e85 100644 --- a/doc/index.doc +++ b/doc/index.doc @@ -17,10 +17,10 @@ Grids. \htmlonly \endhtmlonly - The official webpage is simgrid.gforge.inria.fr. - - The Frequently Asked Questions are here. + - The Frequently Asked Questions are here. - The development webpage is gforge.inria.fr/projects/simgrid. - The user mailing list is - - The SimGrid software package can be downloaded from here. + - The SimGrid software package can be downloaded from here.

@@ -113,10 +113,10 @@ See the \ref XBT_API section for more details. \htmlonly \endhtmlonly
The SimGrid software package can be downloaded from -here.
+here.
If you are interested in the history of SimGrid and in current and planned development, -you can find out more here. +you can find out more here. Any question, remark or suggestion are welcome on the SimGrid users diff --git a/examples/lua/SimSplay/TODO b/examples/lua/SimSplay/TODO index 42dcb7f73b..4e9ad79e4c 100644 --- a/examples/lua/SimSplay/TODO +++ b/examples/lua/SimSplay/TODO @@ -11,7 +11,7 @@ Ideally, its usage would be: simsplay platform_file.{xml|lua} deployment_file.{xml|lua} splay_script.lua [simgrid_options...] I'm not sure about the format of the platform and deployment files yet. -We could accept both XML and Lua files, since their is a great Lua API to +We could accept both XML and Lua files, since there is a great Lua API to describe platforms, or only the XML ones. The simsplay executable (which is compiled C) would initialize SimGrid, create diff --git a/examples/lua/SimSplay/splay_school.lua b/examples/lua/SimSplay/splay_school.lua index 51cd58c40a..358c36f5d9 100644 --- a/examples/lua/SimSplay/splay_school.lua +++ b/examples/lua/SimSplay/splay_school.lua @@ -2,10 +2,10 @@ require("sim_splay") function SPLAYschool() log:print("My ip is: "..job.me.ip()) - for i = 1000,10000 do + for i = 1,200 do log:print(i) end - +--[[ events.sleep(5) if job.me.ip() == job.nodes[1].ip then @@ -13,6 +13,7 @@ function SPLAYschool() end events.sleep(5) os.exit() + --]] end function call_me(from) @@ -21,4 +22,5 @@ end events.thread("SPLAYschool") start.loop() +log:print("Simulation finished") diff --git a/examples/lua/masterslave/slave.lua b/examples/lua/masterslave/slave.lua index 9c257c479b..9ecddc6a3e 100644 --- a/examples/lua/masterslave/slave.lua +++ b/examples/lua/masterslave/slave.lua @@ -6,6 +6,7 @@ function Slave(...) local my_mailbox="slave "..arg[1] simgrid.info("Hello from lua, I'm a poor slave with mbox: "..my_mailbox) + while true do local tk = simgrid.Task.recv(my_mailbox); diff --git a/examples/lua/state_cloner/deployment_duplicated_globals.xml b/examples/lua/state_cloner/deployment_duplicated_globals.xml new file mode 100644 index 0000000000..aca62021da --- /dev/null +++ b/examples/lua/state_cloner/deployment_duplicated_globals.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/examples/lua/state_cloner/duplicated_globals.lua b/examples/lua/state_cloner/duplicated_globals.lua new file mode 100644 index 0000000000..516cc77200 --- /dev/null +++ b/examples/lua/state_cloner/duplicated_globals.lua @@ -0,0 +1,44 @@ +-- This code creates 3 simgrid processes and verifies that the global values +-- in each Lua world are correctly cloned from maestro and become different + +require("simgrid") + +global_string = "A global string set by maestro" + +-- Assigns to the global string the first argument and prints it +function set_global_string(...) + + global_string = arg[1] + simgrid.info("Changing the global string") + print_global() +end + +-- Replaces the function please_dont_change_me() by set_global_string() +-- and calls it +function replace(...) + + simgrid.info("Overwriting function please_dont_replace_me()") + please_dont_replace_me = set_global_string + please_dont_replace_me(...) +end + +-- Shows a hello message and prints the global string +function please_dont_replace_me(...) + + simgrid.info("Hello from please_dont_replace_me(). I'm lucky, I still exist in this state.") + print_global() +end + +-- Prints the value of global_string +function print_global() + + simgrid.info("Global string is '"..global_string.."'") +end + +print_global() + +simgrid.platform("../../msg/small_platform.xml") +simgrid.application("deployment_duplicated_globals.xml") +simgrid.run() +simgrid.clean() + diff --git a/examples/lua/state_cloner/duplicated_globals.tesh b/examples/lua/state_cloner/duplicated_globals.tesh new file mode 100644 index 0000000000..c8029d71d9 --- /dev/null +++ b/examples/lua/state_cloner/duplicated_globals.tesh @@ -0,0 +1,11 @@ +# Checks that global values are correctly duplicated in Lua processes + +$ lua duplicated_globals.lua +> [0.000000] [lua/INFO] Global string is 'A global string set by maestro' +> [Tremblay:set_global_string:(1) 0.000000] [lua/INFO] Changing the global string +> [Tremblay:set_global_string:(1) 0.000000] [lua/INFO] Global string is 'Calling set_global_string() from Tremblay' +> [Bourassa:replace:(2) 0.000000] [lua/INFO] Overwriting function please_dont_replace_me() +> [Bourassa:replace:(2) 0.000000] [lua/INFO] Changing the global string +> [Bourassa:replace:(2) 0.000000] [lua/INFO] Global string is 'Calling replace() from Bourassa' +> [Jupiter:please_dont_replace_me:(3) 0.000000] [lua/INFO] Hello from please_dont_replace_me(). I'm lucky, I still exist in this state. +> [Jupiter:please_dont_replace_me:(3) 0.000000] [lua/INFO] Global string is 'A global string set by maestro' diff --git a/examples/msg/actions/actions.c b/examples/msg/actions/actions.c index f3b9299968..ca75da4b3e 100644 --- a/examples/msg/actions/actions.c +++ b/examples/msg/actions/actions.c @@ -7,7 +7,6 @@ #include #include #include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */ -#include "msg/mailbox.h" /* we play funny tricks with mailboxes and rdv points */ #include "simix/simix.h" /* semaphores for the barrier */ #include "xbt.h" /* calloc, printf */ #include "instr/instr_private.h" @@ -107,8 +106,8 @@ static void action_Isend(const char *const *action) sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()),action[2]); - m_task_t task = MSG_task_create(to,0,parse_double(size),NULL); - msg_comm_t comm = MSG_task_isend_with_matching(task, to, /*matching madness*/NULL,task); + msg_comm_t comm = + MSG_task_isend( MSG_task_create(to,0,parse_double(size),NULL), to); xbt_dynar_push(globals->isends,&comm); XBT_DEBUG("Isend on %s", MSG_process_get_name(MSG_process_self())); @@ -117,12 +116,6 @@ static void action_Isend(const char *const *action) asynchronous_cleanup(); } -static int task_matching(void*ignored,void*sent_task) { - m_task_t t = (m_task_t)sent_task; - if (t!=NULL && MSG_task_get_data_size(t)<65536) - return 1; /* that's supposed to be already arrived */ - return 0; /* rendez-vous mode: it's not there yet */ -} static void action_recv(const char *const *action) { @@ -137,22 +130,6 @@ static void action_recv(const char *const *action) if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose)) name = xbt_str_join_array(action, " "); - /* The next chunk is to deal with the fact that for short messages, - * if the send occurs before the receive, the message is already sent and - * buffered on receiver side when the recv() occurs. - * - * So the next chunk detects this fact and cancel the simix communication instead. - */ - - /* make sure the rdv is created on need by asking to MSG instead of simix directly */ - smx_rdv_t rdv = MSG_mailbox_get_by_alias(mailbox_name); - smx_action_t act = SIMIX_comm_get_send_match(rdv,task_matching,NULL); - if (act!=NULL){ - /* FIXME account for the memcopy time if needed */ - SIMIX_comm_finish(act); - return; - } - #ifdef HAVE_TRACING int rank = get_rank(MSG_process_get_name(MSG_process_self())); int src_traced = get_rank(action[2]); @@ -160,10 +137,13 @@ static void action_recv(const char *const *action) #endif XBT_DEBUG("Receiving: %s", name); - MSG_task_receive(&task, mailbox_name); + MSG_error_t res = MSG_task_receive(&task, mailbox_name); // MSG_task_receive(&task, MSG_process_get_name(MSG_process_self())); XBT_VERB("%s %f", name, MSG_get_clock() - clock); - MSG_task_destroy(task); + + if (res == MSG_OK) { + MSG_task_destroy(task); + } if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose)) free(name); diff --git a/examples/msg/actions/actions.tesh b/examples/msg/actions/actions.tesh index 6edc971307..d548647fc9 100644 --- a/examples/msg/actions/actions.tesh +++ b/examples/msg/actions/actions.tesh @@ -75,7 +75,7 @@ $ ${bindir:=.}/actions --log=actions.thres=verbose homogeneous_3_hosts.xml deplo > [150.005200] (2:p1@host1) p1 send p2 1e9 50.005200 > [150.005200] (3:p2@host2) p2 wait 100.005200 > [150.005200] (3:p2@host2) p2 Isend p0 1e9 0.000000 +> [200.005200] (0:@) Simulation time 200.005 +> [200.005200] (1:p0@host0) p0 recv p2 50.000000 > [200.005200] (3:p2@host2) p2 compute 5e8 50.000000 -> [200.010400] (0:@) Simulation time 200.01 -> [200.010400] (1:p0@host0) p0 recv p2 50.005200 diff --git a/examples/msg/chord/chord.c b/examples/msg/chord/chord.c index 15d3423466..e916d85a9f 100644 --- a/examples/msg/chord/chord.c +++ b/examples/msg/chord/chord.c @@ -82,6 +82,7 @@ static int *powers2; // utility functions static void chord_initialize(void); +static void chord_exit(void); static int normalize(int id); static int is_in_interval(int id, int start, int end); static void get_mailbox(int host_id, char* mailbox); @@ -127,6 +128,11 @@ static void chord_initialize(void) XBT_DEBUG("Sets nb_keys to %d", nb_keys); } +static void chord_exit(void) +{ + xbt_free(powers2); +} + /** * \brief Turns an id into an equivalent id in [0, nb_keys). * \param id an id @@ -342,13 +348,16 @@ int node(int argc, char *argv[]) MSG_process_sleep(5); } } - else { + + if (node.comm_receive && MSG_comm_test(node.comm_receive)) { + // a transfer has occured MSG_error_t status = MSG_comm_get_status(node.comm_receive); if (status != MSG_OK) { XBT_DEBUG("Failed to receive a task. Nevermind."); + MSG_comm_destroy(node.comm_receive); node.comm_receive = NULL; } else { @@ -358,35 +367,12 @@ int node(int argc, char *argv[]) handle_task(&node, task_received); } } - - // see if some communications are finished - /* - while ((index = MSG_comm_testany(node.comms)) != -1) { - comm_send = xbt_dynar_get_as(node.comms, index, msg_comm_t); - MSG_error_t status = MSG_comm_get_status(comm_send); - xbt_dynar_remove_at(node.comms, index, &comm_send); - XBT_DEBUG("Communication %p is finished with status %d, dynar size is now %lu", - comm_send, status, xbt_dynar_length(node.comms)); - m_task_t task = MSG_comm_get_task(comm_send); - MSG_comm_destroy(comm_send); - if (status != MSG_OK) { - task_data_destroy(MSG_task_get_data(task)); - MSG_task_destroy(task); - } - } - */ } - // clean unfinished comms sent - /* unsigned int cursor; - xbt_dynar_foreach(node.comms, cursor, comm_send) { - m_task_t task = MSG_comm_get_task(comm_send); - MSG_task_cancel(task); - task_data_destroy(MSG_task_get_data(task)); - MSG_task_destroy(task); - MSG_comm_destroy(comm_send); - // FIXME: the task is actually not destroyed because MSG thinks that the other side (whose process is dead) is still using it - }*/ + if (node.comm_receive) { + MSG_comm_destroy(node.comm_receive); + node.comm_receive = NULL; + } // leave the ring leave(&node); @@ -936,6 +922,7 @@ int main(int argc, char *argv[]) XBT_INFO("Simulated time: %g", MSG_get_clock()); MSG_clean(); + chord_exit(); if (res == MSG_OK) return 0; diff --git a/examples/msg/chord/chord.tesh b/examples/msg/chord/chord.tesh index d5b0dfb660..776f4af2ee 100644 --- a/examples/msg/chord/chord.tesh +++ b/examples/msg/chord/chord.tesh @@ -425,5 +425,5 @@ $ $SG_TEST_EXENV ${bindir:=.}/chord$EXEEXT -nb_bits=6 ${srcdir:=.}/../msg_platfo > [547.073600] (3:node@iRMX) 54 | 38 > [547.073600] (3:node@iRMX) 6 | 38 > [547.073600] (3:node@iRMX) Predecessor: 32 -> [655.138775] (0:@) Messages created: 838 -> [655.138775] (0:@) Simulated time: 655.139 +> [649.756626] (0:@) Messages created: 838 +> [649.756626] (0:@) Simulated time: 649.757 diff --git a/examples/msg/masterslave/CMakeLists.txt b/examples/msg/masterslave/CMakeLists.txt index 77786c2bb6..dc90fe30c9 100644 --- a/examples/msg/masterslave/CMakeLists.txt +++ b/examples/msg/masterslave/CMakeLists.txt @@ -8,6 +8,7 @@ add_executable(masterslave_mailbox "masterslave_mailbox.c") add_executable(masterslave_bypass "masterslave_bypass.c") add_executable(masterslave_console "masterslave_console.c") add_executable(masterslave_cluster "masterslave_cluster.c") +add_executable(masterslave_kill "masterslave_kill.c") ### Add definitions for compile if(WIN32) @@ -16,11 +17,13 @@ target_link_libraries(masterslave_failure simgrid ) target_link_libraries(masterslave_mailbox simgrid ) target_link_libraries(masterslave_bypass simgrid ) target_link_libraries(masterslave_console simgrid ) +target_link_libraries(masterslave_kill simgrid ) else(WIN32) target_link_libraries(masterslave_forwarder simgrid m ) target_link_libraries(masterslave_failure simgrid m ) target_link_libraries(masterslave_mailbox simgrid m ) target_link_libraries(masterslave_bypass simgrid m ) target_link_libraries(masterslave_console simgrid m ) +target_link_libraries(masterslave_kill simgrid m ) endif(WIN32) target_link_libraries(masterslave_cluster simgrid) \ No newline at end of file diff --git a/examples/msg/masterslave/deployment_masterslave_kill.xml b/examples/msg/masterslave/deployment_masterslave_kill.xml new file mode 100644 index 0000000000..2621d6e11a --- /dev/null +++ b/examples/msg/masterslave/deployment_masterslave_kill.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/msg/masterslave/masterslave_kill.c b/examples/msg/masterslave/masterslave_kill.c new file mode 100644 index 0000000000..b6248aeb6d --- /dev/null +++ b/examples/msg/masterslave/masterslave_kill.c @@ -0,0 +1,81 @@ +/* Copyright (c) 2007, 2009, 2010. 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 "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */ +#include "xbt/sysdep.h" /* calloc */ + +/* Create a log channel to have nice outputs. */ +#include "xbt/log.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, + "Messages specific for this msg example"); + +/** Lazy guy function. This process suspends itself asap. */ +static int slave(int argc, char *argv[]) +{ + XBT_INFO("Hello!"); + XBT_INFO("Suspend process"); + MSG_process_suspend(MSG_process_self()); + MSG_task_execute(MSG_task_create("toto",10000000000000000,0,NULL)); + XBT_INFO("Bye!"); + return 0; +} /* end_of_lazy_guy */ + +static int master(int argc, char *argv[]) +{ + m_process_t bob = NULL; + + XBT_INFO("Hello!"); + bob = MSG_process_create("slave", slave, NULL, MSG_get_host_by_name("bob")); + MSG_process_sleep(10.0); + + XBT_INFO("Resume process"); + MSG_process_resume(bob); + + XBT_INFO("Kill process"); + MSG_process_kill(bob); + + XBT_INFO("OK, goodbye now."); + return 0; +} /* end_of_dram_master */ + +/** Test function */ +static MSG_error_t test_all(const char *platform_file, + const char *application_file) +{ + MSG_error_t res = MSG_OK; + + MSG_create_environment(platform_file); + MSG_function_register("master", master); + MSG_function_register("slave", slave); + MSG_launch_application(application_file); + + res = MSG_main(); + + XBT_INFO("Simulation time %g", MSG_get_clock()); + return res; +} /* end_of_test_all */ + + +/** Main function */ +int main(int argc, char *argv[]) +{ + MSG_error_t res = MSG_OK; + + MSG_global_init(&argc, argv); + if (argc < 3) { + XBT_CRITICAL("Usage: %s platform_file deployment_file\n", argv[0]); + XBT_CRITICAL("example: %s msg_platform.xml msg_deployment_suspend.xml\n", + argv[0]); + exit(1); + } + test_all(argv[1], argv[2]); + res = MSG_clean(); + + if (res == MSG_OK) + return 0; + else + return 1; +} /* end_of_main */ diff --git a/examples/msg/masterslave/masterslave_kill.tesh b/examples/msg/masterslave/masterslave_kill.tesh new file mode 100644 index 0000000000..2db6f370eb --- /dev/null +++ b/examples/msg/masterslave/masterslave_kill.tesh @@ -0,0 +1,12 @@ +#! ./tesh + +p Testing a simple master/slave example application + +$ $SG_TEST_EXENV masterslave/masterslave_kill$EXEEXT ${srcdir:=.}/masterslave/platform_kill.xml ${srcdir:=.}/masterslave/deployment_masterslave_kill.xml +> [alice:master:(1) 0.000000] [msg_test/INFO] Hello! +> [bob:slave:(2) 0.000000] [msg_test/INFO] Hello! +> [bob:slave:(2) 0.000000] [msg_test/INFO] Suspend process +> [alice:master:(1) 10.000000] [msg_test/INFO] Resume process +> [alice:master:(1) 10.000000] [msg_test/INFO] Kill process +> [alice:master:(1) 10.000000] [msg_test/INFO] OK, goodbye now. +> [10.000000] [msg_test/INFO] Simulation time 10 \ No newline at end of file diff --git a/examples/msg/masterslave/platform_kill.xml b/examples/msg/masterslave/platform_kill.xml new file mode 100644 index 0000000000..38ce19340a --- /dev/null +++ b/examples/msg/masterslave/platform_kill.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/msg/tracing/categories.tesh b/examples/msg/tracing/categories.tesh index 736ed84700..b6e08d86ec 100644 --- a/examples/msg/tracing/categories.tesh +++ b/examples/msg/tracing/categories.tesh @@ -64,19 +64,19 @@ $ cat tracing/categories.trace > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeAddVariable 9 > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeSubVariable 10 > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeSetState 11 > % Time date diff --git a/examples/msg/tracing/ms.tesh b/examples/msg/tracing/ms.tesh index bea097779a..44eb072651 100644 --- a/examples/msg/tracing/ms.tesh +++ b/examples/msg/tracing/ms.tesh @@ -3256,19 +3256,19 @@ $ $SG_TEST_EXENV cat tracing/ms.trace > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeAddVariable 9 > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeSubVariable 10 > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeSetState 11 > % Time date diff --git a/examples/msg/tracing/procmig.tesh b/examples/msg/tracing/procmig.tesh index 071e7e5d92..f656d6474a 100644 --- a/examples/msg/tracing/procmig.tesh +++ b/examples/msg/tracing/procmig.tesh @@ -69,19 +69,19 @@ $ cat tracing/procmig.trace > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeAddVariable 9 > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeSubVariable 10 > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeSetState 11 > % Time date diff --git a/examples/msg/tracing/tasks.tesh b/examples/msg/tracing/tasks.tesh index 0370fc56df..252c9507a4 100644 --- a/examples/msg/tracing/tasks.tesh +++ b/examples/msg/tracing/tasks.tesh @@ -103,19 +103,19 @@ $ cat tracing/tasks.trace > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeAddVariable 9 > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeSubVariable 10 > % Time date > % Type string > % Container string -> % Value string +> % Value double > %EndEventDef > %EventDef PajeSetState 11 > % Time date diff --git a/examples/platforms/gridpp_grid_2004.conf b/examples/platforms/conf/gridpp_grid_2004.conf similarity index 100% rename from examples/platforms/gridpp_grid_2004.conf rename to examples/platforms/conf/gridpp_grid_2004.conf diff --git a/examples/platforms/gridpp_grid_2004.xml b/examples/platforms/conf/gridpp_grid_2004.xml similarity index 100% rename from examples/platforms/gridpp_grid_2004.xml rename to examples/platforms/conf/gridpp_grid_2004.xml diff --git a/examples/platforms/lcg_sept2004_grid.conf b/examples/platforms/conf/lcg_sept2004_grid.conf similarity index 100% rename from examples/platforms/lcg_sept2004_grid.conf rename to examples/platforms/conf/lcg_sept2004_grid.conf diff --git a/examples/platforms/lcg_sept2004_grid.xml b/examples/platforms/conf/lcg_sept2004_grid.xml similarity index 100% rename from examples/platforms/lcg_sept2004_grid.xml rename to examples/platforms/conf/lcg_sept2004_grid.xml diff --git a/buildtools/Cmake/transform_optorsim_platform.pl b/examples/platforms/conf/transform_optorsim_platform.pl similarity index 100% rename from buildtools/Cmake/transform_optorsim_platform.pl rename to examples/platforms/conf/transform_optorsim_platform.pl diff --git a/buildtools/Cmake/generate_peer_platform.pl b/examples/platforms/syscoord/generate_peer_platform.pl similarity index 100% rename from buildtools/Cmake/generate_peer_platform.pl rename to examples/platforms/syscoord/generate_peer_platform.pl diff --git a/examples/platforms/median_harvard.syscoord b/examples/platforms/syscoord/median_harvard.syscoord similarity index 100% rename from examples/platforms/median_harvard.syscoord rename to examples/platforms/syscoord/median_harvard.syscoord diff --git a/examples/platforms/median_harvard.xml b/examples/platforms/syscoord/median_harvard.xml similarity index 99% rename from examples/platforms/median_harvard.xml rename to examples/platforms/syscoord/median_harvard.xml index 2620fd886d..26518f70d6 100644 --- a/examples/platforms/median_harvard.xml +++ b/examples/platforms/syscoord/median_harvard.xml @@ -7,8 +7,8 @@ - + diff --git a/examples/platforms/median_meridian.syscoord b/examples/platforms/syscoord/median_meridian.syscoord similarity index 100% rename from examples/platforms/median_meridian.syscoord rename to examples/platforms/syscoord/median_meridian.syscoord diff --git a/examples/platforms/syscoord/median_meridian.xml b/examples/platforms/syscoord/median_meridian.xml new file mode 100644 index 0000000000..2b15b7394f --- /dev/null +++ b/examples/platforms/syscoord/median_meridian.xml @@ -0,0 +1,7516 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/platforms/median_p2psim.syscoord b/examples/platforms/syscoord/median_p2psim.syscoord similarity index 100% rename from examples/platforms/median_p2psim.syscoord rename to examples/platforms/syscoord/median_p2psim.syscoord diff --git a/examples/platforms/syscoord/median_p2psim.xml b/examples/platforms/syscoord/median_p2psim.xml new file mode 100644 index 0000000000..ae81b76de8 --- /dev/null +++ b/examples/platforms/syscoord/median_p2psim.xml @@ -0,0 +1,5236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/bindings/lua/lua_state_cloner.c b/src/bindings/lua/lua_state_cloner.c new file mode 100644 index 0000000000..c5abebbc97 --- /dev/null +++ b/src/bindings/lua/lua_state_cloner.c @@ -0,0 +1,624 @@ +/* Copyright (c) 2010. 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. */ + +/* SimGrid Lua state management */ + +#include "lua_state_cloner.h" +#include "lua_utils.h" +#include "xbt.h" +#include "xbt/log.h" +#include +#include + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_state_cloner, bindings, "Lua state management"); + +static void sglua_add_maestro_table(lua_State* L, int index, void* maestro_table_ptr); +static void* sglua_get_maestro_table_ptr(lua_State* L, int index); +static void sglua_get_table_by_ptr(lua_State* L, void* table_ptr); +static int l_get_from_maestro(lua_State* L); + +static void sglua_copy_nil(lua_State* src, lua_State* dst); +static void sglua_copy_number(lua_State* src, lua_State* dst); +static void sglua_copy_boolean(lua_State* src, lua_State* dst); +static void sglua_copy_string(lua_State* src, lua_State* dst); +static void sglua_copy_table(lua_State* src, lua_State* dst); +static void sglua_copy_function(lua_State* src, lua_State* dst); +static void sglua_copy_lightuserdata(lua_State* src, lua_State* dst); +static void sglua_copy_userdata(lua_State* src, lua_State* dst); +static void sglua_copy_thread(lua_State* src, lua_State* dst); + +/** + * @brief Adds a reference to a maestro table to the list of known maestro + * tables of a state. + * + * TODO identify maestro's tables with my own IDs instead of pointers + * to Lua internals + * + * @param L a state (can be maestro itself) + * @param index index of the copy of the maestro table in the stack of L + * @param maestro_table_ptr pointer to the original table in maestro's world + */ +void sglua_add_maestro_table(lua_State* L, int index, void* maestro_table_ptr) { + + /* we will set both [ptr] -> table and [table] -> ptr */ + + /* ... */ + lua_pushvalue(L, index); + /* ... table */ + lua_pushstring(L, "simgrid.maestro_tables"); + /* ... table "simgrid.maestro_tables" */ + lua_rawget(L, LUA_REGISTRYINDEX); + /* ... table maestrotbs */ + lua_pushvalue(L, -2); + /* ... table maestrotbs table */ + lua_pushlightuserdata(L, maestro_table_ptr); + /* ... table maestrotbs table tableptr */ + lua_pushvalue(L, -1); + /* ... table maestrotbs table tableptr tableptr */ + lua_pushvalue(L, -3); + /* ... table maestrotbs table tableptr tableptr table */ + lua_settable(L, -5); + /* ... table maestrotbs table tableptr */ + lua_settable(L, -3); + /* ... table maestrotbs */ + lua_pop(L, 2); + /* ... */ +} + +/** + * @brief For a table in the stack of L, returns a pointer that identifies the + * same table in in maestro's world. + * @param L a Lua state + * @param index index of a table in the stack of L + * @return a pointer to maestro's copy of this table, or NULL if this table + * did not come from maestro + */ +static void* sglua_get_maestro_table_ptr(lua_State* L, int index) { + + void* maestro_table_ptr = NULL; + /* ... */ + lua_pushvalue(L, index); + /* ... table */ + lua_pushstring(L, "simgrid.maestro_tables"); + /* ... table "simgrid.maestro_tables" */ + lua_rawget(L, LUA_REGISTRYINDEX); + /* ... table maestrotbs */ + lua_pushvalue(L, -2); + /* ... table maestrotbs table */ + lua_gettable(L, -2); + /* ... table maestrotbs tableptr/nil */ + if (!lua_isnil(L, -1)) { + /* ... table maestrotbs tableptr */ + maestro_table_ptr = (void*) lua_topointer(L, -1); + } + + lua_pop(L, 3); + /* ... */ + return maestro_table_ptr; +} + +/** + * @brief Pushes a table knowing a pointer to maestro's copy of this table. + * + * Pushes nil if L does not know this table in maestro. + * + * @param L a Lua state + * @param maestro_table_ptr pointer that identifies a table in maestro's world + */ +static void sglua_get_table_by_ptr(lua_State* L, void* maestro_table_ptr) { + + /* ... */ + lua_pushstring(L, "simgrid.maestro_tables"); + /* ... "simgrid.maestro_tables" */ + lua_rawget(L, LUA_REGISTRYINDEX); + /* ... maestrotbs */ + lua_pushlightuserdata(L, maestro_table_ptr); + /* ... maestrotbs tableptr */ + lua_gettable(L, -2); + /* ... maestrotbs table/nil */ + lua_remove(L, -2); + /* ... table/nil */ +} + +/** + * @brief Pops a value from the stack of a source state and pushes it on the + * stack of another state. + * If the value is a table, its content is copied recursively. + * + * This function is similar to lua_xmove() but it allows to move a value + * between two different global states. + * + * @param src the source state (not necessarily maestro) + * @param dst the destination state + */ +void sglua_move_value(lua_State* src, lua_State *dst) { + + luaL_checkany(src, -1); /* check the value to copy */ + + int indent = (lua_gettop(dst) - 1) * 6; + XBT_DEBUG("%sCopying data %s", sglua_get_spaces(indent), sglua_tostring(src, -1)); + + sglua_stack_dump("src before copying a value (should be ... value): ", src); + sglua_stack_dump("dst before copying a value (should be ...): ", dst); + + switch (lua_type(src, -1)) { + + case LUA_TNIL: + sglua_copy_nil(src, dst); + break; + + case LUA_TNUMBER: + sglua_copy_number(src, dst); + break; + + case LUA_TBOOLEAN: + sglua_copy_boolean(src, dst); + break; + + case LUA_TSTRING: + sglua_copy_string(src, dst); + break; + + case LUA_TFUNCTION: + sglua_copy_function(src, dst); + break; + + case LUA_TTABLE: + sglua_copy_table(src, dst); + break; + + case LUA_TLIGHTUSERDATA: + sglua_copy_lightuserdata(src, dst); + break; + + case LUA_TUSERDATA: + sglua_copy_userdata(src, dst); + break; + + case LUA_TTHREAD: + sglua_copy_thread(src, dst); + break; + } + + /* the value has been copied to dst: remove it from src */ + lua_pop(src, 1); + + indent -= 2; + XBT_DEBUG("%sData copied", sglua_get_spaces(indent)); + + sglua_stack_dump("src after copying a value (should be ...): ", src); + sglua_stack_dump("dst after copying a value (should be ... value): ", dst); +} + +/** + * @brief Copies the nil value on the top of src to the top of dst. + * @param src source state + * @param dst destination state + */ +static void sglua_copy_nil(lua_State* src, lua_State* dst) { + lua_pushnil(dst); +} + +/** + * @brief Copies the number value on the top of src to the top of dst. + * @param src source state + * @param dst destination state + */ +static void sglua_copy_number(lua_State* src, lua_State* dst) { + lua_pushnumber(dst, lua_tonumber(src, -1)); +} + +/** + * @brief Copies the boolean value on the top of src to the top of dst. + * @param src source state + * @param dst destination state + */ +static void sglua_copy_boolean(lua_State* src, lua_State* dst) { + lua_pushboolean(dst, lua_toboolean(src, -1)); +} + +/** + * @brief Copies the string value on the top of src to the top of dst. + * @param src source state + * @param dst destination state + */ +static void sglua_copy_string(lua_State* src, lua_State* dst) { + + /* no worries about memory: lua_pushstring makes a copy */ + lua_pushstring(dst, lua_tostring(src, -1)); +} + +/** + * @brief Copies the table value on the top of src to the top of dst. + * + * A deep copy of the table is made. If the table has a metatable, the + * metatable is also copied. + * If the table is already known by the destination state, it is not copied + * again. + * + * @param src source state + * @param dst destination state + */ +static void sglua_copy_table(lua_State* src, lua_State* dst) { + + /* src: ... table + dst: ... */ + int indent = lua_gettop(dst) * 6 + 2; + + /* get from maestro the pointer that identifies this table */ + void* table_ptr = sglua_get_maestro_table_ptr(src, -1); + if (table_ptr == NULL) { + /* the table didn't come from maestro: nevermind, use the pointer of src */ + table_ptr = (void*) lua_topointer(src, -1); + + if (!sglua_is_maestro(src)) { + XBT_DEBUG("%sMaestro does not know this table", + sglua_get_spaces(indent)); + } + } + + if (sglua_is_maestro(src)) { + /* register the table in maestro itself */ + XBT_DEBUG("%sKeeping track of this table in maestro itself", + sglua_get_spaces(indent)); + sglua_add_maestro_table(src, -1, table_ptr); + xbt_assert(sglua_get_maestro_table_ptr(src, -1) == table_ptr); + } + + /* to avoid infinite recursion, see if this table is already known by dst */ + sglua_get_table_by_ptr(dst, table_ptr); + /* dst: ... table/nil */ + if (!lua_isnil(dst, -1)) { + XBT_DEBUG("%sNothing to do: table already known (%p)", + sglua_get_spaces(indent), table_ptr); + /* dst: ... table */ + } + else { + XBT_DEBUG("%sFirst visit of this table (%p)", sglua_get_spaces(indent), + table_ptr); + /* dst: ... nil */ + lua_pop(dst, 1); + /* dst: ... */ + + /* first visit: create the new table in dst */ + lua_newtable(dst); + /* dst: ... table */ + + /* mark the table as known right now to avoid infinite recursion */ + sglua_add_maestro_table(dst, -1, table_ptr); + /* FIXME: we may have added a table with a non-maestro pointer, is this a + problem? */ + XBT_DEBUG("%sTable marked as known", sglua_get_spaces(indent)); + xbt_assert(sglua_get_maestro_table_ptr(dst, -1) == table_ptr); + + sglua_stack_dump("dst after marking the table as known (should be ... table): ", dst); + + /* copy the metatable if any */ + int has_meta_table = lua_getmetatable(src, -1); + /* src: ... table mt? */ + if (has_meta_table) { + XBT_DEBUG("%sCopying the metatable", sglua_get_spaces(indent)); + /* src: ... table mt */ + sglua_copy_table(src, dst); + /* dst: ... table mt */ + lua_pop(src, 1); + /* src: ... table */ + lua_setmetatable(dst, -2); + /* dst: ... table */ + } + else { + /* src: ... table */ + XBT_DEBUG("%sNo metatable", sglua_get_spaces(indent)); + } + + sglua_stack_dump("src before traversing the table (should be ... table): ", src); + sglua_stack_dump("dst before traversing the table (should be ... table): ", dst); + + /* traverse the table of src and copy each element */ + lua_pushnil(src); + /* src: ... table nil */ + while (lua_next(src, -2) != 0) { + /* src: ... table key value */ + + XBT_DEBUG("%sCopying table element %s", sglua_get_spaces(indent), + sglua_keyvalue_tostring(src, -2, -1)); + + sglua_stack_dump("src before copying table element (should be ... table key value): ", src); + sglua_stack_dump("dst before copying table element (should be ... table): ", dst); + + /* copy the key */ + lua_pushvalue(src, -2); + /* src: ... table key value key */ + indent += 2; + XBT_DEBUG("%sCopying the key part of the table element", + sglua_get_spaces(indent)); + sglua_move_value(src, dst); + /* src: ... table key value + dst: ... table key */ + XBT_DEBUG("%sCopied the key part of the table element", + sglua_get_spaces(indent)); + + /* copy the value */ + XBT_DEBUG("%sCopying the value part of the table element", + sglua_get_spaces(indent)); + sglua_move_value(src, dst); + /* src: ... table key + dst: ... table key value */ + XBT_DEBUG("%sCopied the value part of the table element", + sglua_get_spaces(indent)); + indent -= 2; + + /* set the table element */ + lua_settable(dst, -3); + /* dst: ... table */ + + /* the key stays on top of src for next iteration */ + sglua_stack_dump("src before next iteration (should be ... table key): ", src); + sglua_stack_dump("dst before next iteration (should be ... table): ", dst); + + XBT_DEBUG("%sTable element copied", sglua_get_spaces(indent)); + } + XBT_DEBUG("%sFinished traversing the table", sglua_get_spaces(indent)); + } +} + +/** + * @brief Copies the function on the top of src to the top of dst. + * + * It can be a Lua function or a C function. + * Copying upvalues is not implemented yet. + * + * @param src source state + * @param dst destination state + */ +static void sglua_copy_function(lua_State* src, lua_State* dst) { + + if (lua_iscfunction(src, -1)) { + /* it's a C function */ + + XBT_DEBUG("It's a C function"); + sglua_stack_dump("src before copying upvalues: ", src); + + /* get the function pointer */ + int function_index = lua_gettop(src); + lua_CFunction f = lua_tocfunction(src, function_index); + + /* copy the upvalues */ + int i = 0; + const char* upvalue_name = NULL; + do { + i++; + upvalue_name = lua_getupvalue(src, function_index, i); + + if (upvalue_name != NULL) { + XBT_DEBUG("Upvalue %s", upvalue_name); + sglua_move_value(src, dst); + } + } while (upvalue_name != NULL); + + sglua_stack_dump("src before copying pointer: ", src); + + /* set the function */ + lua_pushcclosure(dst, f, i - 1); + XBT_DEBUG("Function pointer copied"); + } + else { + /* it's a Lua function: dump it from src */ + + s_sglua_buffer_t buffer; + buffer.capacity = 128; /* an empty function uses 77 bytes */ + buffer.size = 0; + buffer.data = xbt_new(char, buffer.capacity); + + /* copy the binary chunk from src into a buffer */ + int error = lua_dump(src, sglua_memory_writer, &buffer); + xbt_assert(!error, "Failed to dump the function from the source state: error %d", + error); + XBT_DEBUG("Fonction dumped: %zu bytes", buffer.size); + + /* + fwrite(buffer.data, buffer.size, buffer.size, stderr); + fprintf(stderr, "\n"); + */ + + /* load the chunk into dst */ + error = luaL_loadbuffer(dst, buffer.data, buffer.size, "(dumped function)"); + xbt_assert(!error, "Failed to load the function into the destination state: %s", + lua_tostring(dst, -1)); + } +} + +/** + * @brief Copies the light userdata on the top of src to the top of dst. + * @param src source state + * @param dst destination state + */ +static void sglua_copy_lightuserdata(lua_State* src, lua_State* dst) { + lua_pushlightuserdata(dst, lua_touserdata(src, -1)); +} + +/** + * @brief Copies the full userdata on the top of src to the top of dst. + * + * If the userdata has a metatable, the metatable is also copied. + * + * @param src source state + * @param dst destination state + */ +static void sglua_copy_userdata(lua_State* src, lua_State* dst) { + + int indent = lua_gettop(dst) * 6 + 2; + + /* copy the data */ + /* src: ... udata + dst: ... */ + size_t size = lua_objlen(src, -1); + void* src_block = lua_touserdata(src, -1); + void* dst_block = lua_newuserdata(dst, size); + /* dst: ... udata */ + memcpy(dst_block, src_block, size); + + /* copy the metatable if any */ + int has_meta_table = lua_getmetatable(src, -1); + /* src: ... udata mt? */ + if (has_meta_table) { + XBT_DEBUG("%sCopying metatable of userdata (%p)", + sglua_get_spaces(indent), lua_topointer(src, -1)); + /* src: ... udata mt */ + sglua_copy_table(src, dst); + /* src: ... udata mt + dst: ... udata mt */ + lua_pop(src, 1); + /* src: ... udata */ + lua_setmetatable(dst, -2); + /* dst: ... udata */ + + XBT_DEBUG("%sMetatable of userdata copied", sglua_get_spaces(indent)); + } + else { + XBT_DEBUG("%sNo metatable for this userdata", + sglua_get_spaces(indent)); + /* src: ... udata */ + } +} + +/** + * @brief This operation is not supported (yet?) so it just pushes nil. + * + * @param src source state + * @param dst destination state + */ +static void sglua_copy_thread(lua_State* src, lua_State* dst) { + + XBT_WARN("Copying a thread from another state is not implemented (yet?)."); + lua_pushnil(dst); +} + +/** + * @brief Copies a global value or a registry value from the maestro state. + * + * The state L must have been created by sglua_clone_maestro_state(). + * This function is meant to be an __index metamethod. + * Consequently, it assumes that the stack has two elements: + * a table (either the environment or the registry of L) and the string key of + * a value that does not exist yet in this table. It copies the corresponding + * value from maestro and pushes it on the stack of L. + * If the value does not exist in maestro state either, nil is pushed. + * + * TODO: make this function thread safe. If the simulation runs in parallel, + * several simulated processes may trigger this __index metamethod at the same + * time and get globals from maestro. + * + * @param L the current state + * @return number of return values pushed (always 1) + */ +static int l_get_from_maestro(lua_State *L) { + + /* check the arguments */ + luaL_checktype(L, 1, LUA_TTABLE); + const char* key = luaL_checkstring(L, 2); + /* L: table key */ + XBT_DEBUG("__index of '%s' begins", key); + + /* want a global or a registry value? */ + int pseudo_index; + if (lua_equal(L, 1, LUA_REGISTRYINDEX)) { + /* registry */ + pseudo_index = LUA_REGISTRYINDEX; + XBT_DEBUG("Will get the value from the registry of maestro"); + } + else { + /* global */ + pseudo_index = LUA_GLOBALSINDEX; + XBT_DEBUG("Will get the value from the globals of maestro"); + } + + /* get the father */ + lua_State* maestro = sglua_get_maestro(); + + /* L: table key */ + + /* get the value from maestro */ + lua_getfield(maestro, pseudo_index, key); + /* maestro: ... value */ + + /* push the value onto the stack of L */ + sglua_move_value(maestro, L); + /* maestro: ... + L: table key value */ + + /* prepare the return value of __index */ + lua_pushvalue(L, -1); + /* L: table key value value */ + lua_insert(L, 1); + /* L: value table key value */ + + /* save the copied value in the table for subsequent accesses */ + lua_settable(L, -3); + /* L: value table */ + lua_settop(L, 1); + /* L: value */ + + XBT_DEBUG("__index of '%s' returns %s", key, sglua_tostring(L, -1)); + + return 1; +} + +/** + * @brief Creates a new Lua state and get its environment from the maestro + * state. + * + * The state created is independent from maestro and has its own copies of + * global and registry values. + * However, the global and registry values are not copied right now from + * the original state; they are copied only the first time they are accessed. + * This behavior saves time and memory, and is okay for Simgrid's needs. + * + * TODO: if the simulation runs in parallel, copy everything right now? + * + * @return the state created + */ +lua_State* sglua_clone_maestro(void) { + + /* create the new state */ + lua_State *L = luaL_newstate(); + + /* set its environment and its registry: + * - create a table newenv + * - create a metatable mt + * - set mt.__index = a function that copies the global from the father state + * - set mt as the metatable of the registry + * - set mt as the metatable of newenv + * - set newenv as the environment of the new state + */ + lua_pushthread(L); /* thread */ + lua_newtable(L); /* thread newenv */ + lua_newtable(L); /* thread newenv mt */ + lua_pushvalue(L, LUA_REGISTRYINDEX); /* thread newenv mt reg */ + lua_pushcfunction(L, l_get_from_maestro); /* thread newenv mt reg f */ + lua_setfield(L, -3, "__index"); /* thread newenv mt reg */ + lua_pushvalue(L, -2); /* thread newenv mt reg mt */ + lua_setmetatable(L, -2); /* thread newenv mt reg */ + lua_pop(L, 1); /* thread newenv mt */ + lua_setmetatable(L, -2); /* thread newenv */ + lua_setfenv(L, -2); /* thread */ + lua_pop(L, 1); /* -- */ + + /* create the table of known tables from maestro */ + lua_pushstring(L, "simgrid.maestro_tables"); + /* "simgrid.maestro_tables" */ + lua_newtable(L); /* "simgrid.maestro_tables" maestrotbs*/ + lua_rawset(L, LUA_REGISTRYINDEX); + /* -- */ + + /* opening the standard libs is not necessary as they are + * inherited like any global values */ + /* luaL_openlibs(L); */ + + XBT_DEBUG("New state created"); + + return L; +} diff --git a/src/bindings/lua/lua_state_cloner.h b/src/bindings/lua/lua_state_cloner.h new file mode 100644 index 0000000000..194cbb1c9b --- /dev/null +++ b/src/bindings/lua/lua_state_cloner.h @@ -0,0 +1,13 @@ +/* Copyright (c) 2010. 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. */ + +/* SimGrid Lua state management */ +#include + +int sglua_is_maestro(lua_State* L); +lua_State* sglua_get_maestro(void); +lua_State* sglua_clone_maestro(void); +void sglua_move_value(lua_State* src, lua_State* dst); diff --git a/src/bindings/lua/lua_utils.c b/src/bindings/lua/lua_utils.c new file mode 100644 index 0000000000..84b8ca2799 --- /dev/null +++ b/src/bindings/lua/lua_utils.c @@ -0,0 +1,161 @@ +/* Copyright (c) 2010. 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. */ + +/* SimGrid Lua helper functions */ + +#include "lua_utils.h" +#include "xbt.h" +#include "xbt/log.h" + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_utils, bindings, "Lua helper functions"); + +/** + * @brief Returns a string representation of a value in the Lua stack. + * + * This function is for debugging purposes. + * It always returns the same pointer. + * + * @param L the Lua state + * @param index index in the stack + * @return a string representation of the value at this index + */ +const char* sglua_tostring(lua_State* L, int index) { + + static char buff[64]; + + switch (lua_type(L, index)) { + + case LUA_TNIL: + sprintf(buff, "nil"); + break; + + case LUA_TNUMBER: + sprintf(buff, "%.3f", lua_tonumber(L, index)); + break; + + case LUA_TBOOLEAN: + sprintf(buff, "%s", lua_toboolean(L, index) ? "true" : "false"); + break; + + case LUA_TSTRING: + snprintf(buff, 63, "'%s'", lua_tostring(L, index)); + break; + + case LUA_TFUNCTION: + if (lua_iscfunction(L, index)) { + sprintf(buff, "C-function"); + } + else { + sprintf(buff, "function"); + } + break; + + case LUA_TTABLE: + sprintf(buff, "table(%p)", lua_topointer(L, index)); + break; + + case LUA_TLIGHTUSERDATA: + case LUA_TUSERDATA: + sprintf(buff, "userdata(%p)", lua_touserdata(L, index)); + break; + + case LUA_TTHREAD: + sprintf(buff, "thread"); + break; + } + return buff; +} + +/** + * @brief Returns a string representation of a key-value pair. + * + * This function is for debugging purposes. + * It always returns the same pointer. + * + * @param L the Lua state + * @param key_index index of the key + * @param value_index index of the value + * @return a string representation of the key-value pair + */ +const char* sglua_keyvalue_tostring(lua_State* L, int key_index, int value_index) { + + static char buff[64]; + /* value_tostring also always returns the same pointer */ + int len = snprintf(buff, 63, "[%s] -> ", sglua_tostring(L, key_index)); + snprintf(buff + len, 63 - len, "%s", sglua_tostring(L, value_index)); + return buff; +} + +/** + * @brief Returns a string composed of the specified number of spaces. + * + * This function can be used to indent strings for debugging purposes. + * It always returns the same pointer. + * + * @param length length of the string + * @return a string of this length with only spaces + */ +const char* sglua_get_spaces(int length) { + + static char spaces[128]; + + xbt_assert(length < 128); + memset(spaces, ' ', length); + spaces[length] = '\0'; + return spaces; +} + +/** + * @brief Dumps the Lua stack if debug logs are enabled. + * @param msg a message to print + * @param L a Lua state + */ +void sglua_stack_dump(const char* msg, lua_State* L) +{ + if (XBT_LOG_ISENABLED(lua_utils, xbt_log_priority_debug)) { + char buff[2048]; + char* p = buff; + int i; + int top = lua_gettop(L); + + //if (1) return; + + fflush(stdout); + + p[0] = '\0'; + for (i = 1; i <= top; i++) { /* repeat for each level */ + + p += sprintf(p, "%s", sglua_tostring(L, i)); + p += sprintf(p, " "); /* put a separator */ + } + XBT_DEBUG("%s%s", msg, buff); + } +} + +/** + * @brief Writes the specified data into a memory buffer. + * + * This function is a valid lua_Writer that writes into a memory buffer passed + * as userdata. + * + * @param L a lua state + * @param source some data + * @param sz number of bytes of data + * @param user_data the memory buffer to write + */ +int sglua_memory_writer(lua_State* L, const void* source, size_t size, + void* userdata) { + + sglua_buffer_t buffer = (sglua_buffer_t) userdata; + while (buffer->capacity < buffer->size + size) { + buffer->capacity *= 2; + buffer->data = xbt_realloc(buffer->data, buffer->capacity); + } + memcpy(buffer->data + buffer->size, source, size); + buffer->size += size; + + return 0; +} diff --git a/src/bindings/lua/lua_utils.h b/src/bindings/lua/lua_utils.h new file mode 100644 index 0000000000..49f8e4d729 --- /dev/null +++ b/src/bindings/lua/lua_utils.h @@ -0,0 +1,26 @@ +/* Copyright (c) 2010. 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. */ + +/* SimGrid Lua helper functions */ + +#include + +/** + * @brief A chunk of memory. + * + * This structure is used as the userdata parameter of lua_Writer. + */ +typedef struct s_sglua_buffer { + char* data; + size_t size; + size_t capacity; +} s_sglua_buffer_t, *sglua_buffer_t; + +const char* sglua_tostring(lua_State* L, int index); +const char* sglua_keyvalue_tostring(lua_State* L, int key_index, int value_index); +void sglua_stack_dump(const char *msg, lua_State* L); +const char* sglua_get_spaces(int length); +int sglua_memory_writer(lua_State* L, const void* source, size_t size, void* userdata); diff --git a/src/bindings/lua/simgrid_lua.c b/src/bindings/lua/simgrid_lua.c index 2002beac00..09dd183acd 100644 --- a/src/bindings/lua/simgrid_lua.c +++ b/src/bindings/lua/simgrid_lua.c @@ -1,11 +1,14 @@ -/* SimGrid Lua bindings */ - /* Copyright (c) 2010. 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. */ + +/* SimGrid Lua bindings */ + #include "simgrid_lua.h" +#include "lua_state_cloner.h" +#include "lua_utils.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua, bindings, "Lua Bindings"); @@ -19,62 +22,27 @@ static lua_State *lua_maestro_state; #define AS_MODULE_NAME "simgrid.AS" #define TRACE_MODULE_NAME "simgrid.Trace" -static void stack_dump(const char *msg, lua_State *L); -static m_task_t check_task(lua_State *L, int index); static void register_c_functions(lua_State *L); -/* ********************************************************************************* */ -/* helper functions */ -/* ********************************************************************************* */ - -/** - * @brief Dumps the Lua stack - * @param msg a message to print - * @param L a Lua state - */ -static void stack_dump(const char *msg, lua_State *L) -{ - char buff[2048]; - char *p = buff; - int i; - int top = lua_gettop(L); - - fflush(stdout); - p += sprintf(p, "STACK(top=%d): ", top); - - for (i = 1; i <= top; i++) { /* repeat for each level */ - int t = lua_type(L, i); - switch (t) { +static void *my_checkudata (lua_State *L, int ud, const char *tname) { - case LUA_TSTRING: /* strings */ - p += sprintf(p, "`%s'", lua_tostring(L, i)); - break; + XBT_DEBUG("Checking the task: ud = %d", ud); + sglua_stack_dump("my_checkudata: ", L); + void *p = lua_touserdata(L, ud); + lua_getfield(L, LUA_REGISTRYINDEX, tname); + const void* correct_mt = lua_topointer(L, -1); - case LUA_TBOOLEAN: /* booleans */ - p += sprintf(p, lua_toboolean(L, i) ? "true" : "false"); - break; + int has_mt = lua_getmetatable(L, ud); + XBT_DEBUG("Checking the task: has metatable ? %d", has_mt); + const void* actual_mt = NULL; + if (has_mt) { actual_mt = lua_topointer(L, -1); lua_pop(L, 1); } + XBT_DEBUG("Checking the task's metatable: expected %p, found %p", correct_mt, actual_mt); + sglua_stack_dump("my_checkudata: ", L); - case LUA_TNUMBER: /* numbers */ - p += sprintf(p, "%g", lua_tonumber(L, i)); - break; - - case LUA_TTABLE: - p += sprintf(p, "Table"); - break; - - default: /* other values */ - p += sprintf(p, "???"); -/* if ((ptr = luaL_checkudata(L,i,TASK_MODULE_NAME))) { - p+=sprintf(p,"task"); - } else { - p+=printf(p,"%s", lua_typename(L, t)); - }*/ - break; - - } - p += sprintf(p, " "); /* put a separator */ - } - XBT_INFO("%s%s", msg, buff); + if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2)) + luaL_typerror(L, ud, tname); + lua_pop(L, 2); + return p; } /** @@ -87,9 +55,12 @@ static void stack_dump(const char *msg, lua_State *L) static m_task_t checkTask(lua_State * L, int index) { m_task_t *pi, tk; + XBT_DEBUG("Lua task: %s", sglua_tostring(L, index)); luaL_checktype(L, index, LUA_TTABLE); lua_getfield(L, index, "__simgrid_task"); - pi = (m_task_t *) luaL_checkudata(L, -1, TASK_MODULE_NAME); + + pi = (m_task_t *) luaL_checkudata(L, lua_gettop(L), TASK_MODULE_NAME); + if (pi == NULL) luaL_typerror(L, index, TASK_MODULE_NAME); tk = *pi; @@ -179,7 +150,7 @@ static int Task_destroy(lua_State * L) static int Task_send(lua_State * L) { - //stackDump("send ",L); + //stack_dump("send ", L); m_task_t tk = checkTask(L, 1); const char *mailbox = luaL_checkstring(L, 2); lua_pop(L, 1); // remove the string so that the task is on top of it @@ -216,7 +187,7 @@ static int Task_recv_with_timeout(lua_State *L) if (res == MSG_OK) { lua_State *sender_stack = MSG_task_get_data(tk); - lua_xmove(sender_stack, L, 1); // copy the data directly from sender's stack + sglua_move_value(sender_stack, L); // copy the data directly from sender's stack MSG_task_set_data(tk, NULL); } else { @@ -285,7 +256,7 @@ static m_host_t checkHost(lua_State * L, int index) m_host_t *pi, ht; luaL_checktype(L, index, LUA_TTABLE); lua_getfield(L, index, "__simgrid_host"); - pi = (m_host_t *) luaL_checkudata(L, -1, HOST_MODULE_NAME); + pi = (m_host_t *) luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME); if (pi == NULL) luaL_typerror(L, index, HOST_MODULE_NAME); ht = *pi; @@ -343,13 +314,19 @@ static int Host_at(lua_State * L) static int Host_self(lua_State * L) { + /* -- */ m_host_t host = MSG_host_self(); lua_newtable(L); - m_host_t *lua_host =(m_host_t *)lua_newuserdata(L,sizeof(m_host_t)); + /* table */ + m_host_t* lua_host = (m_host_t*) lua_newuserdata(L, sizeof(m_host_t)); + /* table ud */ *lua_host = host; luaL_getmetatable(L, HOST_MODULE_NAME); + /* table ud mt */ lua_setmetatable(L, -2); + /* table ud */ lua_setfield(L, -2, "__simgrid_host"); + /* table */ return 1; } @@ -555,11 +532,10 @@ static int run_lua_code(int argc, char **argv) { XBT_DEBUG("Run lua code %s", argv[0]); - lua_State *L = lua_newthread(lua_maestro_state); - int ref = luaL_ref(lua_maestro_state, LUA_REGISTRYINDEX); /* protect the thread from being garbage collected */ + lua_State *L = sglua_clone_maestro(); int res = 1; - /* start the co-routine */ + /* start the function */ lua_getglobal(L, argv[0]); xbt_assert(lua_isfunction(L, -1), "The lua function %s does not seem to exist", argv[0]); @@ -581,8 +557,6 @@ static int run_lua_code(int argc, char **argv) lua_pop(L, 1); /* pop returned value */ } - /* cleanups */ - luaL_unref(lua_maestro_state, LUA_REGISTRYINDEX, ref); XBT_DEBUG("Execution of Lua code %s is over", (argv ? argv[0] : "(null)")); return res; @@ -772,11 +746,32 @@ int luaopen_simgrid(lua_State *L) /* Keep the context mechanism informed of our lua world today */ lua_maestro_state = L; + /* initialize access to my tables by children Lua states */ + lua_newtable(L); + lua_setfield(L, LUA_REGISTRYINDEX, "simgrid.maestro_tables"); + register_c_functions(L); return 1; } +/** + * @brief Returns whether a Lua state is the maestro state. + * @param L a Lua state + * @return true if this is maestro + */ +int sglua_is_maestro(lua_State* L) { + return L == lua_maestro_state; +} + +/** + * @brief Returns the maestro state. + * @return true the maestro Lua state + */ +lua_State* sglua_get_maestro(void) { + return lua_maestro_state; +} + /** * Makes the appropriate Simgrid functions available to the Lua world. * @param L a Lua world diff --git a/src/bindings/lua/simgrid_lua.h b/src/bindings/lua/simgrid_lua.h index 91774956c8..4a04ae85ba 100644 --- a/src/bindings/lua/simgrid_lua.h +++ b/src/bindings/lua/simgrid_lua.h @@ -22,7 +22,6 @@ #include "portable.h" /* Needed for the time of the SIMIX convertion */ #include - extern xbt_dict_t process_function_set; extern xbt_dynar_t process_list; extern xbt_dict_t machine_set; diff --git a/src/instr/instr_paje_trace.c b/src/instr/instr_paje_trace.c index fdc75c428f..d3928a4686 100644 --- a/src/instr/instr_paje_trace.c +++ b/src/instr/instr_paje_trace.c @@ -257,19 +257,19 @@ void TRACE_paje_create_header(void) %% Time date \n\ %% Type string \n\ %% Container string \n\ -%% Value string \n\ +%% Value double \n\ %%EndEventDef\n\ %%EventDef PajeAddVariable %d \n\ %% Time date \n\ %% Type string \n\ %% Container string \n\ -%% Value string \n\ +%% Value double \n\ %%EndEventDef\n\ %%EventDef PajeSubVariable %d \n\ %% Time date \n\ %% Type string \n\ %% Container string \n\ -%% Value string \n\ +%% Value double \n\ %%EndEventDef\n\ %%EventDef PajeSetState %d \n\ %% Time date \n\ diff --git a/src/msg/gos.c b/src/msg/gos.c index 4a09c655dd..cb6c929ae1 100644 --- a/src/msg/gos.c +++ b/src/msg/gos.c @@ -437,8 +437,8 @@ XBT_INLINE msg_comm_t MSG_task_isend_with_matching(m_task_t task, const char *al * \brief Sends a task on a mailbox. * * This is a non blocking detached send function. - * Think of it as a best effort send. The communication - * object will be destroyed by the receiver (if any). + * Think of it as a best effort send. The task should + * be destroyed by the receiver. * * \param task a #m_task_t to send on another location. * \param alias name of the mailbox to sent the task to @@ -623,9 +623,7 @@ void MSG_comm_destroy(msg_comm_t comm) (*comm->task_received)->simdata->isused = 0; } - /* FIXME auto-destroy comms from SIMIX to avoid this request */ - /*SIMIX_req_comm_destroy(comm->s_comm);*/ - free(comm); + xbt_free(comm); } /** \ingroup msg_gos_functions diff --git a/src/msg/task.c b/src/msg/task.c index 2a9a5c09d9..877467c1cd 100644 --- a/src/msg/task.c +++ b/src/msg/task.c @@ -159,25 +159,22 @@ MSG_error_t MSG_task_destroy(m_task_t task) smx_action_t action = NULL; xbt_assert((task != NULL), "Invalid parameter"); - /* why? if somebody is using, then you can't free! ok... but will return MSG_OK? when this task will be destroyed? isn't the user code wrong? */ - if (task->simdata->isused > 0) { - XBT_DEBUG("Cannot destroy task %p since somebody is using it", task); - return MSG_OK; + if (task->simdata->isused) { + /* the task is still being used, it may be an unfinished dsend */ + MSG_task_cancel(task); } #ifdef HAVE_TRACING TRACE_msg_task_destroy(task); #endif - if (task->name) - free(task->name); + xbt_free(task->name); action = task->simdata->compute; if (action) SIMIX_req_host_execution_destroy(action); /* parallel tasks only */ - if (task->simdata->host_list) - xbt_free(task->simdata->host_list); + xbt_free(task->simdata->host_list); /* free main structures */ xbt_free(task->simdata); @@ -201,13 +198,7 @@ MSG_error_t MSG_task_cancel(m_task_t task) } else if (task->simdata->comm) { SIMIX_req_comm_cancel(task->simdata->comm); - } - else { - static int warned = 0; - if (!warned) { - XBT_WARN("Cannot cancel a non-running task"); - warned = 1; - } + task->simdata->isused = 0; } return MSG_OK; } diff --git a/src/simix/process_private.h b/src/simix/process_private.h index c832f6d597..cfc9501a16 100644 --- a/src/simix/process_private.h +++ b/src/simix/process_private.h @@ -26,7 +26,8 @@ typedef struct s_smx_process { int blocked:1; int suspended:1; smx_host_t new_host; /* if not null, the host on which the process must migrate to */ - smx_action_t waiting_action; + smx_action_t waiting_action; /* the current blocking action if any */ + xbt_fifo_t comms; /* the current non-blocking communication actions */ xbt_dict_t properties; s_smx_req_t request; void *data; /* kept for compatibility, it should be replaced with moddata */ diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index ebd3dea594..3485c6b1e9 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -240,7 +240,7 @@ void SIMIX_run(void) /* Clean processes to destroy */ SIMIX_process_empty_trash(); - } while (time != -1.0); + } while (time != -1.0 || xbt_dynar_length(simix_global->process_to_run) > 0); if (xbt_swag_size(simix_global->process_list) != 0) { @@ -363,6 +363,9 @@ void SIMIX_display_process_status(void) XBT_INFO("Process %ld (%s@%s): waiting for %s action %p (%s) to finish", process->pid, process->name, process->smx_host->name, action_description, process->waiting_action, process->waiting_action->name); } + else { + XBT_INFO("Process %ld (%s@%s)", process->pid, process->name, process->smx_host->name); + } } } diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 1325aac2ae..d5d4631509 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -18,6 +18,7 @@ unsigned long int smx_total_comms = 0; static void SIMIX_waitany_req_remove_from_actions(smx_req_t req); static void SIMIX_comm_copy_data(smx_action_t comm); static smx_action_t SIMIX_comm_new(e_smx_comm_type_t type); +static void SIMIX_comm_remove_from_processes(smx_action_t action); static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_action_t comm); static XBT_INLINE void SIMIX_rdv_remove(smx_rdv_t rdv, smx_action_t comm); static smx_action_t SIMIX_rdv_get_request(smx_rdv_t rdv, e_smx_comm_type_t type, @@ -63,8 +64,7 @@ void SIMIX_rdv_destroy(smx_rdv_t rdv) void SIMIX_rdv_free(void *data) { smx_rdv_t rdv = (smx_rdv_t) data; - if (rdv->name) - xbt_free(rdv->name); + xbt_free(rdv->name); xbt_fifo_free(rdv->comm_fifo); xbt_free(rdv); } @@ -310,9 +310,10 @@ smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv, action->state = SIMIX_READY; action->comm.type = SIMIX_COMM_READY; } + xbt_fifo_push(src_proc->comms, action); - /* If the communication action is detached then decrease the refcount - * by one, so it will be eliminated by the receivers destroy call */ + /* if the communication action is detached then decrease the refcount + * by one, so it will be eliminated by the receiver's destroy call */ if (detached) { action->comm.detached = 1; action->comm.refcount--; @@ -353,6 +354,7 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv, action->state = SIMIX_READY; action->comm.type = SIMIX_COMM_READY; } + xbt_fifo_push(dst_proc->comms, action); /* Setup communication request */ action->comm.dst_proc = dst_proc; @@ -513,6 +515,7 @@ XBT_INLINE void SIMIX_comm_start(smx_action_t action) { /* If both the sender and the receiver are already there, start the communication */ if (action->state == SIMIX_READY) { + smx_host_t sender = action->comm.src_proc->smx_host; smx_host_t receiver = action->comm.dst_proc->smx_host; @@ -549,6 +552,8 @@ void SIMIX_comm_finish(smx_action_t action) unsigned int destroy_count = 0; smx_req_t req; + SIMIX_comm_remove_from_processes(action); + while ((req = xbt_fifo_shift(action->request_list))) { /* If a waitany request is waiting for this action to finish, then remove @@ -620,7 +625,9 @@ void SIMIX_comm_finish(smx_action_t action) case SIMIX_LINK_FAILURE: TRY { XBT_DEBUG("Link failure in action %p between '%s' and '%s': posting an exception to the issuer: %s (%p)", - action, action->comm.src_proc->smx_host->name, action->comm.dst_proc->smx_host->name, + action, + action->comm.src_proc ? action->comm.src_proc->smx_host->name : NULL, + action->comm.dst_proc ? action->comm.dst_proc->smx_host->name : NULL, req->issuer->name, req->issuer); THROWF(network_error, 0, "Link failure"); } @@ -673,28 +680,49 @@ void SIMIX_post_comm(smx_action_t action) else action->state = SIMIX_DONE; - XBT_DEBUG("SIMIX_post_comm: action state = %d", action->state); + XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d", + action, action->state, action->comm.src_proc, action->comm.dst_proc, action->comm.detached); - /* After this point the surf actions associated with the simix communicate - action are no longer needed, thus we delete them. */ + /* destroy the surf actions associated with the Simix communication */ SIMIX_comm_destroy_internal_actions(action); - /* If there are requests associated with the action, then answer them */ - if (xbt_fifo_size(action->request_list)) + /* if there are requests associated with the action, then answer them */ + if (xbt_fifo_size(action->request_list)) { SIMIX_comm_finish(action); + } + else { + SIMIX_comm_remove_from_processes(action); + } +} + +/** + * \brief Removes a communication action from the list of pending communications + * of both processes (if they still exist) + * \param action a communication action + */ +static void SIMIX_comm_remove_from_processes(smx_action_t action) { + + if (action->comm.src_proc) { + xbt_fifo_remove(action->comm.src_proc->comms, action); + } + if (action->comm.dst_proc) { + xbt_fifo_remove(action->comm.dst_proc->comms, action); + } } void SIMIX_comm_cancel(smx_action_t action) { - /* If the action is a waiting state means that it is still in a rdv */ + /* if the action is a waiting state means that it is still in a rdv */ /* so remove from it and delete it */ if (action->state == SIMIX_WAITING) { SIMIX_rdv_remove(action->comm.rdv, action); - action->state = SIMIX_FAILED; - } else { - /* When running the MC there are no surf actions */ - if(!MC_IS_ENABLED) - surf_workstation_model->action_cancel(action->comm.surf_comm); + action->state = SIMIX_CANCELED; + } + else if (!MC_IS_ENABLED + && (action->state == SIMIX_READY || action->state == SIMIX_RUNNING)) { + + /* when running the MC there are no surf actions */ + surf_workstation_model->action_cancel(action->comm.surf_comm); } } diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index bf5707b098..0b150c8e1b 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -35,7 +35,41 @@ XBT_INLINE smx_process_t SIMIX_process_self(void) */ void SIMIX_process_cleanup(smx_process_t process) { - XBT_DEBUG("Cleanup process %s", process->name); + XBT_DEBUG("Cleanup process %s (%p), waiting action %p", + process->name, process, process->waiting_action); + + /* cancel non-blocking communications */ + smx_action_t action; + while ((action = xbt_fifo_pop(process->comms))) { + + /* make sure no one will finish the comm after this process is destroyed */ + SIMIX_comm_cancel(action); + + if (action->comm.src_proc == process) { + XBT_DEBUG("Found an unfinished send comm %p (detached = %d), state %d", + action, action->comm.detached, action->state); + action->comm.src_proc = NULL; + + if (action->comm.detached) { + /* the receiver was supposed to destroy the comm after completion, + * but the comm will actually never finish */ + action->comm.refcount++; + } + } + else if (action->comm.dst_proc == process){ + XBT_DEBUG("Found an unfinished recv comm %p, state %d", action, action->state); + action->comm.dst_proc = NULL; + } + else { + XBT_DEBUG("Strange, I'm not in comm %p, state = %d, src = %p, dst = %p", action, + action->state, action->comm.src_proc, action->comm.dst_proc); + THROW_IMPOSSIBLE; + } + + /* FIXME uncommenting this instruction crashes complex simulations + SIMIX_comm_destroy(action); */ + } + /*xbt_swag_remove(process, simix_global->process_to_run);*/ xbt_swag_remove(process, simix_global->process_list); xbt_swag_remove(process, process->smx_host->process_list); @@ -61,6 +95,8 @@ void SIMIX_process_empty_trash(void) if (process->properties) xbt_dict_free(&process->properties); + xbt_fifo_free(process->comms); + free(process->name); process->name = NULL; free(process); @@ -143,6 +179,7 @@ void SIMIX_process_create(smx_process_t *process, (*process)->name = xbt_strdup(name); (*process)->smx_host = host; (*process)->data = data; + (*process)->comms = xbt_fifo_new(); XBT_VERB("Create context %s", (*process)->name); (*process)->context = SIMIX_context_new(code, argc, argv, @@ -201,6 +238,7 @@ void SIMIX_process_kill(smx_process_t process) { process->suspended = 0; /* FIXME: set doexception to 0 also? */ + /* destroy the blocking action if any */ if (process->waiting_action) { switch (process->waiting_action->type) { diff --git a/src/simix/smx_smurf.c b/src/simix/smx_smurf.c index 6a65331648..bd82cea5d6 100644 --- a/src/simix/smx_smurf.c +++ b/src/simix/smx_smurf.c @@ -29,7 +29,8 @@ void SIMIX_request_push() void SIMIX_request_answer(smx_req_t req) { if (req->issuer != simix_global->maestro_process){ - XBT_DEBUG("Answer request %s (%d)", SIMIX_request_name(req->call), req->call); + XBT_DEBUG("Answer request %s (%d) issued by %s (%p)", SIMIX_request_name(req->call), req->call, + req->issuer->name, req->issuer); req->issuer->request.call = REQ_NO_REQ; xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, req->issuer); } diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 243adf3082..464fc34895 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -807,8 +807,7 @@ void SIMIX_req_comm_destroy(smx_action_t comm) { xbt_assert(comm, "Invalid parameter"); - /* FIXME remove this request type: comms are auto-destroyed now, - * but what happens with unfinished comms? */ + /* FIXME remove this request type: comms are auto-destroyed now */ /* smx_req_t req = SIMIX_req_mine(); diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 8fb18e696f..6f6e69504d 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -1931,6 +1931,7 @@ static void routing_parse_Speer(void) SURFXML_BUFFER_SET(host_availability_file, peer_availability_file); SURFXML_BUFFER_SET(host_state_file, peer_state_file); SURFXML_BUFFER_SET(host_coordinates, ""); + SURFXML_BUFFER_SET(host_core, "1.0"); SURFXML_START_TAG(host); SURFXML_END_TAG(host);