A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
We must put the location where we copy the task
[simgrid.git]
/
src
/
bindings
/
ruby
/
MasterSlave.rb
diff --git
a/src/bindings/ruby/MasterSlave.rb
b/src/bindings/ruby/MasterSlave.rb
index
19afa26
..
7b04171
100644
(file)
--- a/
src/bindings/ruby/MasterSlave.rb
+++ b/
src/bindings/ruby/MasterSlave.rb
@@
-2,18
+2,19
@@
# make -C ../.. && valgrind ruby MasterSlave.rb --log=ruby.thres:debug 2>&1 | less
require 'simgrid'
# make -C ../.. && valgrind ruby MasterSlave.rb --log=ruby.thres:debug 2>&1 | less
require 'simgrid'
+
include MSG
#################################################
# Class Master
#################################################
include MSG
#################################################
# Class Master
#################################################
-class Master < M
sg
Process
+class Master < M
SG::
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
# 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
- info("args["+String(i)+"]="+args[i])
+
MSG::
info("args["+String(i)+"]="+args[i])
end
raise "Master needs 3 arguments" if size < 3
end
raise "Master needs 3 arguments" if size < 3
@@
-24,46
+25,49
@@
class Master < MsgProcess
# Creates and sends the tasks
for i in 0..numberOfTask-1
# Creates and sends the tasks
for i in 0..numberOfTask-1
- task = Task.new("Task_"+ i.to_s, taskComputeSize , taskCommunicationSize);
+ task =
MSG::
Task.new("Task_"+ i.to_s, taskComputeSize , taskCommunicationSize);
mailbox = "slave " + (i%slaveCount).to_s
mailbox = "slave " + (i%slaveCount).to_s
-
info("Master Sending "+ Task.name(task)
+ " to " + mailbox + " with Comput Size " +
-
Task.compSize(task)
.to_s)
+
MSG::info("Master Sending "+ task.name
+ " to " + mailbox + " with Comput Size " +
+
task.compSize
.to_s)
# task.compSize.to_s) # FIXME: This version creates a deadlock. Interesting
# task.compSize.to_s) # FIXME: This version creates a deadlock. Interesting
-
Task.send(task,
mailbox)
-
info("Master Done Sending " +Task.name(task)
+ " to " + mailbox)
+
task.send(
mailbox)
+
MSG::info("Master Done Sending " + task.name
+ " to " + mailbox)
end
end
- # Sending Finalize Tasks
-
info
("Master: All tasks have been dispatched. Let's tell everybody the computation is over.")
+ # Sending Finalize
MSG::
Tasks
+
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
for i in 0..slaveCount-1
mailbox = "slave " + i.to_s
- info ("Master Sending Finalize to " + mailbox)
- Task.send(Task.new("finalize",0,0),mailbox)
+ MSG::info("Master Sending Finalize to " + mailbox)
+ finalize_task = Task.new("finalize",0,0)
+ finalize_task.send(mailbox)
end
end
- info("Master : Everything's Done")
+
MSG::
info("Master : Everything's Done")
end
end
#################################################
# Class Slave
#################################################
end
end
#################################################
# Class Slave
#################################################
-class Slave < M
sg
Process
+class Slave < M
SG::
Process
def main(args)
mailbox = "slave " + args[0]
def main(args)
mailbox = "slave " + args[0]
+ for i in 0..args.size-1
+ MSG::debug("args["+String(i)+"]="+args[i])
+ end
while true
info("Ready to Receive Task")
while true
info("Ready to Receive Task")
- task = Task.receive(mailbox)
- task_name = Task.name(task)
- info ("Task Received : " + task.name)
+ task = MSG::Task.receive(mailbox)
+ MSG::info("Task Received : " + task.name)
if (task_name == "finalize")
if (task_name == "finalize")
- info("Slave" + s_mailbox + "got finalize msg")
+
MSG::
info("Slave" + s_mailbox + "got finalize msg")
break
end
break
end
-
info("Slave " + s_mailbox + " ...Processing" + Task.name(task)
)
- Task.execute(task)
+
MSG::info("Slave " + s_mailbox + " ...Processing" + task.name
)
+ task.execute
end
end
- info("Slave " + s_mailbox + "I'm Done , See You !!")
+
MSG::
info("Slave " + s_mailbox + "I'm Done , See You !!")
end
end
end
end
@@
-82,6
+86,6
@@
else
end
# Thread.list.each {|t| p t}
end
# Thread.list.each {|t| p t}
-MSG.run
()
-MSG.getClock()
+MSG.run
+puts "Simulation time : " + MSG.getClock .to_s
# exit()
# exit()