From 6a921002725af476cba5bffbbb228dbcec625fee Mon Sep 17 00:00:00 2001 From: coldpeace Date: Tue, 15 Jun 2010 14:46:46 +0000 Subject: [PATCH 1/1] basic layer for simdag bindings ( modifyin' the return value of simulate from SD_task_t* to xbt_dynar_t) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7864 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/bindings/rubyDag/Makefile | 4 ++-- src/bindings/rubyDag/example.rb | 7 +++++-- src/bindings/rubyDag/rb_SD_task.c | 18 ++++++++++-------- src/bindings/rubyDag/rb_SD_workstation.c | 2 ++ src/bindings/rubyDag/rb_simdag.c | 1 + 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/bindings/rubyDag/Makefile b/src/bindings/rubyDag/Makefile index 48d3c0d7b5..b7d9c737da 100644 --- a/src/bindings/rubyDag/Makefile +++ b/src/bindings/rubyDag/Makefile @@ -40,8 +40,8 @@ sitelibdir = $(sitedir)/$(ruby_version) CC = gcc LIBRUBY = $(LIBRUBY_SO) LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a -LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME) -I . ../../.libs/libsimgrid.a -I /usr/include/lua5.1/ -ldl -llua5.1 -LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static +LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME) -I . ../../../lib/libsimgrid_static.a +LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static RUBY_EXTCONF_H = CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC $(cflags) diff --git a/src/bindings/rubyDag/example.rb b/src/bindings/rubyDag/example.rb index c3993a0842..e828d531f3 100644 --- a/src/bindings/rubyDag/example.rb +++ b/src/bindings/rubyDag/example.rb @@ -47,16 +47,19 @@ class Example rate = -1 + # Scheduling - DAG::Task.schedule(taskA,workstation_number,workstation_list,computation_amount,communication_amount,rate) + DAG::Task.schedule(taskA,workstation_number,workstation_list,computation_amount,communication_amount,rate) DAG::Task.schedule(taskB,workstation_number,workstation_list,computation_amount,communication_amount,rate) DAG::Task.schedule(taskC,workstation_number,workstation_list,computation_amount,communication_amount,rate) DAG::Task.schedule(taskD,workstation_number,workstation_list,computation_amount,communication_amount,rate) - + + changed_tasks = Array.new() changed_tasks = DAG::Task.simulate(-1.0) + for i in 0..changed_tasks.size-1 puts "Task "+ changed_tasks[i].name + " Started at " + changed_tasks[i].startTime.to_s + " has been done at "+ changed_tasks[i].finishTime.to_s diff --git a/src/bindings/rubyDag/rb_SD_task.c b/src/bindings/rubyDag/rb_SD_task.c index 076599fca3..740084b28c 100644 --- a/src/bindings/rubyDag/rb_SD_task.c +++ b/src/bindings/rubyDag/rb_SD_task.c @@ -4,6 +4,7 @@ /* 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 "ruby_simdag.h" #include "rb_SD_task.h" // Free Method @@ -160,16 +161,17 @@ static VALUE rb_SD_task_finish_time(VALUE class,VALUE task) static VALUE rb_SD_simulate(VALUE class,VALUE how_long) { int i; + SD_task_t task ; double hl = NUM2DBL(how_long); - SD_task_t * tasks = SD_simulate(hl); + xbt_dynar_t simulated_tasks = SD_simulate(hl) ; + VALUE rb_tasks = rb_ary_new(); - for (i = 0; tasks[i] != NULL; i++) - { - VALUE tk = Qnil; - tk = Data_Wrap_Struct(class, 0, SD_task_free, tasks[i]); - rb_ary_push(rb_tasks,tk); - - } + xbt_dynar_foreach(simulated_tasks, i, task){ + VALUE tk = Qnil; + tk = Data_Wrap_Struct(class, 0, SD_task_free, task); + rb_ary_push(rb_tasks,tk); + } + return rb_tasks; } diff --git a/src/bindings/rubyDag/rb_SD_workstation.c b/src/bindings/rubyDag/rb_SD_workstation.c index 615a745884..6b81d1bca1 100644 --- a/src/bindings/rubyDag/rb_SD_workstation.c +++ b/src/bindings/rubyDag/rb_SD_workstation.c @@ -4,8 +4,10 @@ /* 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 "ruby_simdag.h" #include "rb_SD_workstation.h" + static void SD_workstation_free(SD_workstation_t wrk) { //NOTHING TO DO diff --git a/src/bindings/rubyDag/rb_simdag.c b/src/bindings/rubyDag/rb_simdag.c index 0e2e06a043..322afdff52 100644 --- a/src/bindings/rubyDag/rb_simdag.c +++ b/src/bindings/rubyDag/rb_simdag.c @@ -15,6 +15,7 @@ *(GNU LGPL) which comes with this package. */ +//FIXME #include "ruby_simdag.h" #include "rb_SD_task.c" #include "rb_SD_workstation.c" #include -- 2.20.1