Parcourir la source

Intermediate commit

Grégory Beurier il y a 7 ans
Parent
commit
a6dff5c34f

+ 35 - 34
src/artis/kernel/AbstractCoupledModel.hpp

@@ -82,7 +82,7 @@ public:
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
             << utils::TraceElement < utils::DoubleTime >(
-                   boost::core::demangle(typeid(T).name()).erase(0,6),
+                   AbstractCoupledModel < T, U, V, W >::path(this).erase(0,6),
                    utils::DoubleTime::null,
                    utils::DESTRUCT);
         utils::Trace < utils::DoubleTime >::trace().flush();
@@ -94,10 +94,9 @@ public:
 
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
-                                                         utils::AFTER_COMPUTE)
-            << "AFTER - "
-            << AbstractCoupledModel < T, U, V, W >::path(this);
+            << utils::TraceElement < utils::DoubleTime >(
+                  AbstractCoupledModel < T, U, V, W >::path(this),
+                   t, utils::AFTER_COMPUTE);
         utils::Trace < utils::DoubleTime >::trace().flush();
         trace_model(t, false);
 #else
@@ -123,10 +122,9 @@ public:
 
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
-                                                         utils::BEFORE_COMPUTE)
-            << "BEFORE - "
-            << AbstractCoupledModel < T, U, V, W >::path(this);
+            << utils::TraceElement < utils::DoubleTime >(
+                  AbstractCoupledModel < T, U, V, W >::path(this),
+                   t, utils::BEFORE_COMPUTE);
         utils::Trace < utils::DoubleTime >::trace().flush();
         trace_model(t, false);
 #else
@@ -339,45 +337,48 @@ public:
 
 #ifdef WITH_TRACE
     virtual void trace_model(typename U::type t) const {
-        trace_model(t, true);
-    }
-    void trace_model(typename U::type t, bool in_depth) const
-    {
         for (size_t i = 0; i < Internals < T, U, V >::size(); ++i) {
             if (not Internals < T, U, V >::get(i).is_null()) {
                 utils::Trace < utils::DoubleTime >::trace()
-                    << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
-                                                                 utils::KERNEL)
-                    << AbstractCoupledModel < T, U, V, W >::path(this) << ":"
-                    << Internals < T, U, V >::name(i) << " = "
-                    << Internals < T, U, V >::get(i).to_string(
-                        dynamic_cast < const T* >(this));
-                utils::Trace < utils::DoubleTime >::trace().flush();
+                    << utils::KernelInfo({
+                           Internals < T, U, V >::name(i), true,
+                           Internals < T, U, V >::get(i).to_string(
+                               dynamic_cast < const T* >(this))
+                           });
             }
         }
 
         for (size_t i = 0; i < Externals < T, U, V >::size(); ++i) {
             if (not Externals < T, U, V >::get(i).is_null()) {
                 utils::Trace < utils::DoubleTime >::trace()
-                    << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
-                                                                 utils::KERNEL)
-                    << AbstractCoupledModel < T, U, V, W >::path(this) << ":"
-                    << "*" << Externals < T, U, V >::name(i) << " = "
-                    << Externals < T, U, V >::get(i).to_string(
-                        dynamic_cast < const T* >(this));
-                utils::Trace < utils::DoubleTime >::trace().flush();
+                        << utils::KernelInfo(
+                               Externals < T, U, V >::name(i), false,
+                               Externals < T, U, V >::get(i).to_string(
+                                   dynamic_cast < const T* >(this))
+                               );
             }
         }
+    }
+
+    virtual utils::TraceElement < utils::DoubleTime > trace_element(){
+        utils::Trace < utils::DoubleTime >::trace()
+            << utils::TraceElement < utils::DoubleTime >(
+                  AbstractCoupledModel < T, U, V, W >::path(this),
+                   t, trace_type);
+    }
 
+    void trace_indepth_model(typename U::type t, utils::Trace::TraceType trace_type) const
+    {
 
-        if(in_depth) {
-            typename AbstractCoupledModel::Submodels::const_iterator it =
-                submodels.begin();
 
-            while (it != submodels.end()) {
-                it->second->trace_model(t);
-                ++it;
-            }
+        utils::Trace < utils::DoubleTime >::trace().flush();
+        typename AbstractCoupledModel::Submodels::const_iterator it =
+            submodels.begin();
+
+        while (it != submodels.end()) {
+            if(it->)
+            it->second->trace_indepth_model(t);
+            ++it;
         }
     }
 #endif

+ 1 - 1
src/artis/kernel/Simulator.hpp

@@ -62,8 +62,8 @@ public:
                                                          utils::INIT)
             << "GLOBAL VALUES - "
             << _model->path(_model);
-        utils::Trace < utils::DoubleTime >::trace().flush();
         _model->trace_model(0);
+        utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
     }
 

+ 7 - 15
src/artis/utils/Trace.hpp

@@ -39,6 +39,10 @@ namespace artis { namespace utils {
 enum TraceType { NONE = 0, CHECK, CONSTRUCT, SUBMODEL_ADD, INTERNAL_DECL,
                  EXTERNAL_DECL, INTERNAL_LINK, INIT, START, BEFORE_COMPUTE,
                  COMPUTE, PUT, AFTER_COMPUTE, DESTRUCT, KERNEL};
+static const std::vector <std::string> TraceTypesStr = {
+    "none", "check", "construct", "submodel_add", "internal_decl",
+    "external_decl", "internal_link", "init", "start", "before_compute",
+    "compute", "put", "after_compute", "destruct", "kernel"};
 
 struct KernelInfo
 {
@@ -194,19 +198,7 @@ public:
                 time = "(" + date + ")";
             }
             ss << time;
-            std::string type = "none";
-            switch (it->get_type())
-            {
-            case NONE: type = "none"; break;
-            case CONSTRUCT: type = "construct"; break;
-            case DESTRUCT: type = "destruct"; break;
-            case CHECK: type = "check"; break;
-            case COMPUTE:  type = "compute"; break;
-            case INIT: type = "init"; break;
-            case KERNEL: type = "kernel"; break;
-            case PUT: type = "put"; break;
-            };
-            type = "<" + type + ">";
+            std::string type = "<" + TraceTypesStr[it->get_type()] + ">";
             ss << type;
             std::string model_name = it->get_model_name();
             ss << " " << model_name;
@@ -217,9 +209,9 @@ public:
 
             for (std::vector < KernelInfo >::const_iterator itk = it->get_kernel_info().begin(); itk != it->get_kernel_info().end(); ++itk) {
                 ss << std::endl;
-                ss << "TRACE: ";
+                ss << "INFO: ";
                 ss << time << type << " " << model_name;
-                ss << itk->to_string();
+//                ss << itk->to_string();
             }
             ss << std::endl;
         }

+ 2 - 0
src/test/test-context.cpp

@@ -68,6 +68,8 @@ int main()
         oa << context;
     }
 
+    exit(0);
+
     std::cout << "==== PAUSE ====" << std::endl;
 
     {