-# Debug it with this command:
-# make -C ../.. && valgrind ruby MasterSlave.rb --log=ruby.thres:debug 2>&1 | less
require 'simgrid'
include MSG
#################################################
# Creates and sends the tasks
for i in 0..numberOfTask-1
- task = RTask.new("Task_"+ i.to_s, taskComputeSize , taskCommunicationSize);
+ 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)
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 = RTask.new("finalize",0,0)
+ finalize_task = Task.new("finalize",0,0)
finalize_task.send(mailbox)
end
MSG::info("Master : Everything's Done")
end
MSG.run
puts "Simulation time : " + MSG.getClock .to_s
-MSG.exit
\ No newline at end of file
+MSG.exit
# MasterSlave Ruby Example
-$ ruby MasterSlave.rb
+$ 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
#PingPong Example
-$ ruby PingPong.rb
+$ 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
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("Greate !! Thx !!")
MSG::info("Here is my table after a quicksort :)")
p result
- MSG::info("Bye !! I finished My HomeWork !! Time to Sleep :)")
+ MSG::info("Bye Now :)")
end
end
lazy_friend = MSG::Host.getByName(args[0]).name
send_mailbox = args[1]
recv_mailbox = self.class
- MSG::info("Oh Not Again !! Grrr")
+ 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("Ok "+lazy_friend+ "I did it, next time try to do it yourself:)")
+ MSG::info("Sort Done ... Sending Back the new table")
task.send(send_mailbox)
- MSG::info("Bye lazy Friend !!")
+ MSG::info("Bye lazy Boy!!")
end
return i + 1
end
-
end
#################################################
#QuickSort Ruby Example
-$ ruby Quicksort.rb
+$ 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
- Execute:
(WARNING: the current directory must be examples/ruby/)
- ruby MasterSlave.rb
+ ruby -I ../../src/bindings/ruby MasterSlave.rb
===============================================================================
* PingPong.rb
- Execute:
(WARNING: the current directory must be examples/ruby/)
- ruby PingPong.rb
+ ruby -I ../../src/bindings/ruby PingPong.rb
================================================================================
* Quicksort.rb
- Execute:
(WARNING: the current directory must be examples/ruby/)
- ruby Quicksort.rb
+ ruby -I ../../src/bindings/ruby Quicksort.rb