Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
inline two C calls in surf
[simgrid.git] / src / simgrid / host.cpp
index d707b3e..5c881b0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-201. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -16,7 +16,7 @@ size_t sg_host_count()
 
 const char *sg_host_get_name(sg_host_t host)
 {
-       return host->id().c_str();
+       return host->getName().c_str();
 }
 
 void* sg_host_extension_get(sg_host_t host, size_t ext)
@@ -61,27 +61,23 @@ int ROUTING_HOST_LEVEL;
 int USER_HOST_LEVEL;
 
 #include "src/msg/msg_private.h" // MSG_host_priv_free. FIXME: killme
-#include "src/simdag/private.h" // __SD_workstation_destroy. FIXME: killme
+#include "src/simdag/simdag_private.h" // __SD_workstation_destroy. FIXME: killme
 #include "src/simix/smx_host_private.h" // SIMIX_host_destroy. FIXME: killme
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/surf_routing.hpp"
 
-static XBT_INLINE void surf_cpu_free(void *r) {
-  delete static_cast<simgrid::surf::Cpu*>(r);
-}
-static XBT_INLINE void routing_asr_host_free(void *p) {
-  delete static_cast<simgrid::surf::RoutingEdge*>(p);
-}
-
 void sg_host_init()
 {
   MSG_HOST_LEVEL = simgrid::Host::extension_create([](void *p) {
     __MSG_host_priv_free((msg_host_priv_t) p);
   });
+
+  ROUTING_HOST_LEVEL = simgrid::Host::extension_create([](void *p) {
+         delete static_cast<simgrid::surf::NetCard*>(p);
+  });
+
   SD_HOST_LEVEL = simgrid::Host::extension_create(__SD_workstation_destroy);
   SIMIX_HOST_LEVEL = simgrid::Host::extension_create(SIMIX_host_destroy);
-  simgrid::surf::Cpu::classInit();
-  ROUTING_HOST_LEVEL = simgrid::Host::extension_create(routing_asr_host_free);
   USER_HOST_LEVEL = simgrid::Host::extension_create(NULL);
 }
 
@@ -128,31 +124,11 @@ void sg_host_simix_destroy(sg_host_t host) {
   host->extension_set(SIMIX_HOST_LEVEL, nullptr);
 }
 
-// ========== SURF CPU ============
-surf_cpu_t sg_host_surfcpu(sg_host_t host) {
-       return host->extension<simgrid::surf::Cpu>();
-}
-void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) {
-  host->extension_set(simgrid::surf::Cpu::EXTENSION_ID, cpu); // FIXME: use the typesafe version
-}
-void sg_host_surfcpu_destroy(sg_host_t host) {
-  host->extension_set<simgrid::surf::Cpu>(nullptr);
-}
-// ========== RoutingEdge ============
-surf_RoutingEdge *sg_host_edge(sg_host_t host) {
-       return (surf_RoutingEdge*) host->extension(ROUTING_HOST_LEVEL);
-}
-void sg_host_edge_set(sg_host_t host, surf_RoutingEdge *edge) {
-  host->extension_set(ROUTING_HOST_LEVEL, edge);
-}
-void sg_host_edge_destroy(sg_host_t host, int do_callback) {
-  host->extension_set(ROUTING_HOST_LEVEL, nullptr, do_callback);
-}
-
 // =========== user-level functions ===============
 // ================================================
+/** @brief Get the speed of the cpu associated to a host */
 double sg_host_get_speed(sg_host_t host){
-  return surf_host_get_speed(host, 1.0);
+       return host->p_cpu->getSpeed(1.0);
 }
 
 double sg_host_get_available_speed(sg_host_t host){
@@ -160,7 +136,7 @@ double sg_host_get_available_speed(sg_host_t host){
 }
 /** @brief Returns the number of core of the processor. */
 int sg_host_get_core(sg_host_t host) {
-       return surf_host_get_core(host);
+       return host->p_cpu->getCore();
 }
 /** @brief Returns the state of a host.
  *  @return 1 if the host is active or 0 if it has crashed.
@@ -196,7 +172,7 @@ int sg_host_get_pstate(sg_host_t host) {
 namespace simgrid {
 
 Host::Host(std::string const& id)
-  : id_(id)
+  : name_(id)
 {
 }