2
0

2 Revīzijas a6dff5c34f ... ac5457e2a2

Autors SHA1 Ziņojums Datums
  gbeurier ac5457e2a2 Refactored kernel traces 7 gadi atpakaļ
  gbeurier 8d4f129f8a Added trace methods to models 7 gadi atpakaļ

+ 43 - 35
src/artis/kernel/AbstractAtomicModel.hpp

@@ -59,12 +59,8 @@ public:
     virtual ~AbstractAtomicModel()
     {
 #ifdef WITH_TRACE
-        utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >(
-                   boost::core::demangle(typeid(T).name()).erase(0,6),
-                   utils::DoubleTime::null,
-                   utils::DESTRUCT);
-        utils::Trace < utils::DoubleTime >::trace().flush();
+        trace_element(utils::DoubleTime::null,
+                      utils::CONSTRUCT);
 #endif
     }
 
@@ -75,13 +71,8 @@ public:
     {
 
 #ifdef WITH_TRACE
-        utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
-                                                         utils::KERNEL)
-            << "AFTER - "
-            << AbstractAtomicModel < T, U, V >::path(this);
-        utils::Trace < utils::DoubleTime >::trace().flush();
-        trace_model(t);
+        trace_element(t, utils::AFTER_COMPUTE);
+        trace_internals(t, utils::AFTER_COMPUTE);
 #else
         (void) t;
 #endif
@@ -92,13 +83,9 @@ public:
     {
 
 #ifdef WITH_TRACE
-        utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
-                                                         utils::KERNEL)
-            << "BEFORE - "
-            << AbstractAtomicModel < T, U, V >::path(this);
-        utils::Trace < utils::DoubleTime >::trace().flush();
-       trace_model(t);
+        trace_element(t, utils::BEFORE_COMPUTE);
+        trace_internals(t, utils::BEFORE_COMPUTE);
+        trace_externals(t, utils::BEFORE_COMPUTE);
 #else
         (void) t;
 #endif
@@ -187,36 +174,57 @@ public:
         state.last_time(type::last_time);
     }
 
-#ifdef WITH_TRACE
-    virtual void trace_model(typename U::type t) const
+    virtual void trace_element(typename U::type t, utils::TraceType type = utils::KERNEL) const
+    {
+        utils::Trace < utils::DoubleTime >::trace()
+            << utils::TraceElement < utils::DoubleTime >(
+                  AbstractAtomicModel < T, U, V >::path(this),
+                   t, type);
+        utils::Trace < utils::DoubleTime >::trace().flush();
+    }
+
+    virtual void trace_internals(typename U::type t, utils::TraceType type) 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)
-                    << AbstractAtomicModel < T, U, V >::path(this) << ":"
-                    << Internals < T, U, V >::name(i) << " = "
-                    << Internals < T, U, V >::get(i).to_string(
-                        dynamic_cast < const T* >(this));
+                        << utils::TraceElement < utils::DoubleTime >(
+                              AbstractAtomicModel < T, U, V >::path(this),
+                               t, type)
+                        << utils::KernelInfo(
+                               Internals < T, U, V >::name(i), true,
+                               Internals < T, U, V >::get(i).to_string(
+                                   dynamic_cast < const T* >(this))
+                               );
                 utils::Trace < utils::DoubleTime >::trace().flush();
             }
         }
+    }
 
+    virtual void trace_externals(typename U::type t, utils::TraceType type = utils::KERNEL) const
+    {
         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)
-                    << AbstractAtomicModel < T, U, V >::path(this) << ":"
-                    << "*" << Externals < T, U, V >::name(i) << " = "
-                    << Externals < T, U, V >::get(i).to_string(
-                        dynamic_cast < const T* >(this));
+                        << utils::TraceElement < utils::DoubleTime >(
+                              AbstractAtomicModel < T, U, V >::path(this),
+                               t, type)
+                        << utils::KernelInfo(
+                               Externals < T, U, V >::name(i), false,
+                               Externals < T, U, V >::get(i).to_string(
+                                   dynamic_cast < const T* >(this))
+                               );
                 utils::Trace < utils::DoubleTime >::trace().flush();
             }
         }
     }
-#endif
+
+    virtual void trace_model(typename U::type t, utils::TraceType type = utils::KERNEL) const
+    {
+        trace_element(t, type);
+        trace_internals(t, type);
+        trace_externals(t, type);
+    }
 
     virtual void stable()
     { Externals < T, U, V >::updated = false; }

+ 73 - 76
src/artis/kernel/AbstractCoupledModel.hpp

@@ -80,12 +80,8 @@ public:
     virtual ~AbstractCoupledModel()
     {
 #ifdef WITH_TRACE
-        utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >(
-                   AbstractCoupledModel < T, U, V, W >::path(this).erase(0,6),
-                   utils::DoubleTime::null,
-                   utils::DESTRUCT);
-        utils::Trace < utils::DoubleTime >::trace().flush();
+        trace_element(utils::DoubleTime::null,
+                      utils::DESTRUCT);
 #endif
     }
 
@@ -93,12 +89,8 @@ public:
     {
 
 #ifdef WITH_TRACE
-        utils::Trace < utils::DoubleTime >::trace()
-            << 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);
+        trace_element(t, utils::AFTER_COMPUTE);
+        trace_internals(t, utils::AFTER_COMPUTE);
 #else
         (void) t;
 #endif
@@ -121,12 +113,9 @@ public:
     {
 
 #ifdef WITH_TRACE
-        utils::Trace < utils::DoubleTime >::trace()
-            << 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);
+        trace_element(t, utils::BEFORE_COMPUTE);
+        trace_internals(t, utils::BEFORE_COMPUTE);
+        trace_externals(t, utils::BEFORE_COMPUTE);
 #else
         (void) t;
 #endif
@@ -335,53 +324,64 @@ public:
         Externals < T, U, V >::save(this, state);
     }
 
-#ifdef WITH_TRACE
-    virtual void trace_model(typename U::type t) const {
+    virtual void trace_element(typename U::type t, utils::TraceType type = utils::KERNEL) const
+    {
+        utils::Trace < utils::DoubleTime >::trace()
+            << utils::TraceElement < utils::DoubleTime >(
+                  AbstractCoupledModel < T, U, V, W >::path(this),
+                   t, type);
+        utils::Trace < utils::DoubleTime >::trace().flush();
+    }
+
+    virtual void trace_internals(typename U::type t, utils::TraceType type) 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::KernelInfo({
-                           Internals < T, U, V >::name(i), true,
-                           Internals < T, U, V >::get(i).to_string(
-                               dynamic_cast < const T* >(this))
-                           });
+                        << utils::TraceElement < utils::DoubleTime >(
+                              AbstractCoupledModel < T, U, V, W >::path(this),
+                               t, type)
+                        << utils::KernelInfo(
+                               Internals < T, U, V >::name(i), true,
+                               Internals < T, U, V >::get(i).to_string(
+                                   dynamic_cast < const T* >(this))
+                               );
+                utils::Trace < utils::DoubleTime >::trace().flush();
             }
         }
+    }
 
+    virtual void trace_externals(typename U::type t, utils::TraceType type = utils::KERNEL) const
+    {
         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 >(
+                              AbstractCoupledModel < T, U, V, W >::path(this),
+                               t, type)
                         << utils::KernelInfo(
                                Externals < T, U, V >::name(i), false,
                                Externals < T, U, V >::get(i).to_string(
                                    dynamic_cast < const T* >(this))
                                );
+                utils::Trace < utils::DoubleTime >::trace().flush();
             }
         }
     }
 
-    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
+    virtual void trace_model(typename U::type t, utils::TraceType type = utils::KERNEL) const
     {
-
-
-        utils::Trace < utils::DoubleTime >::trace().flush();
+        trace_element(t, type);
+        trace_internals(t, type);
+        trace_externals(t, type);
         typename AbstractCoupledModel::Submodels::const_iterator it =
-            submodels.begin();
+                submodels.begin();
 
         while (it != submodels.end()) {
-            if(it->)
-            it->second->trace_indepth_model(t);
+            it->second->trace_model(t, type);
             ++it;
         }
     }
-#endif
 
 
     virtual void stable()
@@ -422,18 +422,17 @@ protected:
         submodel_internals[index] =
             std::pair < type*, int >(model, sub_index);
 #ifdef WITH_TRACE
-                utils::Trace < utils::DoubleTime >::trace()
-                        << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                                     utils::INTERNAL_LINK)
-                        << "LINK INTERNAL "
-                        << AbstractCoupledModel < T, U, V, W >::path(this)
-                        << ":"
-                        << var_name
-                        << " to "
-                        << AbstractCoupledModel < T, U, V, W >::path(model)
-                        << ":"
-                        << sub_var_name;
-                utils::Trace < utils::DoubleTime >::trace().flush();
+        utils::Trace < utils::DoubleTime >::trace()
+                << utils::TraceElement < utils::DoubleTime >(
+                      AbstractCoupledModel < T, U, V, W >::path(this),
+                      utils::DoubleTime::null,
+                      utils::INTERNAL_LINK)
+                << utils::KernelInfo(
+                       var_name,
+                       AbstractCoupledModel < T, U, V, W >::path(model),
+                       sub_var_name);
+        utils::Trace < utils::DoubleTime >::trace().flush();
+
 #endif
     }
 
@@ -446,18 +445,16 @@ protected:
                 std::pair < type*, int >(it->model, it->sub_index);
 
 #ifdef WITH_TRACE
-                utils::Trace < utils::DoubleTime >::trace()
-                        << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                                     utils::INTERNAL_DECL)
-                        << "LINK INTERNAL "
-                        << AbstractCoupledModel < T, U, V, W >::path(this)
-                        << ":"
-                        << it->var_name
-                        << " to "
-                        << AbstractCoupledModel < T, U, V, W >::path(it->model)
-                        << ":"
-                        << it->sub_var_name;
-                utils::Trace < utils::DoubleTime >::trace().flush();
+            utils::Trace < utils::DoubleTime >::trace()
+                    << utils::TraceElement < utils::DoubleTime >(
+                          AbstractCoupledModel < T, U, V, W >::path(this),
+                          utils::DoubleTime::null,
+                          utils::INTERNAL_LINK)
+                    << utils::KernelInfo(
+                           it->var_name,
+                           AbstractCoupledModel < T, U, V, W >::path(it->model),
+                           it->sub_var_name);
+            utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
         }
     }
@@ -473,12 +470,12 @@ protected:
 
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                         utils::SUBMODEL_ADD)
-            << "SUBMODEL - "
-            << AbstractCoupledModel < T, U, V, W >::path(it->second)
-            << " to "
-            << AbstractCoupledModel < T, U, V, W >::path(this);
+                << utils::TraceElement < utils::DoubleTime >(
+                       AbstractCoupledModel < T, U, V, W >::path(this),
+                       utils::DoubleTime::null,
+                       utils::SUBMODEL_ADD)
+                << utils::KernelInfo(
+                       AbstractCoupledModel < T, U, V, W >::path(it->second));
         utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
 
@@ -495,12 +492,12 @@ protected:
 
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                         utils::KERNEL)
-            << "SUBMODEL - "
-            << AbstractCoupledModel < T, U, V, W >::path(model)
-            << " added to "
-            << AbstractCoupledModel < T, U, V, W >::path(this);
+                << utils::TraceElement < utils::DoubleTime >(
+                       AbstractCoupledModel < T, U, V, W >::path(this),
+                       utils::DoubleTime::null,
+                       utils::SUBMODEL_ADD)
+                << utils::KernelInfo(
+                       AbstractCoupledModel < T, U, V, W >::path(model));
         utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
     }

+ 9 - 3
src/artis/kernel/AbstractModel.hpp

@@ -23,9 +23,11 @@
 #ifndef __ARTIS_KERNEL_ABSTRACT_MODEL_HPP
 #define __ARTIS_KERNEL_ABSTRACT_MODEL_HPP
 
+
 #include <artis/kernel/Node.hpp>
 #include <artis/context/State.hpp>
 #include <artis/utils/DoubleTime.hpp>
+#include <artis/utils/Trace.hpp>
 
 #include <boost/core/demangle.hpp>
 
@@ -79,6 +81,9 @@ public:
         before(t);
         if (check(t) and (last_time != t or
                           (last_time == t and is_updated()))) {
+#ifdef WITH_TRACE
+        trace_element(t, utils::COMPUTE);
+#endif
             compute(t, last_time == t);
             last_time = t;
             stable();
@@ -126,9 +131,10 @@ public:
 
     virtual void save(context::State < Time >& state) const = 0;
 
-#ifdef WITH_TRACE
-    virtual void trace_model(typename Time::type t) const = 0;
-#endif
+    virtual void trace_element(typename Time::type t, utils::TraceType type) const = 0;
+    virtual void trace_internals(typename Time::type t, utils::TraceType type) const = 0;
+    virtual void trace_externals(typename Time::type t, utils::TraceType type) const = 0;
+    virtual void trace_model(typename Time::type t, utils::TraceType type) const = 0;
 
     void set_parent(const AbstractModel < Time, Parameters >* p)
     { parent = p; }

+ 19 - 22
src/artis/kernel/Externals.hpp

@@ -88,12 +88,11 @@ public:
 
 #ifdef WITH_TRACE
             utils::Trace < utils::DoubleTime >::trace()
-                    << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                                 utils::KERNEL)
-                    << "EXTERNAL - "
-                    << dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this))
-                    << " declare "
-                    << it->name;
+                    << utils::TraceElement < utils::DoubleTime >(
+                           dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this)),
+                           utils::DoubleTime::null,
+                           utils::EXTERNAL_DECL)
+                    << utils::KernelInfo(it->name, false);
             utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
         }
@@ -110,14 +109,13 @@ public:
         external_names[index] = name;
 
 #ifdef WITH_TRACE
-            utils::Trace < utils::DoubleTime >::trace()
-                    << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                                 utils::KERNEL)
-                    << "EXTERNAL - "
-                    << dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this)) //useless submodels not added yet
-                    << " declare "
-                    << name;
-            utils::Trace < utils::DoubleTime >::trace().flush();
+        utils::Trace < utils::DoubleTime >::trace()
+                << utils::TraceElement < utils::DoubleTime >(
+                       dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this)),
+                       utils::DoubleTime::null,
+                       utils::EXTERNAL_DECL)
+                << utils::KernelInfo(name, false);
+        utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
     }
 
@@ -143,14 +141,13 @@ public:
         }
 
 #ifdef WITH_TRACE
-            utils::Trace < utils::DoubleTime >::trace()
-                    << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
-                                                                 utils::KERNEL)
-                    << "PUT - "
-                    << get(index).to_string(dynamic_cast < const T* >(this))
-                    << " in "
-                    << dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this)) << ":" << external_names[index];
-            utils::Trace < utils::DoubleTime >::trace().flush();
+        utils::Trace < utils::DoubleTime >::trace()
+                << utils::TraceElement < utils::DoubleTime >(
+                       dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this)),
+                       t, utils::PUT)
+                << utils::KernelInfo(external_names[index], true,
+                                     get(index).to_string(dynamic_cast < const T* >(this)));
+        utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
     }
 

+ 12 - 14
src/artis/kernel/Internals.hpp

@@ -70,12 +70,11 @@ public:
 
 #ifdef WITH_TRACE
             utils::Trace < utils::DoubleTime >::trace()
-                    << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                                 utils::KERNEL)
-                    << "INTERNAL - "
-                    << dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this))
-                    << " declare "
-                    << it->name;
+                    << utils::TraceElement < utils::DoubleTime >(
+                           dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this)),
+                           utils::DoubleTime::null,
+                           utils::INTERNAL_DECL)
+                    << utils::KernelInfo(it->name, true);
             utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
         }
@@ -93,14 +92,13 @@ public:
         internal_names[index] = name;
 
 #ifdef WITH_TRACE
-            utils::Trace < utils::DoubleTime >::trace()
-                    << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                                 utils::KERNEL)
-                    << "INTERNAL - "
-                    << dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this))
-                    << " declare "
-                    << name;
-            utils::Trace < utils::DoubleTime >::trace().flush();
+        utils::Trace < utils::DoubleTime >::trace()
+                << utils::TraceElement < utils::DoubleTime >(
+                       dynamic_cast<T*>(this)->path(dynamic_cast<T*>(this)),
+                       utils::DoubleTime::null,
+                       utils::INTERNAL_DECL)
+                << utils::KernelInfo(name, true);
+        utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
     }
 

+ 4 - 7
src/artis/kernel/Simulator.hpp

@@ -57,13 +57,10 @@ public:
         _observer.init();
 
 #ifdef WITH_TRACE
-        utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", 0,
-                                                         utils::INIT)
-            << "GLOBAL VALUES - "
-            << _model->path(_model);
-        _model->trace_model(0);
-        utils::Trace < utils::DoubleTime >::trace().flush();
+        _model->trace_element(utils::DoubleTime::null,
+                              utils::INIT);
+        _model->trace_model(utils::DoubleTime::null,
+                            utils::INIT);
 #endif
     }
 

+ 51 - 36
src/artis/utils/Trace.hpp

@@ -34,6 +34,10 @@
 #include <artis/utils/DateTime.hpp>
 #include <artis/kernel/Any.hpp>
 
+#if WIN32
+#include <iso646.h>
+#endif
+
 namespace artis { namespace utils {
 
 enum TraceType { NONE = 0, CHECK, CONSTRUCT, SUBMODEL_ADD, INTERNAL_DECL,
@@ -44,37 +48,48 @@ static const std::vector <std::string> TraceTypesStr = {
     "external_decl", "internal_link", "init", "start", "before_compute",
     "compute", "put", "after_compute", "destruct", "kernel"};
 
-struct KernelInfo
+class KernelInfo
 {
-    std::string         _var;
-    bool                _internal_var;
-    std::string         _value;
-    std::string         _tgt_model;
-    std::string         _tgt_internal_var;
+public:
+    const std::string& var() const {return _var;}
+    std::string value() const {return _value;}
+    std::string tgt_model() const {return _tgt_model;}
+    std::string tgt_internal_var() const {return _tgt_internal_var;}
+    bool internal_var() const {return _internal_var;}
+    bool empty() const {return _empty;}
+
+    KernelInfo() :
+        _var(""), _internal_var(false), _value(""),
+        _tgt_model(""), _tgt_internal_var(""), _empty(true)
+    { }
 
     KernelInfo(const std::string& var, bool internal_var,
                const std::string& value) :
         _var(var), _internal_var(internal_var), _value(value),
-        _tgt_model(""), _tgt_internal_var("")
+        _tgt_model(""), _tgt_internal_var(""), _empty(false)
     { }
 
     KernelInfo(const std::string& var, const std::string& tgt_model,
                const std::string& tgt_internal_var) :
         _var(var), _internal_var(true), _value(""),
-        _tgt_model(tgt_model), _tgt_internal_var(tgt_internal_var)
+        _tgt_model(tgt_model), _tgt_internal_var(tgt_internal_var),
+        _empty(false)
     { }
 
     KernelInfo(const std::string& var, bool internal_var) :
         _var(var), _internal_var(internal_var), _value(""),
-        _tgt_model(""), _tgt_internal_var("")
+        _tgt_model(""), _tgt_internal_var(""), _empty(false)
     { }
 
     KernelInfo(const std::string& tgt_model) :
         _var(""), _internal_var(false), _value(""),
-        _tgt_model(tgt_model), _tgt_internal_var("")
+        _tgt_model(tgt_model), _tgt_internal_var(""),
+        _empty(false)
     { }
 
-    const std::string& to_string() const {
+
+
+    std::string to_string() const {
         std::ostringstream ss;
         if( not _var.empty() ){
             ss << ":";
@@ -87,7 +102,7 @@ struct KernelInfo
             ss << "=" << _value;
         }
         if(not _tgt_model.empty()) {
-            ss << " " << _tgt_model;
+            ss << " -> " << _tgt_model;
             if(not _tgt_internal_var.empty()) {
                 ss << ":" << _tgt_internal_var;
             }
@@ -95,6 +110,15 @@ struct KernelInfo
 
         return ss.str();
     }
+
+private:
+    std::string         _var;
+    bool                _internal_var;
+    std::string         _value;
+    std::string         _tgt_model;
+    std::string         _tgt_internal_var;
+    bool                _empty;
+
 };
 
 template < class Time >
@@ -124,21 +148,21 @@ public:
     TraceType get_type() const
     { return _type; }
 
-    const std::vector< KernelInfo >& get_kernel_info() const
+    const KernelInfo& get_kernel_info() const
     { return _kernel_info; }
 
     void set_comment(const std::string& comment)
     { _comment = comment; }
 
-    void add_kernel_info(const KernelInfo& info)
-    { _kernel_info.push_back(info); }
+    void set_kernel_info(const KernelInfo& info)
+    { _kernel_info = info; }
 
 private:
     std::string         _model_name;
     typename Time::type _time;
     TraceType           _type;
     std::string         _comment;
-    std::vector< KernelInfo > _kernel_info;
+    KernelInfo         _kernel_info;
 };
 
 template < class Time >
@@ -191,28 +215,19 @@ public:
         for (typename TraceElements < Time >::const_iterator it =
              TraceElements < Time >::begin();
              it != TraceElements < Time >::end(); ++it) {
-            ss << "TRACE: ";
-            std::string time = "";
+            ss << "TRACE";
             if(it->get_time() != Time::null) {
-                std::string date = utils::DateTime::toJulianDayFmt(it->get_time(), date_format);
-                time = "(" + date + ")";
+               ss << "(" << utils::DateTime::toJulianDayFmt(it->get_time(), date_format) << ")";
+            }
+            ss << ": ";
+            ss << "<" + TraceTypesStr[it->get_type()] + ">";
+            ss << " " << it->get_model_name();
+            if(not it->get_kernel_info().empty()) {
+                ss << it->get_kernel_info().to_string();
             }
-            ss << time;
-            std::string type = "<" + TraceTypesStr[it->get_type()] + ">";
-            ss << type;
-            std::string model_name = it->get_model_name();
-            ss << " " << model_name;
-
             if (not it->get_comment().empty()) {
                 ss << " => " << it->get_comment();
             }
-
-            for (std::vector < KernelInfo >::const_iterator itk = it->get_kernel_info().begin(); itk != it->get_kernel_info().end(); ++itk) {
-                ss << std::endl;
-                ss << "INFO: ";
-                ss << time << type << " " << model_name;
-//                ss << itk->to_string();
-            }
             ss << std::endl;
         }
         return ss.str();
@@ -256,8 +271,8 @@ public:
     void set_element(const TraceElement < Time >& element)
     { _element = element; }
 
-    void add_kernel_info(const KernelInfo& info)
-    { _element.add_kernel_info(info); }
+    void set_kernel_info(const KernelInfo& info)
+    { _element.set_kernel_info(info); }
 
     std::ostringstream& sstream()
     {
@@ -300,7 +315,7 @@ artis::utils::Trace < Time >& operator<<(
 {
     std::lock_guard < std::mutex > lock(trace.mutex());
 
-    trace.add_kernel_info(info);
+    trace.set_kernel_info(info);
     return trace;
 }