Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Need to have a double because the result should not be an integer.
authornavarro <navarro@caraja.(none)>
Fri, 22 Jun 2012 11:07:42 +0000 (13:07 +0200)
committernavarro <navarro@caraja.(none)>
Fri, 22 Jun 2012 11:07:57 +0000 (13:07 +0200)
examples/msg/io/file.c
examples/msg/io/io.tesh
include/msg/msg.h
include/simgrid/simix.h
src/msg/msg_io.c
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/surf/storage.c

index e899d95..21c1b83 100644 (file)
@@ -36,7 +36,7 @@ int host(int argc, char *argv[])
   s_msg_stat_t stat;
   void *ptr = NULL;
   char* mount = bprintf("/home");
-  size_t read,write;
+  double read,write;
 
   if(!strcmp(MSG_process_get_name(MSG_process_self()),"0"))
     file = MSG_file_open(mount,FILENAME1,"rw");
@@ -51,16 +51,16 @@ int host(int argc, char *argv[])
   XBT_INFO("\tOpen file '%s'",file->name);
 
   read = MSG_file_read(ptr,10000000,sizeof(char*),file);     // Read for 10Mo
-  XBT_INFO("\tHaving read  %zu \ton %s",read,file->name);
+  XBT_INFO("\tHaving read  %.1f \ton %s",read,file->name);
 
   write = MSG_file_write(ptr,100000,sizeof(char*),file);  // Write for 100Ko
-  XBT_INFO("\tHaving write %zu \ton %s",write,file->name);
+  XBT_INFO("\tHaving write %.1f \ton %s",write,file->name);
 
   read = MSG_file_read(ptr,10000000,sizeof(char*),file);     // Read for 10Mo
-  XBT_INFO("\tHaving read  %zu \ton %s",read,file->name);
+  XBT_INFO("\tHaving read  %.1f \ton %s",read,file->name);
 
   MSG_file_stat(file,&stat);
-  XBT_INFO("\tFile stat %s Size %f",file->name,stat.size);
+  XBT_INFO("\tFile stat %s Size %.1f",file->name,stat.size);
 
   XBT_INFO("\tClose file '%s'",file->name);
   MSG_file_close(file);
@@ -76,9 +76,9 @@ int main(int argc, char **argv)
   MSG_create_environment(argv[1]);
   xbt_dynar_t hosts =  MSG_hosts_as_dynar();
   MSG_function_register("host", host);
-
-  XBT_INFO("Number of host '%lu'",xbt_dynar_length(hosts));
-  for(i = 0 ; i<xbt_dynar_length(hosts); i++)
+  unsigned long nb_hosts = xbt_dynar_length(hosts);
+  XBT_INFO("Number of host '%lu'",nb_hosts);
+  for(i = 0 ; i<nb_hosts; i++)
   {
     char* name_host = bprintf("%d",i);
     MSG_process_create( name_host, host, NULL, xbt_dynar_get_as(hosts,i,m_host_t) );
index 441671a..8f1131f 100644 (file)
@@ -7,24 +7,24 @@ $ ${bindir:=.}/io/file ${srcdir:=.}/examples/platforms/storage.xml "--log=root.f
 > [  0.000000] (2:1@alice)     Open file './doc/simgrid/examples/platforms/One_cluster_no_backbone.xml'
 > [  0.000000] (3:2@carl)      Open file './doc/simgrid/examples/platforms/g5k_cabinets.xml'
 > [  0.000000] (4:3@bob)       Open file './doc/simgrid/examples/platforms/nancy.xml'
-> [  0.000005] (2:1@alice)     Having read  482        on ./doc/simgrid/examples/platforms/One_cluster_no_backbone.xml
-> [  0.000040] (4:3@bob)       Having read  4028       on ./doc/simgrid/examples/platforms/nancy.xml
-> [  0.000170] (1:0@denise)    Having read  17028      on ./doc/simgrid/examples/platforms/g5k.xml
-> [  0.000226] (3:2@carl)      Having read  22645      on ./doc/simgrid/examples/platforms/g5k_cabinets.xml
-> [  0.003338] (2:1@alice)     Having write 100000     on ./doc/simgrid/examples/platforms/One_cluster_no_backbone.xml
-> [  0.003374] (4:3@bob)       Having write 100000     on ./doc/simgrid/examples/platforms/nancy.xml
-> [  0.003504] (1:0@denise)    Having write 100000     on ./doc/simgrid/examples/platforms/g5k.xml
-> [  0.003560] (3:2@carl)      Having write 100000     on ./doc/simgrid/examples/platforms/g5k_cabinets.xml
-> [  0.004343] (2:1@alice)     Having read  100482     on ./doc/simgrid/examples/platforms/One_cluster_no_backbone.xml
-> [  0.004343] (2:1@alice)     File stat ./doc/simgrid/examples/platforms/One_cluster_no_backbone.xml Size 100482
+> [  0.000005] (2:1@alice)     Having read  482.0      on ./doc/simgrid/examples/platforms/One_cluster_no_backbone.xml
+> [  0.000040] (4:3@bob)       Having read  4028.0     on ./doc/simgrid/examples/platforms/nancy.xml
+> [  0.000170] (1:0@denise)    Having read  17028.0    on ./doc/simgrid/examples/platforms/g5k.xml
+> [  0.000226] (3:2@carl)      Having read  22645.0    on ./doc/simgrid/examples/platforms/g5k_cabinets.xml
+> [  0.003338] (2:1@alice)     Having write 100000.0   on ./doc/simgrid/examples/platforms/One_cluster_no_backbone.xml
+> [  0.003374] (4:3@bob)       Having write 100000.0   on ./doc/simgrid/examples/platforms/nancy.xml
+> [  0.003504] (1:0@denise)    Having write 100000.0   on ./doc/simgrid/examples/platforms/g5k.xml
+> [  0.003560] (3:2@carl)      Having write 100000.0   on ./doc/simgrid/examples/platforms/g5k_cabinets.xml
+> [  0.004343] (2:1@alice)     Having read  100482.0   on ./doc/simgrid/examples/platforms/One_cluster_no_backbone.xml
+> [  0.004343] (2:1@alice)     File stat ./doc/simgrid/examples/platforms/One_cluster_no_backbone.xml Size 100482.0
 > [  0.004343] (2:1@alice)     Close file './doc/simgrid/examples/platforms/One_cluster_no_backbone.xml'
-> [  0.004414] (4:3@bob)       Having read  104028     on ./doc/simgrid/examples/platforms/nancy.xml
-> [  0.004414] (4:3@bob)       File stat ./doc/simgrid/examples/platforms/nancy.xml Size 104028
+> [  0.004414] (4:3@bob)       Having read  104028.0   on ./doc/simgrid/examples/platforms/nancy.xml
+> [  0.004414] (4:3@bob)       File stat ./doc/simgrid/examples/platforms/nancy.xml Size 104028.0
 > [  0.004414] (4:3@bob)       Close file './doc/simgrid/examples/platforms/nancy.xml'
-> [  0.004674] (1:0@denise)    Having read  117028     on ./doc/simgrid/examples/platforms/g5k.xml
-> [  0.004674] (1:0@denise)    File stat ./doc/simgrid/examples/platforms/g5k.xml Size 117028
+> [  0.004674] (1:0@denise)    Having read  117028.0   on ./doc/simgrid/examples/platforms/g5k.xml
+> [  0.004674] (1:0@denise)    File stat ./doc/simgrid/examples/platforms/g5k.xml Size 117028.0
 > [  0.004674] (1:0@denise)    Close file './doc/simgrid/examples/platforms/g5k.xml'
-> [  0.004786] (3:2@carl)      Having read  122645     on ./doc/simgrid/examples/platforms/g5k_cabinets.xml
-> [  0.004786] (3:2@carl)      File stat ./doc/simgrid/examples/platforms/g5k_cabinets.xml Size 122645
+> [  0.004786] (3:2@carl)      Having read  122645.0   on ./doc/simgrid/examples/platforms/g5k_cabinets.xml
+> [  0.004786] (3:2@carl)      File stat ./doc/simgrid/examples/platforms/g5k_cabinets.xml Size 122645.0
 > [  0.004786] (3:2@carl)      Close file './doc/simgrid/examples/platforms/g5k_cabinets.xml'
-> [  0.004786] (0:@) Simulation time 0.00478623
\ No newline at end of file
+> [  0.004786] (0:@) Simulation time 0.00478623
index a947576..8194d19 100644 (file)
@@ -73,7 +73,7 @@ XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void);
 
 
 /************************** File handling ***********************************/
-XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream);
+XBT_PUBLIC(double) MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream);
 XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t stream);
 XBT_PUBLIC(msg_file_t) MSG_file_open(const char* mount, const char* path, const char* mode);
 XBT_PUBLIC(int) MSG_file_close(msg_file_t fp);
index 872af4a..1dd29b9 100644 (file)
@@ -431,7 +431,7 @@ XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem,
 XBT_PUBLIC(unsigned int) simcall_sem_acquire_any(xbt_dynar_t sems);
 XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
 
-XBT_PUBLIC(size_t) simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream);
+XBT_PUBLIC(double) simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream);
 XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
 XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path, const char* mode);
 XBT_PUBLIC(int) simcall_file_close(smx_file_t fp);
index affae9d..3774f1e 100644 (file)
@@ -28,7 +28,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg,
  * \param stream to read
  * \return the number of items successfully read
  */
-size_t MSG_file_read(void* ptr, size_t size, size_t nmemb,  msg_file_t stream)
+double MSG_file_read(void* ptr, size_t size, size_t nmemb,  msg_file_t stream)
 {
   return simcall_file_read(ptr, size, nmemb, stream->simdata->smx_file);
 }
index 6ce40e2..083008a 100644 (file)
@@ -513,7 +513,7 @@ typedef struct s_smx_simcall {
       size_t size;
       size_t nmemb;
       smx_file_t stream;
-      size_t result;
+      double result;
     } file_read;
 
     struct {
index c0f8af0..25f75a3 100644 (file)
@@ -1203,7 +1203,7 @@ int simcall_sem_get_capacity(smx_sem_t sem)
   return simcall->sem_get_capacity.result;
 }
 
-size_t simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
 {
   smx_simcall_t simcall = SIMIX_simcall_mine();
 
index 15db4c7..7aed75e 100644 (file)
@@ -76,12 +76,9 @@ static surf_action_t storage_action_close(void *storage, surf_file_t fp)
 
 static surf_action_t storage_action_read(void *storage, void* ptr, double size, size_t nmemb, surf_file_t stream)
 {
-  char *filename = stream->name;
   surf_stat_t content = stream->content;
-  XBT_INFO("\tRead file '%s' size '%f/%f'",filename,content->stat.size,size);
   if(size > content->stat.size)
     size = content->stat.size;
-  XBT_INFO("Really read file '%s' for %f",filename,size);
   surf_action_t action = storage_action_execute(storage,size,READ);
   return action;
 }
@@ -212,10 +209,8 @@ static void storage_update_actions_state(double now, double delta)
     if(action->type == WRITE)
     {
       double rate = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
-      XBT_INFO("Update %f + %f = %f",((surf_action_t)action)->file->content->stat.size,delta * rate,((surf_action_t)action)->file->content->stat.size+delta * rate);
       ((storage_t)(action->storage))->used_size += delta * rate; // disk usage
       ((surf_action_t)action)->file->content->stat.size += delta * rate; // file size
-      XBT_INFO("Have updating to %f",((surf_action_t)action)->file->content->stat.size);
     }
   }