Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
getting closer: no more MSG_STORAGE_LEVEL
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 8 Jun 2017 19:00:52 +0000 (21:00 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 8 Jun 2017 19:00:52 +0000 (21:00 +0200)
next step, stop using storage_lib in surf at all, now that it's a mere
map

21 files changed:
include/simgrid/msg.h
include/surf/surf_routing.h [deleted file]
src/bindings/java/jmsg.h
src/bindings/java/jmsg_storage.cpp
src/include/surf/surf.h
src/msg/msg_environment.cpp
src/msg/msg_global.cpp
src/msg/msg_host.cpp
src/msg/msg_io.cpp
src/msg/msg_private.h
src/simix/libsmx.cpp
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/simcalls.in
src/simix/smx_io.cpp
src/surf/StorageImpl.cpp
src/surf/sg_platf.cpp
src/surf/surf_c_bindings.cpp
tools/cmake/DefinePackages.cmake

index 98580d4..38e1f5f 100644 (file)
@@ -75,29 +75,13 @@ typedef struct msg_file_priv {
 typedef struct msg_file_priv* msg_file_t;
 
 /* ******************************** Storage ************************************ */
 typedef struct msg_file_priv* msg_file_t;
 
 /* ******************************** Storage ************************************ */
-/* TODO: PV: to comment */
-
-extern int MSG_STORAGE_LEVEL;
 
 /** @brief Storage datatype.
  *  @ingroup msg_storage_management
  *
  *  You should consider this as an opaque object.
  */
 
 /** @brief Storage datatype.
  *  @ingroup msg_storage_management
  *
  *  You should consider this as an opaque object.
  */
-typedef xbt_dictelm_t msg_storage_t;
-
-struct msg_storage_priv  {
-  const char* name;
-  const char* hostname;
-  sg_size_t size;
-  void* data;
-};
-typedef struct msg_storage_priv  s_msg_storage_priv_t;
-typedef struct msg_storage_priv* msg_storage_priv_t;
-
-static inline msg_storage_priv_t MSG_storage_priv(msg_storage_t storage){
-  return (msg_storage_priv_t )xbt_lib_get_level(storage, MSG_STORAGE_LEVEL);
-}
+typedef sg_storage_t msg_storage_t;
 
 /**
  * \brief @brief Communication action.
 
 /**
  * \brief @brief Communication action.
diff --git a/include/surf/surf_routing.h b/include/surf/surf_routing.h
deleted file mode 100644 (file)
index 2d19df1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright (c) 2004-2015. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* 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. */
-
-#ifndef SURF_SURF_ROUTING_H
-#define SURF_SURF_ROUTING_H
-
-#include "xbt/lib.h"
-
-SG_BEGIN_DECL()
-
-// FIXME: this header file should die
-
-XBT_PUBLIC_DATA(xbt_lib_t) storage_lib;
-XBT_PUBLIC_DATA(int) SURF_STORAGE_LEVEL;  // Surf storage level
-
-SG_END_DECL()
-
-#endif                          /* _SURF_SURF_H */
index 34ba2a2..c0e7e2d 100644 (file)
@@ -23,7 +23,7 @@ SG_BEGIN_DECL()
 /* end of eclipse-mandated pimple */
 
 extern int JAVA_HOST_LEVEL;
 /* end of eclipse-mandated pimple */
 
 extern int JAVA_HOST_LEVEL;
-static std::unordered_map<char*, jobject> java_storage_map;
+static std::unordered_map<msg_storage_t, jobject> java_storage_map;
 
 JavaVM *get_java_VM();
 JNIEnv *get_current_thread_env();
 
 JavaVM *get_java_VM();
 JNIEnv *get_current_thread_env();
index e38230c..2d3a029 100644 (file)
@@ -69,7 +69,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j
   }
   env->ReleaseStringUTFChars(jname, name);
 
   }
   env->ReleaseStringUTFChars(jname, name);
 
-  if (java_storage_map.find(storage->key) == java_storage_map.end()) {
+  if (java_storage_map.find(storage) == java_storage_map.end()) {
     /* Instantiate a new java storage */
     jstorage = jstorage_new_instance(env);
 
     /* Instantiate a new java storage */
     jstorage = jstorage_new_instance(env);
 
@@ -93,9 +93,9 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j
     /* the native storage data field is set with the global reference to the
      * java storage returned by this function
      */
     /* the native storage data field is set with the global reference to the
      * java storage returned by this function
      */
-    java_storage_map.insert({storage->key, jstorage});
+    java_storage_map.insert({storage, jstorage});
   } else
   } else
-    jstorage = java_storage_map.at(storage->key);
+    jstorage = java_storage_map.at(storage);
 
   /* return the global reference to the java storage instance */
   return (jobject)jstorage;
 
   /* return the global reference to the java storage instance */
   return (jobject)jstorage;
@@ -215,8 +215,8 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Storage_all(JNIEnv * env, jc
 
   for (index = 0; index < count; index++) {
     storage = xbt_dynar_get_as(table,index,msg_storage_t);
 
   for (index = 0; index < count; index++) {
     storage = xbt_dynar_get_as(table,index,msg_storage_t);
-    if (java_storage_map.find(storage->key) != java_storage_map.end()) {
-      jstorage = java_storage_map.at(storage->key);
+    if (java_storage_map.find(storage) != java_storage_map.end()) {
+      jstorage = java_storage_map.at(storage);
     } else {
       jname = env->NewStringUTF(MSG_storage_get_name(storage));
       jstorage = Java_org_simgrid_msg_Storage_getByName(env, cls_arg, jname);
     } else {
       jname = env->NewStringUTF(MSG_storage_get_name(storage));
       jstorage = Java_org_simgrid_msg_Storage_getByName(env, cls_arg, jname);
index 4a3c109..4388b32 100644 (file)
@@ -15,7 +15,6 @@
 #include "src/internal_config.h"
 #include "surf/surf_routing.h"
 #include "surf/datatypes.h"
 #include "src/internal_config.h"
 #include "surf/surf_routing.h"
 #include "surf/datatypes.h"
-#include "xbt/lib.h"
 #include "simgrid/datatypes.h"
 #include "simgrid/forward.h"
 
 #include "simgrid/datatypes.h"
 #include "simgrid/forward.h"
 
@@ -85,8 +84,6 @@ typedef surf_NetworkModel *surf_network_model_t;
 typedef surf_StorageModel *surf_storage_model_t;
 typedef surf_Storage* surf_storage_t;
 
 typedef surf_StorageModel *surf_storage_model_t;
 typedef surf_Storage* surf_storage_t;
 
-typedef xbt_dictelm_t surf_resource_t;
-
 /** @ingroup SURF_c_bindings
  *  \brief Action structure
  *
 /** @ingroup SURF_c_bindings
  *  \brief Action structure
  *
@@ -116,15 +113,6 @@ XBT_PUBLIC(void) model_help(const char *category, s_surf_model_description_t * t
 /* Generic model object */
 /***************************/
 
 /* Generic model object */
 /***************************/
 
-static inline surf_storage_t surf_storage_resource_priv(const void* storage)
-{
-  return (surf_storage_t)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
-}
-
-static inline void *surf_storage_resource_by_name(const char *name){
-  return xbt_lib_get_elm_or_null(storage_lib, name);
-}
-
 /** @{ @ingroup SURF_c_bindings */
 
 /**
 /** @{ @ingroup SURF_c_bindings */
 
 /**
@@ -258,7 +246,7 @@ XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host, surf_file_t fd, sg_offset_t
  * @param resource The surf storage
  * @return The size in bytes of the storage
  */
  * @param resource The surf storage
  * @return The size in bytes of the storage
  */
-XBT_PUBLIC(sg_size_t) surf_storage_get_size(surf_resource_t resource);
+XBT_PUBLIC(sg_size_t) surf_storage_get_size(surf_storage_t resource);
 
 /**
  * @brief Get the available size in bytes of a storage
 
 /**
  * @brief Get the available size in bytes of a storage
@@ -266,7 +254,7 @@ XBT_PUBLIC(sg_size_t) surf_storage_get_size(surf_resource_t resource);
  * @param resource The surf storage
  * @return The available size in bytes of the storage
  */
  * @param resource The surf storage
  * @return The available size in bytes of the storage
  */
-XBT_PUBLIC(sg_size_t) surf_storage_get_free_size(surf_resource_t resource);
+XBT_PUBLIC(sg_size_t) surf_storage_get_free_size(surf_storage_t resource);
 
 /**
  * @brief Get the size in bytes of a storage
 
 /**
  * @brief Get the size in bytes of a storage
@@ -274,10 +262,10 @@ XBT_PUBLIC(sg_size_t) surf_storage_get_free_size(surf_resource_t resource);
  * @param resource The surf storage
  * @return The used size in bytes of the storage
  */
  * @param resource The surf storage
  * @return The used size in bytes of the storage
  */
-XBT_PUBLIC(sg_size_t) surf_storage_get_used_size(surf_resource_t resource);
+XBT_PUBLIC(sg_size_t) surf_storage_get_used_size(surf_storage_t resource);
 
 /** @brief return the properties set associated to that storage */
 
 /** @brief return the properties set associated to that storage */
-XBT_PUBLIC(xbt_dict_t) surf_storage_get_properties(surf_resource_t resource);
+XBT_PUBLIC(xbt_dict_t) surf_storage_get_properties(surf_storage_t resource);
 
 /**
  * @brief [brief description]
 
 /**
  * @brief [brief description]
@@ -320,8 +308,8 @@ XBT_PUBLIC(xbt_dict_t) surf_storage_action_get_ls_dict(surf_action_t action);
  * @return The host name
  * may not exist.
  */
  * @return The host name
  * may not exist.
  */
-XBT_PUBLIC(const char * ) surf_storage_get_host(surf_resource_t resource);
-XBT_PUBLIC(const char * ) surf_storage_get_name(surf_resource_t resource);
+XBT_PUBLIC(const char*) surf_storage_get_host(surf_storage_t resource);
+XBT_PUBLIC(const char*) surf_storage_get_name(surf_storage_t resource);
 
 /** @} */
 
 
 /** @} */
 
index fc067f7..1c3ea9b 100644 (file)
@@ -36,17 +36,6 @@ void MSG_create_environment(const char *file)
   SIMIX_create_environment(file);
 }
 
   SIMIX_create_environment(file);
 }
 
-void MSG_post_create_environment() {
-  xbt_lib_cursor_t cursor;
-  void **data;
-  char *name;
-
-  /* Initialize MSG storages */
-  xbt_lib_foreach(storage_lib, cursor, name, data) {
-    __MSG_storage_create(xbt_dict_cursor_get_elm(cursor));
-  }
-}
-
 msg_netzone_t MSG_zone_get_root()
 {
   return simgrid::s4u::Engine::instance()->netRoot();
 msg_netzone_t MSG_zone_get_root()
 {
   return simgrid::s4u::Engine::instance()->netRoot();
index 2dd6fc9..7c2e367 100644 (file)
@@ -51,8 +51,6 @@ void MSG_init_nocheck(int *argc, char **argv) {
     SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
     SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
 
     SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
     SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
 
-    simgrid::s4u::onPlatformCreated.connect(MSG_post_create_environment);
-
     simgrid::MsgHostExt::EXTENSION_ID = simgrid::s4u::Host::extension_create<simgrid::MsgHostExt>();
     simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
       host.extension_set<simgrid::MsgHostExt>(new simgrid::MsgHostExt());
     simgrid::MsgHostExt::EXTENSION_ID = simgrid::s4u::Host::extension_create<simgrid::MsgHostExt>();
     simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
       host.extension_set<simgrid::MsgHostExt>(new simgrid::MsgHostExt());
@@ -64,8 +62,6 @@ void MSG_init_nocheck(int *argc, char **argv) {
     MC_ignore_heap(&(msg_global->sent_msg), sizeof(msg_global->sent_msg));
   }
 
     MC_ignore_heap(&(msg_global->sent_msg), sizeof(msg_global->sent_msg));
   }
 
-  XBT_DEBUG("ADD MSG LEVELS");
-  MSG_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, (void_f_pvoid_t) __MSG_storage_destroy);
   if (xbt_cfg_get_boolean("clean-atexit"))
     atexit(MSG_exit);
 }
   if (xbt_cfg_get_boolean("clean-atexit"))
     atexit(MSG_exit);
 }
index 43a6b24..edab20d 100644 (file)
@@ -271,7 +271,7 @@ xbt_dict_t MSG_host_get_storage_content(msg_host_t host)
   xbt_dict_t storage_list = host->mountedStoragesAsDict();
 
   xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
   xbt_dict_t storage_list = host->mountedStoragesAsDict();
 
   xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
-    storage = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib,storage_name));
+    storage            = simgrid::s4u::Storage::byName(storage_name);
     xbt_dict_t content = MSG_storage_get_content(storage);
     xbt_dict_set(contents,mount_name, content,nullptr);
   }
     xbt_dict_t content = MSG_storage_get_content(storage);
     xbt_dict_set(contents,mount_name, content,nullptr);
   }
index ef67c5b..0da4d08 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "../surf/StorageImpl.hpp"
 #include "simgrid/s4u/Host.hpp"
 
 #include "../surf/StorageImpl.hpp"
 #include "simgrid/s4u/Host.hpp"
+#include "simgrid/s4u/Storage.hpp"
 #include "src/msg/msg_private.h"
 #include <numeric>
 
 #include "src/msg/msg_private.h"
 #include <numeric>
 
@@ -108,14 +109,13 @@ sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size)
     return 0;
 
   /* Find the host where the file is physically located and read it */
     return 0;
 
   /* Find the host where the file is physically located and read it */
-  msg_storage_t storage_src           = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib, fd->storageId));
-  msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
-  msg_host_t attached_host            = MSG_host_by_name(storage_priv_src->hostname);
+  msg_storage_t storage_src           = simgrid::s4u::Storage::byName(fd->storageId);
+  msg_host_t attached_host            = MSG_host_by_name(storage_src->host());
   read_size                           = simcall_file_read(fd->simdata->smx_file, size, attached_host);
 
   read_size                           = simcall_file_read(fd->simdata->smx_file, size, attached_host);
 
-  if (strcmp(storage_priv_src->hostname, MSG_host_self()->cname())) {
+  if (strcmp(storage_src->host(), MSG_host_self()->cname())) {
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
-    XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, read_size);
+    XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_src->host(), read_size);
     msg_host_t m_host_list[] = {MSG_host_self(), attached_host};
     double flops_amount[]    = {0, 0};
     double bytes_amount[]    = {0, 0, static_cast<double>(read_size), 0};
     msg_host_t m_host_list[] = {MSG_host_self(), attached_host};
     double flops_amount[]    = {0, 0};
     double bytes_amount[]    = {0, 0, static_cast<double>(read_size), 0};
@@ -150,13 +150,12 @@ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size)
     return 0;
 
   /* Find the host where the file is physically located (remote or local)*/
     return 0;
 
   /* Find the host where the file is physically located (remote or local)*/
-  msg_storage_t storage_src           = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib, fd->storageId));
-  msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
-  msg_host_t attached_host            = MSG_host_by_name(storage_priv_src->hostname);
+  msg_storage_t storage_src = simgrid::s4u::Storage::byName(fd->storageId);
+  msg_host_t attached_host  = MSG_host_by_name(storage_src->host());
 
 
-  if (strcmp(storage_priv_src->hostname, MSG_host_self()->cname())) {
+  if (strcmp(storage_src->host(), MSG_host_self()->cname())) {
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
-    XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, size);
+    XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_src->host(), size);
     msg_host_t m_host_list[] = {MSG_host_self(), attached_host};
     double flops_amount[]    = {0, 0};
     double bytes_amount[]    = {0, static_cast<double>(size), 0, 0};
     msg_host_t m_host_list[] = {MSG_host_self(), attached_host};
     double flops_amount[]    = {0, 0};
     double bytes_amount[]    = {0, static_cast<double>(size), 0, 0};
@@ -232,9 +231,8 @@ int MSG_file_close(msg_file_t fd)
 msg_error_t MSG_file_unlink(msg_file_t fd)
 {
   /* Find the host where the file is physically located (remote or local)*/
 msg_error_t MSG_file_unlink(msg_file_t fd)
 {
   /* Find the host where the file is physically located (remote or local)*/
-  msg_storage_t storage_src           = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib, fd->storageId));
-  msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
-  msg_host_t attached_host            = MSG_host_by_name(storage_priv_src->hostname);
+  msg_storage_t storage_src           = simgrid::s4u::Storage::byName(fd->storageId);
+  msg_host_t attached_host            = MSG_host_by_name(storage_src->host());
   int res                             = simcall_file_unlink(fd->simdata->smx_file, attached_host);
   __MSG_file_destroy(fd);
   return static_cast<msg_error_t>(res);
   int res                             = simcall_file_unlink(fd->simdata->smx_file, attached_host);
   __MSG_file_destroy(fd);
   return static_cast<msg_error_t>(res);
@@ -306,9 +304,8 @@ msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath)
 msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpath)
 {
   /* Find the host where the file is physically located and read it */
 msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpath)
 {
   /* Find the host where the file is physically located and read it */
-  msg_storage_t storage_src = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib, file->storageId));
-  msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
-  msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
+  msg_storage_t storage_src = simgrid::s4u::Storage::byName(file->storageId);
+  msg_host_t attached_host  = MSG_host_by_name(storage_src->host());
   MSG_file_seek(file, 0, SEEK_SET);
   sg_size_t read_size = simcall_file_read(file->simdata->smx_file, file->size, attached_host);
 
   MSG_file_seek(file, 0, SEEK_SET);
   sg_size_t read_size = simcall_file_read(file->simdata->smx_file, file->size, attached_host);
 
@@ -329,25 +326,22 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa
     if (not strcmp(file_mount_name, mount_name) && strlen(mount_name) > longest_prefix_length) {
       /* The current mount name is found in the full path and is bigger than the previous*/
       longest_prefix_length = strlen(mount_name);
     if (not strcmp(file_mount_name, mount_name) && strlen(mount_name) > longest_prefix_length) {
       /* The current mount name is found in the full path and is bigger than the previous*/
       longest_prefix_length = strlen(mount_name);
-      storage_dest          = (msg_storage_t)xbt_lib_get_elm_or_null(storage_lib, storage_name);
+      storage_dest          = simgrid::s4u::Storage::byName(storage_name);
     }
     xbt_free(file_mount_name);
   }
   xbt_dict_free(&storage_list);
 
     }
     xbt_free(file_mount_name);
   }
   xbt_dict_free(&storage_list);
 
-  char* host_name_dest = nullptr;
   if(longest_prefix_length>0){
     /* Mount point found, retrieve the host the storage is attached to */
   if(longest_prefix_length>0){
     /* Mount point found, retrieve the host the storage is attached to */
-    msg_storage_priv_t storage_dest_priv = MSG_storage_priv(storage_dest);
-    host_name_dest = (char*)storage_dest_priv->hostname;
-    host_dest = MSG_host_by_name(host_name_dest);
+    host_dest = MSG_host_by_name(storage_dest->host());
   }else{
     XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->cname());
     return MSG_TASK_CANCELED;
   }
 
   }else{
     XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->cname());
     return MSG_TASK_CANCELED;
   }
 
-  XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname,
-            host_name_dest);
+  XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_src->host(),
+            storage_dest->host());
   msg_host_t m_host_list[] = {attached_host, host_dest};
   double flops_amount[]    = {0, 0};
   double bytes_amount[]    = {0, static_cast<double>(read_size), 0, 0};
   msg_host_t m_host_list[] = {attached_host, host_dest};
   double flops_amount[]    = {0, 0};
   double bytes_amount[]    = {0, static_cast<double>(read_size), 0, 0};
@@ -359,7 +353,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa
 
   if(transfer != MSG_OK){
     if (transfer == MSG_HOST_FAILURE)
 
   if(transfer != MSG_OK){
     if (transfer == MSG_HOST_FAILURE)
-      XBT_WARN("Transfer error, %s remote host just turned off!", host_name_dest);
+      XBT_WARN("Transfer error, %s remote host just turned off!", storage_dest->host());
     if (transfer == MSG_TASK_CANCELED)
       XBT_WARN("Transfer error, task has been canceled!");
 
     if (transfer == MSG_TASK_CANCELED)
       XBT_WARN("Transfer error, task has been canceled!");
 
@@ -403,25 +397,6 @@ void __MSG_file_destroy(msg_file_t file)
  * (#msg_storage_t) and the functions for managing it.
  */
 
  * (#msg_storage_t) and the functions for managing it.
  */
 
-msg_storage_t __MSG_storage_create(smx_storage_t storage)
-{
-  msg_storage_priv_t storage_private = xbt_new0(s_msg_storage_priv_t, 1);
-
-  storage_private->name     = surf_storage_get_name(storage);
-  storage_private->hostname = surf_storage_get_host(storage);
-  storage_private->size     = surf_storage_get_size(storage);
-
-  xbt_lib_set(storage_lib, storage_private->name, MSG_STORAGE_LEVEL, storage_private);
-  return xbt_lib_get_elm_or_null(storage_lib, storage_private->name);
-}
-
-/**
- * \brief Destroys a storage (internal call only)
- */
-void __MSG_storage_destroy(msg_storage_priv_t storage) {
-  free(storage);
-}
-
 /** \ingroup msg_storage_management
  *
  * \brief Returns the name of the #msg_storage_t.
 /** \ingroup msg_storage_management
  *
  * \brief Returns the name of the #msg_storage_t.
@@ -430,8 +405,7 @@ void __MSG_storage_destroy(msg_storage_priv_t storage) {
  */
 const char *MSG_storage_get_name(msg_storage_t storage) {
   xbt_assert((storage != nullptr), "Invalid parameters");
  */
 const char *MSG_storage_get_name(msg_storage_t storage) {
   xbt_assert((storage != nullptr), "Invalid parameters");
-  msg_storage_priv_t priv = MSG_storage_priv(storage);
-  return priv->name;
+  return storage->name();
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
@@ -440,7 +414,7 @@ const char *MSG_storage_get_name(msg_storage_t storage) {
  * \return the free space size of the storage element (as a #sg_size_t)
  */
 sg_size_t MSG_storage_get_free_size(msg_storage_t storage){
  * \return the free space size of the storage element (as a #sg_size_t)
  */
 sg_size_t MSG_storage_get_free_size(msg_storage_t storage){
-  return simgrid::simix::kernelImmediate([storage] { return surf_storage_resource_priv(storage)->getFreeSize(); });
+  return storage->sizeFree();
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
@@ -449,7 +423,7 @@ sg_size_t MSG_storage_get_free_size(msg_storage_t storage){
  * \return the used space size of the storage element (as a #sg_size_t)
  */
 sg_size_t MSG_storage_get_used_size(msg_storage_t storage){
  * \return the used space size of the storage element (as a #sg_size_t)
  */
 sg_size_t MSG_storage_get_used_size(msg_storage_t storage){
-  return simgrid::simix::kernelImmediate([storage] { return surf_storage_resource_priv(storage)->getUsedSize(); });
+  return storage->sizeUsed();
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
@@ -460,7 +434,7 @@ sg_size_t MSG_storage_get_used_size(msg_storage_t storage){
 xbt_dict_t MSG_storage_get_properties(msg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)");
 xbt_dict_t MSG_storage_get_properties(msg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)");
-  return (simcall_storage_get_properties(storage));
+  return storage->properties();
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
@@ -472,7 +446,7 @@ xbt_dict_t MSG_storage_get_properties(msg_storage_t storage)
  */
 void MSG_storage_set_property_value(msg_storage_t storage, const char* name, char* value)
 {
  */
 void MSG_storage_set_property_value(msg_storage_t storage, const char* name, char* value)
 {
-  xbt_dict_set(MSG_storage_get_properties(storage), name, value, nullptr);
+  storage->setProperty(name, value);
 }
 
 /** \ingroup m_storage_management
 }
 
 /** \ingroup m_storage_management
@@ -484,7 +458,7 @@ void MSG_storage_set_property_value(msg_storage_t storage, const char* name, cha
  */
 const char *MSG_storage_get_property_value(msg_storage_t storage, const char *name)
 {
  */
 const char *MSG_storage_get_property_value(msg_storage_t storage, const char *name)
 {
-  return static_cast<char*>(xbt_dict_get_or_null(MSG_storage_get_properties(storage), name));
+  return storage->property(name);
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
@@ -494,23 +468,16 @@ const char *MSG_storage_get_property_value(msg_storage_t storage, const char *na
  */
 msg_storage_t MSG_storage_get_by_name(const char *name)
 {
  */
 msg_storage_t MSG_storage_get_by_name(const char *name)
 {
-  return static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib,name));
+  return simgrid::s4u::Storage::byName(name);
 }
 
 /** \ingroup msg_storage_management
  * \brief Returns a dynar containing all the storage elements declared at a given point of time
  */
 xbt_dynar_t MSG_storages_as_dynar() {
 }
 
 /** \ingroup msg_storage_management
  * \brief Returns a dynar containing all the storage elements declared at a given point of time
  */
 xbt_dynar_t MSG_storages_as_dynar() {
-  xbt_lib_cursor_t cursor;
-  char *key;
-  void **data;
   xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),nullptr);
   xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),nullptr);
-
-  xbt_lib_foreach(storage_lib, cursor, key, data) {
-    if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), MSG_STORAGE_LEVEL) != nullptr) {
-      xbt_dictelm_t elm = xbt_dict_cursor_get_elm(cursor);
-      xbt_dynar_push(res, &elm);
-    }
+  for (auto s : *simgrid::s4u::allStorages()) {
+    xbt_dynar_push(res, &(s.second));
   }
   return res;
 }
   }
   return res;
 }
@@ -522,8 +489,7 @@ xbt_dynar_t MSG_storages_as_dynar() {
  */
 msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data)
 {
  */
 msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data)
 {
-  msg_storage_priv_t priv = MSG_storage_priv(storage);
-  priv->data = data;
+  storage->setUserdata(data);
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
@@ -536,8 +502,7 @@ msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data)
 void *MSG_storage_get_data(msg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters");
 void *MSG_storage_get_data(msg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters");
-  msg_storage_priv_t priv = MSG_storage_priv(storage);
-  return priv->data;
+  return storage->userdata();
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
@@ -548,8 +513,7 @@ void *MSG_storage_get_data(msg_storage_t storage)
  */
 xbt_dict_t MSG_storage_get_content(msg_storage_t storage)
 {
  */
 xbt_dict_t MSG_storage_get_content(msg_storage_t storage)
 {
-  std::map<std::string, sg_size_t*>* content =
-      simgrid::simix::kernelImmediate([storage] { return surf_storage_resource_priv(storage)->getContent(); });
+  std::map<std::string, sg_size_t*>* content = storage->content();
   xbt_dict_t content_dict = xbt_dict_new_homogeneous(nullptr);
 
   for (auto entry : *content) {
   xbt_dict_t content_dict = xbt_dict_new_homogeneous(nullptr);
 
   for (auto entry : *content) {
@@ -566,8 +530,7 @@ xbt_dict_t MSG_storage_get_content(msg_storage_t storage)
  */
 sg_size_t MSG_storage_get_size(msg_storage_t storage)
 {
  */
 sg_size_t MSG_storage_get_size(msg_storage_t storage)
 {
-  msg_storage_priv_t priv = MSG_storage_priv(storage);
-  return priv->size;
+  return storage->size();
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
@@ -578,8 +541,7 @@ sg_size_t MSG_storage_get_size(msg_storage_t storage)
  */
 const char *MSG_storage_get_host(msg_storage_t storage) {
   xbt_assert((storage != nullptr), "Invalid parameters");
  */
 const char *MSG_storage_get_host(msg_storage_t storage) {
   xbt_assert((storage != nullptr), "Invalid parameters");
-  msg_storage_priv_t priv = MSG_storage_priv(storage);
-  return priv->hostname;
+  return storage->host();
 }
 
 SG_END_DECL()
 }
 
 SG_END_DECL()
index d83517b..b083103 100644 (file)
@@ -104,8 +104,6 @@ XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
 /*************************************************************/
 
 XBT_PRIVATE msg_host_t __MSG_host_create(sg_host_t host);
 /*************************************************************/
 
 XBT_PRIVATE msg_host_t __MSG_host_create(sg_host_t host);
-XBT_PRIVATE msg_storage_t __MSG_storage_create(smx_storage_t storage);
-XBT_PRIVATE void __MSG_storage_destroy(msg_storage_priv_t host);
 XBT_PRIVATE void __MSG_file_destroy(msg_file_t file);
 
 XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc);
 XBT_PRIVATE void __MSG_file_destroy(msg_file_t file);
 
 XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc);
@@ -114,8 +112,6 @@ XBT_PRIVATE smx_actor_t MSG_process_create_from_SIMIX(const char* name, std::fun
                                                       smx_actor_t parent_process);
 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_activity_t comm, void* buff, size_t buff_size);
 
                                                       smx_actor_t parent_process);
 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_activity_t comm, void* buff, size_t buff_size);
 
-XBT_PRIVATE void MSG_post_create_environment();
-
 XBT_PRIVATE void MSG_host_add_task(msg_host_t host, msg_task_t task);
 XBT_PRIVATE void MSG_host_del_task(msg_host_t host, msg_task_t task);
 
 XBT_PRIVATE void MSG_host_add_task(msg_host_t host, msg_task_t task);
 XBT_PRIVATE void MSG_host_del_task(msg_host_t host, msg_task_t task);
 
index a3aad4a..ddb760a 100644 (file)
@@ -746,18 +746,6 @@ int simcall_file_move(smx_file_t fd, const char* fullpath)
   return simcall_BODY_file_move(fd, fullpath);
 }
 
   return simcall_BODY_file_move(fd, fullpath);
 }
 
-/**
- * \ingroup simix_storage_management
- * \brief Returns a dict of the properties assigned to a storage element.
- *
- * \param storage A storage element
- * \return The properties of this storage element
- */
-xbt_dict_t simcall_storage_get_properties(smx_storage_t storage)
-{
-  return simcall_BODY_storage_get_properties(storage);
-}
-
 void simcall_run_kernel(std::function<void()> const& code)
 {
   simcall_BODY_run_kernel(&code);
 void simcall_run_kernel(std::function<void()> const& code)
 {
   simcall_BODY_run_kernel(&code);
index 8ce7f9f..fed1099 100644 (file)
@@ -979,19 +979,6 @@ static inline void simcall_file_move__set__result(smx_simcall_t simcall, int res
     simgrid::simix::marshal<int>(simcall->result, result);
 }
 
     simgrid::simix::marshal<int>(simcall->result, result);
 }
 
-static inline smx_storage_t simcall_storage_get_properties__get__storage(smx_simcall_t simcall) {
-  return simgrid::simix::unmarshal<smx_storage_t>(simcall->args[0]);
-}
-static inline void simcall_storage_get_properties__set__storage(smx_simcall_t simcall, smx_storage_t arg) {
-    simgrid::simix::marshal<smx_storage_t>(simcall->args[0], arg);
-}
-static inline xbt_dict_t simcall_storage_get_properties__get__result(smx_simcall_t simcall){
-    return simgrid::simix::unmarshal<xbt_dict_t>(simcall->result);
-}
-static inline void simcall_storage_get_properties__set__result(smx_simcall_t simcall, xbt_dict_t result){
-    simgrid::simix::marshal<xbt_dict_t>(simcall->result, result);
-}
-
 static inline int simcall_mc_random__get__min(smx_simcall_t simcall) {
   return simgrid::simix::unmarshal<int>(simcall->args[0]);
 }
 static inline int simcall_mc_random__get__min(smx_simcall_t simcall) {
   return simgrid::simix::unmarshal<int>(simcall->args[0]);
 }
index 758d874..afef6c4 100644 (file)
@@ -348,12 +348,6 @@ inline static int simcall_BODY_file_move(smx_file_t fd, const char* fullpath) {
     return simcall<int, smx_file_t, const char*>(SIMCALL_FILE_MOVE, fd, fullpath);
   }
   
     return simcall<int, smx_file_t, const char*>(SIMCALL_FILE_MOVE, fd, fullpath);
   }
   
-inline static xbt_dict_t simcall_BODY_storage_get_properties(smx_storage_t storage) {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) SIMIX_storage_get_properties(storage);
-    return simcall<xbt_dict_t, smx_storage_t>(SIMCALL_STORAGE_GET_PROPERTIES, storage);
-  }
-  
 inline static int simcall_BODY_mc_random(int min, int max) {
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) simcall_HANDLER_mc_random(&SIMIX_process_self()->simcall, min, max);
 inline static int simcall_BODY_mc_random(int min, int max) {
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) simcall_HANDLER_mc_random(&SIMIX_process_self()->simcall, min, max);
index e533a24..4e59ccf 100644 (file)
@@ -71,7 +71,6 @@ typedef enum {
   SIMCALL_FILE_SEEK,
   SIMCALL_FILE_GET_INFO,
   SIMCALL_FILE_MOVE,
   SIMCALL_FILE_SEEK,
   SIMCALL_FILE_GET_INFO,
   SIMCALL_FILE_MOVE,
-  SIMCALL_STORAGE_GET_PROPERTIES,
   SIMCALL_MC_RANDOM,
   SIMCALL_SET_CATEGORY,
   SIMCALL_RUN_KERNEL,
   SIMCALL_MC_RANDOM,
   SIMCALL_SET_CATEGORY,
   SIMCALL_RUN_KERNEL,
index 45bd19d..c18c10e 100644 (file)
@@ -77,7 +77,6 @@ const char* simcall_names[] = {
     "SIMCALL_FILE_SEEK",
     "SIMCALL_FILE_GET_INFO",
     "SIMCALL_FILE_MOVE",
     "SIMCALL_FILE_SEEK",
     "SIMCALL_FILE_GET_INFO",
     "SIMCALL_FILE_MOVE",
-    "SIMCALL_STORAGE_GET_PROPERTIES",
     "SIMCALL_MC_RANDOM",
     "SIMCALL_SET_CATEGORY",
     "SIMCALL_RUN_KERNEL",
     "SIMCALL_MC_RANDOM",
     "SIMCALL_SET_CATEGORY",
     "SIMCALL_RUN_KERNEL",
@@ -336,11 +335,6 @@ case SIMCALL_FILE_MOVE:
       SIMIX_simcall_answer(simcall);
       break;
 
       SIMIX_simcall_answer(simcall);
       break;
 
-case SIMCALL_STORAGE_GET_PROPERTIES:
-      simgrid::simix::marshal<xbt_dict_t>(simcall->result, SIMIX_storage_get_properties(simgrid::simix::unmarshal<smx_storage_t>(simcall->args[0])));
-      SIMIX_simcall_answer(simcall);
-      break;
-
 case SIMCALL_MC_RANDOM:
       simgrid::simix::marshal<int>(simcall->result, simcall_HANDLER_mc_random(simcall, simgrid::simix::unmarshal<int>(simcall->args[0]), simgrid::simix::unmarshal<int>(simcall->args[1])));
       SIMIX_simcall_answer(simcall);
 case SIMCALL_MC_RANDOM:
       simgrid::simix::marshal<int>(simcall->result, simcall_HANDLER_mc_random(simcall, simgrid::simix::unmarshal<int>(simcall->args[0]), simgrid::simix::unmarshal<int>(simcall->args[1])));
       SIMIX_simcall_answer(simcall);
index 31bc278..649adfa 100644 (file)
@@ -96,8 +96,6 @@ int         file_seek(smx_file_t fd, sg_offset_t offset, int origin);
 xbt_dynar_t file_get_info(smx_file_t fd);
 int         file_move(smx_file_t fd, const char* fullpath);
 
 xbt_dynar_t file_get_info(smx_file_t fd);
 int         file_move(smx_file_t fd, const char* fullpath);
 
-xbt_dict_t storage_get_properties(smx_storage_t storage) [[nohandler]];
-
 int        mc_random(int min, int max);
 void       set_category(smx_activity_t synchro, const char* category) [[nohandler]];
 
 int        mc_random(int min, int max);
 void       set_category(smx_activity_t synchro, const char* category) [[nohandler]];
 
index 38659ca..9ba2b7e 100644 (file)
@@ -176,10 +176,6 @@ int SIMIX_file_move(smx_actor_t process, smx_file_t file, const char* fullpath)
   return  surf_host_file_move(host, file->surf_file, fullpath);
 }
 
   return  surf_host_file_move(host, file->surf_file, fullpath);
 }
 
-xbt_dict_t SIMIX_storage_get_properties(smx_storage_t storage){
-  return surf_storage_get_properties(storage);
-}
-
 void SIMIX_io_destroy(smx_activity_t synchro)
 {
   simgrid::kernel::activity::Io *io = static_cast<simgrid::kernel::activity::Io*>(synchro);
 void SIMIX_io_destroy(smx_activity_t synchro)
 {
   simgrid::kernel::activity::Io *io = static_cast<simgrid::kernel::activity::Io*>(synchro);
index d15ab37..e4b801e 100644 (file)
@@ -15,7 +15,6 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
 
 xbt_lib_t storage_lib;
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
 
 xbt_lib_t storage_lib;
-int MSG_STORAGE_LEVEL                           = -1; // Msg storage level
 int SURF_STORAGE_LEVEL                          = -1;
 simgrid::surf::StorageModel* surf_storage_model = nullptr;
 
 int SURF_STORAGE_LEVEL                          = -1;
 simgrid::surf::StorageModel* surf_storage_model = nullptr;
 
index 7eb25fc..f2be0fe 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u/Engine.hpp"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u/Engine.hpp"
+#include "simgrid/s4u/Storage.hpp"
 
 #include "src/kernel/EngineImpl.hpp"
 #include "src/simix/smx_private.h"
 
 #include "src/kernel/EngineImpl.hpp"
 #include "src/simix/smx_private.h"
@@ -424,8 +425,7 @@ void sg_platf_new_mount(sg_platf_mount_cbarg_t mount){
 
   if (mount_list.empty())
     XBT_DEBUG("Create a Mount list for %s", A_surfxml_host_id);
 
   if (mount_list.empty())
     XBT_DEBUG("Create a Mount list for %s", A_surfxml_host_id);
-  mount_list.insert(
-      {std::string(mount->name), surf_storage_resource_priv(surf_storage_resource_by_name(mount->storageId))});
+  mount_list.insert({std::string(mount->name), simgrid::surf::StorageImpl::byName(mount->storageId)});
 }
 
 void sg_platf_new_route(sg_platf_route_cbarg_t route)
 }
 
 void sg_platf_new_route(sg_platf_route_cbarg_t route)
index 23cc5cc..0f00618 100644 (file)
@@ -206,28 +206,34 @@ int surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath){
   return host->pimpl_->fileMove(fd, fullpath);
 }
 
   return host->pimpl_->fileMove(fd, fullpath);
 }
 
-sg_size_t surf_storage_get_size(surf_resource_t resource){
-  return static_cast<simgrid::surf::StorageImpl*>(surf_storage_resource_priv(resource))->size_;
+sg_size_t surf_storage_get_size(surf_storage_t resource)
+{
+  return static_cast<simgrid::surf::StorageImpl*>(resource)->size_;
 }
 
 }
 
-sg_size_t surf_storage_get_free_size(surf_resource_t resource){
-  return static_cast<simgrid::surf::StorageImpl*>(surf_storage_resource_priv(resource))->getFreeSize();
+sg_size_t surf_storage_get_free_size(surf_storage_t resource)
+{
+  return static_cast<simgrid::surf::StorageImpl*>(resource)->getFreeSize();
 }
 
 }
 
-sg_size_t surf_storage_get_used_size(surf_resource_t resource){
-  return static_cast<simgrid::surf::StorageImpl*>(surf_storage_resource_priv(resource))->getUsedSize();
+sg_size_t surf_storage_get_used_size(surf_storage_t resource)
+{
+  return static_cast<simgrid::surf::StorageImpl*>(resource)->getUsedSize();
 }
 
 }
 
-xbt_dict_t surf_storage_get_properties(surf_resource_t resource){
-  return static_cast<simgrid::surf::StorageImpl*>(surf_storage_resource_priv(resource))->getProperties();
+xbt_dict_t surf_storage_get_properties(surf_storage_t resource)
+{
+  return static_cast<simgrid::surf::StorageImpl*>(resource)->getProperties();
 }
 
 }
 
-const char* surf_storage_get_host(surf_resource_t resource){
-  return static_cast<simgrid::surf::StorageImpl*>(surf_storage_resource_priv(resource))->attach_;
+const char* surf_storage_get_host(surf_storage_t resource)
+{
+  return static_cast<simgrid::surf::StorageImpl*>(resource)->attach_;
 }
 
 }
 
-const char* surf_storage_get_name(surf_resource_t resource){
-  return static_cast<simgrid::surf::StorageImpl*>(surf_storage_resource_priv(resource))->cname();
+const char* surf_storage_get_name(surf_storage_t resource)
+{
+  return static_cast<simgrid::surf::StorageImpl*>(resource)->cname();
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
index 1226d70..a2789e3 100644 (file)
@@ -688,7 +688,6 @@ set(headers_to_install
   include/smpi/smpi_extended_traces.h
   include/smpi/smpi_extended_traces_fortran.h
   include/smpi/forward.hpp
   include/smpi/smpi_extended_traces.h
   include/smpi/smpi_extended_traces_fortran.h
   include/smpi/forward.hpp
-  include/surf/surf_routing.h
   include/xbt.h
   include/xbt/RngStream.h
   include/xbt/asserts.h
   include/xbt.h
   include/xbt/RngStream.h
   include/xbt/asserts.h