Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move last MSG io example to teshsuite
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 5 Dec 2017 09:53:59 +0000 (10:53 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 5 Dec 2017 09:53:59 +0000 (10:53 +0100)
rename s4u-io to s4u-io-file-system
update doc

.gitignore
examples/msg/CMakeLists.txt
examples/msg/README.doc
examples/s4u/CMakeLists.txt
examples/s4u/README.doc
examples/s4u/io-file-system/.gitignore [moved from examples/s4u/io/.gitignore with 100% similarity]
examples/s4u/io-file-system/s4u-io-file-system.cpp [moved from examples/s4u/io/s4u-io.cpp with 94% similarity]
examples/s4u/io-file-system/s4u-io-file-system.tesh [moved from examples/s4u/io/s4u-io.tesh with 95% similarity]
teshsuite/msg/CMakeLists.txt
teshsuite/msg/io-file/io-file.c [moved from examples/msg/io-file/io-file.c with 57% similarity]
teshsuite/msg/io-file/io-file.tesh [moved from examples/msg/io-file/io-file.tesh with 100% similarity]

index d985817..dcce047 100644 (file)
@@ -135,7 +135,6 @@ examples/msg/energy-consumption/energy-consumption
 examples/msg/energy-onoff/energy-onoff
 examples/msg/energy-pstate/energy-pstate
 examples/msg/energy-vm/energy-vm
 examples/msg/energy-onoff/energy-onoff
 examples/msg/energy-pstate/energy-pstate
 examples/msg/energy-vm/energy-vm
-examples/msg/io-file/io-file
 examples/msg/io-file-unlink/io-file-unlink
 examples/msg/io-remote/io-remote
 examples/msg/io-storage/io-storage
 examples/msg/io-file-unlink/io-file-unlink
 examples/msg/io-remote/io-remote
 examples/msg/io-storage/io-storage
@@ -206,7 +205,7 @@ examples/s4u/energy-link/s4u-energy-link
 examples/s4u/energy-ptask/s4u-energy-ptask
 examples/s4u/energy-pstate/s4u-energy-pstate
 examples/s4u/energy-vm/s4u-energy-vm
 examples/s4u/energy-ptask/s4u-energy-ptask
 examples/s4u/energy-pstate/s4u-energy-pstate
 examples/s4u/energy-vm/s4u-energy-vm
-examples/s4u/io/s4u-io
+examples/s4u/io-file-system/s4u-io-file-system
 examples/s4u/io-file-remote/s4u-io-file-remote
 examples/s4u/io-storage-raw/s4u-io-storage-raw
 examples/s4u/mutex/s4u-mutex
 examples/s4u/io-file-remote/s4u-io-file-remote
 examples/s4u/io-storage-raw/s4u-io-storage-raw
 examples/s4u/mutex/s4u-mutex
@@ -274,6 +273,7 @@ teshsuite/msg/host_on_off/host_on_off
 teshsuite/msg/host_on_off_processes/host_on_off_processes
 teshsuite/msg/host_on_off_recv/host_on_off_recv
 teshsuite/msg/host_on_off_wait/host_on_off_wait
 teshsuite/msg/host_on_off_processes/host_on_off_processes
 teshsuite/msg/host_on_off_recv/host_on_off_recv
 teshsuite/msg/host_on_off_wait/host_on_off_wait
+teshsuite/msg/io-file/io-file
 teshsuite/msg/io-file-remote/io-file-remote
 teshsuite/msg/io-raw-storage/io-raw-storage
 teshsuite/msg/listen_async/listen_async
 teshsuite/msg/io-file-remote/io-file-remote
 teshsuite/msg/io-raw-storage/io-raw-storage
 teshsuite/msg/listen_async/listen_async
index d0764e1..d630d38 100644 (file)
@@ -2,7 +2,7 @@
 foreach(x app-masterworker app-pingpong app-token-ring 
           cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks
           dht-pastry energy-consumption energy-onoff energy-vm platform-failures 
 foreach(x app-masterworker app-pingpong app-token-ring 
           cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks
           dht-pastry energy-consumption energy-onoff energy-vm platform-failures 
-          io-file task-priority 
+          task-priority 
           plugin-hostload
           process-create process-join
           synchro-semaphore trace-categories 
           plugin-hostload
           process-create process-join
           synchro-semaphore trace-categories 
@@ -73,7 +73,7 @@ set(xml_files    ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/a
 
 foreach(x app-chainsend app-masterworker app-pingpong app-token-ring
           cloud-capping cloud-masterworker cloud-migration cloud-simple 
 
 foreach(x app-chainsend app-masterworker app-pingpong app-token-ring
           cloud-capping cloud-masterworker cloud-migration cloud-simple 
-          cloud-two-tasks dht-pastry dht-kademlia platform-failures io-file task-priority
+          cloud-two-tasks dht-pastry dht-kademlia platform-failures task-priority
           energy-consumption energy-onoff energy-vm
           plugin-hostload
           process-create process-join
           energy-consumption energy-onoff energy-vm
           plugin-hostload
           process-create process-join
index 5a772cf..0cd0792 100644 (file)
@@ -12,7 +12,6 @@ documentation, but it should remain readable directly.
     - @ref msg_ex_tracing_user_variables
   - @ref msg_ex_models
     - @ref msg_ex_ns3
     - @ref msg_ex_tracing_user_variables
   - @ref msg_ex_models
     - @ref msg_ex_ns3
-    - @ref msg_ex_io
   - @ref msg_ex_apps
   - @ref msg_ex_misc
 
   - @ref msg_ex_apps
   - @ref msg_ex_misc
 
@@ -133,16 +132,6 @@ TODO: merge the C files
 
 TODO: show the XML files instead if it's what is interesting. On a "XML example files" page that does not exist yet.
 
 
 TODO: show the XML files instead if it's what is interesting. On a "XML example files" page that does not exist yet.
 
-@subsection msg_ex_io Simulating disks and files
-
-The examples of this section demonstrate how to interact with the
-simulated storages.
-
-  - <b>File Management</b>. @ref examples/msg/io-file/io-file.c \n
-    This example illustrates the use of operations on file
-    (@ref MSG_file_open, @ref MSG_file_read, @ref MSG_file_write,
-    or @ref MSG_file_close).
-
 @section msg_ex_misc Miscellaneous
 
  - <b>Task priorities</b>.
 @section msg_ex_misc Miscellaneous
 
  - <b>Task priorities</b>.
@@ -178,8 +167,6 @@ top of the example file).
 
 @example examples/msg/network-ns3/network-ns3.c
 
 
 @example examples/msg/network-ns3/network-ns3.c
 
-@example examples/msg/io-file/io-file.c
-
 @example examples/msg/task-priority/task-priority.c
 
 */
 @example examples/msg/task-priority/task-priority.c
 
 */
index d20f005..251e1c4 100644 (file)
@@ -3,7 +3,7 @@ foreach (example actions-comm actions-storage
                  app-masterworker app-pingpong app-token-ring
                  async-wait async-waitany async-waitall
                  energy-link energy-pstate energy-ptask energy-vm
                  app-masterworker app-pingpong app-token-ring
                  async-wait async-waitany async-waitall
                  energy-link energy-pstate energy-ptask energy-vm
-                 io io-file-remote io-storage-raw
+                 io-file-system io-file-remote io-storage-raw
                  platform-properties plugin-hostload mutex)
   add_executable       (s4u-${example}  ${example}/s4u-${example}.cpp)
   target_link_libraries(s4u-${example}  simgrid)
                  platform-properties plugin-hostload mutex)
   add_executable       (s4u-${example}  ${example}/s4u-${example}.cpp)
   target_link_libraries(s4u-${example}  simgrid)
@@ -70,7 +70,7 @@ foreach(example actions-comm actions-storage
                 dht-chord 
                 energy-link energy-pstate energy-ptask energy-vm
                 platform-properties plugin-hostload mutex
                 dht-chord 
                 energy-link energy-pstate energy-ptask energy-vm
                 platform-properties plugin-hostload mutex
-                io io-file-remote io-storage-raw)
+                io-file-system io-file-remote io-storage-raw)
   ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" 
                                     --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} 
                                    --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
   ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" 
                                     --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} 
                                    --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
index 4fa7b4b..efcefaa 100644 (file)
@@ -169,6 +169,10 @@ also the tesh files in the example directories for details.
 The examples of this section demonstrate how to interact with the
 simulated storages.
 
 The examples of this section demonstrate how to interact with the
 simulated storages.
 
+  - <b>File Management</b>. @ref examples/s4u/io-file-system/s4u-io-file-system.cpp \n
+    This example illustrates the use of operations on files
+    (read, write, seek, tell, unlink, ...).
+
   - <b>Access to raw storage devices </b>.
     @ref examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp \n
     This example illustrates how to simply read and write data on a
   - <b>Access to raw storage devices </b>.
     @ref examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp \n
     This example illustrates how to simply read and write data on a
@@ -211,6 +215,7 @@ simulated storages.
 @example examples/s4u/async-waitall/s4u-async-waitall.cpp
 @example examples/s4u/async-waitany/s4u-async-waitany.cpp
 @example examples/s4u/energy-pstate/s4u-energy-pstate.cpp
 @example examples/s4u/async-waitall/s4u-async-waitall.cpp
 @example examples/s4u/async-waitany/s4u-async-waitany.cpp
 @example examples/s4u/energy-pstate/s4u-energy-pstate.cpp
+@example examples/s4u/io-file-system/s4u-io-file-system.cpp
 @example examples/s4u/io-file-remote/s4u-io-file-remote.cpp
 @example examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp \n
 @example examples/s4u/mutex/s4u-mutex.cpp
 @example examples/s4u/io-file-remote/s4u-io-file-remote.cpp
 @example examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp \n
 @example examples/s4u/mutex/s4u-mutex.cpp
similarity index 94%
rename from examples/s4u/io/s4u-io.cpp
rename to examples/s4u/io-file-system/s4u-io-file-system.cpp
index 7e6c110..269cab9 100644 (file)
@@ -27,7 +27,8 @@ public:
     }
   }
 
     }
   }
 
-  void operator()() {
+  void operator()()
+  {
     std::unordered_map<std::string, simgrid::s4u::Storage*> const& mounts =
         simgrid::s4u::Host::current()->getMountedStorages();
 
     std::unordered_map<std::string, simgrid::s4u::Storage*> const& mounts =
         simgrid::s4u::Host::current()->getMountedStorages();
 
@@ -37,7 +38,7 @@ public:
     std::string filename     = "/home/tmp/data.txt";
     simgrid::s4u::File* file = new simgrid::s4u::File(filename, nullptr);
 
     std::string filename     = "/home/tmp/data.txt";
     simgrid::s4u::File* file = new simgrid::s4u::File(filename, nullptr);
 
-    sg_size_t write = file->write(200000);  // Write 200,000 bytes
+    sg_size_t write = file->write(200000); // Write 200,000 bytes
     XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, filename.c_str());
 
     // check that sizes have changed
     XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, filename.c_str());
 
     // check that sizes have changed
@@ -50,7 +51,7 @@ public:
     XBT_INFO("Read %llu bytes on %s", read, filename.c_str());
 
     // Now write 100,000 bytes in tmp/data.txt
     XBT_INFO("Read %llu bytes on %s", read, filename.c_str());
 
     // Now write 100,000 bytes in tmp/data.txt
-    write = file->write(100000);  // Write 100,000 bytes
+    write = file->write(100000); // Write 100,000 bytes
     XBT_INFO("Write %llu bytes on %s", write, filename.c_str());
 
     simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName("Disk4");
     XBT_INFO("Write %llu bytes on %s", write, filename.c_str());
 
     simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName("Disk4");
@@ -88,7 +89,7 @@ public:
   }
 };
 
   }
 };
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   simgrid::s4u::Engine e(&argc, argv);
   sg_storage_file_system_init();
 {
   simgrid::s4u::Engine e(&argc, argv);
   sg_storage_file_system_init();
similarity index 95%
rename from examples/s4u/io/s4u-io.tesh
rename to examples/s4u/io-file-system/s4u-io-file-system.tesh
index 1c3ae8b..e89c8e1 100644 (file)
@@ -1,6 +1,6 @@
 #! ./tesh
 
 #! ./tesh
 
-$ $SG_TEST_EXENV ${bindir:=.}/s4u-io ${platfdir}/storage/storage.xml
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-io-file-system ${platfdir}/storage/storage.xml
 > [denise:host:(1) 0.000000] [s4u_test/INFO] Storage info on denise:
 > [denise:host:(1) 0.000000] [s4u_test/INFO]     Disk2 (c:) Used: 2391537133; Free: 534479374867; Total: 536870912000.
 > [denise:host:(1) 0.000000] [s4u_test/INFO]     Disk4 (/home) Used: 13221994; Free: 536857690006; Total: 536870912000.
 > [denise:host:(1) 0.000000] [s4u_test/INFO] Storage info on denise:
 > [denise:host:(1) 0.000000] [s4u_test/INFO]     Disk2 (c:) Used: 2391537133; Free: 534479374867; Total: 536870912000.
 > [denise:host:(1) 0.000000] [s4u_test/INFO]     Disk4 (/home) Used: 13221994; Free: 536857690006; Total: 536870912000.
index 92d3042..513493d 100644 (file)
@@ -4,7 +4,7 @@ foreach(x actions-comm actions-storage
           cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes    
           process-daemon process-kill process-lifetime process-migration process-suspend process-yield
           energy-ptask energy-pstate platform-properties
           cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes    
           process-daemon process-kill process-lifetime process-migration process-suspend process-yield
           energy-ptask energy-pstate platform-properties
-          io-raw-storage io-file-remote
+          io-file io-raw-storage io-file-remote
           trace_integration)
   add_executable       (${x}  ${x}/${x}.c)
   target_link_libraries(${x}  simgrid)
           trace_integration)
   add_executable       (${x}  ${x}/${x}.c)
   target_link_libraries(${x}  simgrid)
@@ -79,7 +79,7 @@ foreach(x
     task_destroy_cancel task_listen_from task_progress 
     process-daemon process-kill process-lifetime process-migration process-suspend process-yield
     energy-ptask
     task_destroy_cancel task_listen_from task_progress 
     process-daemon process-kill process-lifetime process-migration process-suspend process-yield
     energy-ptask
-    io-raw-storage io-file-remote
+    io-file io-raw-storage io-file-remote
     platform-properties
     trace_integration)
   ADD_TESH_FACTORIES(tesh-msg-${x} "thread;ucontext;raw;boost" 
     platform-properties
     trace_integration)
   ADD_TESH_FACTORIES(tesh-msg-${x} "thread;ucontext;raw;boost" 
similarity index 57%
rename from examples/msg/io-file/io-file.c
rename to teshsuite/msg/io-file/io-file.c
index ec15057..2c22834 100644 (file)
@@ -8,7 +8,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example");
 
-static int host(int argc, char *argv[])
+static int host(int argc, charargv[])
 {
   msg_file_t file = NULL;
   sg_size_t read;
 {
   msg_file_t file = NULL;
   sg_size_t read;
@@ -16,46 +16,45 @@ static int host(int argc, char *argv[])
   msg_storage_t st;
   const char* st_name;
 
   msg_storage_t st;
   const char* st_name;
 
-  switch(MSG_process_self_PID()){
-  case 1:
-    file    = MSG_file_open("c:\\Windows\\setupact.log", NULL);
-    st_name = "Disk2";
-    break;
-  case 2:
-    file    = MSG_file_open("/home/doc/simgrid/examples/platforms/nancy.xml", NULL);
-    st_name = "Disk1";
-    break;
-  case 3:
-    file    = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k_cabinets.xml", NULL);
-    st_name = "Disk3";
-    break;
-  case 4:
-    file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k.xml", NULL);
-    MSG_file_dump(file);
-    st_name = "Disk4";
-    break;
-  default:
-    xbt_die("FILENAME NOT DEFINED %s",MSG_process_get_name(MSG_process_self()));
+  switch (MSG_process_self_PID()) {
+    case 1:
+      file    = MSG_file_open("c:\\Windows\\setupact.log", NULL);
+      st_name = "Disk2";
+      break;
+    case 2:
+      file    = MSG_file_open("/home/doc/simgrid/examples/platforms/nancy.xml", NULL);
+      st_name = "Disk1";
+      break;
+    case 3:
+      file    = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k_cabinets.xml", NULL);
+      st_name = "Disk3";
+      break;
+    case 4:
+      file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k.xml", NULL);
+      MSG_file_dump(file);
+      st_name = "Disk4";
+      break;
+    default:
+      xbt_die("FILENAME NOT DEFINED %s", MSG_process_get_name(MSG_process_self()));
   }
 
   const char* filename = MSG_file_get_name(file);
   }
 
   const char* filename = MSG_file_get_name(file);
-  XBT_INFO("\tOpen file '%s'",filename);
+  XBT_INFO("\tOpen file '%s'", filename);
   st = MSG_storage_get_by_name(st_name);
 
   st = MSG_storage_get_by_name(st_name);
 
-  XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
-            filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
+  XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st),
+           MSG_storage_get_size(st));
 
   /* Try to read for 10MB */
   read = MSG_file_read(file, 10000000);
 
   /* Try to read for 10MB */
   read = MSG_file_read(file, 10000000);
-  XBT_INFO("\tHave read %llu from '%s'",read,filename);
+  XBT_INFO("\tHave read %llu from '%s'", read, filename);
 
   /* Write 100KB in file from the current position, i.e, end of file or 10MB */
   write = MSG_file_write(file, 100000);
 
   /* Write 100KB in file from the current position, i.e, end of file or 10MB */
   write = MSG_file_write(file, 100000);
-  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu",write,filename, MSG_file_get_size(file));
+  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write, filename, MSG_file_get_size(file));
 
 
-
-  XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
-            filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
+  XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st),
+           MSG_storage_get_size(st));
 
   /* rewind to the beginning of the file */
   XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename);
 
   /* rewind to the beginning of the file */
   XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename);
@@ -63,7 +62,7 @@ static int host(int argc, char *argv[])
 
   /* Try to read 110KB */
   read = MSG_file_read(file, 110000);
 
   /* Try to read 110KB */
   read = MSG_file_read(file, 110000);
-  XBT_INFO("\tHave read %llu from '%s' (of size %llu)",read,filename, MSG_file_get_size(file));
+  XBT_INFO("\tHave read %llu from '%s' (of size %llu)", read, filename, MSG_file_get_size(file));
 
   /* rewind once again to the beginning of the file */
   XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename);
 
   /* rewind once again to the beginning of the file */
   XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename);
@@ -71,12 +70,12 @@ static int host(int argc, char *argv[])
 
   /* Write 110KB in file from the current position, i.e, end of file or 10MB */
   write = MSG_file_write(file, 110000);
 
   /* Write 110KB in file from the current position, i.e, end of file or 10MB */
   write = MSG_file_write(file, 110000);
-  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write,filename, MSG_file_get_size(file));
+  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write, filename, MSG_file_get_size(file));
 
 
-  XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
-            filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
+  XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st),
+           MSG_storage_get_size(st));
 
 
-  if (MSG_process_self_PID() == 1){
+  if (MSG_process_self_PID() == 1) {
     XBT_INFO("\tUnlink file '%s'", MSG_file_get_name(file));
     MSG_file_unlink(file);
   } else {
     XBT_INFO("\tUnlink file '%s'", MSG_file_get_name(file));
     MSG_file_unlink(file);
   } else {
@@ -86,18 +85,18 @@ static int host(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   MSG_init(&argc, argv);
   MSG_storage_file_system_init();
 
   MSG_create_environment(argv[1]);
 {
   MSG_init(&argc, argv);
   MSG_storage_file_system_init();
 
   MSG_create_environment(argv[1]);
-  xbt_dynar_t hosts =  MSG_hosts_as_dynar();
+  xbt_dynar_t hosts = MSG_hosts_as_dynar();
   MSG_function_register("host", host);
   unsigned long nb_hosts = xbt_dynar_length(hosts);
   MSG_function_register("host", host);
   unsigned long nb_hosts = xbt_dynar_length(hosts);
-  XBT_INFO("Number of host '%lu'",nb_hosts);
-  for(int i = 0 ; i < nb_hosts; i++){
-    MSG_process_create("host", host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t));
+  XBT_INFO("Number of host '%lu'", nb_hosts);
+  for (int i = 0; i < nb_hosts; i++) {
+    MSG_process_create("host", host, NULL, xbt_dynar_get_as(hosts, i, msg_host_t));
   }
   xbt_dynar_free(&hosts);
 
   }
   xbt_dynar_free(&hosts);