Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new tesh suite for msg-storage
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Mon, 2 Jun 2014 07:34:10 +0000 (09:34 +0200)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Fri, 20 Jun 2014 13:30:55 +0000 (15:30 +0200)
teshsuite/msg/storage/CMakeLists.txt
teshsuite/msg/storage/concurrent_rw.c [new file with mode: 0644]
teshsuite/msg/storage/one_host_platform.xml [new file with mode: 0644]
teshsuite/msg/storage/storage_basic.tesh

index 55b0bcc..7a217ab 100644 (file)
@@ -3,12 +3,15 @@ cmake_minimum_required(VERSION 2.6)
 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
 
 add_executable(storage_basic storage_basic.c)
 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
 
 add_executable(storage_basic storage_basic.c)
+add_executable(concurrent_rw concurrent_rw.c)
 
 ### Add definitions for compile
 if(NOT WIN32)
   target_link_libraries(storage_basic simgrid m pthread )
 
 ### Add definitions for compile
 if(NOT WIN32)
   target_link_libraries(storage_basic simgrid m pthread )
+  target_link_libraries(concurrent_rw simgrid m pthread )
 else()
   target_link_libraries(storage_basic simgrid)
 else()
   target_link_libraries(storage_basic simgrid)
+  target_link_libraries(concurrent_rw simgrid)
 endif()
 
 set(tesh_files
 endif()
 
 set(tesh_files
@@ -20,11 +23,13 @@ set(xml_files
   ${xml_files}
   ${CMAKE_CURRENT_SOURCE_DIR}/platform.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/deployment.xml
   ${xml_files}
   ${CMAKE_CURRENT_SOURCE_DIR}/platform.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/deployment.xml
+  ${CMAKE_CURRENT_SOURCE_DIR}/one_host_platform.xml
   PARENT_SCOPE
   )
 set(teshsuite_src
   ${teshsuite_src}
   ${CMAKE_CURRENT_SOURCE_DIR}/storage_basic.c
   PARENT_SCOPE
   )
 set(teshsuite_src
   ${teshsuite_src}
   ${CMAKE_CURRENT_SOURCE_DIR}/storage_basic.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/concurrent_rw.c
   PARENT_SCOPE
   )
 set(bin_files
   PARENT_SCOPE
   )
 set(bin_files
diff --git a/teshsuite/msg/storage/concurrent_rw.c b/teshsuite/msg/storage/concurrent_rw.c
new file mode 100644 (file)
index 0000000..8d938bb
--- /dev/null
@@ -0,0 +1,136 @@
+/* Copyright (c) 2008-2010, 2012-2014. The SimGrid Team.
+ * All rights reserved.
+*/
+
+#include "msg/msg.h"
+#include "xbt/log.h"
+#include <unistd.h>
+
+
+#define FILENAME1 "/sd1/doc/simgrid/examples/cxx/autoDestination/Main.cxx"
+
+int host(int argc, char *argv[]);
+void storage_info(msg_host_t host);
+void display_storage_properties(msg_storage_t storage);
+void dump_storage_by_name(char *name);
+void display_storage_content(msg_storage_t storage);
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
+
+
+
+void storage_info(msg_host_t host)
+{
+  const char* host_name = MSG_host_get_name(host);
+  XBT_INFO("*** Storage info on %s ***", host_name);
+
+  xbt_dict_cursor_t cursor = NULL;
+  char* mount_name;
+  char* storage_name;
+  msg_storage_t storage;
+
+  xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(host);
+
+  xbt_dict_foreach(storage_list,cursor,mount_name,storage_name)
+  {
+    XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name);
+
+    storage = MSG_storage_get_by_name(storage_name);
+
+    sg_size_t free_size = MSG_storage_get_free_size(storage);
+    sg_size_t used_size = MSG_storage_get_used_size(storage);
+
+    XBT_INFO("\t\tFree size: %llu bytes", free_size);
+    XBT_INFO("\t\tUsed size: %llu bytes", used_size);
+
+    display_storage_properties(storage);
+    dump_storage_by_name(storage_name);
+  }
+  xbt_dict_free(&storage_list);
+}
+
+void display_storage_properties(msg_storage_t storage){
+  xbt_dict_cursor_t cursor = NULL;
+  char *key, *data;
+  xbt_dict_t props = MSG_storage_get_properties(storage);
+  if (xbt_dict_length(props) > 0){
+    XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage));
+    xbt_dict_foreach(props, cursor, key, data)
+         XBT_INFO("\t\t'%s' -> '%s'", key, data);
+  }else{
+       XBT_INFO("\tNo property attached.");
+  }
+}
+
+void dump_storage_by_name(char *name){
+  XBT_INFO("*** Dump a storage element ***");
+  msg_storage_t storage = MSG_storage_get_by_name(name);
+
+  if(storage){
+    display_storage_content(storage);
+  }
+  else{
+    XBT_INFO("Unable to retrieve storage element by its name: %s.", name);
+  }
+}
+
+void display_storage_content(msg_storage_t storage){
+  XBT_INFO("Print the content of the storage element: %s",MSG_storage_get_name(storage));
+  xbt_dict_cursor_t cursor = NULL;
+  char *file;
+  sg_size_t *psize;
+  xbt_dict_t content = MSG_storage_get_content(storage);
+  if (content){
+    xbt_dict_foreach(content, cursor, file, psize)
+    XBT_INFO("\t%s size: %llu bytes", file, *psize);
+  } else {
+    XBT_INFO("\tNo content.");
+  }
+  xbt_dict_free(&content);
+}
+
+
+
+
+
+int host(int argc, char *argv[])
+{
+       char name[2048];
+       sprintf(name,"%s%i", FILENAME1,MSG_process_self_PID());
+       msg_file_t file = MSG_file_open(name, NULL);
+       //MSG_file_read(file, MSG_file_get_size(file));
+       MSG_file_write(file, 500000);
+
+       XBT_INFO("Size of %s: %llu", MSG_file_get_name(file), MSG_file_get_size(file));
+       MSG_file_close(file);
+
+       return 1;
+}
+
+
+int main(int argc, char **argv)
+{
+
+  int res, i;
+  MSG_init(&argc, argv);
+  MSG_create_environment(argv[1]);
+
+  MSG_function_register("host", host);
+  storage_info(MSG_get_host_by_name(xbt_strdup("host")));
+  for(i = 0 ; i<10; i++){
+       MSG_process_create(xbt_strdup("host"), host, NULL, MSG_get_host_by_name(xbt_strdup("host")));
+  }
+
+
+
+
+  res = MSG_main();
+  storage_info(MSG_get_host_by_name(xbt_strdup("host")));
+  XBT_INFO("Simulation time %g", MSG_get_clock());
+
+  if (res == MSG_OK)
+    return 0;
+  else
+    return 1;
+
+}
diff --git a/teshsuite/msg/storage/one_host_platform.xml b/teshsuite/msg/storage/one_host_platform.xml
new file mode 100644 (file)
index 0000000..e4262df
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+
+<platform version="3">
+       <AS id="AS0" routing="Full">
+               <!-- STORAGE TYPES -->
+               <storage_type id="single_HDD" model="linear_no_lat" size="750GiB" content_type="txt_unix">
+                       <model_prop id="Bwrite" value="30MBps" />
+                       <model_prop id="Bread" value="100MBps" />
+                       <model_prop id="Bconnection" value="150MBps" />
+               </storage_type>
+
+               <!-- DISKS -->
+               <storage id="cdisk" typeId="single_HDD" content="storage_content_c.txt" attach="host"/>
+
+               <!-- HOSTS -->
+               <host id="host" power="1000000000">
+                       <mount storageId="cdisk" name="/sd1" />
+               </host>
+       </AS>
+</platform>
index 2b6e0f9..56c8f88 100644 (file)
@@ -61,3 +61,6 @@ $ ./storage_basic$EXEEXT --cfg=path:${srcdir:=.} ${srcdir:=.}/platform.xml ${src
 > [  3.208145] (1:server@server) Storage sdisk1 is attached to server
 > [  3.208145] (1:server@server) Storage sdisk2 is attached to server
 > [  3.208145] (0:@) Simulated time: 3.20814
 > [  3.208145] (1:server@server) Storage sdisk1 is attached to server
 > [  3.208145] (1:server@server) Storage sdisk2 is attached to server
 > [  3.208145] (0:@) Simulated time: 3.20814
+
+$ ./concurrent_rw$EXEEXT --cfg=path:${srcdir:=.} ${srcdir:=.}/one_host_platform.xml 0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+