Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
disentangle file opening
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 10 Jul 2017 08:55:08 +0000 (10:55 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 10 Jul 2017 08:55:08 +0000 (10:55 +0200)
14 files changed:
include/simgrid/simix.h
src/kernel/activity/SynchroIo.cpp
src/s4u/s4u_file.cpp
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/FileImpl.cpp
src/surf/FileImpl.hpp
src/surf/StorageImpl.hpp
src/surf/storage_n11.cpp

index 8c57c13..6a117c1 100644 (file)
@@ -291,7 +291,6 @@ XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
 /*****************************   File   **********************************/
 XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host);
 XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PUBLIC(surf_file_t) simcall_file_open(const char* mount, const char* path, sg_storage_t st);
 /************************** MC simcalls   **********************************/
 XBT_PUBLIC(int) simcall_mc_random(int min, int max);
 
index d09bd1d..e954fae 100644 (file)
@@ -25,11 +25,6 @@ void simgrid::kernel::activity::IoImpl::post()
 {
   for (smx_simcall_t simcall : simcalls) {
     switch (simcall->call) {
-    case SIMCALL_FILE_OPEN: {
-      surf_file_t tmp = static_cast<simgrid::surf::StorageAction*>(surf_io)->file_;
-      simcall_file_open__set__result(simcall, tmp);
-      break;
-    }
     case SIMCALL_FILE_WRITE:
       simcall_file_write__set__result(simcall, surf_io->getCost());
       break;
index a60d35f..ad9f634 100644 (file)
@@ -43,7 +43,8 @@ File::File(const char* fullpath, sg_host_t host, void* userdata) : path_(fullpat
   } else
     xbt_die("Can't find mount point for '%s' on '%s'", fullpath, host->getCname());
 
-  pimpl_       = simcall_file_open(mount_point.c_str(), path.c_str(), st);
+  pimpl_ =
+      simgrid::simix::kernelImmediate([this, st, path] { return new simgrid::surf::FileImpl(st, path, mount_point); });
   storage_type = st->getType();
   storageId    = st->getName();
 }
index a8b1a01..d5c9811 100644 (file)
@@ -623,15 +623,6 @@ sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host)
   return simcall_BODY_file_write(fd, size, host);
 }
 
-/**
- * \ingroup simix_file_management
- * \brief
- */
-surf_file_t simcall_file_open(const char* mount, const char* path, sg_storage_t st)
-{
-  return simcall_BODY_file_open(mount, path, st);
-}
-
 void simcall_run_kernel(std::function<void()> const& code)
 {
   simcall_BODY_run_kernel(&code);
index 71c0857..9bdee47 100644 (file)
@@ -1552,55 +1552,6 @@ static inline void simcall_file_write__set__result(smx_simcall_t simcall, sg_siz
     simgrid::simix::marshal<sg_size_t>(simcall->result, result);
 }
 
-static inline const char* simcall_file_open__get__mount(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<const char*>(simcall->args[0]);
-}
-static inline const char* simcall_file_open__getraw__mount(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<const char*>(simcall->args[0]);
-}
-static inline void simcall_file_open__set__mount(smx_simcall_t simcall, const char* arg)
-{
-  simgrid::simix::marshal<const char*>(simcall->args[0], arg);
-}
-static inline const char* simcall_file_open__get__path(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<const char*>(simcall->args[1]);
-}
-static inline const char* simcall_file_open__getraw__path(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<const char*>(simcall->args[1]);
-}
-static inline void simcall_file_open__set__path(smx_simcall_t simcall, const char* arg)
-{
-  simgrid::simix::marshal<const char*>(simcall->args[1], arg);
-}
-static inline sg_storage_t simcall_file_open__get__st(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<sg_storage_t>(simcall->args[2]);
-}
-static inline sg_storage_t simcall_file_open__getraw__st(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<sg_storage_t>(simcall->args[2]);
-}
-static inline void simcall_file_open__set__st(smx_simcall_t simcall, sg_storage_t arg)
-{
-  simgrid::simix::marshal<sg_storage_t>(simcall->args[2], arg);
-}
-static inline surf_file_t simcall_file_open__get__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<surf_file_t>(simcall->result);
-}
-static inline surf_file_t simcall_file_open__getraw__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<surf_file_t>(simcall->result);
-}
-static inline void simcall_file_open__set__result(smx_simcall_t simcall, surf_file_t result)
-{
-  simgrid::simix::marshal<surf_file_t>(simcall->result, result);
-}
-
 static inline int simcall_mc_random__get__min(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<int>(simcall->args[0]);
@@ -1740,5 +1691,4 @@ XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_
 XBT_PRIVATE int simcall_HANDLER_sem_get_capacity(smx_simcall_t simcall, smx_sem_t sem);
 XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host);
 XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PRIVATE void simcall_HANDLER_file_open(smx_simcall_t simcall, const char* mount, const char* path, sg_storage_t st);
 XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max);
\ No newline at end of file
index 3d8785c..8d0c849 100644 (file)
@@ -328,14 +328,6 @@ inline static int simcall_BODY_sem_get_capacity(smx_sem_t sem) {
     return simcall<sg_size_t, surf_file_t, sg_size_t, sg_host_t>(SIMCALL_FILE_WRITE, fd, size, host);
   }
 
-  inline static surf_file_t simcall_BODY_file_open(const char* mount, const char* path, sg_storage_t st)
-  {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0)
-      simcall_HANDLER_file_open(&SIMIX_process_self()->simcall, mount, path, st);
-    return simcall<surf_file_t, const char*, const char*, sg_storage_t>(SIMCALL_FILE_OPEN, mount, path, st);
-  }
-
 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 4317f36..eede34f 100644 (file)
@@ -60,7 +60,6 @@ typedef enum {
   SIMCALL_SEM_GET_CAPACITY,
   SIMCALL_FILE_READ,
   SIMCALL_FILE_WRITE,
-  SIMCALL_FILE_OPEN,
   SIMCALL_MC_RANDOM,
   SIMCALL_SET_CATEGORY,
   SIMCALL_RUN_KERNEL,
index d9ee962..cf13847 100644 (file)
@@ -66,7 +66,6 @@ const char* simcall_names[] = {
     "SIMCALL_SEM_GET_CAPACITY",
     "SIMCALL_FILE_READ",
     "SIMCALL_FILE_WRITE",
-    "SIMCALL_FILE_OPEN",
     "SIMCALL_MC_RANDOM",
     "SIMCALL_SET_CATEGORY",
     "SIMCALL_RUN_KERNEL",
@@ -324,12 +323,6 @@ case SIMCALL_FILE_WRITE:
                              simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]));
   break;
 
-case SIMCALL_FILE_OPEN:
-  simcall_HANDLER_file_open(simcall, simgrid::simix::unmarshal<const char*>(simcall->args[0]),
-                            simgrid::simix::unmarshal<const char*>(simcall->args[1]),
-                            simgrid::simix::unmarshal<sg_storage_t>(simcall->args[2]));
-  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);
index 109f207..d5b7cc1 100644 (file)
@@ -83,7 +83,6 @@ int       sem_get_capacity(smx_sem_t sem);
 
 sg_size_t   file_read(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
 sg_size_t   file_write(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
-surf_file_t  file_open(const char* mount, const char* path, sg_storage_t st) [[block]];
 
 int        mc_random(int min, int max);
 void       set_category(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> synchro, const char* category) [[nohandler]];
index 0287a64..1b31af0 100644 (file)
@@ -67,28 +67,6 @@ smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size, sg_host_t host
   return synchro;
 }
 
-//SIMIX FILE OPEN
-void simcall_HANDLER_file_open(smx_simcall_t simcall, const char* mount, const char* path, sg_storage_t st)
-{
-  smx_activity_t synchro = SIMIX_file_open(mount, path, st);
-  synchro->simcalls.push_back(simcall);
-  simcall->issuer->waiting_synchro = synchro;
-}
-
-smx_activity_t SIMIX_file_open(const char* mount, const char* path, sg_storage_t st)
-{
-  if (st->getHost()->isOff())
-    THROWF(host_error, 0, "Host %s failed, you cannot call this function", st->getHost()->getCname());
-
-  simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
-  synchro->host                              = st->getHost();
-  synchro->surf_io                           = st->pimpl_->open(mount, path);
-  synchro->surf_io->setData(synchro);
-  XBT_DEBUG("Create io synchro %p", synchro);
-
-  return synchro;
-}
-
 void SIMIX_io_destroy(smx_activity_t synchro)
 {
   simgrid::kernel::activity::IoImplPtr io = boost::static_pointer_cast<simgrid::kernel::activity::IoImpl>(synchro);
index 59530a9..5c7cda0 100644 (file)
@@ -11,6 +11,20 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_file, surf, "Logging specific to the SURF f
 namespace simgrid {
 namespace surf {
 
+FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_(path), mount_point_(mount)
+{
+  XBT_DEBUG("\tOpen file '%s'", path.c_str());
+  std::map<std::string, sg_size_t>* content = st->pimpl_->content_;
+  // if file does not exist create an empty file
+  if (content->find(path) != content->end())
+    size_ = content->at(path);
+  else {
+    size_ = 0;
+    content->insert({path, size_});
+    XBT_DEBUG("File '%s' was not found, file created.", path.c_str());
+  }
+}
+
 int FileImpl::seek(sg_offset_t offset, int origin)
 {
   switch (origin) {
index 98cb343..b23a10f 100644 (file)
@@ -15,7 +15,7 @@ namespace surf {
 
 class FileImpl {
 public:
-  FileImpl(const char* path, const char* mount, sg_size_t size) : path_(path), mount_point_(mount), size_(size) {}
+  FileImpl(sg_storage_t st, std::string path, std::string mount);
   ~FileImpl() = default;
 
   std::string name() { return path_; }
index 8a1d515..8091af1 100644 (file)
@@ -109,15 +109,6 @@ public:
   std::string attach_; // Name of the host to which this storage is attached.
                        // Only used until the platform is fully parsed only.
                        // Then the interface stores the Host directly.
-                       /**
-                        * @brief Open a file
-                        *
-                        * @param mount The mount point
-                        * @param path The path to the file
-                        *
-                        * @return The StorageAction corresponding to the opening
-                        */
-  virtual StorageAction* open(const char* mount, const char* path) = 0;
 
   /**
    * @brief Read a file
@@ -175,9 +166,7 @@ public:
  */
 typedef enum {
   READ = 0, /**< Read a file */
-  WRITE,    /**< Write in a file */
-  OPEN,     /**< Open a file */
-  CLOSE     /**< Close a file */
+  WRITE     /**< Write in a file */
 } e_surf_action_storage_type_t;
 
 /** @ingroup SURF_storage_interface
index e430af2..6b5addb 100644 (file)
@@ -137,27 +137,6 @@ StorageN11::StorageN11(StorageModel* model, const char* name, lmm_system_t maxmi
   simgrid::s4u::Storage::onCreation(this->piface_);
 }
 
-StorageAction *StorageN11::open(const char* mount, const char* path)
-{
-  XBT_DEBUG("\tOpen file '%s'",path);
-
-  sg_size_t size;
-  // if file does not exist create an empty file
-  if (content_->find(path) != content_->end())
-    size = content_->at(path);
-  else {
-    size = 0;
-    content_->insert({path, size});
-    XBT_DEBUG("File '%s' was not found, file created.",path);
-  }
-  FileImpl* file = new FileImpl(path, mount, size);
-
-  StorageAction* action = new StorageN11Action(model(), 0, isOff(), this, OPEN);
-  action->file_         = file;
-
-  return action;
-}
-
 StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size)
 {
   if (fd->tell() + size > fd->size()) {
@@ -203,8 +182,6 @@ StorageN11Action::StorageN11Action(Model* model, double cost, bool failed, Stora
   // Must be less than the max bandwidth for all actions
   lmm_expand(model->getMaxminSystem(), storage->constraint(), getVariable(), 1.0);
   switch(type) {
-  case OPEN:
-    break;
   case READ:
     lmm_expand(model->getMaxminSystem(), storage->constraintRead_, getVariable(), 1.0);
     break;