From 587fc1a190958ab7dbaaa3269e930e7776bd5b07 Mon Sep 17 00:00:00 2001 From: navarrop Date: Fri, 25 Feb 2011 12:03:54 +0000 Subject: [PATCH] Completely remove ruby and java from simgrid project. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9720 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- buildtools/Cmake/AddTests.cmake | 17 -- buildtools/Cmake/CompleteInFiles.cmake | 3 - buildtools/Cmake/DefinePackages.cmake | 24 -- buildtools/Cmake/Distrib.cmake | 29 -- buildtools/Cmake/MakeLib.cmake | 13 - buildtools/Cmake/Option.cmake | 5 - buildtools/Cmake/Pipol.cmake | 8 - buildtools/Cmake/PrintArgs.cmake | 2 - buildtools/Cmake/memcheck_tests.cmake | 10 - examples/{ruby => lua}/deploy.xml | 0 examples/lua/master_slave.lua | 2 +- examples/lua/mult_matrix.lua | 4 +- .../{ruby => lua}/quicksort_deployment.xml | 0 examples/{ruby => lua}/quicksort_platform.xml | 0 examples/ruby/MasterSlave.rb | 83 ------ examples/ruby/MasterSlave.tesh | 54 ---- examples/ruby/PingPong.rb | 88 ------- examples/ruby/PingPong.tesh | 14 - examples/ruby/Quicksort.rb | 106 -------- examples/ruby/Quicksort.tesh | 13 - examples/ruby/README | 58 ---- examples/ruby/ping_pong_deployment.xml | 8 - examples/ruby/ping_pong_platform.xml | 92 ------- examples/ruby/platform.xml | 90 ------- src/bindings/ruby/MasterSlave.rb | 86 ------ src/bindings/ruby/MasterSlaveData.rb | 89 ------- src/bindings/ruby/PingPong.rb | 93 ------- src/bindings/ruby/Quicksort.rb | 107 -------- src/bindings/ruby/basic_platform.xml | 91 ------- src/bindings/ruby/deploy.xml | 24 -- src/bindings/ruby/deploy2.xml | 15 -- src/bindings/ruby/ping_pong_deployment.xml | 8 - src/bindings/ruby/ping_pong_platform.xml | 92 ------- src/bindings/ruby/platform.xml | 91 ------- src/bindings/ruby/quicksort_deployment.xml | 14 - src/bindings/ruby/quicksort_platform.xml | 92 ------- src/bindings/ruby/rb_application_handler.c | 112 -------- src/bindings/ruby/rb_msg_host.c | 108 -------- src/bindings/ruby/rb_msg_process.c | 189 -------------- src/bindings/ruby/rb_msg_task.c | 223 ---------------- src/bindings/ruby/simgrid.rb | 247 ------------------ src/bindings/ruby/simgrid_ruby.c | 231 ---------------- src/bindings/ruby_bindings.h | 139 ---------- src/msg/task.c | 6 - src/simix/smx_context_ruby.c | 126 --------- 45 files changed, 3 insertions(+), 2903 deletions(-) rename examples/{ruby => lua}/deploy.xml (100%) rename examples/{ruby => lua}/quicksort_deployment.xml (100%) rename examples/{ruby => lua}/quicksort_platform.xml (100%) delete mode 100644 examples/ruby/MasterSlave.rb delete mode 100644 examples/ruby/MasterSlave.tesh delete mode 100644 examples/ruby/PingPong.rb delete mode 100644 examples/ruby/PingPong.tesh delete mode 100644 examples/ruby/Quicksort.rb delete mode 100644 examples/ruby/Quicksort.tesh delete mode 100644 examples/ruby/README delete mode 100644 examples/ruby/ping_pong_deployment.xml delete mode 100644 examples/ruby/ping_pong_platform.xml delete mode 100644 examples/ruby/platform.xml delete mode 100644 src/bindings/ruby/MasterSlave.rb delete mode 100644 src/bindings/ruby/MasterSlaveData.rb delete mode 100644 src/bindings/ruby/PingPong.rb delete mode 100644 src/bindings/ruby/Quicksort.rb delete mode 100644 src/bindings/ruby/basic_platform.xml delete mode 100644 src/bindings/ruby/deploy.xml delete mode 100644 src/bindings/ruby/deploy2.xml delete mode 100644 src/bindings/ruby/ping_pong_deployment.xml delete mode 100644 src/bindings/ruby/ping_pong_platform.xml delete mode 100644 src/bindings/ruby/platform.xml delete mode 100644 src/bindings/ruby/quicksort_deployment.xml delete mode 100644 src/bindings/ruby/quicksort_platform.xml delete mode 100644 src/bindings/ruby/rb_application_handler.c delete mode 100644 src/bindings/ruby/rb_msg_host.c delete mode 100644 src/bindings/ruby/rb_msg_process.c delete mode 100644 src/bindings/ruby/rb_msg_task.c delete mode 100644 src/bindings/ruby/simgrid.rb delete mode 100644 src/bindings/ruby/simgrid_ruby.c delete mode 100644 src/bindings/ruby_bindings.h delete mode 100644 src/simix/smx_context_ruby.c diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index 1f7604b6f9..1f854de6f7 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -370,16 +370,6 @@ set_tests_properties(lua-masterslave-bypass PROPERTIES ENVIRONMENT "LUA_CPATH set_tests_properties(lua-msg-masterslave-console PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/examples/lua/?.so") endif(HAVE_LUA) -# Ruby examples -if(HAVE_RUBY) -ADD_TEST(ruby-masterslave ${CMAKE_BINARY_DIR}/bin/tesh --cd ${CMAKE_HOME_DIRECTORY}/examples/ruby MasterSlave.tesh) -ADD_TEST(ruby-ping-pong ${CMAKE_BINARY_DIR}/bin/tesh --cd ${CMAKE_HOME_DIRECTORY}/examples/ruby PingPong.tesh) -ADD_TEST(ruby-quicksort ${CMAKE_BINARY_DIR}/bin/tesh --cd ${CMAKE_HOME_DIRECTORY}/examples/ruby Quicksort.tesh) -set_tests_properties(ruby-masterslave PROPERTIES ENVIRONMENT "RUBYLIB=${CMAKE_BINARY_DIR}/lib") -set_tests_properties(ruby-ping-pong PROPERTIES ENVIRONMENT "RUBYLIB=${CMAKE_BINARY_DIR}/lib") -set_tests_properties(ruby-quicksort PROPERTIES ENVIRONMENT "RUBYLIB=${CMAKE_BINARY_DIR}/lib") -endif(HAVE_RUBY) - # END TESH TESTS if(enable_smpi) @@ -424,13 +414,6 @@ set_tests_properties(amok-bandwidth-sg-64-raw amok-bandwidth-sg-64-thread amok-b set_tests_properties(amok-saturate-sg-64-raw amok-saturate-sg-64-thread amok-saturate-sg-64-ucontext PROPERTIES WILL_FAIL true) endif(${ARCH_32_BITS}) -if(HAVE_RUBY) -# for the moment with ruby 1.9 -> undefined method `release' -set_tests_properties(ruby-quicksort PROPERTIES WILL_FAIL true) -set_tests_properties(ruby-ping-pong PROPERTIES WILL_FAIL true) -set_tests_properties(ruby-masterslave PROPERTIES WILL_FAIL true) -endif(HAVE_RUBY) - endif(NOT enable_memcheck) ADD_TEST(tesh-simdag-full-links01 ${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms/basic_parsing_test ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms/two_clusters.xml FULL_LINK) diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index 48577c5edc..d9fd831056 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -20,9 +20,6 @@ endif(enable_pcre) if(enable_gtnets) include(FindGTnets) endif(enable_gtnets) -if(enable_ruby) - include(FindRubySimgrid) -endif(enable_ruby) if(enable_smpi) include(FindF2c) endif(enable_smpi) diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index b8331bcaad..33cc4c787b 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -327,14 +327,6 @@ set(JEDULE_SRC src/instr/jedule/jedule_sd_binding.c ) -set(RUBY_SRC - src/simix/smx_context_ruby.c - src/bindings/ruby/rb_msg_process.c - src/bindings/ruby/rb_msg_host.c - src/bindings/ruby/rb_msg_task.c - src/bindings/ruby/rb_application_handler.c -) - set(MC_SRC src/mc/mc_memory.c src/mc/mc_checkpoint.c @@ -499,21 +491,6 @@ elseif(${HAVE_LUA}) ) endif(${HAVE_LUA}) - -if(${HAVE_RUBY}) - set(simgrid_sources - ${simgrid_sources} - ${RUBY_SRC} - src/bindings/ruby/simgrid_ruby.c - ) -else(${HAVE_RUBY}) - set(EXTRA_DIST - ${EXTRA_DIST} - ${RUBY_SRC} - src/bindings/ruby/simgrid_ruby.c - ) -endif(${HAVE_RUBY}) - file(GLOB_RECURSE examples_to_install_in_doc "examples/*.c" "examples/*.h" @@ -814,7 +791,6 @@ set(source_to_pack ${GRAS_SG_SRC} ${AMOK_SRC} ${LUA_SRC} - ${RUBY_SRC} ${MC_SRC} ${add_src_files} ${include_files} diff --git a/buildtools/Cmake/Distrib.cmake b/buildtools/Cmake/Distrib.cmake index e1968f93aa..a17eb4dc33 100644 --- a/buildtools/Cmake/Distrib.cmake +++ b/buildtools/Cmake/Distrib.cmake @@ -99,25 +99,6 @@ if(HAVE_LUA) ) endif(HAVE_LUA) -if(HAVE_RUBY) - string(REGEX REPLACE "^.*ruby/" "" install_link_ruby "${RUBY_ARCH_DIR}") - file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}") - add_custom_target(ruby_simgrid ALL - DEPENDS simgrid - ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE} - ) - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE} - COMMAND ${CMAKE_COMMAND} -E create_symlink ../../../libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE} - ) - install(FILES ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE} - DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/ruby/${install_link_ruby}/ - ) - install(FILES ${CMAKE_HOME_DIRECTORY}/src/bindings/ruby/simgrid.rb - DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/ruby/${install_link_ruby}/) - -endif(HAVE_RUBY) - ########################################### ### Fill in the "make uninstall" target ### ########################################### @@ -162,16 +143,6 @@ if(HAVE_LUA) ) endif(HAVE_LUA) -if(HAVE_RUBY) - string(REGEX REPLACE "^.*ruby/" "" install_link_ruby "${RUBY_ARCH_DIR}") - add_custom_command(TARGET uninstall - COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding ruby ok" - COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE} - COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/ruby/${install_link_ruby}/simgrid.rb - WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}/" - ) -endif(HAVE_RUBY) - ################################################################ ## Build a sain "make dist" target to build a source package ### ## containing only the files that I explicitely state ### diff --git a/buildtools/Cmake/MakeLib.cmake b/buildtools/Cmake/MakeLib.cmake index a1fb29c823..e5902b8bd4 100644 --- a/buildtools/Cmake/MakeLib.cmake +++ b/buildtools/Cmake/MakeLib.cmake @@ -77,19 +77,6 @@ if(HAVE_PCRE_LIB) SET(SIMGRID_DEP "${SIMGRID_DEP} -lpcre") endif(HAVE_PCRE_LIB) -if(HAVE_RUBY) - set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME}") - ADD_CUSTOM_TARGET(link_simgrid_ruby ALL - DEPENDS simgrid ${CMAKE_BINARY_DIR}/src/bindings/ruby/libsimgrid.${LIB_EXE} - ) - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/src/bindings/ruby/libsimgrid.${LIB_EXE} - COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/src/bindings/ruby/libsimgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/src/bindings/ruby/ - COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/src/bindings/ruby/libsimgrid.${LIB_EXE} - ) -endif(HAVE_RUBY) - if(pthread) if(${CONTEXT_THREADS}) SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread") diff --git a/buildtools/Cmake/Option.cmake b/buildtools/Cmake/Option.cmake index c7d2db7428..c942375f58 100644 --- a/buildtools/Cmake/Option.cmake +++ b/buildtools/Cmake/Option.cmake @@ -16,16 +16,13 @@ endif(NOT CMAKE_INSTALL_PREFIX) set(pipol_user ${pipol_user} CACHE TYPE INTERNAL FORCE) option(enable_gtnets "Whether gtnets model is activated." on) -option(enable_java "Whether the Java bindings are activated." off) option(enable_smpi "This variable set smpi lib." on) option(enable_lua "Whether the lua bindings are activated." on) -option(enable_ruby "Whether the Ruby bindings are activated." on) option(enable_pcre "Whether the pcre lib is activated." on) if(WIN32 OR APPLE) set(enable_smpi off CACHE TYPE INTERNAL FORCE) set(enable_lua off CACHE TYPE INTERNAL FORCE) -set(enable_ruby off CACHE TYPE INTERNAL FORCE) endif(WIN32 OR APPLE) option(enable_compile_optimizations "" on) @@ -53,8 +50,6 @@ mark_as_advanced(HAVE_RSYNC) #mark_as_advanced(enable_memcheck) #mark_as_advanced(enable_print_message) mark_as_advanced(BIBTEX2HTML_PATH) -mark_as_advanced(RUBY_LIB_PATH_1) -mark_as_advanced(RUBY_LIB_PATH_2) mark_as_advanced(BUILDNAME) mark_as_advanced(ADDR2LINE) mark_as_advanced(BIBTOOL_PATH) diff --git a/buildtools/Cmake/Pipol.cmake b/buildtools/Cmake/Pipol.cmake index 4f796f06e2..b01c5748d8 100644 --- a/buildtools/Cmake/Pipol.cmake +++ b/buildtools/Cmake/Pipol.cmake @@ -20,18 +20,10 @@ IF(pipol_user) set(CMAKE_OPTIONS "${CMAKE_OPTIONS} -Denable_smpi=on") endif(enable_smpi) - if(enable_java) - set(CMAKE_OPTIONS "${CMAKE_OPTIONS} -Denable_java=on") - endif(enable_java) - if(enable_lua) set(CMAKE_OPTIONS "${CMAKE_OPTIONS} -Denable_lua=on") endif(enable_lua) - if(enable_ruby) - set(CMAKE_OPTIONS "${CMAKE_OPTIONS} -Denable_ruby=on") - endif(enable_ruby) - if(enable_compile_optimizations) set(CMAKE_OPTIONS "${CMAKE_OPTIONS} -Denable_compile_optimizations=on") endif(enable_compile_optimizations) diff --git a/buildtools/Cmake/PrintArgs.cmake b/buildtools/Cmake/PrintArgs.cmake index 46c9443669..4f626b4ec2 100644 --- a/buildtools/Cmake/PrintArgs.cmake +++ b/buildtools/Cmake/PrintArgs.cmake @@ -91,9 +91,7 @@ if(NOT APPLE AND NOT WIN32) message(" Compile Gtnets : ${HAVE_GTNETS}") message(" Gtnets path : ${gtnets_path}") endif(NOT APPLE AND NOT WIN32) -message(" Compile Java : ${HAVE_JAVA}") message(" Compile Lua : ${HAVE_LUA}") -message(" Compile Ruby : ${HAVE_RUBY}") message(" Compile Smpi : ${enable_smpi}") message(" Compile Static : ${enable_lib_static}") message("") diff --git a/buildtools/Cmake/memcheck_tests.cmake b/buildtools/Cmake/memcheck_tests.cmake index ad6d65ecf0..f1452ca0e4 100644 --- a/buildtools/Cmake/memcheck_tests.cmake +++ b/buildtools/Cmake/memcheck_tests.cmake @@ -556,13 +556,3 @@ set_tests_properties(memcheck-lua-masterslave-bypass-0 PROPERTIES ENVIRONMENT set_tests_properties(memcheck-lua-msg-masterslave-console-0 PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/examples/lua/?.so") endif(HAVE_LUA) -# Ruby examples -if(HAVE_RUBY) -ADD_TEST(memcheck-ruby-masterslave-0 ruby -I ../../src/bindings/ruby MasterSlave.rb --cd /home/navarrop/simgrid/simgrid/trunk/examples/ruby/) -ADD_TEST(memcheck-ruby-ping-pong-0 ruby -I ../../src/bindings/ruby PingPong.rb --cd /home/navarrop/simgrid/simgrid/trunk/examples/ruby/) -ADD_TEST(memcheck-ruby-quicksort-0 ruby -I ../../src/bindings/ruby Quicksort.rb --cd /home/navarrop/simgrid/simgrid/trunk/examples/ruby/) -set_tests_properties(memcheck-ruby-masterslave-0 PROPERTIES ENVIRONMENT "RUBYLIB=${CMAKE_BINARY_DIR}/lib") -set_tests_properties(memcheck-ruby-ping-pong-0 PROPERTIES ENVIRONMENT "RUBYLIB=${CMAKE_BINARY_DIR}/lib") -set_tests_properties(memcheck-ruby-quicksort-0 PROPERTIES ENVIRONMENT "RUBYLIB=${CMAKE_BINARY_DIR}/lib") -endif(HAVE_RUBY) - diff --git a/examples/ruby/deploy.xml b/examples/lua/deploy.xml similarity index 100% rename from examples/ruby/deploy.xml rename to examples/lua/deploy.xml diff --git a/examples/lua/master_slave.lua b/examples/lua/master_slave.lua index 1aca1b9282..9c28bd0c41 100644 --- a/examples/lua/master_slave.lua +++ b/examples/lua/master_slave.lua @@ -73,7 +73,7 @@ simgrid.platform(arg[1]) simgrid.application(arg[2]) else simgrid.platform("../msg/small_platform.xml") -simgrid.application("../ruby/deploy.xml") +simgrid.application("deploy.xml") end simgrid.run() simgrid.info("Simulation's over.See you.") diff --git a/examples/lua/mult_matrix.lua b/examples/lua/mult_matrix.lua index a026691e0f..afe53bf36d 100644 --- a/examples/lua/mult_matrix.lua +++ b/examples/lua/mult_matrix.lua @@ -90,8 +90,8 @@ end --end require "simgrid" -simgrid.platform("../ruby/quicksort_platform.xml") -simgrid.application("../ruby/quicksort_deployment.xml") +simgrid.platform("quicksort_platform.xml") +simgrid.application("quicksort_deployment.xml") simgrid.run() simgrid.info("Simulation's over.See you.") simgrid.clean() diff --git a/examples/ruby/quicksort_deployment.xml b/examples/lua/quicksort_deployment.xml similarity index 100% rename from examples/ruby/quicksort_deployment.xml rename to examples/lua/quicksort_deployment.xml diff --git a/examples/ruby/quicksort_platform.xml b/examples/lua/quicksort_platform.xml similarity index 100% rename from examples/ruby/quicksort_platform.xml rename to examples/lua/quicksort_platform.xml diff --git a/examples/ruby/MasterSlave.rb b/examples/ruby/MasterSlave.rb deleted file mode 100644 index 198c4caedc..0000000000 --- a/examples/ruby/MasterSlave.rb +++ /dev/null @@ -1,83 +0,0 @@ -require 'simgrid' -include MSG -################################################# -# Class Master -################################################# - -class Master < MSG::Process - # main : that function that will be executed when running simulation - - def main(args) # args is an array containing arguments for function master - size = args.size - for i in 0..size-1 - MSG::info("args["+String(i)+"]="+args[i]) - end - - raise "Master needs 3 arguments" if size < 3 - numberOfTask = Integer(args[0]) - taskComputeSize = Float(args[1]) - taskCommunicationSize = Float(args[2]) - slaveCount = Integer(args[3]) - - # Creates and sends the tasks - for i in 0..numberOfTask-1 - task = Task.new("Task_"+ i.to_s, taskComputeSize , taskCommunicationSize); - mailbox = "slave " + (i%slaveCount).to_s - MSG::info("Master Sending "+ task.name + " to " + mailbox + " with Comput Size " + - task.compSize.to_s) - task.send(mailbox) - MSG::info("Master Done Sending " + task.name + " to " + mailbox) - end - - # Sending Finalize MSG::Tasks - #MSG::info("Master: All "+numberOfTask+" tasks have been dispatched. Let's tell everybody the computation is over.") - MSG::info("Master: All tasks have been dispatched. Let's tell everybody the computation is over.") - for i in 0..slaveCount-1 - mailbox = "slave " + i.to_s - finalize_task = Task.new("finalize",0,0) - finalize_task.send(mailbox) - end - MSG::info("Master : Everything's Done") - end -end - -# end_of_master - -################################################# -# Class Slave -################################################# -class Slave < MSG::Process - - def main(args) - mailbox = "slave " + args[0] - for i in 0..args.size-1 - MSG::debug("args["+String(i)+"]="+args[i]) - end - - while true - task = Task.receive(mailbox) - if (task.name == "finalize") - break - end - task.execute - MSG::debug("Slave '" + mailbox + "' done executing task "+ task.name + ".") - end - MSG::info("I'm done, see you") - end -end - -# end_of_slave - -################################################# -# main chunck -################################################# -if (ARGV.length == 2) - MSG.createEnvironment(ARGV[0]) - MSG.deployApplication(ARGV[1]) -else - MSG.createEnvironment("platform.xml") - MSG.deployApplication("deploy.xml") -end -MSG.run -puts "Simulation time : " + MSG.getClock .to_s -MSG.exit diff --git a/examples/ruby/MasterSlave.tesh b/examples/ruby/MasterSlave.tesh deleted file mode 100644 index 5b54ad5ce1..0000000000 --- a/examples/ruby/MasterSlave.tesh +++ /dev/null @@ -1,54 +0,0 @@ -# MasterSlave Ruby Example - -$ ruby -I ../../src/bindings/ruby MasterSlave.rb -> [Tremblay:Master:(1) 0.000000] [ruby/INFO] args[0]=20 -> [Tremblay:Master:(1) 0.000000] [ruby/INFO] args[1]=50000000 -> [Tremblay:Master:(1) 0.000000] [ruby/INFO] args[2]=1000000 -> [Tremblay:Master:(1) 0.000000] [ruby/INFO] args[3]=4 -> [Tremblay:Master:(1) 0.000000] [ruby/INFO] Master Sending Task_0 to slave 0 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 0.215872] [ruby/INFO] Master Done Sending Task_0 to slave 0 -> [Tremblay:Master:(1) 0.215872] [ruby/INFO] Master Sending Task_1 to slave 1 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 0.381834] [ruby/INFO] Master Done Sending Task_1 to slave 1 -> [Tremblay:Master:(1) 0.381834] [ruby/INFO] Master Sending Task_2 to slave 2 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 0.599987] [ruby/INFO] Master Done Sending Task_2 to slave 2 -> [Tremblay:Master:(1) 0.599987] [ruby/INFO] Master Sending Task_3 to slave 3 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 0.740447] [ruby/INFO] Master Done Sending Task_3 to slave 3 -> [Tremblay:Master:(1) 0.740447] [ruby/INFO] Master Sending Task_4 to slave 0 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 1.462843] [ruby/INFO] Master Done Sending Task_4 to slave 0 -> [Tremblay:Master:(1) 1.462843] [ruby/INFO] Master Sending Task_5 to slave 1 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 1.628804] [ruby/INFO] Master Done Sending Task_5 to slave 1 -> [Tremblay:Master:(1) 1.628804] [ruby/INFO] Master Sending Task_6 to slave 2 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 1.846957] [ruby/INFO] Master Done Sending Task_6 to slave 2 -> [Tremblay:Master:(1) 1.846957] [ruby/INFO] Master Sending Task_7 to slave 3 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 1.987417] [ruby/INFO] Master Done Sending Task_7 to slave 3 -> [Tremblay:Master:(1) 1.987417] [ruby/INFO] Master Sending Task_8 to slave 0 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 2.709813] [ruby/INFO] Master Done Sending Task_8 to slave 0 -> [Tremblay:Master:(1) 2.709813] [ruby/INFO] Master Sending Task_9 to slave 1 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 2.875775] [ruby/INFO] Master Done Sending Task_9 to slave 1 -> [Tremblay:Master:(1) 2.875775] [ruby/INFO] Master Sending Task_10 to slave 2 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 3.093928] [ruby/INFO] Master Done Sending Task_10 to slave 2 -> [Tremblay:Master:(1) 3.093928] [ruby/INFO] Master Sending Task_11 to slave 3 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 3.234387] [ruby/INFO] Master Done Sending Task_11 to slave 3 -> [Tremblay:Master:(1) 3.234387] [ruby/INFO] Master Sending Task_12 to slave 0 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 3.956783] [ruby/INFO] Master Done Sending Task_12 to slave 0 -> [Tremblay:Master:(1) 3.956783] [ruby/INFO] Master Sending Task_13 to slave 1 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 4.122745] [ruby/INFO] Master Done Sending Task_13 to slave 1 -> [Tremblay:Master:(1) 4.122745] [ruby/INFO] Master Sending Task_14 to slave 2 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 4.340898] [ruby/INFO] Master Done Sending Task_14 to slave 2 -> [Tremblay:Master:(1) 4.340898] [ruby/INFO] Master Sending Task_15 to slave 3 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 4.481357] [ruby/INFO] Master Done Sending Task_15 to slave 3 -> [Tremblay:Master:(1) 4.481357] [ruby/INFO] Master Sending Task_16 to slave 0 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 5.203753] [ruby/INFO] Master Done Sending Task_16 to slave 0 -> [Tremblay:Master:(1) 5.203753] [ruby/INFO] Master Sending Task_17 to slave 1 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 5.369715] [ruby/INFO] Master Done Sending Task_17 to slave 1 -> [Tremblay:Master:(1) 5.369715] [ruby/INFO] Master Sending Task_18 to slave 2 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 5.587868] [ruby/INFO] Master Done Sending Task_18 to slave 2 -> [Tremblay:Master:(1) 5.587868] [ruby/INFO] Master Sending Task_19 to slave 3 with Comput Size 50000000.0 -> [Tremblay:Master:(1) 5.728328] [ruby/INFO] Master Done Sending Task_19 to slave 3 -> [Tremblay:Master:(1) 5.728328] [ruby/INFO] Master: All tasks have been dispatched. Let's tell everybody the computation is over. -> [Bourassa:Slave:(2) 6.255187] [ruby/INFO] I'm done, see you -> [Jupiter:Slave:(3) 6.270387] [ruby/INFO] I'm done, see you -> [Fafard:Slave:(4) 6.290937] [ruby/INFO] I'm done, see you -> [Tremblay:Master:(1) 6.772657] [ruby/INFO] Master : Everything's Done -> [Ginette:Slave:(5) 6.772657] [ruby/INFO] I'm done, see you -> Simulation time : 6.77265731195289 diff --git a/examples/ruby/PingPong.rb b/examples/ruby/PingPong.rb deleted file mode 100644 index 26a79f07e1..0000000000 --- a/examples/ruby/PingPong.rb +++ /dev/null @@ -1,88 +0,0 @@ -require 'simgrid' - -include MSG - -##################### -#PingPongTask Class -##################### - -class PingPongTask < MSG::Task - - # The initialize method has no effect - @time - def setTime(t) - @time = t - end - - def getTime() - return @time - end -end - -#################### -# Sender Class -#################### - -class Sender < MSG::Process - - def main(args) - MSG::info("Hello from Sender") - hostCount = args.size - MSG::info("Host count :" + hostCount.to_s) - mailboxes = Array.new - - for i in 0..hostCount-1 - mailboxes<< MSG::Host.getByName(args[i]).name - end - - for i in 0..hostCount-1 - time = MSG.getClock - MSG::info("sender time :"+time.to_s) - task = PingPongTask.new("PingTask",10000,2000) - MSG::info("task created :" + task.name); - #task.join(time) -- MSG::task.join(data) is a Native method you can use to attach any data you want to the task - task.setTime(time) - task.send(mailboxes[i]) - end - MSG::info("Bye!!") - end - end - -#################### -# Receiver Class -#################### - -class Receiver < MSG::Process - - def main(args) - MSG::info("Hello from Receiver") - time = MSG.getClock - host = MSG::Host.getHostProcess(self) - task = PingPongTask.receive(host.name) - timeGot = MSG.getClock - MSG::info("Got at time: "+timeGot.to_s) - #timeSent = task.data -- - timeSent = task.getTime - MSG::info("Was sent at time "+timeSent.to_s) - communicationTime = timeGot - time - MSG::info("Communication Time: "+communicationTime.to_s) - MSG::info("--- bw "+(100000000/communicationTime).to_s+" ----") - MSG::info("Bye!!") - end - -end - -################################################# -# main chunck -################################################# - -if (ARGV.length == 2) - MSG.createEnvironment(ARGV[0]) - MSG.deployApplication(ARGV[1]) -else - MSG.createEnvironment("ping_pong_platform.xml") - MSG.deployApplication("ping_pong_deployment.xml") -end - -MSG.run -MSG.exit diff --git a/examples/ruby/PingPong.tesh b/examples/ruby/PingPong.tesh deleted file mode 100644 index 90380e5253..0000000000 --- a/examples/ruby/PingPong.tesh +++ /dev/null @@ -1,14 +0,0 @@ -#PingPong Example - -$ ruby -I ../../src/bindings/ruby PingPong.rb -> [Inmos:Sender:(1) 0.000000] [ruby/INFO] Hello from Sender -> [Inmos:Sender:(1) 0.000000] [ruby/INFO] Host count :1 -> [Inmos:Sender:(1) 0.000000] [ruby/INFO] sender time :0.0 -> [Inmos:Sender:(1) 0.000000] [ruby/INFO] task created :PingTask -> [Bellevue:Receiver:(2) 0.000000] [ruby/INFO] Hello from Receiver -> [Inmos:Sender:(1) 0.015501] [ruby/INFO] Bye!! -> [Bellevue:Receiver:(2) 0.015501] [ruby/INFO] Got at time: 0.0155013008533275 -> [Bellevue:Receiver:(2) 0.015501] [ruby/INFO] Was sent at time 0.0 -> [Bellevue:Receiver:(2) 0.015501] [ruby/INFO] Communication Time: 0.0155013008533275 -> [Bellevue:Receiver:(2) 0.015501] [ruby/INFO] --- bw 6451071490.46357 ---- -> [Bellevue:Receiver:(2) 0.015501] [ruby/INFO] Bye!! diff --git a/examples/ruby/Quicksort.rb b/examples/ruby/Quicksort.rb deleted file mode 100644 index 6c1b5500a7..0000000000 --- a/examples/ruby/Quicksort.rb +++ /dev/null @@ -1,106 +0,0 @@ -# Debug it with this command: -# make -C ../.. && valgrind ruby MasterSlave.rb --log=ruby.thres:debug 2>&1 | less - -require 'simgrid' - -include MSG - - -################################################# -# Class Asker -################################################# - -class Sender < MSG::Process - # main : that function that will be executed when running simulation - def main(args) # args is an array containing arguments for function master - - hardworking_friend = MSG::Host.getByName(args[0]).name - taskComputeSize = Float(args[1]) - taskCommunicationSize = Float(args[2]) - send_mailbox =args[3] - - myTable = Array.new - myTable <<1<<-2<<45<<67<<87<<76<<89<<56<<78<<3<<-4<<99 - MSG::info("Hello " + hardworking_friend + " !!, Please !! I need you to help me to sort my table , Here it is :") - p myTable - # Creates and send Task With the Table inside - task = MSG::Task.new("quicksort_task",taskComputeSize, taskCommunicationSize); - task.join(myTable); - MSG::debug("Sending "+ task.name + " to " + send_mailbox + " with Comput Size " + - task.compSize.to_s) - task.send(send_mailbox) - MSG::debug("Done Sending " + task.name + " to " + send_mailbox) - - #waiting for results - - recv_mailbox = self.class - res_task = MSG::Task.receive(recv_mailbox.to_s) - result = res_task.data - MSG::info("Greate !! Thx !!") - MSG::info("Here is my table after a quicksort :)") - p result - MSG::info("Bye Now :)") - end - -end - - -################################################# -# Class Clever -################################################# -class Receiver < MSG::Process - - def main(args) - - lazy_friend = MSG::Host.getByName(args[0]).name - send_mailbox = args[1] - recv_mailbox = self.class - MSG::info("Receiving Table from "+lazy_friend) - task = MSG::Task.receive(recv_mailbox.to_s) - table = task.data - quicksort(table,0,table.size-1) - task.join(table) - MSG::info("Sort Done ... Sending Back the new table") - task.send(send_mailbox) - MSG::info("Bye lazy Boy!!") - - end - - def quicksort(list, p, r) - if p < r then - q = partition(list, p, r) - quicksort(list, p, q-1) - quicksort(list, q+1, r) - end -end - -def partition(list, p, r) - pivot = list[r] - i = p - 1 - p.upto(r-1) do |j| - if list[j] <= pivot - i = i+1 - list[i], list[j] = list[j],list[i] - end - end - list[i+1],list[r] = list[r],list[i+1] - return i + 1 -end - -end - -################################################# -# main chunck -################################################# - -if (ARGV.length == 2) - MSG.createEnvironment(ARGV[0]) - MSG.deployApplication(ARGV[1]) -else - MSG.createEnvironment("quicksort_platform.xml") - MSG.deployApplication("quicksort_deployment.xml") -end - -MSG.run -puts "Simulation time : " + MSG.getClock .to_s -MSG.exit diff --git a/examples/ruby/Quicksort.tesh b/examples/ruby/Quicksort.tesh deleted file mode 100644 index 152036472e..0000000000 --- a/examples/ruby/Quicksort.tesh +++ /dev/null @@ -1,13 +0,0 @@ -#QuickSort Ruby Example - -$ ruby -I ../../src/bindings/ruby Quicksort.rb -> [Inmos:Sender:(1) 0.000000] [ruby/INFO] Hello Bellevue !!, Please !! I need you to help me to sort my table , Here it is : -> [1, -2, 45, 67, 87, 76, 89, 56, 78, 3, -4, 99] -> [Bellevue:Receiver:(2) 0.000000] [ruby/INFO] Receiving Table from Inmos -> [Bellevue:Receiver:(2) 0.030276] [ruby/INFO] Sort Done ... Sending Back the new table -> [Inmos:Sender:(1) 0.060552] [ruby/INFO] Greate !! Thx !! -> [Inmos:Sender:(1) 0.060552] [ruby/INFO] Here is my table after a quicksort :) -> [-4, -2, 1, 3, 45, 56, 67, 76, 78, 87, 89, 99] -> [Inmos:Sender:(1) 0.060552] [ruby/INFO] Bye Now :) -> [Bellevue:Receiver:(2) 0.060552] [ruby/INFO] Bye lazy Boy!! -> Simulation time : 0.0605519589327544 diff --git a/examples/ruby/README b/examples/ruby/README deleted file mode 100644 index 6a1d538907..0000000000 --- a/examples/ruby/README +++ /dev/null @@ -1,58 +0,0 @@ - -Examples containing in this directory - -=============================================================================== -* MasterSlave.rb -=============================================================================== - - Description: - Simple master slave application - - - Platform Files: - platform.xml - - - Deployment Files: - deploy.xml - - - Execute: - (WARNING: the current directory must be examples/ruby/) - ruby -I ../../src/bindings/ruby MasterSlave.rb - -=============================================================================== -* PingPong.rb -=============================================================================== - - Description: - This is a stupid ping/pong example. The processes exchange a simple - task and time them - NB : in this example we inherit MSG::Task to make our PingPongTask with - our own methods - - - Platform Files: - ping_pong_platform.xml - - - Deployment Files: - ping_pong_deployment.xml - - - Execute: - (WARNING: the current directory must be examples/ruby/) - ruby -I ../../src/bindings/ruby PingPong.rb - -================================================================================ -* Quicksort.rb -================================================================================ - - Description: - simple example to show how to exchange data between two process (ruby) - in this example : - *Process Sender : send a task with a table , receive and print the result - *Process Receiver : receiving and sorting the 'Sender' table - NB: in the example we use the methods MSG::Task.join(data) and MSG::Task.data() to exchange data - - - Platform Files: - quicksort_platform.xml - - - Deployment Files: - quicksort_deployment.xml - - - Execute: - (WARNING: the current directory must be examples/ruby/) - ruby -I ../../src/bindings/ruby Quicksort.rb - diff --git a/examples/ruby/ping_pong_deployment.xml b/examples/ruby/ping_pong_deployment.xml deleted file mode 100644 index c26a3154d5..0000000000 --- a/examples/ruby/ping_pong_deployment.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/examples/ruby/ping_pong_platform.xml b/examples/ruby/ping_pong_platform.xml deleted file mode 100644 index 12679166a3..0000000000 --- a/examples/ruby/ping_pong_platform.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/ruby/platform.xml b/examples/ruby/platform.xml deleted file mode 100644 index c72c033fe8..0000000000 --- a/examples/ruby/platform.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/bindings/ruby/MasterSlave.rb b/src/bindings/ruby/MasterSlave.rb deleted file mode 100644 index 7c1ca60a04..0000000000 --- a/src/bindings/ruby/MasterSlave.rb +++ /dev/null @@ -1,86 +0,0 @@ -# Debug it with this command: -# make -C ../.. && valgrind ruby MasterSlave.rb --log=ruby.thres:debug 2>&1 | less - -require 'simgrid' - -include MSG - -################################################# -# Class Master -################################################# - -class Master < MSG::Process - # main : that function that will be executed when running simulation - - def main(args) # args is an array containing arguments for function master - size = args.size - for i in 0..size-1 - MSG::info("args["+String(i)+"]="+args[i]) - end - - raise "Master needs 3 arguments" if size < 3 - numberOfTask = Integer(args[0]) - taskComputeSize = Float(args[1]) - taskCommunicationSize = Float(args[2]) - slaveCount = Integer(args[3]) - - # Creates and sends the tasks - for i in 0..numberOfTask-1 - task = MSG::Task.new("Task_"+ i.to_s, taskComputeSize , taskCommunicationSize); - mailbox = "slave " + (i%slaveCount).to_s - MSG::debug("Master Sending "+ task.name + " to " + mailbox + " with Comput Size " + - task.compSize.to_s) - task.send(mailbox) - MSG::debug("Master Done Sending " + task.name + " to " + mailbox) - end - - # Sending Finalize MSG::Tasks - #MSG::info("Master: All "+numberOfTask+" tasks have been dispatched. Let's tell everybody the computation is over.") - MSG::info("Master: All tasks have been dispatched. Let's tell everybody the computation is over.") - for i in 0..slaveCount-1 - mailbox = "slave " + i.to_s - finalize_task = Task.new("finalize",0,0) - finalize_task.send(mailbox) - end - MSG::info("Master : Everything's Done") - end -end - -################################################# -# Class Slave -################################################# -class Slave < MSG::Process - - def main(args) - mailbox = "slave " + args[0] - for i in 0..args.size-1 - MSG::debug("args["+String(i)+"]="+args[i]) - end - - while true - task = MSG::Task.receive(mailbox) - if (task.name == "finalize") - break - end - task.execute - MSG::debug("Slave '" + mailbox + "' done executing task "+ task.name + ".") - end - MSG::info("I'm done, see you") - end -end - -################################################# -# main chunck -################################################# - -if (ARGV.length == 2) - MSG.createEnvironment(ARGV[0]) - MSG.deployApplication(ARGV[1]) -else - MSG.createEnvironment("platform.xml") - MSG.deployApplication("deploy.xml") -end - -MSG.run -puts "Simulation time : " + MSG.getClock .to_s -MSG.exit diff --git a/src/bindings/ruby/MasterSlaveData.rb b/src/bindings/ruby/MasterSlaveData.rb deleted file mode 100644 index 8d4901aa5c..0000000000 --- a/src/bindings/ruby/MasterSlaveData.rb +++ /dev/null @@ -1,89 +0,0 @@ -# Debug it with this command: -# make -C ../.. && valgrind ruby MasterSlave.rb --log=ruby.thres:debug 2>&1 | less - -require 'simgrid' - -include MSG - -################################################# -# Class Master -################################################# - -class Master < MSG::Process - # main : that function that will be executed when running simulation - - def main(args) # args is an array containing arguments for function master - size = args.size - for i in 0..size-1 - MSG::info("args["+String(i)+"]="+args[i]) - end - - raise "Master needs 3 arguments" if size < 3 - numberOfTask = Integer(args[0]) - taskComputeSize = Float(args[1]) - taskCommunicationSize = Float(args[2]) - slaveCount = Integer(args[3]) - - # Creates and sends the tasks - for i in 0..numberOfTask-1 - task = MSG::Task.new("Task_"+ i.to_s, taskComputeSize , taskCommunicationSize); - task.setData("a messgae..."); - mailbox = "slave " + (i%slaveCount).to_s - MSG::debug("Master Sending "+ task.name + " to " + mailbox + " with Comput Size " + - task.compSize.to_s) - task.send(mailbox) - MSG::debug("Master Done Sending " + task.name + " to " + mailbox) - end - - # Sending Finalize MSG::Tasks - #MSG::info("Master: All "+numberOfTask+" tasks have been dispatched. Let's tell everybody the computation is over.") - MSG::info("Master: All tasks have been dispatched. Let's tell everybody the computation is over.") - for i in 0..slaveCount-1 - mailbox = "slave " + i.to_s - finalize_task = Task.new("finalize",0,0) - finalize_task.send(mailbox) - end - MSG::info("Master : Everything's Done") - end -end - -################################################# -# Class Slave -################################################# -class Slave < MSG::Process - - def main(args) - mailbox = "slave " + args[0] - for i in 0..args.size-1 - MSG::debug("args["+String(i)+"]="+args[i]) - end - - while true - task = MSG::Task.receive(mailbox) - data = task.data if (task.hasData) - MSG::info("The data inside was :" + data) - if (task.name == "finalize") - break - end - task.execute - MSG::debug("Slave '" + mailbox + "' done executing task "+ task.name + ".") - end - MSG::info("I'm done, see you") - end -end - -################################################# -# main chunck -################################################# - -if (ARGV.length == 2) - MSG.createEnvironment(ARGV[0]) - MSG.deployApplication(ARGV[1]) -else - MSG.createEnvironment("platform.xml") - MSG.deployApplication("deploy.xml") -end - -MSG.run -puts "Simulation time : " + MSG.getClock .to_s -MSG.exit diff --git a/src/bindings/ruby/PingPong.rb b/src/bindings/ruby/PingPong.rb deleted file mode 100644 index 57adbc42f3..0000000000 --- a/src/bindings/ruby/PingPong.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'simgrid' - -include MSG - -##################### -#PingPongTask Class -##################### - -class PingPongTask < MSG::Task - - def initialize(*args) - puts "Here is the ping pong initializer" - #Has No Role, Since Its The Task Class ( Created from C ) tht will be called , - # and any instruction here will be ignored - end - -end - -#################### -# Sender Class -#################### - -class Sender < MSG::Process - - def main(args) - MSG::info("Hello from Sender") - hostCount = args.size - MSG::info("Host count :" + hostCount.to_s) - mailboxes = Array.new - - for i in 0..hostCount-1 - - mailboxes<< MSG::Host.getByName(args[i]).name - -# FIXME Handel Exceptions - end - - for i in 0..hostCount-1 - time = MSG.getClock - MSG::info("sender time :"+time.to_s) - task = PingPongTask.new("PingTask",10000,2000) - MSG::info("task created :" + task.name); - task.setData(time) - p "mailboxe >>> "+ mailboxes[i] - task.send(mailboxes[i]) - end - - MSG::info("GoodBye !!!") - - end - - end - -#################### -# Receiver Class -#################### - -class Receiver < MSG::Process - - def main(args) - MSG::info("Hello from Receiver") - time = MSG.getClock - MSG::info("Try to get a task") - host = MSG::Host.getHostProcess(self) - task = PingPongTask.receive(host.name) - p "task name recevied : "+ task.name - timeGot = MSG.getClock - MSG::info("Got at time: "+timeGot.to_s) - timeSent = task.data - MSG::info("Was sent at time "+timeSent.to_s) - communicationTime = timeGot - time - MSG::info("Communication Time: "+communicationTime.to_s) - MSG::info("--- bw "+(100000000/communicationTime).to_s+" ----") - MSG::info("GoodBye !!!") - end - -end - -################################################# -# main chunck -################################################# - -if (ARGV.length == 2) - MSG.createEnvironment(ARGV[0]) - MSG.deployApplication(ARGV[1]) -else - MSG.createEnvironment("ping_pong_platform.xml") - MSG.deployApplication("ping_pong_deployment.xml") -end - -MSG.run -MSG.exit - \ No newline at end of file diff --git a/src/bindings/ruby/Quicksort.rb b/src/bindings/ruby/Quicksort.rb deleted file mode 100644 index 2b336029d3..0000000000 --- a/src/bindings/ruby/Quicksort.rb +++ /dev/null @@ -1,107 +0,0 @@ -# Debug it with this command: -# make -C ../.. && valgrind ruby MasterSlave.rb --log=ruby.thres:debug 2>&1 | less - -require 'simgrid' - -include MSG - -################################################# -# Class Asker -################################################# - -class Sender < MSG::Process - # main : that function that will be executed when running simulation - def main(args) # args is an array containing arguments for function master - - hardworking_friend = MSG::Host.getByName(args[0]).name - taskComputeSize = Float(args[1]) - taskCommunicationSize = Float(args[2]) - send_mailbox =args[3] - - myTable = Array.new - myTable <<1<<-2<<45<<67<<87<<76<<89<<56<<78<<3<<-4<<99 - MSG::info("Hello " + hardworking_friend + " !!, Please !! I need you to help me to sort my table , Here it is :") - p myTable - # Creates and send Task With the Table inside - task = MSG::Task.new("quicksort_task",taskComputeSize, taskCommunicationSize); - task.setData(myTable); - MSG::debug("Sending "+ task.name + " to " + send_mailbox + " with Comput Size " + - task.compSize.to_s) - task.send(send_mailbox) - MSG::debug("Done Sending " + task.name + " to " + send_mailbox) - - #waiting for results - - recv_mailbox = self.class - res_task = MSG::Task.receive(recv_mailbox.to_s) - result = res_task.data - MSG::info("Greate !! Thx Dude , you're my Best Friend !!") - MSG::info("Here is my table after a quicksort :)") - p result - MSG::info("Bye !! I finished My HomeWork !! Time to Sleep :)") - end - -end - - -################################################# -# Class Clever -################################################# -class Receiver < MSG::Process - - def main(args) - - lazy_friend = MSG::Host.getByName(args[0]).name - send_mailbox = args[1] - recv_mailbox = self.class - - MSG::info("Oh Not Again !! Grrr") - task = MSG::Task.receive(recv_mailbox.to_s) - table = task.data - quicksort(table,0,table.size-1) - task.setData(table) - MSG::info("Ok "+lazy_friend+ "I did it, next time try to do it on your own :)") - task.send(send_mailbox) - MSG::info("Bye lazy Friend !!") - - end - - def quicksort(list, p, r) - if p < r then - q = partition(list, p, r) - quicksort(list, p, q-1) - quicksort(list, q+1, r) - end -end - -def partition(list, p, r) - pivot = list[r] - i = p - 1 - p.upto(r-1) do |j| - if list[j] <= pivot - i = i+1 - list[i], list[j] = list[j],list[i] - end - end - list[i+1],list[r] = list[r],list[i+1] - return i + 1 -end - - -end - -################################################# -# main chunck -################################################# - -if (ARGV.length == 2) - MSG.createEnvironment(ARGV[0]) - MSG.deployApplication(ARGV[1]) -else - MSG.createEnvironment("quicksort_platform.xml") - MSG.deployApplication("quicksort_deployment.xml") -end - -MSG.run -puts "Simulation time : " + MSG.getClock .to_s -MSG.exit diff --git a/src/bindings/ruby/basic_platform.xml b/src/bindings/ruby/basic_platform.xml deleted file mode 100644 index badfb92dd8..0000000000 --- a/src/bindings/ruby/basic_platform.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/bindings/ruby/deploy.xml b/src/bindings/ruby/deploy.xml deleted file mode 100644 index c9841a9d11..0000000000 --- a/src/bindings/ruby/deploy.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/bindings/ruby/deploy2.xml b/src/bindings/ruby/deploy2.xml deleted file mode 100644 index 764cd640d7..0000000000 --- a/src/bindings/ruby/deploy2.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/bindings/ruby/ping_pong_deployment.xml b/src/bindings/ruby/ping_pong_deployment.xml deleted file mode 100644 index c26a3154d5..0000000000 --- a/src/bindings/ruby/ping_pong_deployment.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/bindings/ruby/ping_pong_platform.xml b/src/bindings/ruby/ping_pong_platform.xml deleted file mode 100644 index 12679166a3..0000000000 --- a/src/bindings/ruby/ping_pong_platform.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/bindings/ruby/platform.xml b/src/bindings/ruby/platform.xml deleted file mode 100644 index badfb92dd8..0000000000 --- a/src/bindings/ruby/platform.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/bindings/ruby/quicksort_deployment.xml b/src/bindings/ruby/quicksort_deployment.xml deleted file mode 100644 index 1b4473b99c..0000000000 --- a/src/bindings/ruby/quicksort_deployment.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/bindings/ruby/quicksort_platform.xml b/src/bindings/ruby/quicksort_platform.xml deleted file mode 100644 index 12679166a3..0000000000 --- a/src/bindings/ruby/quicksort_platform.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/bindings/ruby/rb_application_handler.c b/src/bindings/ruby/rb_application_handler.c deleted file mode 100644 index 2ba6fe722d..0000000000 --- a/src/bindings/ruby/rb_application_handler.c +++ /dev/null @@ -1,112 +0,0 @@ -/* 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. */ - -#include "bindings/ruby_bindings.h" -#include "surf/surfxml_parse.h" - -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby); - -// Used to instanciate the Process -static VALUE args; -static VALUE prop; -static VALUE function_name; -static VALUE host_name; - -static VALUE rb_process_instance(VALUE fct_name, VALUE arguments, - VALUE properties) -{ - ruby_init(); - ruby_init_loadpath(); - char *p_className = RSTRING_PTR(fct_name); // name of process is the one of the class - return rb_funcall(rb_const_get(rb_cObject, rb_intern(p_className)), - rb_intern("new"), 3, fct_name, arguments, properties); -} - -// FIXME: don't mess with MSG internals here, use MSG_process_create_with_arguments() -static void rb_process_create_with_args(VALUE fct_name, VALUE arguments, - VALUE properties, VALUE ht_name) -{ - - VALUE ruby_process = - rb_process_instance(fct_name, arguments, properties); - m_process_t process = NULL; // Native Process to Create - const char *name; // Name of C Native Processs - - - if (!fct_name) - rb_raise(rb_eRuntimeError, - "Internal error: Process name cannot be NULL"); - name = RSTRING_PTR(fct_name); - XBT_DEBUG("Create native process %s", name); - - char **argv = xbt_new(char *, 2); - argv[0] = bprintf("%s@%s", name, RSTRING_PTR(ht_name)); - argv[1] = NULL; - - // Allocate the data for the simulation - process = MSG_process_create_with_arguments(name, - (xbt_main_func_t) ruby_process, - process, - MSG_get_host_by_name(RSTRING_PTR(ht_name)), - 1, argv); - - // Bind The Ruby Process instance to The Native Process - rb_process_bind(ruby_process, process); -} - - -void rb_application_handler_on_start_document(void) -{ - - - args = rb_ary_new(); // Max length = 16 !! - prop = rb_ary_new(); - -} - -void rb_application_handler_on_end_document(void) -{ - - args = Qnil; - prop = Qnil; - function_name = Qnil; - host_name = Qnil; -} - -void rb_application_handler_on_begin_process(void) -{ - - host_name = rb_str_new2(A_surfxml_process_host); - function_name = rb_str_new2(A_surfxml_process_function); - - args = rb_ary_new(); // Max length = 16 ?! - prop = rb_ary_new(); - -} - -void rb_application_handler_on_process_arg(void) -{ - - VALUE arg = rb_str_new2(A_surfxml_argument_value); - rb_ary_push(args, arg); -} - -void rb_application_handler_on_property(void) -{ - - VALUE id = rb_str_new2(A_surfxml_prop_id); - VALUE val = rb_str_new2(A_surfxml_prop_value); - int i_id = NUM2INT(id); - rb_ary_store(prop, i_id, val); - -} - -void rb_application_handler_on_end_process(void) -{ - - rb_process_create_with_args(function_name, args, prop, host_name); - -} diff --git a/src/bindings/ruby/rb_msg_host.c b/src/bindings/ruby/rb_msg_host.c deleted file mode 100644 index d00c329a40..0000000000 --- a/src/bindings/ruby/rb_msg_host.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Host-related bindings to ruby */ - -/* 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. */ - -#include "bindings/ruby_bindings.h" - -// Free Method -void rb_host_free(m_host_t ht) -{ - //Nothing to do !!? -} - -// New Method : return a Host -VALUE rb_host_get_by_name(VALUE class, VALUE name) -{ - - const char *h_name = RSTRING_PTR(name); - m_host_t host = MSG_get_host_by_name(h_name); - - if (!host){ - char *message = bprintf("No host called '%s' found", h_name); - VALUE errorobj = rb_exc_new2(rb_eRuntimeError, message); - xbt_free(message); - rb_exc_raise(errorobj); - } - return Data_Wrap_Struct(class, 0, rb_host_free, host); -} - -//Get Name -VALUE rb_host_name(VALUE class, VALUE host) -{ - - // Wrap Ruby Value to m_host_t struct - m_host_t ht; - Data_Get_Struct(host, s_m_host_t, ht); - return rb_str_new2(MSG_host_get_name(ht)); - -} - -// Get Number -VALUE rb_host_number(VALUE class) -{ - return INT2NUM(MSG_get_host_number()); -} - -// Host Speed ( Double ) -VALUE rb_host_speed(VALUE class, VALUE host) -{ - m_host_t ht; - Data_Get_Struct(host, s_m_host_t, ht); - return MSG_get_host_speed(ht); -} - -// Host is Avail -VALUE rb_host_is_avail(VALUE class, VALUE host) -{ - m_host_t ht; - Data_Get_Struct(host, s_m_host_t, ht); - if (!ht) { - rb_raise(rb_eRuntimeError, "Host not Bound"); - return Qnil; - } - - if (MSG_host_is_avail(ht)) - return Qtrue; - - return Qfalse; -} - -// getHost from process -VALUE rb_host_process(VALUE class, VALUE ruby_process) -{ - - m_process_t process = rb_process_to_native(ruby_process); - m_host_t host; - - - if (!process) { - rb_raise(rb_eRuntimeError, "Process Not Bound...while getting Host"); - return Qnil; // NULL - } - - host = MSG_process_get_host(process); - - return Data_Wrap_Struct(class, 0, rb_host_free, host); - -} - -// get all hosts -VALUE rb_host_get_all_hosts(VALUE class) -{ - int nb, index; - m_host_t *hosts; - VALUE rb_hosts; - nb = MSG_get_host_number(); - hosts = MSG_get_host_table(); - rb_hosts = rb_ary_new2(nb); - - for (index = 0; index < nb; index++) - rb_ary_push(rb_hosts, - Data_Wrap_Struct(class, 0, rb_host_free, hosts[index])); - - return rb_hosts; -} diff --git a/src/bindings/ruby/rb_msg_process.c b/src/bindings/ruby/rb_msg_process.c deleted file mode 100644 index c774597e4b..0000000000 --- a/src/bindings/ruby/rb_msg_process.c +++ /dev/null @@ -1,189 +0,0 @@ -/* 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. */ - -#include "msg/private.h" /* s_simdata_process_t */ -#include "bindings/ruby_bindings.h" - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ruby, bindings, "Ruby Bindings"); - -/* - * Functions for Ruby Process Management (Up Calls) - */ - -// get Ruby Process Name -VALUE rb_process_getName(VALUE ruby_process) -{ - return rb_funcall(ruby_process, rb_intern("getName"), 0); -} - -// Get Process ID -VALUE rb_process_getID(VALUE ruby_process) -{ - return rb_funcall(ruby_process, rb_intern("getID"), 0); -} - -// Get Bind -VALUE rb_process_getBind(VALUE ruby_process) -{ - return rb_funcall(ruby_process, rb_intern("getBind"), 0); -} - -// Set Bind -void rb_process_setBind(VALUE ruby_process, long bind) -{ - VALUE r_bind = LONG2FIX(bind); - rb_funcall(ruby_process, rb_intern("setBind"), 1, r_bind); -} - -// isAlive -VALUE rb_process_isAlive(VALUE ruby_process) -{ - return rb_funcall(ruby_process, rb_intern("alive?"), 0); -} - -// Kill Process -void rb_process_kill_up(VALUE ruby_process) -{ - rb_funcall(ruby_process, rb_intern("kill"), 0); -} - -// join Process -void rb_process_join(VALUE ruby_process) -{ - rb_funcall(ruby_process, rb_intern("join"), 0); -} - -// FIXME: all this calls must be manually inlined I guess -// unschedule Process -void rb_process_unschedule(VALUE ruby_process) -{ - rb_funcall(ruby_process, rb_intern("unschedule"), 0); -} - -// schedule Process -void rb_process_schedule(VALUE ruby_process) -{ - rb_funcall(ruby_process, rb_intern("schedule"), 0); -} - -/*************************************************** -Function for Native Process ( Bound ) Management - -Methods Belong to MSG Module -****************************************************/ - -// Process To Native -m_process_t rb_process_to_native(VALUE ruby_process) -{ - VALUE id = rb_process_getBind(ruby_process); - if (!id) { - rb_raise(rb_eRuntimeError, "Process Not Bound >>> id_Bind Null"); - return NULL; - } - long l_id = FIX2LONG(id); - return (m_process_t) l_id; -} - -// Bind Process -void rb_process_bind(VALUE ruby_process, m_process_t process) -{ - long bind = (long) (process); - rb_process_setBind(ruby_process, bind); -} - - -// Process Management -void rb_process_suspend(VALUE class, VALUE ruby_process) -{ - - m_process_t process = rb_process_to_native(ruby_process); - - if (!process) { - rb_raise(rb_eRuntimeError, - "Process Not Bound...while suspending process"); - return; - } - // Trying to suspend The Process - - if (MSG_OK != MSG_process_suspend(process)) - rb_raise(rb_eRuntimeError, "MSG_process_suspend() failed"); -} - -void rb_process_resume(VALUE class, VALUE ruby_process) -{ - m_process_t process = rb_process_to_native(ruby_process); - if (!process) { - rb_raise(rb_eRuntimeError, - "Process not Bound...while resuming process"); - return; - } - // Trying to resume the process - if (MSG_OK != MSG_process_resume(process)) - rb_raise(rb_eRuntimeError, "MSG_process_resume() failed"); -} - -VALUE rb_process_isSuspended(VALUE class, VALUE ruby_process) -{ - m_process_t process = rb_process_to_native(ruby_process); - if (!process) { - rb_raise(rb_eRuntimeError, - "Process not Bound...while testing if suspended"); - return Qfalse; - } - if (MSG_process_is_suspended(process)) - return Qtrue; - return Qfalse; -} - -void rb_process_kill_down(VALUE class, VALUE ruby_process) -{ - m_process_t process = rb_process_to_native(ruby_process); - - if (!process) { - rb_raise(rb_eRuntimeError, - "Process Not Bound...while killing process"); - return; - } - // Delete The Global Reference / Ruby Process - rb_process_kill_up(ruby_process); - // Delete the Native Process - MSG_process_kill(process); -} - -VALUE rb_process_getHost(VALUE class, VALUE ruby_process) -{ - m_process_t process = rb_process_to_native(ruby_process); - m_host_t host; - - - if (!process) { - rb_raise(rb_eRuntimeError, "Process Not Bound...while getting Host"); - return Qnil; // NULL - } - - host = MSG_process_get_host(process); - - return Data_Wrap_Struct(class, 0, rb_host_free, host); - /*if(host->data) printf("Ok\n"); - - if(!host->data) { - rb_raise (rb_eRuntimeError,"MSG_process_get_host() failed"); - return Qnil; - } - printf("Houuuuuuuuuuuuuuna3!!\n"); - return Data_Wrap_Struct(class, 0, rb_host_free, host); */ -} - -void rb_process_exit(VALUE class, VALUE ruby_process) -{ - m_process_t process = rb_process_to_native(ruby_process); - if (!process) { - rb_raise(rb_eRuntimeError, - "Process Not Bound...while exiting process"); - return; - } - SIMIX_context_stop(SIMIX_process_self()->context); -} diff --git a/src/bindings/ruby/rb_msg_task.c b/src/bindings/ruby/rb_msg_task.c deleted file mode 100644 index bf24c2107b..0000000000 --- a/src/bindings/ruby/rb_msg_task.c +++ /dev/null @@ -1,223 +0,0 @@ -/* Task-related bindings to ruby */ - -/* 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. */ - - -#include "bindings/ruby_bindings.h" - -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby); - -// Free Method -void rb_task_free(m_task_t tk) -{ - //MSG_task_destroy(tk); ( This cause a bug !! is it really necessary ?!! not really sure !! ) -} - -// New Method -VALUE rb_task_new(VALUE class, VALUE name, VALUE comp_size, - VALUE comm_size) -{ - m_task_t task = MSG_task_create(RSTRING_PTR(name), NUM2INT(comp_size), - NUM2INT(comm_size), NULL); - rb_data_t data = malloc(sizeof(s_ruby_data_t)); - data->ruby_task = NULL; - data->user_data = NULL; - MSG_task_set_data(task, (void *) data); - // Wrap m_task_t to a Ruby Value - return Data_Wrap_Struct(class, 0, rb_task_free, task); -} - -//Get Computation Size -VALUE rb_task_comp(VALUE class, VALUE task) -{ - double size; - m_task_t tk; - // Wrap Ruby Value to m_task_t struct - Data_Get_Struct(task, s_m_task_t, tk); - size = MSG_task_get_compute_duration(tk); - return rb_float_new(size); -} - -//Get Name -VALUE rb_task_name(VALUE class, VALUE task) -{ - - // Wrap Ruby Value to m_task_t struct - m_task_t tk; - Data_Get_Struct(task, s_m_task_t, tk); - return rb_str_new2(MSG_task_get_name(tk)); -} - -// Execute Task -VALUE rb_task_execute(VALUE class, VALUE task) -{ - - // Wrap Ruby Value to m_task_t struct - m_task_t tk; - Data_Get_Struct(task, s_m_task_t, tk); - return INT2NUM(MSG_task_execute(tk)); -} - -// Sending Task -void rb_task_send(VALUE class, VALUE task, VALUE mailbox) -{ - - MSG_error_t rv; - rb_data_t data; - // Wrap Ruby Value to m_task_t struct - m_task_t tk; - Data_Get_Struct(task, s_m_task_t, tk); - data = MSG_task_get_data(tk); - data->ruby_task = (void *) task; - MSG_task_set_data(tk, (void *) data); - XBT_DEBUG("Sending task %p", tk); - rv = MSG_task_send(tk, RSTRING_PTR(mailbox)); - if (rv != MSG_OK) { - if (rv == MSG_TRANSFER_FAILURE) - rb_raise(rb_eRuntimeError, "Transfer failure while Sending"); - else if (rv == MSG_HOST_FAILURE) - rb_raise(rb_eRuntimeError, "Host failure while Sending"); - else if (rv == MSG_TIMEOUT) - rb_raise(rb_eRuntimeError, "Timeout failure while Sending"); - else - rb_raise(rb_eRuntimeError, "MSG_task_send failed"); - } -} - -// Receiving Task (returns a Task) -VALUE rb_task_receive(VALUE class, VALUE mailbox) -{ - // We must put the location where we copy the task - // pointer to on the heap, because the stack may move - // during the context switches (damn ruby internals) - m_task_t *ptask = malloc(sizeof(m_task_t)); - m_task_t task; - *ptask = NULL; - rb_data_t data = NULL; - XBT_DEBUG("Receiving a task on mailbox '%s', store it into %p", - RSTRING_PTR(mailbox), &task); - MSG_task_receive(ptask, RSTRING_PTR(mailbox)); - task = *ptask; - free(ptask); - data = MSG_task_get_data(task); - if (data == NULL) - printf("Empty task while receving"); - return (VALUE) data->ruby_task; -} - -// It Return a Native Process ( m_process_t ) -VALUE rb_task_sender(VALUE class, VALUE task) -{ - m_task_t tk; - Data_Get_Struct(task, s_m_task_t, tk); - THROW_UNIMPLEMENTED; - return 0; //MSG_task_get_sender(tk); -} - -// it return a Host -VALUE rb_task_source(VALUE class, VALUE task) -{ - m_task_t tk; - Data_Get_Struct(task, s_m_task_t, tk); - - m_host_t host = MSG_task_get_source(tk); - if (!host->data) { - rb_raise(rb_eRuntimeError, "MSG_task_get_source() failed"); - return Qnil; - } - THROW_UNIMPLEMENTED; - return 0; //host; -} - -// Return Boolean -VALUE rb_task_listen(VALUE class, VALUE task, VALUE alias) -{ - m_task_t tk; - const char *p_alias; - int rv; - - Data_Get_Struct(task, s_m_task_t, tk); - p_alias = RSTRING_PTR(alias); - - rv = MSG_task_listen(p_alias); - - if (rv) - return Qtrue; - - return Qfalse; -} - -// return Boolean -VALUE rb_task_listen_host(VALUE class, VALUE task, VALUE alias, VALUE host) -{ - - m_task_t tk; - m_host_t ht; - const char *p_alias; - int rv; - - Data_Get_Struct(task, s_m_task_t, tk); - Data_Get_Struct(host, s_m_host_t, ht); - p_alias = RSTRING_PTR(alias); - rv = MSG_task_listen_from_host(p_alias, ht); - if (rv) - return Qtrue; - return Qfalse; -} - - -// Set Priority -void rb_task_set_priority(VALUE class, VALUE task, VALUE priority) -{ - - m_task_t tk; - double prt = NUM2DBL(priority); - Data_Get_Struct(task, s_m_task_t, tk); - MSG_task_set_priority(tk, prt); - -} - -// Cancel -void rb_task_cancel(VALUE class, VALUE task) -{ - m_task_t tk; - Data_Get_Struct(task, s_m_task_t, tk); - MSG_task_cancel(tk); - -} - -void rb_task_set_data(VALUE class, VALUE task, VALUE data) -{ - m_task_t tk; - rb_data_t rb_data; - Data_Get_Struct(task, s_m_task_t, tk); - rb_data = MSG_task_get_data(tk); - rb_data->user_data = (void *) data; - MSG_task_set_data(tk, (void *) rb_data); - -} - -VALUE rb_task_get_data(VALUE class, VALUE task) -{ - m_task_t tk; - Data_Get_Struct(task, s_m_task_t, tk); - rb_data_t rb_data = MSG_task_get_data(tk); - if (!rb_data->user_data) - XBT_ERROR("the task %s contain no user data", MSG_task_get_name(tk)); - - return (VALUE) rb_data->user_data; -} - -VALUE rb_task_has_data(VALUE class, VALUE task) -{ - m_task_t tk; - Data_Get_Struct(task, s_m_task_t, tk); - rb_data_t rb_data = MSG_task_get_data(tk); - if (!rb_data->user_data) - return Qfalse; - return Qtrue; -} diff --git a/src/bindings/ruby/simgrid.rb b/src/bindings/ruby/simgrid.rb deleted file mode 100644 index 32fbbe2814..0000000000 --- a/src/bindings/ruby/simgrid.rb +++ /dev/null @@ -1,247 +0,0 @@ -# Task-related bindings to ruby */ -# -# Copyright 2010. The SimGrid Team. All right 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. */ -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -require 'libsimgrid.so' -require 'thread' - -####################################### -# Semaphore -####################################### - -class Semaphore - def initialize(initvalue = 0) - @counter = initvalue - @waiting_list = [] - end - - def acquire - Thread.critical = true - if (@counter -= 1) < 0 - MSG::debug(Thread.current.to_s+" acquires "+self.to_s+". That's blocking.") - @waiting_list.push(Thread.current) - Thread.stop - else - MSG::debug(Thread.current.to_s+" acquires "+self.to_s+". It was free.") - end - self - ensure - Thread.critical = false - end - - def release - Thread.critical = true - begin - if (@counter += 1) <= 0 - t = @waiting_list.shift - t.wakeup if t - MSG::debug(Thread.current.to_s+" releases "+self.to_s+". Wakeup "+t.to_s) - else - MSG::debug(Thread.current.to_s+" releases "+self.to_s+". Nobody to wakeup") - end - rescue ThreadError - retry - end - self - ensure - Thread.critical = false - end -end - -######################################################################## -# Class Process -######################################################################## -class MSG::Process < Thread - @@nextProcessId = 0 - -# Attributes - attr_reader :name, :pargs ,:properties # Read only - - def initialize(*args) - super(){ - - raise "Bad number of arguments to create a Ruby process. Expected (name,args,prop) " if args.size < 3 - - @schedBegin = Semaphore.new(0) - @schedEnd = Semaphore.new(0) - @id = @@nextProcessId - @@nextProcessId +=1 - @name = args[0] - @pargs = args[1] - @properties = args[2] - start() - } - end - - def main(args) - # To be overriden by childs - raise("You must define a main() function in your process, containing the code of this process") - end - - def start() - @schedBegin.acquire - MSG::debug("Let's execute the main() of the Ruby process") - main(@pargs) - @schedEnd.release - MSG::debug("Released my schedEnd, bailing out") - processExit(self) # Exit the Native Process - - end - - def getBind() - return @bind - end - - def setBind(bind) - @bind = bind - end - - def unschedule() - @schedEnd.release - @schedBegin.acquire - end - - def schedule() - @schedBegin.release - @schedEnd.acquire - end - - def pause() - processSuspend(self) - end - - def restart() - processResume(self) - end - - def isSuspended() - processIsSuspended(self) - end - - def getHost() - processGetHost(self) - end - -end -############################################ -# Task Extend from the native Class RbTask -############################################ -class MSG::Task < MSG::RbTask - - def initialize(*args) - #Nothing todo - end - - def join(value) - super(self,value) - end - - def data() - super(self) - end - - def name - super(self) - end - - def compSize - super(self) - end - - def send(mailbox) - super(self,mailbox) - end - - def receive(mailbox) - super(self) - end - - def source - super(self) - end - - def sender - super(self) - end - - def listen(t_alias) - super(self) - end - - def execute - super(self) - end - - def listenFromHost(t_alias,host) - super(self) - end - - def setPriority(priority) - super(self,priority) - end - - def cancel - super(self) - end - - def hasData - super(self) - end - -end - -#################################################### -# Host Extend from the native Class RbHost -#################################################### -class MSG::Host < MSG::RbHost - - attr_reader :data - def initialize(*ars) - @data = 1 - p "Host Initializer" - end - - def data() - return @data - end - - def setData(value) - @data = value - end - - def getByName(name) - super(name) - end - - def name - super(self) - end - - def speed - super(self) - end - - def getData - super(self) - end - - def isAvail - super(self) - end - - def number - super() - end - - def getHostProcess(process) - super(process) - end - -end -######################### -# Main chunck -######################### -MSG.init(ARGV) diff --git a/src/bindings/ruby/simgrid_ruby.c b/src/bindings/ruby/simgrid_ruby.c deleted file mode 100644 index 96bc897675..0000000000 --- a/src/bindings/ruby/simgrid_ruby.c +++ /dev/null @@ -1,231 +0,0 @@ -/* SimGrid Ruby 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. */ - -#include "xbt.h" -#include "bindings/ruby_bindings.h" - -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby); - -// MSG Module -VALUE rb_msg; -// MSG Classes -VALUE rb_task; -VALUE rb_host; - -//Init Msg From Ruby -static void msg_init(VALUE Class, VALUE args) -{ - char **argv = NULL; - const char *tmp; - int argc, type, i; - VALUE *ptr; - // Testing The Args Type - type = TYPE(args); - if (type != T_ARRAY) { - rb_raise(rb_eRuntimeError, - "Bad arguments to msg_init (expecting an array)"); - return; - } - ptr = RARRAY_PTR(args); - argc = RARRAY_LEN(args); - // Create C array to hold data_get_struct - argc++; - argv = xbt_new0(char *, argc); - argv[0] = strdup("ruby"); - for (i = 0; i < argc - 1; i++) { - VALUE value = ptr[i]; - type = TYPE(value); - // if (type == T_STRING) - tmp = RSTRING_PTR(value); - argv[i + 1] = strdup(tmp); - } - // Calling C Msg_Init Method - MSG_global_init(&argc, argv); - - // Cleanups - for (i = 0; i < argc; i++) - free(argv[i]); - free(argv); -} - -//Init Msg_Run From Ruby -static void msg_run(VALUE class) -{ - XBT_DEBUG("Start Running..."); - m_host_t *hosts; - int cpt, host_count; - VALUE rbHost; - // Let's Run - //printf("msg_run3\n"); - if (MSG_OK != MSG_main()) { - rb_raise(rb_eRuntimeError, "MSG_main() failed"); - } - - XBT_DEBUG - ("MSG_main finished. Bail out before cleanup since there is a bug in this part."); - /* Cleanup Ruby hosts */ - XBT_DEBUG("Clean Ruby World "); - hosts = MSG_get_host_table(); - host_count = MSG_get_host_number(); - for (cpt = 0; cpt < host_count; cpt++) { - rbHost = (VALUE) ((hosts[cpt])->data); - } - return; -} - -static void msg_clean(VALUE class) -{ - if (MSG_OK != MSG_clean()) - rb_raise(rb_eRuntimeError, "MSG_clean() failed"); - -} - -static void msg_createEnvironment(VALUE class, VALUE plateformFile) -{ - - int type = TYPE(plateformFile); - if (type != T_STRING) - rb_raise(rb_eRuntimeError, "Bad Argument's Type"); - const char *platform = RSTRING_PTR(plateformFile); - MSG_create_environment(platform); - XBT_DEBUG("Create Environment (%s)...Done", platform); -} - -//deploy Application -static void msg_deployApplication(VALUE class, VALUE deploymentFile) -{ - - int type = TYPE(deploymentFile); - if (type != T_STRING) - rb_raise(rb_eRuntimeError, - "Bad Argument's Type for deployApplication "); - const char *dep_file = RSTRING_PTR(deploymentFile); - surf_parse_reset_callbacks(); - surfxml_add_callback(STag_surfxml_process_cb_list, - rb_application_handler_on_begin_process); - surfxml_add_callback(ETag_surfxml_argument_cb_list, - rb_application_handler_on_process_arg); - - surfxml_add_callback(STag_surfxml_prop_cb_list, - rb_application_handler_on_property); - - surfxml_add_callback(ETag_surfxml_process_cb_list, - rb_application_handler_on_end_process); - - surf_parse_open(dep_file); - rb_application_handler_on_start_document(); - if (surf_parse()) - rb_raise(rb_eRuntimeError, "surf_parse() failed"); - surf_parse_close(); - - rb_application_handler_on_end_document(); - - XBT_DEBUG("Deploy Application(%s)...Done", dep_file); -} - -// INFO -static void msg_info(VALUE class, VALUE msg) -{ - const char *s = RSTRING_PTR(msg); - XBT_INFO("%s", s); -} - -static void msg_debug(VALUE class, VALUE msg) -{ - const char *s = RSTRING_PTR(msg); - XBT_DEBUG("%s", s); -} - -// get Clock -static VALUE msg_get_clock(VALUE class) -{ - return rb_float_new(MSG_get_clock()); - -} - -typedef VALUE(*rb_meth) (ANYARGS); -void Init_libsimgrid() -{ - smx_factory_initializer_to_use = SIMIX_ctx_ruby_factory_init; - - // Modules - rb_msg = rb_define_module("MSG"); - //Associated Environment Methods - rb_define_module_function(rb_msg, "init", (rb_meth) msg_init, 1); - rb_define_module_function(rb_msg, "run", (rb_meth) msg_run, 0); - rb_define_module_function(rb_msg, "createEnvironment", - (rb_meth) msg_createEnvironment, 1); - rb_define_module_function(rb_msg, "deployApplication", - (rb_meth) msg_deployApplication, 1); - rb_define_module_function(rb_msg, "info", (rb_meth) msg_info, 1); - rb_define_module_function(rb_msg, "debug", (rb_meth) msg_debug, 1); - rb_define_module_function(rb_msg, "getClock", (rb_meth) msg_get_clock, - 0); - rb_define_module_function(rb_msg, "exit", (rb_meth) msg_clean, 0); - - //Associated Process Methods - rb_define_method(rb_msg, "processSuspend", (rb_meth) rb_process_suspend, - 1); - rb_define_method(rb_msg, "processResume", (rb_meth) rb_process_resume, - 1); - rb_define_method(rb_msg, "processIsSuspend", - (rb_meth) rb_process_isSuspended, 1); - rb_define_method(rb_msg, "processKill", (rb_meth) rb_process_kill_up, 1); - rb_define_method(rb_msg, "processKillDown", - (rb_meth) rb_process_kill_down, 1); - rb_define_method(rb_msg, "processGetHost", (rb_meth) rb_process_getHost, - 1); - rb_define_method(rb_msg, "processExit", (rb_meth) rb_process_exit, 1); - - //Classes - rb_task = rb_define_class_under(rb_msg, "RbTask", rb_cObject); - rb_host = rb_define_class_under(rb_msg, "RbHost", rb_cObject); - - //Task Methods - rb_define_module_function(rb_task, "new", (rb_meth) rb_task_new, 3); - rb_define_module_function(rb_task, "compSize", (rb_meth) rb_task_comp, - 1); - rb_define_module_function(rb_task, "name", (rb_meth) rb_task_name, 1); - rb_define_module_function(rb_task, "execute", (rb_meth) rb_task_execute, - 1); - rb_define_module_function(rb_task, "send", (rb_meth) rb_task_send, 2); - rb_define_module_function(rb_task, "receive", (rb_meth) rb_task_receive, - 1); - rb_define_module_function(rb_task, "sender", (rb_meth) rb_task_sender, - 1); - rb_define_module_function(rb_task, "source", (rb_meth) rb_task_source, - 1); - rb_define_module_function(rb_task, "listen", (rb_meth) rb_task_listen, - 2); - rb_define_module_function(rb_task, "listenFromHost", - (rb_meth) rb_task_listen_host, 3); - rb_define_module_function(rb_task, "setPriority", - (rb_meth) rb_task_set_priority, 2); - rb_define_module_function(rb_task, "cancel", (rb_meth) rb_task_cancel, - 1); - rb_define_module_function(rb_task, "hasData", (rb_meth) rb_task_has_data, - 1); - rb_define_module_function(rb_task, "setData", (rb_meth) rb_task_set_data, - 2); - rb_define_module_function(rb_task, "data", (rb_meth) rb_task_get_data, - 1); - - //Host Methods - rb_define_module_function(rb_host, "getByName", - (rb_meth) rb_host_get_by_name, 1); - rb_define_module_function(rb_host, "name", (rb_meth) rb_host_name, 1); - rb_define_module_function(rb_host, "speed", (rb_meth) rb_host_speed, 1); - rb_define_module_function(rb_host, "number", (rb_meth) rb_host_number, - 0); - rb_define_module_function(rb_host, "isAvail", (rb_meth) rb_host_is_avail, - 1); - rb_define_module_function(rb_host, "getHostProcess", - (rb_meth) rb_host_process, 1); - rb_define_module_function(rb_host, "all", - (rb_meth) rb_host_get_all_hosts, 0); -} diff --git a/src/bindings/ruby_bindings.h b/src/bindings/ruby_bindings.h deleted file mode 100644 index 965d36bec5..0000000000 --- a/src/bindings/ruby_bindings.h +++ /dev/null @@ -1,139 +0,0 @@ -/* SimGrid -- Ruby 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. */ - - -#ifndef RB_SG_BINDINGS -#define RB_SG_BINDINGS -/* - * There is 4 sections in this file: - * - Header loading (ruby makes it quite difficult, damn it) - * - definitions of ruby contextes for use in simix - * - Functions to Manage The Ruby Process (named Up Calls) - * - Functions to Manage The Native Process Simulation Bound (named Down Calls) - */ - -#include "msg/msg.h" -#include "msg/datatypes.h" - -#include "surf/surfxml_parse.h" -#include "simix/simix.h" -#include "simix/private.h" -#include "xbt/sysdep.h" -#include "xbt/log.h" -#include "xbt/asserts.h" - -#include "simix/context.h" - -/* Damn Ruby. They load their full config.h, which breaks since we also load ours. - * So, we undef the offending defines - */ -#undef PACKAGE_VERSION -#undef PACKAGE_NAME -#undef PACKAGE_TARNAME -#undef PACKAGE_STRING -#undef PACKAGE_BUGREPORT -#undef _GNU_SOURCE -#include - -/* ********************* * - * Context related stuff * - * ********************* */ -typedef struct s_smx_ctx_ruby { - s_smx_ctx_base_t super; /* Fields of super implementation */ - VALUE process; // The Ruby Process Instance - //... -} s_smx_ctx_ruby_t, *smx_ctx_ruby_t; -void SIMIX_ctx_ruby_factory_init(smx_context_factory_t * factory); - -void Init_libsimgrid(void); /* Load the bindings */ -void initRuby(void); // Mandatory to call Ruby methods from C - -/* *********************************************** * - * Functions for Ruby Process Management (Up Call) * - * * - * Independent Methods * - * *********************************************** */ - -VALUE rb_process_getName(VALUE ruby_process); -VALUE rb_process_getID(VALUE ruby_process); -VALUE rb_process_getBind(VALUE ruby_class); -void rb_process_setBind(VALUE ruby_class, long bind); -VALUE rb_process_isAlive(VALUE ruby_process); -void rb_process_kill_up(VALUE ruby_process); -void rb_process_join(VALUE ruby_process); -void rb_process_unschedule(VALUE ruby_process); -void rb_process_schedule(VALUE ruby_process); - -/* ********************************************** * - * Function for Native Process (Bound) Management * - * * - * Methods Belonging to The MSG Module * - * ********************************************** */ - -// ProcessBind Method ; Process Ruby >> Process C - -//friend Method // Not belong to the Class but Called within !! -m_process_t rb_process_to_native(VALUE ruby_process); -// Binding Process >> Friend Method -void rb_process_bind(VALUE ruby_class, m_process_t process); -void rb_process_create(VALUE Class, VALUE rb_process, VALUE host); -void rb_process_suspend(VALUE Class, VALUE ruby_process); -void rb_process_resume(VALUE Class, VALUE ruby_process); -// Returns Boolean ( Qtrue / Qfalse ) -VALUE rb_process_isSuspended(VALUE Class, VALUE ruby_process); -void rb_process_kill_down(VALUE Class, VALUE ruby_process); -VALUE rb_process_getHost(VALUE Class, VALUE ruby_process); -void rb_process_exit(VALUE Class, VALUE ruby_process); - -/* Functions related to hosts */ -void rb_host_free(m_host_t ht); -VALUE rb_host_get_by_name(VALUE Class, VALUE name); -VALUE rb_host_name(VALUE Class, VALUE host); -VALUE rb_host_number(VALUE Class); -VALUE rb_host_speed(VALUE Class, VALUE host); -void rb_host_set_data(VALUE Class, VALUE host, VALUE data); -VALUE rb_host_get_data(VALUE Class, VALUE host); -VALUE rb_host_is_avail(VALUE Class, VALUE host); -VALUE rb_host_process(VALUE Class, VALUE process); -VALUE rb_host_get_all_hosts(VALUE Class); - -/* Functions related to tasks */ - -typedef struct ruby_data { - void *ruby_task; // Pointer to send the ruby_task - void *user_data; // Pointer on the user data -} s_ruby_data_t, *rb_data_t; - -void rb_task_free(m_task_t tk); -VALUE rb_task_new(VALUE Class, VALUE name, VALUE comp_size, - VALUE comm_size); -VALUE rb_task_comp(VALUE Class, VALUE task); // Get Computation Size -VALUE rb_task_name(VALUE Class, VALUE task); -VALUE rb_task_execute(VALUE Class, VALUE task); -void rb_task_send(VALUE Class, VALUE task, VALUE mailbox); -VALUE rb_task_receive(VALUE Class, VALUE mailbox); // Receive : return a task -void rb_task_receive2(VALUE Class, VALUE task, VALUE mailbox); // Receive Task 2 << Not Appreciated -VALUE rb_task_sender(VALUE Class, VALUE task); -VALUE rb_task_source(VALUE Class, VALUE task); -VALUE rb_task_listen(VALUE Class, VALUE task, VALUE alias); //Listen From Alias (=mailbox) -VALUE rb_task_listen_host(VALUE Class, VALUE task, VALUE alias, VALUE host); //Listen from Host -void rb_task_set_priority(VALUE Class, VALUE task, VALUE priority); // Set Priority -void rb_task_cancel(VALUE Class, VALUE task); // Cancel -VALUE rb_task_has_data(VALUE Class, VALUE task); // check if the task contains a data -VALUE rb_task_get_data(VALUE Class, VALUE task); // get data -void rb_task_set_data(VALUE Class, VALUE task, VALUE data); // set data - -/* Upcalls for the application handler */ -void rb_application_handler_on_start_document(void); -void rb_application_handler_on_end_document(void); -void rb_application_handler_on_begin_process(void); -void rb_application_handler_on_process_arg(void); -void rb_application_handler_on_property(void); -void rb_application_handler_on_end_process(void); - -#endif /* RB_SG_BINDINGS */ diff --git a/src/msg/task.c b/src/msg/task.c index b0c0114e93..116725c358 100644 --- a/src/msg/task.c +++ b/src/msg/task.c @@ -23,12 +23,6 @@ * message size and some private data. */ -#ifdef HAVE_RUBY /* FIXME: KILLME */ -XBT_LOG_EXTERNAL_CATEGORY(ruby); -#endif - - - XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)"); diff --git a/src/simix/smx_context_ruby.c b/src/simix/smx_context_ruby.c deleted file mode 100644 index 07739f5939..0000000000 --- a/src/simix/smx_context_ruby.c +++ /dev/null @@ -1,126 +0,0 @@ -/* context_Ruby - implementation of context switching with/for ruby */ - -/* 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. */ - -#include "xbt/function_types.h" -#include "xbt/sysdep.h" -#include "xbt/log.h" -#include "xbt/asserts.h" - -#include "bindings/ruby_bindings.h" - -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby); - -static smx_context_t -smx_ctx_ruby_create_context(xbt_main_func_t code, int argc, char **argv, - void_pfn_smxprocess_t cleanup_func, - void *data); - -static void smx_ctx_ruby_stop(smx_context_t context); -static void smx_ctx_ruby_suspend(smx_context_t context); -static void smx_ctx_ruby_resume(smx_context_t new_context); -static void smx_ctx_ruby_runall(xbt_dynar_t processes); - -void SIMIX_ctx_ruby_factory_init(smx_context_factory_t * factory) -{ - smx_ctx_base_factory_init(factory); - - (*factory)->create_context = smx_ctx_ruby_create_context; - /* Do not overload that method (*factory)->finalize */ - /* Do not overload that method (*factory)->free */ - (*factory)->stop = smx_ctx_ruby_stop; - (*factory)->suspend = smx_ctx_ruby_suspend; - (*factory)->name = "smx_ruby_context_factory"; - (*factory)->runall = smx_ctx_ruby_runall; - ruby_init(); - ruby_init_loadpath(); -} - -static smx_context_t -smx_ctx_ruby_create_context(xbt_main_func_t code, int argc, char **argv, - void_pfn_smxprocess_t cleanup_func, void *data) -{ - - smx_ctx_ruby_t context = (smx_ctx_ruby_t) - smx_ctx_base_factory_create_context_sized(sizeof(s_smx_ctx_ruby_t), - code, argc, argv, - cleanup_func, data); - - /* if the user provided a function for the process , then use it - Otherwise it's the context for maestro */ - if (code) { - context->process = (VALUE) code; - - XBT_DEBUG("smx_ctx_ruby_create_context(%s)...Done", argv[0]); - } - - return (smx_context_t) context; -} - -static void smx_ctx_ruby_stop(smx_context_t context) -{ - XBT_DEBUG("smx_ctx_ruby_stop()"); - VALUE process = Qnil; - smx_ctx_ruby_t ctx_ruby, current; - - smx_ctx_base_stop(context); - - ctx_ruby = (smx_ctx_ruby_t) context; - - if (smx_current_context->iwannadie) { - if (ctx_ruby->process) { - - //if the Ruby Process still Alive ,let's Schedule it - if (rb_process_isAlive(ctx_ruby->process)) { - - current = (smx_ctx_ruby_t) smx_current_context; - rb_process_schedule(current->process); - process = ctx_ruby->process; - // interupt/kill The Ruby Process - rb_process_kill_up(process); - } - } - } else { - - if (ctx_ruby->process) - ctx_ruby->process = Qnil; - - } -} - -static void smx_ctx_ruby_suspend(smx_context_t context) -{ - - XBT_DEBUG("smx_ctx_ruby_suspend(%s)", context->argv[0]); - smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) context; - if (ctx_ruby->process) - rb_process_unschedule(ctx_ruby->process); -} - -static void smx_ctx_ruby_resume(smx_context_t new_context) -{ - XBT_DEBUG("smx_ctx_ruby_resume(%s)", - (new_context->argc ? new_context->argv[0] : "maestro")); - - smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) new_context; - rb_process_schedule(ctx_ruby->process); -} - -static void smx_ctx_ruby_runall(xbt_dynar_t processes) -{ - smx_process_t process; - smx_context_t old_context; - unsigned int cursor; - - xbt_dynar_foreach(processes, cursor, process) { - old_context = smx_current_context; - smx_current_context = process->context; - smx_ctx_ruby_resume(smx_current_context); - smx_current_context = old_context; - } - xbt_dynar_reset(processes); -} -- 2.20.1