Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bypass the C binding layer (surf_action and surf_host)
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 8 Jan 2016 12:45:36 +0000 (13:45 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 8 Jan 2016 13:29:05 +0000 (14:29 +0100)
14 files changed:
src/simdag/sd_global.cpp
src/simdag/sd_task.cpp
src/simix/smx_global.cpp
src/simix/smx_host.cpp
src/simix/smx_io.cpp
src/simix/smx_network.cpp
src/simix/smx_process.cpp
src/simix/smx_synchro.cpp
src/simix/smx_vm.cpp
src/surf/plugins/energy.cpp
src/surf/surf_c_bindings.cpp
src/surf/vm_hl13.cpp
teshsuite/surf/surf_usage/surf_usage.cpp
teshsuite/surf/surf_usage/surf_usage2.cpp

index e51bd37..f2726b1 100644 (file)
@@ -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 "src/surf/surf_interface.hpp"
 #include "src/simdag/simdag_private.h"
 #include "instr/instr_interface.h"
 #include "xbt/sysdep.h"
@@ -303,8 +304,8 @@ xbt_swag_t SD_simulate_swag(double how_long) {
     /* let's see which tasks are done */
     xbt_dynar_foreach(all_existing_models, iter, model) {
       while ((action = surf_model_extract_done_action_set(model))) {
-        task = (SD_task_t)surf_action_get_data(action);
-        task->start_time = surf_action_get_start_time(task->surf_action);
+        task = (SD_task_t) action->getData();
+        task->start_time = task->surf_action->getStartTime();
 
         task->finish_time = surf_get_clock();
         XBT_VERB("Task '%s' done", SD_task_get_name(task));
@@ -370,12 +371,12 @@ xbt_swag_t SD_simulate_swag(double how_long) {
 
       /* let's see which tasks have just failed */
       while ((action = surf_model_extract_failed_action_set(model))) {
-        task = (SD_task_t)surf_action_get_data(action);
+        task = (SD_task_t) action->getData();
         task->start_time = surf_action_get_start_time(task->surf_action);
         task->finish_time = surf_get_clock();
         XBT_VERB("Task '%s' failed", SD_task_get_name(task));
         __SD_task_set_state(task, SD_FAILED);
-        surf_action_unref(action);
+        action->unref();
         task->surf_action = NULL;
 
         xbt_swag_insert(task,sd_global->return_set);
index ea1e37e..4f06748 100644 (file)
@@ -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 "src/surf/surf_interface.hpp"
 #include "src/simdag/simdag_private.h"
 #include "simgrid/simdag.h"
 #include "xbt/sysdep.h"
@@ -247,7 +248,7 @@ void SD_task_destroy(SD_task_t task)
   xbt_free(task->name);
 
   if (task->surf_action != NULL)
-       surf_action_unref(task->surf_action);
+       task->surf_action->unref();
 
   xbt_free(task->workstation_list);
   xbt_free(task->bytes_amount);
@@ -350,11 +351,11 @@ void __SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state)
     break;
   case SD_RUNNING:
     task->state_set = sd_global->running_task_set;
-    task->start_time = surf_action_get_start_time(task->surf_action);
+    task->start_time = task->surf_action->getStartTime();
     break;
   case SD_DONE:
     task->state_set = sd_global->done_task_set;
-    task->finish_time = surf_action_get_finish_time(task->surf_action);
+    task->finish_time = task->surf_action->getFinishTime();
     task->remains = 0;
 #ifdef HAVE_JEDULE
     jedule_log_sd_event(task);
@@ -1053,7 +1054,7 @@ void SD_task_unschedule(SD_task_t task)
   }
 
   if (__SD_task_is_running(task))       /* the task should become SD_FAILED */
-       surf_action_cancel(task->surf_action);
+       task->surf_action->cancel();
   else {
     if (task->unsatisfied_dependencies == 0)
       __SD_task_set_state(task, SD_SCHEDULABLE);
@@ -1139,7 +1140,7 @@ void __SD_task_really_run(SD_task_t task)
                                                                     bytes_amount,
                                                                     task->rate);
 
-  surf_action_set_data(task->surf_action, task);
+  task->surf_action->setData(task);
 
   XBT_DEBUG("surf_action = %p", task->surf_action);
 
@@ -1226,7 +1227,7 @@ void __SD_task_just_done(SD_task_t task)
   candidates = xbt_new(SD_task_t, 8);
 
   __SD_task_set_state(task, SD_DONE);
-  surf_action_unref(task->surf_action);
+  task->surf_action->unref();
   task->surf_action = NULL;
 
   XBT_DEBUG("Looking for candidates");
@@ -1384,7 +1385,7 @@ static void __SD_task_remove_dependencies(SD_task_t task)
 double SD_task_get_start_time(SD_task_t task)
 {
   if (task->surf_action)
-    return surf_action_get_start_time(task->surf_action);
+    return task->surf_action->getStartTime();
   else
     return task->start_time;
 }
@@ -1403,7 +1404,7 @@ double SD_task_get_start_time(SD_task_t task)
 double SD_task_get_finish_time(SD_task_t task)
 {
   if (task->surf_action)        /* should never happen as actions are destroyed right after their completion */
-    return surf_action_get_finish_time(task->surf_action);
+    return task->surf_action->getFinishTime();
   else
     return task->finish_time;
 }
index 1da0f27..be74fbf 100644 (file)
@@ -11,6 +11,7 @@
 # include <sys/ptrace.h>
 #endif
 
+#include "src/surf/surf_interface.hpp"
 #include "smx_private.h"
 #include "smx_private.hpp"
 #include "xbt/heap.h"
@@ -462,15 +463,15 @@ void SIMIX_run(void)
         XBT_DEBUG("Handling process whose action failed");
         while ((action = surf_model_extract_failed_action_set(model))) {
           XBT_DEBUG("   Handling Action %p",action);
-          SIMIX_simcall_exit((smx_synchro_t) surf_action_get_data(action));
+          SIMIX_simcall_exit((smx_synchro_t) action->getData());
         }
         XBT_DEBUG("Handling process whose action terminated normally");
         while ((action = surf_model_extract_done_action_set(model))) {
           XBT_DEBUG("   Handling Action %p",action);
-          if (surf_action_get_data(action) == NULL)
+          if (action->getData() == NULL)
             XBT_DEBUG("probably vcpu's action %p, skip", action);
           else
-            SIMIX_simcall_exit((smx_synchro_t) surf_action_get_data(action));
+            SIMIX_simcall_exit((smx_synchro_t) action->getData());
         }
       }
     }
@@ -500,15 +501,15 @@ void SIMIX_run(void)
       XBT_DEBUG("Handling process whose action failed");
       while ((action = surf_model_extract_failed_action_set(model))) {
         XBT_DEBUG("   Handling Action %p",action);
-        SIMIX_simcall_exit((smx_synchro_t) surf_action_get_data(action));
+        SIMIX_simcall_exit((smx_synchro_t) action->getData());
       }
       XBT_DEBUG("Handling process whose action terminated normally");
       while ((action = surf_model_extract_done_action_set(model))) {
         XBT_DEBUG("   Handling Action %p",action);
-        if (surf_action_get_data(action) == NULL)
+        if (action->getData() == NULL)
           XBT_DEBUG("probably vcpu's action %p, skip", action);
         else
-          SIMIX_simcall_exit((smx_synchro_t) surf_action_get_data(action));
+          SIMIX_simcall_exit((smx_synchro_t) action->getData());
       }
     }
 
index 65d59d6..17ae79b 100644 (file)
@@ -324,16 +324,18 @@ smx_synchro_t SIMIX_process_execute(smx_process_t issuer, const char *name,
   if (!MC_is_active() && !MC_record_replay_is_active()) {
 
     synchro->execution.surf_exec = surf_host_execute(issuer->host, flops_amount);
-    surf_action_set_data(synchro->execution.surf_exec, synchro);
-    surf_action_set_priority(synchro->execution.surf_exec, priority);
+    synchro->execution.surf_exec->setData(synchro);
+    synchro->execution.surf_exec->setPriority(priority);
 
     if (bound != 0)
-      surf_cpu_action_set_bound(synchro->execution.surf_exec, bound);
+      static_cast<simgrid::surf::CpuAction*>(synchro->execution.surf_exec)
+        ->setBound(bound);
 
     if (affinity_mask != 0) {
       /* just a double check to confirm that this host is the host where this task is running. */
       xbt_assert(synchro->execution.host == issuer->host);
-      surf_cpu_action_set_affinity(synchro->execution.surf_exec, issuer->host, affinity_mask);
+      static_cast<simgrid::surf::CpuAction*>(synchro->execution.surf_exec)
+        ->setAffinity(issuer->host->p_cpu, affinity_mask);
     }
   }
 
@@ -382,7 +384,7 @@ smx_synchro_t SIMIX_process_parallel_execute(const char *name,
       surf_host_model_execute_parallel_task(surf_host_model,
                  host_nb, host_list_cpy, flops_amount, bytes_amount, rate);
 
-    surf_action_set_data(synchro->execution.surf_exec, synchro);
+    synchro->execution.surf_exec->setData(synchro);
   }
   XBT_DEBUG("Create parallel execute synchro %p", synchro);
 
@@ -393,7 +395,7 @@ void SIMIX_process_execution_destroy(smx_synchro_t synchro){
   XBT_DEBUG("Destroy synchro %p", synchro);
 
   if (synchro->execution.surf_exec) {
-    surf_action_unref(synchro->execution.surf_exec);
+    synchro->execution.surf_exec->unref();
     synchro->execution.surf_exec = NULL;
   }
   xbt_free(synchro->name);
@@ -404,7 +406,7 @@ void SIMIX_process_execution_cancel(smx_synchro_t synchro){
   XBT_DEBUG("Cancel synchro %p", synchro);
 
   if (synchro->execution.surf_exec)
-    surf_action_cancel(synchro->execution.surf_exec);
+    synchro->execution.surf_exec->cancel();
 }
 
 double SIMIX_process_execution_get_remains(smx_synchro_t synchro){
@@ -423,13 +425,14 @@ e_smx_state_t SIMIX_process_execution_get_state(smx_synchro_t synchro){
 void SIMIX_process_execution_set_priority(smx_synchro_t synchro, double priority){
 
   if(synchro->execution.surf_exec)
-       surf_action_set_priority(synchro->execution.surf_exec, priority);
+       synchro->execution.surf_exec->setPriority(priority);
 }
 
 void SIMIX_process_execution_set_bound(smx_synchro_t synchro, double bound){
 
   if(synchro->execution.surf_exec)
-       surf_cpu_action_set_bound(synchro->execution.surf_exec, bound);
+       static_cast<simgrid::surf::CpuAction*>(synchro->execution.surf_exec)
+    ->setBound(bound);
 }
 
 void SIMIX_process_execution_set_affinity(smx_synchro_t synchro, sg_host_t host, unsigned long mask){
@@ -438,7 +441,8 @@ void SIMIX_process_execution_set_affinity(smx_synchro_t synchro, sg_host_t host,
   if (synchro->execution.surf_exec) {
     /* just a double check to confirm that this host is the host where this task is running. */
     xbt_assert(synchro->execution.host == host);
-    surf_cpu_action_set_affinity(synchro->execution.surf_exec, host, mask);
+    static_cast<simgrid::surf::CpuAction*>(synchro->execution.surf_exec)
+      ->setAffinity(host->p_cpu, mask);
   }
 }
 
@@ -465,13 +469,13 @@ void simcall_HANDLER_process_execution_wait(smx_simcall_t simcall, smx_synchro_t
 void SIMIX_host_execution_suspend(smx_synchro_t synchro)
 {
   if(synchro->execution.surf_exec)
-    surf_action_suspend(synchro->execution.surf_exec);
+    synchro->execution.surf_exec->suspend();
 }
 
 void SIMIX_host_execution_resume(smx_synchro_t synchro)
 {
   if(synchro->execution.surf_exec)
-    surf_action_resume(synchro->execution.surf_exec);
+    synchro->execution.surf_exec->resume();
 }
 
 void SIMIX_execution_finish(smx_synchro_t synchro)
@@ -526,7 +530,7 @@ void SIMIX_post_host_execute(smx_synchro_t synchro)
     /* If the host running the synchro failed, notice it so that the asking
      * process can be killed if it runs on that host itself */
     synchro->state = SIMIX_FAILED;
-  } else if (surf_action_get_state(synchro->execution.surf_exec) == SURF_ACTION_FAILED) {
+  } else if (synchro->execution.surf_exec->getState() == SURF_ACTION_FAILED) {
     /* If the host running the synchro didn't fail, then the synchro was
      * canceled */
     synchro->state = SIMIX_CANCELED;
@@ -535,7 +539,7 @@ void SIMIX_post_host_execute(smx_synchro_t synchro)
   }
 
   if (synchro->execution.surf_exec) {
-    surf_action_unref(synchro->execution.surf_exec);
+    synchro->execution.surf_exec->unref();
     synchro->execution.surf_exec = NULL;
   }
 
@@ -550,9 +554,9 @@ void SIMIX_set_category(smx_synchro_t synchro, const char *category)
 {
   if (synchro->state != SIMIX_RUNNING) return;
   if (synchro->type == SIMIX_SYNC_EXECUTE){
-    surf_action_set_category(synchro->execution.surf_exec, category);
+    synchro->execution.surf_exec->setCategory(category);
   }else if (synchro->type == SIMIX_SYNC_COMMUNICATE){
-    surf_action_set_category(synchro->comm.surf_comm, category);
+    synchro->comm.surf_comm->setCategory(category);
   }
 }
 
index 9b1db2b..046ff2f 100644 (file)
@@ -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 "src/surf/surf_interface.hpp"
 #include "smx_private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
@@ -74,7 +75,7 @@ smx_synchro_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
   synchro->io.host = host;
   synchro->io.surf_io = surf_host_read(host, fd->surf_file, size);
 
-  surf_action_set_data(synchro->io.surf_io, synchro);
+  synchro->io.surf_io->setData(synchro);
   XBT_DEBUG("Create io synchro %p", synchro);
 
   return synchro;
@@ -106,7 +107,7 @@ smx_synchro_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
   synchro->io.host = host;
   synchro->io.surf_io = surf_host_write(host, fd->surf_file, size);
 
-  surf_action_set_data(synchro->io.surf_io, synchro);
+  synchro->io.surf_io->setData(synchro);
   XBT_DEBUG("Create io synchro %p", synchro);
 
   return synchro;
@@ -138,7 +139,7 @@ smx_synchro_t SIMIX_file_open(const char* fullpath, sg_host_t host)
   synchro->io.host = host;
   synchro->io.surf_io = surf_host_open(host, fullpath);
 
-  surf_action_set_data(synchro->io.surf_io, synchro);
+  synchro->io.surf_io->setData(synchro);
   XBT_DEBUG("Create io synchro %p", synchro);
 
   return synchro;
@@ -170,7 +171,7 @@ smx_synchro_t SIMIX_file_close(smx_file_t fd, sg_host_t host)
   synchro->io.host = host;
   synchro->io.surf_io = surf_host_close(host, fd->surf_file);
 
-  surf_action_set_data(synchro->io.surf_io, synchro);
+  synchro->io.surf_io->setData(synchro);
   XBT_DEBUG("Create io synchro %p", synchro);
 
   return synchro;
@@ -309,11 +310,13 @@ void SIMIX_post_io(smx_synchro_t synchro)
       simcall_file_close__set__result(simcall, 0);
       break;
     case SIMCALL_FILE_WRITE:
-      simcall_file_write__set__result(simcall, surf_action_get_cost(synchro->io.surf_io));
+      simcall_file_write__set__result(simcall,
+        synchro->io.surf_io->getCost());
       break;
 
     case SIMCALL_FILE_READ:
-      simcall_file_read__set__result(simcall, surf_action_get_cost(synchro->io.surf_io));
+      simcall_file_read__set__result(simcall,
+        synchro->io.surf_io->getCost());
       break;
 
     default:
@@ -321,7 +324,7 @@ void SIMIX_post_io(smx_synchro_t synchro)
     }
   }
 
-  switch (surf_action_get_state(synchro->io.surf_io)) {
+  switch (synchro->io.surf_io->getState()) {
 
     case SURF_ACTION_FAILED:
       synchro->state = SIMIX_FAILED;
@@ -343,7 +346,7 @@ void SIMIX_io_destroy(smx_synchro_t synchro)
 {
   XBT_DEBUG("Destroy synchro %p", synchro);
   if (synchro->io.surf_io)
-    surf_action_unref(synchro->io.surf_io);
+    synchro->io.surf_io->unref();
   xbt_mallocator_release(simix_global->synchro_mallocator, synchro);
 }
 
index 4f3c34a..e2a0538 100644 (file)
@@ -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 "src/surf/surf_interface.hpp"
 #include "smx_private.h"
 #include "xbt/log.h"
 #include "mc/mc.h"
@@ -314,17 +315,17 @@ void SIMIX_comm_destroy_internal_actions(smx_synchro_t synchro)
 #ifdef HAVE_LATENCY_BOUND_TRACKING
     synchro->latency_limited = SIMIX_comm_is_latency_bounded(synchro);
 #endif
-    surf_action_unref(synchro->comm.surf_comm);
+    synchro->comm.surf_comm->unref();
     synchro->comm.surf_comm = NULL;
   }
 
   if (synchro->comm.src_timeout){
-    surf_action_unref(synchro->comm.src_timeout);
+    synchro->comm.src_timeout->unref();
     synchro->comm.src_timeout = NULL;
   }
 
   if (synchro->comm.dst_timeout){
-    surf_action_unref(synchro->comm.dst_timeout);
+    synchro->comm.dst_timeout->unref();
     synchro->comm.dst_timeout = NULL;
   }
 }
@@ -609,7 +610,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_synchro_t synchro, dou
     SIMIX_comm_finish(synchro);
   } else { /* if (timeout >= 0) { we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */
     sleep = surf_host_sleep(simcall->issuer->host, timeout);
-    surf_action_set_data(sleep, synchro);
+    sleep->setData(synchro);
 
     if (simcall->issuer == synchro->comm.src_proc)
       synchro->comm.src_timeout = sleep;
@@ -729,12 +730,12 @@ static inline void SIMIX_comm_start(smx_synchro_t synchro)
                                                                    sender, receiver,
                                                                    synchro->comm.task_size, synchro->comm.rate);
 
-    surf_action_set_data(synchro->comm.surf_comm, synchro);
+    synchro->comm.surf_comm->setData(synchro);
 
     synchro->state = SIMIX_RUNNING;
 
     /* If a link is failed, detect it immediately */
-    if (surf_action_get_state(synchro->comm.surf_comm) == SURF_ACTION_FAILED) {
+    if (synchro->comm.surf_comm->getState() == SURF_ACTION_FAILED) {
       XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure",
                 SIMIX_host_get_name(sender), SIMIX_host_get_name(receiver));
       synchro->state = SIMIX_LINK_FAILURE;
@@ -754,7 +755,7 @@ static inline void SIMIX_comm_start(smx_synchro_t synchro)
         XBT_DEBUG("The communication is suspended on startup because dst (%s:%s) were suspended since it initiated the communication",
                   SIMIX_host_get_name(synchro->comm.dst_proc->host), synchro->comm.dst_proc->name);
 
-      surf_action_suspend(synchro->comm.surf_comm);
+      synchro->comm.surf_comm->suspend();
 
     }
   }
@@ -902,19 +903,19 @@ void SIMIX_post_comm(smx_synchro_t synchro)
 {
   /* Update synchro state */
   if (synchro->comm.src_timeout &&
-      surf_action_get_state(synchro->comm.src_timeout) == SURF_ACTION_DONE)
+      synchro->comm.src_timeout->getState() == SURF_ACTION_DONE)
     synchro->state = SIMIX_SRC_TIMEOUT;
   else if (synchro->comm.dst_timeout &&
-         surf_action_get_state(synchro->comm.dst_timeout) == SURF_ACTION_DONE)
+         synchro->comm.dst_timeout->getState() == SURF_ACTION_DONE)
     synchro->state = SIMIX_DST_TIMEOUT;
   else if (synchro->comm.src_timeout &&
-         surf_action_get_state(synchro->comm.src_timeout) == SURF_ACTION_FAILED)
+         synchro->comm.src_timeout->getState() == SURF_ACTION_FAILED)
     synchro->state = SIMIX_SRC_HOST_FAILURE;
   else if (synchro->comm.dst_timeout &&
-      surf_action_get_state(synchro->comm.dst_timeout) == SURF_ACTION_FAILED)
+      synchro->comm.dst_timeout->getState() == SURF_ACTION_FAILED)
     synchro->state = SIMIX_DST_HOST_FAILURE;
   else if (synchro->comm.surf_comm &&
-         surf_action_get_state(synchro->comm.surf_comm) == SURF_ACTION_FAILED) {
+         synchro->comm.surf_comm->getState() == SURF_ACTION_FAILED) {
     XBT_DEBUG("Puta madre. Surf says that the link broke");
     synchro->state = SIMIX_LINK_FAILURE;
   } else
@@ -944,7 +945,7 @@ void SIMIX_comm_cancel(smx_synchro_t synchro)
            && !MC_record_replay_is_active()
            && (synchro->state == SIMIX_READY || synchro->state == SIMIX_RUNNING)) {
 
-    surf_action_cancel(synchro->comm.surf_comm);
+    synchro->comm.surf_comm->cancel();
   }
 }
 
@@ -952,7 +953,7 @@ void SIMIX_comm_suspend(smx_synchro_t synchro)
 {
   /*FIXME: shall we suspend also the timeout synchro? */
   if (synchro->comm.surf_comm)
-    surf_action_suspend(synchro->comm.surf_comm);
+    synchro->comm.surf_comm->suspend();
   /* in the other case, the action will be suspended on creation, in SIMIX_comm_start() */
 }
 
@@ -960,7 +961,7 @@ void SIMIX_comm_resume(smx_synchro_t synchro)
 {
   /*FIXME: check what happen with the timeouts */
   if (synchro->comm.surf_comm)
-    surf_action_resume(synchro->comm.surf_comm);
+    synchro->comm.surf_comm->resume();
   /* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */
 }
 
index c939390..46d0fbd 100644 (file)
@@ -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 "src/surf/surf_interface.hpp"
 #include "smx_private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
@@ -721,7 +722,7 @@ void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_process_t process,
 
 static int SIMIX_process_join_finish(smx_process_exit_status_t status, smx_synchro_t sync){
   if (sync->sleep.surf_sleep) {
-    surf_action_cancel(sync->sleep.surf_sleep);
+    sync->sleep.surf_sleep->cancel();
 
     smx_simcall_t simcall;
     while ((simcall = (smx_simcall_t) xbt_fifo_shift(sync->simcalls))) {
@@ -735,7 +736,7 @@ static int SIMIX_process_join_finish(smx_process_exit_status_t status, smx_synch
         SIMIX_simcall_answer(simcall);
       }
     }
-    surf_action_unref(sync->sleep.surf_sleep);
+    sync->sleep.surf_sleep->unref();
     sync->sleep.surf_sleep = NULL;
   }
   xbt_mallocator_release(simix_global->synchro_mallocator, sync);
@@ -781,7 +782,7 @@ smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration)
   synchro->sleep.host = host;
   synchro->sleep.surf_sleep = surf_host_sleep(host, duration);
 
-  surf_action_set_data(synchro->sleep.surf_sleep, synchro);
+  synchro->sleep.surf_sleep->setData(synchro);
   XBT_DEBUG("Create sleep synchronization %p", synchro);
 
   return synchro;
@@ -795,7 +796,7 @@ void SIMIX_post_process_sleep(smx_synchro_t synchro)
 
   while ((simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls))) {
 
-    switch(surf_action_get_state(synchro->sleep.surf_sleep)){
+    switch (synchro->sleep.surf_sleep->getState()){
       case SURF_ACTION_FAILED:
         simcall->issuer->context->iwannadie = 1;
         //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
@@ -833,7 +834,7 @@ void SIMIX_process_sleep_destroy(smx_synchro_t synchro)
   xbt_assert(synchro->type == SIMIX_SYNC_SLEEP || synchro->type == SIMIX_SYNC_JOIN);
 
   if (synchro->sleep.surf_sleep) {
-    surf_action_unref(synchro->sleep.surf_sleep);
+    synchro->sleep.surf_sleep->unref();
     synchro->sleep.surf_sleep = NULL;
   }
   if (synchro->type == SIMIX_SYNC_SLEEP)
@@ -843,14 +844,14 @@ void SIMIX_process_sleep_destroy(smx_synchro_t synchro)
 void SIMIX_process_sleep_suspend(smx_synchro_t synchro)
 {
   xbt_assert(synchro->type == SIMIX_SYNC_SLEEP);
-  surf_action_suspend(synchro->sleep.surf_sleep);
+  synchro->sleep.surf_sleep->suspend();
 }
 
 void SIMIX_process_sleep_resume(smx_synchro_t synchro)
 {
   XBT_DEBUG("Synchro state is %d on process_sleep_resume.", synchro->state);
   xbt_assert(synchro->type == SIMIX_SYNC_SLEEP);
-  surf_action_resume(synchro->sleep.surf_sleep);
+  synchro->sleep.surf_sleep->resume();
 }
 
 /**
index 090c872..ff7f7e7 100644 (file)
@@ -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 "src/surf/surf_interface.hpp"
 #include "smx_private.h"
 #include "xbt/log.h"
 
@@ -30,7 +31,7 @@ static smx_synchro_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout)
   sync->name = xbt_strdup("synchro");
   sync->synchro.sleep = surf_host_sleep(smx_host, timeout);
 
-  surf_action_set_data(sync->synchro.sleep, sync);
+  sync->synchro.sleep->setData(sync);
   XBT_OUT();
   return sync;
 }
@@ -71,7 +72,7 @@ void SIMIX_synchro_destroy(smx_synchro_t synchro)
   XBT_IN("(%p)",synchro);
   XBT_DEBUG("Destroying synchro %p", synchro);
   xbt_assert(synchro->type == SIMIX_SYNC_SYNCHRO);
-  surf_action_unref(synchro->synchro.sleep);
+  synchro->synchro.sleep->unref();
   xbt_free(synchro->name);
   xbt_mallocator_release(simix_global->synchro_mallocator, synchro);
   XBT_OUT();
@@ -81,9 +82,9 @@ void SIMIX_post_synchro(smx_synchro_t synchro)
 {
   XBT_IN("(%p)",synchro);
   xbt_assert(synchro->type == SIMIX_SYNC_SYNCHRO);
-  if (surf_action_get_state(synchro->synchro.sleep) == SURF_ACTION_FAILED)
+  if (synchro->synchro.sleep->getState() == SURF_ACTION_FAILED)
     synchro->state = SIMIX_FAILED;
-  else if(surf_action_get_state(synchro->synchro.sleep) == SURF_ACTION_DONE)
+  else if(synchro->synchro.sleep->getState() == SURF_ACTION_DONE)
     synchro->state = SIMIX_SRC_TIMEOUT;
 
   SIMIX_synchro_finish(synchro);  
index 24cc2b9..6be0a15 100644 (file)
@@ -93,8 +93,9 @@ static int __can_be_started(sg_host_t vm)
 void SIMIX_vm_start(sg_host_t ind_vm)
 {
   if (__can_be_started(ind_vm))
-    static_cast<simgrid::surf::VirtualMachine*>(surf_host_resource_priv(ind_vm))
-      ->setState(SURF_VM_STATE_RUNNING);
+    static_cast<simgrid::surf::VirtualMachine*>(
+      ind_vm->extension<simgrid::surf::Host>()
+    )->setState(SURF_VM_STATE_RUNNING);
   else
     THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm));
 }
@@ -102,7 +103,9 @@ void SIMIX_vm_start(sg_host_t ind_vm)
 
 e_surf_vm_state_t SIMIX_vm_get_state(sg_host_t ind_vm)
 {
-  return static_cast<simgrid::surf::VirtualMachine*>(surf_host_resource_priv(ind_vm))->getState();
+  return static_cast<simgrid::surf::VirtualMachine*>(
+    ind_vm->extension<simgrid::surf::Host>()
+  )->getState();
 }
 
 /**
@@ -345,7 +348,9 @@ void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_process_t issuer)
   }
 
   /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
-  static_cast<simgrid::surf::VirtualMachine*>(surf_host_resource_priv(ind_vm))->setState(SURF_VM_STATE_CREATED);
+  static_cast<simgrid::surf::VirtualMachine*>(
+    ind_vm->extension<simgrid::surf::Host>()
+  )->setState(SURF_VM_STATE_CREATED);
 }
 
 void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t ind_vm)
index 1fddaab..feacbf1 100644 (file)
@@ -123,10 +123,10 @@ void sg_energy_plugin_init() {
            e_surf_action_state_t old,
            e_surf_action_state_t cur) {
          const char *name = getActionCpu(action)->getName();
-         simgrid::surf::Host *host = surf_host_resource_priv(sg_host_by_name(name));
+         simgrid::surf::Host *host = sg_host_by_name(name)->extension<simgrid::surf::Host>();
          simgrid::surf::VirtualMachine *vm = dynamic_cast<simgrid::surf::VirtualMachine*>(host);
          if (vm) // If it's a VM, take the corresponding PM
-             host = surf_host_resource_priv(vm->getPm());
+             host = vm->getPm()->extension<simgrid::surf::Host>();
 
          HostEnergy *host_energy = (*simgrid::energy::surf_energy)[host];
 
index 372bedc..866faf2 100644 (file)
@@ -19,11 +19,11 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
  *********/
 
 static simgrid::surf::Host *get_casted_host(sg_host_t host){
-  return static_cast<simgrid::surf::Host*>(surf_host_resource_priv(host));
+  return host->extension<simgrid::surf::Host>();
 }
 
 static simgrid::surf::VirtualMachine *get_casted_vm(sg_host_t host){
-  return static_cast<simgrid::surf::VirtualMachine*>(surf_host_resource_priv(host));
+  return static_cast<simgrid::surf::VirtualMachine*>(host->extension<simgrid::surf::Host>());
 }
 
 extern double NOW;
@@ -514,5 +514,5 @@ surf_file_t surf_storage_action_get_file(surf_action_t action){
 }
 
 surf_host_t surf_host_resource_priv(sg_host_t host) {
-  return host->extension(simgrid::surf::Host::EXTENSION_ID);
+  return host->extension<simgrid::surf::Host>();
 }
index 99b8723..4b93bba 100644 (file)
@@ -238,7 +238,7 @@ void VMHL13::restore()
  */
 void VMHL13::migrate(sg_host_t host_dest)
 {
-   Host *surfHost_dst = surf_host_resource_priv(host_dest);
+   Host *surfHost_dst = host_dest->extension<Host>();
    const char *vm_name = getName();
    const char *pm_name_src = p_hostPM->getName().c_str();
    const char *pm_name_dst = surfHost_dst->getName();
index fe6b1d4..83c5c50 100644 (file)
@@ -10,6 +10,7 @@
 #include "simgrid/sg_config.h"
 #include "surf/surf.h"
 #include "surf/surfxml_parse.h" // for reset callback
+#include "src/surf/surf_interface.hpp"
 
 #include "xbt/log.h"
 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
@@ -65,9 +66,9 @@ void test(char *platform)
   actionC = surf_host_sleep(hostB, 7.32);
 
   /* Use whatever calling style you want... */
-  stateActionA = surf_action_get_state(actionA);     /* When you know actionA model type */
-  stateActionB = surf_action_get_state(actionB);        /* If you're unsure about it's model type */
-  stateActionC = surf_action_get_state(actionC);     /* When you know actionA model type */
+  stateActionA = actionA->getState(); /* When you know actionA model type */
+  stateActionB = actionB->getState(); /* If you're unsure about it's model type */
+  stateActionC = actionC->getState(); /* When you know actionA model type */
 
   /* And just look at the state of these tasks */
   XBT_DEBUG("actionA : %p (%s)", actionA, string_action(stateActionA));
@@ -89,23 +90,23 @@ void test(char *platform)
     while ((action =
             surf_model_extract_failed_action_set((surf_model_t)surf_cpu_model_pm))) {
       XBT_DEBUG("\t * Failed : %p", action);
-      surf_action_unref(action);
+      action->unref();
     }
     while ((action =
             surf_model_extract_done_action_set((surf_model_t)surf_cpu_model_pm))) {
       XBT_DEBUG("\t * Done : %p", action);
-      surf_action_unref(action);
+      action->unref();
     }
     XBT_DEBUG("\t Network actions");
     while ((action =
             surf_model_extract_failed_action_set((surf_model_t)surf_network_model))) {
       XBT_DEBUG("\t * Failed : %p", action);
-      surf_action_unref(action);
+      action->unref();
     }
     while ((action =
             surf_model_extract_done_action_set((surf_model_t)surf_network_model))) {
       XBT_DEBUG("\t * Done : %p", action);
-      surf_action_unref(action);
+      action->unref();
     }
 
   } while ((surf_model_running_action_set_size((surf_model_t)surf_network_model) ||
index 7859613..9c95d45 100644 (file)
@@ -10,6 +10,7 @@
 #include "simgrid/sg_config.h"
 #include "surf/surf.h"
 #include "surf/surfxml_parse.h" // for reset callback
+#include "src/surf/surf_interface.hpp"
 
 #include "xbt/log.h"
 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
@@ -76,11 +77,11 @@ void test(char *platform)
       XBT_DEBUG("\t Actions");
       while ((action = surf_model_extract_failed_action_set((surf_model_t)model))) {
         XBT_DEBUG("\t * Failed : %p", action);
-        surf_action_unref(action);
+        action->unref();
       }
       while ((action = surf_model_extract_done_action_set((surf_model_t)model))) {
         XBT_DEBUG("\t * Done : %p", action);
-        surf_action_unref(action);
+        action->unref();
       }
       if (surf_model_running_action_set_size((surf_model_t)model)) {
         XBT_DEBUG("running that model");