Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
also save the cbps in SG, the same way I do in RL since a long time. I love calltree
[simgrid.git] / src / gras / DataDesc / ddt_exchange.c
index 49f0879..77915d4 100644 (file)
@@ -13,7 +13,7 @@
 #include "gras/DataDesc/datadesc_private.h"
 #include "gras/Transport/transport_interface.h" /* gras_trp_send/recv */
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_exchange,datadesc,
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_ddt_exchange,gras_ddt,
                                 "Sending data over the network");
 const char *gras_datadesc_cat_names[9] = { 
   "undefined", 
@@ -122,8 +122,8 @@ gras_datadesc_copy_rec(gras_cbps_t           state,
 
   VERB4("Copy a %s (%s) from %p to %p", 
        type->name, gras_datadesc_cat_names[type->category_code],
-       src,dst);
-
+       src,dst);       
+   
   if (type->send) {
     type->send(type,state,src);
   }
@@ -154,9 +154,27 @@ gras_datadesc_copy_rec(gras_cbps_t           state,
       if (field->send)
        field->send(type,state,field_src);
       
-      VERB1("Copy field %s",field->name);
+      DEBUG1("Copy field %s",field->name);
       count += gras_datadesc_copy_rec(state,refs,sub_type, field_src, field_dst, 0,
                                      detect_cycle || sub_type->cycle);
+       
+       if (XBT_LOG_ISENABLED(gras_ddt_exchange,xbt_log_priority_verbose)) {
+         if (sub_type == gras_datadesc_by_name("unsigned int")) {
+            VERB2("Copied value for field '%s': %d (type: unsigned int)",field->name, *(unsigned int*)field_dst);
+         } else if (sub_type == gras_datadesc_by_name("int")) {
+            VERB2("Copied value for field '%s': %d (type: int)",field->name, *(int*)field_dst);
+            
+         } else if (sub_type == gras_datadesc_by_name("unsigned long int")) {
+            VERB2("Copied value for field '%s': %ld (type: unsigned long int)",field->name, *(unsigned long int*)field_dst);
+         } else if (sub_type == gras_datadesc_by_name("long int")) {
+            VERB2("Copied value for field '%s': %ld (type: long int)",field->name, *(long int*)field_dst);
+
+         } else if (sub_type == gras_datadesc_by_name("string")) {
+            VERB2("Copied value for field '%s': '%s' (type: string)", field->name, *(char**)field_dst);         
+         } else {
+            VERB1("Copied a value for field '%s' (type not scalar?)", field->name);
+         }
+       }
       
     }
     VERB1("<< Copied all fields of the structure %s", type->name);
@@ -338,6 +356,7 @@ gras_datadesc_copy_rec(gras_cbps_t           state,
   default:
     xbt_assert0(0, "Invalid type");
   }
+   
   return count;
 }
 /**
@@ -350,21 +369,22 @@ gras_datadesc_copy_rec(gras_cbps_t           state,
 int gras_datadesc_copy(gras_datadesc_type_t type, 
                       void *src, void *dst) {
   xbt_ex_t e;
-  gras_cbps_t  state;
+  static gras_cbps_t  state=NULL;
   xbt_dict_t  refs; /* all references already sent */
   int size=0;
  
   xbt_assert0(type,"called with NULL type descriptor");
 
   refs = xbt_dict_new();
-  state = gras_cbps_new();
+  if (!state)
+    state = gras_cbps_new();
   
   TRY {
     size = gras_datadesc_copy_rec(state,refs,type,(char*)src,(char*)dst,0, 
                                  type->cycle);
   } CLEANUP {
     xbt_dict_free(&refs);
-    gras_cbps_free(&state);
+    gras_cbps_reset(state);
   } CATCH(e) {
     RETHROW;
   }