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)
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)
if(enable_gtnets)
include(FindGTnets)
endif(enable_gtnets)
-if(enable_ruby)
- include(FindRubySimgrid)
-endif(enable_ruby)
if(enable_smpi)
include(FindF2c)
endif(enable_smpi)
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
)
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"
${GRAS_SG_SRC}
${AMOK_SRC}
${LUA_SRC}
- ${RUBY_SRC}
${MC_SRC}
${add_src_files}
${include_files}
)
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 ###
###########################################
)
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 ###
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")
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)
#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)
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)
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("")
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)
-
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.")
--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()
+++ /dev/null
-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
+++ /dev/null
-# 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
+++ /dev/null
-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
+++ /dev/null
-#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!!
+++ /dev/null
-# 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
+++ /dev/null
-#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
+++ /dev/null
-
-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
-
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-<platform version="3">
- <process host="Inmos" function="Sender">
- <argument value="Bellevue"/>
- </process>
-<process host="Bellevue" function="Receiver"/>
-</platform>
+++ /dev/null
-<?xml version='1.0'?>
- <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
- <platform version="3">
- <AS id="AS0" routing="Full">
- <!-- ljlkj -->
- <host id="Inmos" power="98095000"/>
- <host id="Bellevue" power="76296000"/>
- <host id="Fafard" power="76296000"/>
- <host id="Ginette" power="48492000"/>
- <host id="Bourassa" power="48492000"/>
- <link id="6" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="11" bandwidth="252750" latency="0.00570455"/>
- <link id="3" bandwidth="34285625" latency="0.000514433"/>
- <link id="7" bandwidth="11618875" latency="0.00018998"/>
- <link id="9" bandwidth="7209750" latency="0.001461517"/>
- <link id="12" bandwidth="1792625" latency="0.007877863"/>
- <link id="2" bandwidth="118682500" latency="0.000136931"/>
- <link id="8" bandwidth="8158000" latency="0.000270544"/>
- <link id="1" bandwidth="34285625" latency="0.000514433"/>
- <link id="4" bandwidth="10099625" latency="0.00047978"/>
- <link id="0" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="10" bandwidth="4679750" latency="0.000848712"/>
- <link id="5" bandwidth="27946250" latency="0.000278066"/>
- <link id="loopback_FATPIPE" bandwidth="10000000" latency="0.1" sharing_policy="FATPIPE"/>
- <link id="loopback" bandwidth="498000000" latency="0.000015"/>
- <route src="Inmos" dst="Inmos"><link_ctn id="loopback"/></route>
- <route src="Bellevue" dst="Bellevue"><link_ctn id="loopback"/></route>
- <route src="Fafard" dst="Fafard"><link_ctn id="loopback"/></route>
- <route src="Ginette" dst="Ginette"><link_ctn id="loopback"/></route>
- <route src="Bourassa" dst="Bourassa"><link_ctn id="loopback"/></route>
- <route src="Inmos" dst="Bellevue">
- <link_ctn id="9"/>
- </route>
- <route src="Inmos" dst="Fafard">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Inmos" dst="Ginette">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Inmos" dst="Bourassa">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Bellevue" dst="Inmos">
- <link_ctn id="9"/>
- </route>
- <route src="Bellevue" dst="Fafard">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Bellevue" dst="Ginette">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Bellevue" dst="Bourassa">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Fafard" dst="Inmos">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Fafard" dst="Bellevue">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Fafard" dst="Ginette">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- <route src="Fafard" dst="Bourassa">
- <link_ctn id="8"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Ginette" dst="Inmos">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Ginette" dst="Bellevue">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Ginette" dst="Fafard">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Ginette" dst="Bourassa">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Bourassa" dst="Inmos">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Bourassa" dst="Bellevue">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Bourassa" dst="Fafard">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="8"/>
- </route>
- <route src="Bourassa" dst="Ginette">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- </AS>
- </platform>
+++ /dev/null
-<?xml version='1.0'?>
- <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
- <platform version="3">
- <AS id="AS0" routing="Full">
- <host id="Tremblay" power="98095000"/>
- <host id="Jupiter" power="76296000"/>
- <host id="Fafard" power="76296000"/>
- <host id="Ginette" power="48492000"/>
- <host id="Bourassa" power="48492000"/>
- <link id="6" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="11" bandwidth="252750" latency="0.00570455"/>
- <link id="3" bandwidth="34285625" latency="0.000514433"/>
- <link id="7" bandwidth="11618875" latency="0.00018998"/>
- <link id="9" bandwidth="7209750" latency="0.001461517"/>
- <link id="12" bandwidth="1792625" latency="0.007877863"/>
- <link id="2" bandwidth="118682500" latency="0.000136931"/>
- <link id="8" bandwidth="8158000" latency="0.000270544"/>
- <link id="1" bandwidth="34285625" latency="0.000514433"/>
- <link id="4" bandwidth="10099625" latency="0.00047978"/>
- <link id="0" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="10" bandwidth="4679750" latency="0.000848712"/>
- <link id="5" bandwidth="27946250" latency="0.000278066"/>
- <link id="loopback" bandwidth="498000000" latency="0.000015" sharing_policy="FATPIPE"/>
- <route src="Tremblay" dst="Tremblay"><link_ctn id="loopback"/></route>
- <route src="Jupiter" dst="Jupiter"><link_ctn id="loopback"/></route>
- <route src="Fafard" dst="Fafard"><link_ctn id="loopback"/></route>
- <route src="Ginette" dst="Ginette"><link_ctn id="loopback"/></route>
- <route src="Bourassa" dst="Bourassa"><link_ctn id="loopback"/></route>
- <route src="Tremblay" dst="Jupiter">
- <link_ctn id="9"/>
- </route>
- <route src="Tremblay" dst="Fafard">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Tremblay" dst="Ginette">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Tremblay" dst="Bourassa">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Jupiter" dst="Tremblay">
- <link_ctn id="9"/>
- </route>
- <route src="Jupiter" dst="Fafard">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Jupiter" dst="Ginette">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Jupiter" dst="Bourassa">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Fafard" dst="Tremblay">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Fafard" dst="Jupiter">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Fafard" dst="Ginette">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- <route src="Fafard" dst="Bourassa">
- <link_ctn id="8"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Ginette" dst="Tremblay">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Ginette" dst="Jupiter">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Ginette" dst="Fafard">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Ginette" dst="Bourassa">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Bourassa" dst="Tremblay">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Bourassa" dst="Jupiter">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Bourassa" dst="Fafard">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="8"/>
- </route>
- <route src="Bourassa" dst="Ginette">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- </AS>
- </platform>
+++ /dev/null
-# 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
+++ /dev/null
-# 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
+++ /dev/null
-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
+++ /dev/null
-# 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
+++ /dev/null
-<?xml version='1.0'?>
- <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
- <platform version="3">
- <AS id="AS0" routing="Full">
- <!-- ljlkj -->
- <host id="Tremblay" power="98095000"/>
- <host id="Jupiter" power="76296000"/>
- <host id="Fafard" power="76296000"/>
- <host id="Ginette" power="48492000"/>
- <host id="Bourassa" power="48492000"/>
- <link id="6" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="11" bandwidth="252750" latency="0.00570455"/>
- <link id="3" bandwidth="34285625" latency="0.000514433"/>
- <link id="7" bandwidth="11618875" latency="0.00018998"/>
- <link id="9" bandwidth="7209750" latency="0.001461517"/>
- <link id="12" bandwidth="1792625" latency="0.007877863"/>
- <link id="2" bandwidth="118682500" latency="0.000136931"/>
- <link id="8" bandwidth="8158000" latency="0.000270544"/>
- <link id="1" bandwidth="34285625" latency="0.000514433"/>
- <link id="4" bandwidth="10099625" latency="0.00047978"/>
- <link id="0" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="10" bandwidth="4679750" latency="0.000848712"/>
- <link id="5" bandwidth="27946250" latency="0.000278066"/>
- <link id="loopback" bandwidth="498000000" latency="0.000015" sharing_policy="FATPIPE"/>
- <route src="Tremblay" dst="Tremblay"><link_ctn id="loopback"/></route>
- <route src="Jupiter" dst="Jupiter"><link_ctn id="loopback"/></route>
- <route src="Fafard" dst="Fafard"><link_ctn id="loopback"/></route>
- <route src="Ginette" dst="Ginette"><link_ctn id="loopback"/></route>
- <route src="Bourassa" dst="Bourassa"><link_ctn id="loopback"/></route>
- <route src="Tremblay" dst="Jupiter">
- <link_ctn id="9"/>
- </route>
- <route src="Tremblay" dst="Fafard">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Tremblay" dst="Ginette">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Tremblay" dst="Bourassa">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Jupiter" dst="Tremblay">
- <link_ctn id="9"/>
- </route>
- <route src="Jupiter" dst="Fafard">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Jupiter" dst="Ginette">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Jupiter" dst="Bourassa">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Fafard" dst="Tremblay">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Fafard" dst="Jupiter">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Fafard" dst="Ginette">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- <route src="Fafard" dst="Bourassa">
- <link_ctn id="8"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Ginette" dst="Tremblay">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Ginette" dst="Jupiter">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Ginette" dst="Fafard">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Ginette" dst="Bourassa">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Bourassa" dst="Tremblay">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Bourassa" dst="Jupiter">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Bourassa" dst="Fafard">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="8"/>
- </route>
- <route src="Bourassa" dst="Ginette">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- </AS>
- </platform>
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-<platform version="3">
- <!-- The master process (with some arguments) -->
- <process host="Tremblay" function="Master">
- <argument value="20"/> <!-- Number of tasks -->
- <argument value="50000000"/> <!-- Computation size of tasks -->
- <argument value="1000000"/> <!-- Communication size of tasks -->
- <argument value="4"/> <!-- Amount of slaves -->
- </process>
- <!-- The slave process (argument: slave rank) -->
- <process host="Bourassa" function="Slave">
- <argument value="0"/>
- </process>
- <process host="Jupiter" function="Slave">
- <argument value="1"/>
- </process>
- <process host="Fafard" function="Slave">
- <argument value="2"/>
- </process>
- <process host="Ginette" function="Slave">
- <argument value="3"/>
- </process>
-</platform>
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-<platform version="3">
- <!-- The master process (with some arguments) -->
- <process host="Tremblay" function="Master">
- <argument value="1"/> <!-- Number of tasks -->
- <argument value="50000000"/> <!-- Computation size of tasks -->
- <argument value="1000000"/> <!-- Communication size of tasks -->
- <argument value="1"/> <!-- Amount of slaves -->
- </process>
- <!-- The slave process (with no argument) -->
- <process host="Bourassa" function="Slave">
- <argument value="0"/>
- </process>
-</platform>
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-<platform version="3">
- <process host="Inmos" function="Sender">
- <argument value="Bellevue"/>
- </process>
-<process host="Bellevue" function="Receiver"/>
-</platform>
+++ /dev/null
-<?xml version='1.0'?>
- <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
- <platform version="3">
- <AS id="AS0" routing="Full">
- <!-- ljlkj -->
- <host id="Inmos" power="98095000"/>
- <host id="Bellevue" power="76296000"/>
- <host id="Fafard" power="76296000"/>
- <host id="Ginette" power="48492000"/>
- <host id="Bourassa" power="48492000"/>
- <link id="6" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="11" bandwidth="252750" latency="0.00570455"/>
- <link id="3" bandwidth="34285625" latency="0.000514433"/>
- <link id="7" bandwidth="11618875" latency="0.00018998"/>
- <link id="9" bandwidth="7209750" latency="0.001461517"/>
- <link id="12" bandwidth="1792625" latency="0.007877863"/>
- <link id="2" bandwidth="118682500" latency="0.000136931"/>
- <link id="8" bandwidth="8158000" latency="0.000270544"/>
- <link id="1" bandwidth="34285625" latency="0.000514433"/>
- <link id="4" bandwidth="10099625" latency="0.00047978"/>
- <link id="0" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="10" bandwidth="4679750" latency="0.000848712"/>
- <link id="5" bandwidth="27946250" latency="0.000278066"/>
- <link id="loopback_FATPIPE" bandwidth="10000000" latency="0.1" sharing_policy="FATPIPE"/>
- <link id="loopback" bandwidth="498000000" latency="0.000015"/>
- <route src="Inmos" dst="Inmos"><link_ctn id="loopback"/></route>
- <route src="Bellevue" dst="Bellevue"><link_ctn id="loopback"/></route>
- <route src="Fafard" dst="Fafard"><link_ctn id="loopback"/></route>
- <route src="Ginette" dst="Ginette"><link_ctn id="loopback"/></route>
- <route src="Bourassa" dst="Bourassa"><link_ctn id="loopback"/></route>
- <route src="Inmos" dst="Bellevue">
- <link_ctn id="9"/>
- </route>
- <route src="Inmos" dst="Fafard">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Inmos" dst="Ginette">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Inmos" dst="Bourassa">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Bellevue" dst="Inmos">
- <link_ctn id="9"/>
- </route>
- <route src="Bellevue" dst="Fafard">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Bellevue" dst="Ginette">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Bellevue" dst="Bourassa">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Fafard" dst="Inmos">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Fafard" dst="Bellevue">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Fafard" dst="Ginette">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- <route src="Fafard" dst="Bourassa">
- <link_ctn id="8"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Ginette" dst="Inmos">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Ginette" dst="Bellevue">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Ginette" dst="Fafard">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Ginette" dst="Bourassa">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Bourassa" dst="Inmos">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Bourassa" dst="Bellevue">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Bourassa" dst="Fafard">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="8"/>
- </route>
- <route src="Bourassa" dst="Ginette">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- </AS>
- </platform>
+++ /dev/null
-<?xml version='1.0'?>
- <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
- <platform version="3">
- <AS id="AS0" routing="Full">
- <!-- ljlkj -->
- <host id="Tremblay" power="98095000"/>
- <host id="Jupiter" power="76296000"/>
- <host id="Fafard" power="76296000"/>
- <host id="Ginette" power="48492000"/>
- <host id="Bourassa" power="48492000"/>
- <link id="6" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="11" bandwidth="252750" latency="0.00570455"/>
- <link id="3" bandwidth="34285625" latency="0.000514433"/>
- <link id="7" bandwidth="11618875" latency="0.00018998"/>
- <link id="9" bandwidth="7209750" latency="0.001461517"/>
- <link id="12" bandwidth="1792625" latency="0.007877863"/>
- <link id="2" bandwidth="118682500" latency="0.000136931"/>
- <link id="8" bandwidth="8158000" latency="0.000270544"/>
- <link id="1" bandwidth="34285625" latency="0.000514433"/>
- <link id="4" bandwidth="10099625" latency="0.00047978"/>
- <link id="0" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="10" bandwidth="4679750" latency="0.000848712"/>
- <link id="5" bandwidth="27946250" latency="0.000278066"/>
- <link id="loopback" bandwidth="498000000" latency="0.000015" sharing_policy="FATPIPE"/>
- <route src="Tremblay" dst="Tremblay"><link_ctn id="loopback"/></route>
- <route src="Jupiter" dst="Jupiter"><link_ctn id="loopback"/></route>
- <route src="Fafard" dst="Fafard"><link_ctn id="loopback"/></route>
- <route src="Ginette" dst="Ginette"><link_ctn id="loopback"/></route>
- <route src="Bourassa" dst="Bourassa"><link_ctn id="loopback"/></route>
- <route src="Tremblay" dst="Jupiter">
- <link_ctn id="9"/>
- </route>
- <route src="Tremblay" dst="Fafard">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Tremblay" dst="Ginette">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Tremblay" dst="Bourassa">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Jupiter" dst="Tremblay">
- <link_ctn id="9"/>
- </route>
- <route src="Jupiter" dst="Fafard">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Jupiter" dst="Ginette">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Jupiter" dst="Bourassa">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Fafard" dst="Tremblay">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Fafard" dst="Jupiter">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Fafard" dst="Ginette">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- <route src="Fafard" dst="Bourassa">
- <link_ctn id="8"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Ginette" dst="Tremblay">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Ginette" dst="Jupiter">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Ginette" dst="Fafard">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Ginette" dst="Bourassa">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Bourassa" dst="Tremblay">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Bourassa" dst="Jupiter">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Bourassa" dst="Fafard">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="8"/>
- </route>
- <route src="Bourassa" dst="Ginette">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- </AS>
- </platform>
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-<platform version="3">
- <process host="Inmos" function="Sender">
- <argument value ="Bellevue"/>
- <argument value="5000000"/>
- <argument value="100000"/>
- <argument value="Receiver"/> <!--will be used as a mailbox alias-->
- </process>
- <process host="Bellevue" function="Receiver">
- <argument value="Inmos"/>
- <argument value="Sender"/> <!--will be used as a mailbox alias-->
- </process>
-</platform>
+++ /dev/null
-<?xml version='1.0'?>
- <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
- <platform version="3">
- <AS id="AS0" routing="Full">
- <!-- ljlkj -->
- <host id="Inmos" power="98095000"/>
- <host id="Bellevue" power="76296000"/>
- <host id="Fafard" power="76296000"/>
- <host id="Ginette" power="48492000"/>
- <host id="Bourassa" power="48492000"/>
- <link id="6" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="11" bandwidth="252750" latency="0.00570455"/>
- <link id="3" bandwidth="34285625" latency="0.000514433"/>
- <link id="7" bandwidth="11618875" latency="0.00018998"/>
- <link id="9" bandwidth="7209750" latency="0.001461517"/>
- <link id="12" bandwidth="1792625" latency="0.007877863"/>
- <link id="2" bandwidth="118682500" latency="0.000136931"/>
- <link id="8" bandwidth="8158000" latency="0.000270544"/>
- <link id="1" bandwidth="34285625" latency="0.000514433"/>
- <link id="4" bandwidth="10099625" latency="0.00047978"/>
- <link id="0" bandwidth="41279125" latency="5.9904e-05"/>
- <link id="10" bandwidth="4679750" latency="0.000848712"/>
- <link id="5" bandwidth="27946250" latency="0.000278066"/>
- <link id="loopback_FATPIPE" bandwidth="10000000" latency="0.1" sharing_policy="FATPIPE"/>
- <link id="loopback" bandwidth="498000000" latency="0.000015"/>
- <route src="Inmos" dst="Inmos"><link_ctn id="loopback"/></route>
- <route src="Bellevue" dst="Bellevue"><link_ctn id="loopback"/></route>
- <route src="Fafard" dst="Fafard"><link_ctn id="loopback"/></route>
- <route src="Ginette" dst="Ginette"><link_ctn id="loopback"/></route>
- <route src="Bourassa" dst="Bourassa"><link_ctn id="loopback"/></route>
- <route src="Inmos" dst="Bellevue">
- <link_ctn id="9"/>
- </route>
- <route src="Inmos" dst="Fafard">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Inmos" dst="Ginette">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Inmos" dst="Bourassa">
- <link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Bellevue" dst="Inmos">
- <link_ctn id="9"/>
- </route>
- <route src="Bellevue" dst="Fafard">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Bellevue" dst="Ginette">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="5"/>
- </route>
- <route src="Bellevue" dst="Bourassa">
- <link_ctn id="9"/><link_ctn id="4"/><link_ctn id="3"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Fafard" dst="Inmos">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Fafard" dst="Bellevue">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Fafard" dst="Ginette">
- <link_ctn id="8"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- <route src="Fafard" dst="Bourassa">
- <link_ctn id="8"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Ginette" dst="Inmos">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Ginette" dst="Bellevue">
- <link_ctn id="5"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Ginette" dst="Fafard">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="8"/>
- </route>
- <route src="Ginette" dst="Bourassa">
- <link_ctn id="5"/><link_ctn id="2"/><link_ctn id="0"/><link_ctn id="1"/><link_ctn id="6"/><link_ctn id="7"/>
- </route>
- <route src="Bourassa" dst="Inmos">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/>
- </route>
- <route src="Bourassa" dst="Bellevue">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="3"/><link_ctn id="4"/><link_ctn id="9"/>
- </route>
- <route src="Bourassa" dst="Fafard">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="8"/>
- </route>
- <route src="Bourassa" dst="Ginette">
- <link_ctn id="7"/><link_ctn id="6"/><link_ctn id="1"/><link_ctn id="0"/><link_ctn id="2"/><link_ctn id="5"/>
- </route>
- </AS>
- </platform>
+++ /dev/null
-/* 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);
-
-}
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-/* 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);
-}
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-# 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)
+++ /dev/null
-/* 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);
-}
+++ /dev/null
-/* 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 <ruby.h>
-
-/* ********************* *
- * 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 */
* <em>message size</em> and some <em>private data</em>.
*/
-#ifdef HAVE_RUBY /* FIXME: KILLME */
-XBT_LOG_EXTERNAL_CATEGORY(ruby);
-#endif
-
-
-
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg,
"Logging specific to MSG (task)");
+++ /dev/null
-/* 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);
-}