<commit_before>#ifndef DESOLIN_TG_EXPRESSION_GRAPH_HPP
#define DESOLIN_TG_EXPRESSION_GRAPH_HPP

#include <algorithm>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <boost/function.hpp>
#include <vector>
#include <map>
#include <TaskGraph>
#include <desolin/tg/Desolin_tg_fwd.hpp>

namespace desolin_internal
{

template<typename T_element>
class TGExpressionGraph
{
private:
  TGExpressionGraph(const TGExpressionGraph&);
  TGExpressionGraph& operator=(const TGExpressionGraph&);
  
  boost::ptr_vector< TGExpressionNode<T_element> >  exprVector;
  tg::tuTaskGraph taskGraphObject;
  NameGenerator generator;

  mutable bool isHashCached;
  mutable std::size_t cachedHash;
  
  void generateCode()
  {
    TGCodeGenerator<T_element> codeGenerator(*this);
    accept(codeGenerator);
  }

  static void applyVisitor(TGExpressionNode<T_element>& node, TGExpressionNodeVisitor<T_element>& visitor)
  {
    node.accept(visitor);
  }

public:
  TGExpressionGraph() : isHashCached(false)
  {
  }
  
  inline void add(TGExpressionNode<T_element>* value)
  {
    assert(!isHashCached);
    exprVector.push_back(value);
  }

  inline NameGenerator& getNameGenerator()
  {
    return generator;
  }

  const inline int size() const
  {
    return exprVector.size();
  }

  void generateCode(boost::function<void ()>& generateNodes)
  {
    tu_taskgraph(taskGraphObject)
    {
      generateNodes();
      generateCode(); 
    };
  }

  void compile()
  {
    // Twice for good measure ;)
    taskGraphObject.applyOptimisation("fusion");
    taskGraphObject.applyOptimisation("fusion");
    taskGraphObject.compile(tg::GCC, false);	
  }

  inline void print() const
  {
    const_cast<tg::tuTaskGraph&>(taskGraphObject).print();
  }

  void execute(const ParameterHolder& parameterHolder)
  {
    parameterHolder.setParameters(taskGraphObject);
    taskGraphObject.execute();
  }

  void accept(TGExpressionNodeVisitor<T_element>& visitor)
  {
    std::for_each(exprVector.begin(), exprVector.end(), boost::bind(applyVisitor, _1, boost::ref(visitor)));
  }

  bool operator==(const TGExpressionGraph& right) const
  {
    if (exprVector.size() != right.exprVector.size())
    {
      return false;
    }
    else
    {<commit_msg>Use the Intel C Compiler.<commit_after>#ifndef DESOLIN_TG_EXPRESSION_GRAPH_HPP
#define DESOLIN_TG_EXPRESSION_GRAPH_HPP

#include <algorithm>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <boost/function.hpp>
#include <vector>
#include <map>
#include <TaskGraph>
#include <desolin/tg/Desolin_tg_fwd.hpp>

namespace desolin_internal
{

template<typename T_element>
class TGExpressionGraph
{
private:
  TGExpressionGraph(const TGExpressionGraph&);
  TGExpressionGraph& operator=(const TGExpressionGraph&);
  
  boost::ptr_vector< TGExpressionNode<T_element> >  exprVector;
  tg::tuTaskGraph taskGraphObject;
  NameGenerator generator;

  mutable bool isHashCached;
  mutable std::size_t cachedHash;
  
  void generateCode()
  {
    TGCodeGenerator<T_element> codeGenerator(*this);
    accept(codeGenerator);
  }

  static void applyVisitor(TGExpressionNode<T_element>& node, TGExpressionNodeVisitor<T_element>& visitor)
  {
    node.accept(visitor);
  }

public:
  TGExpressionGraph() : isHashCached(false)
  {
  }
  
  inline void add(TGExpressionNode<T_element>* value)
  {
    assert(!isHashCached);
    exprVector.push_back(value);
  }

  inline NameGenerator& getNameGenerator()
  {
    return generator;
  }

  const inline int size() const
  {
    return exprVector.size();
  }

  void generateCode(boost::function<void ()>& generateNodes)
  {
    tu_taskgraph(taskGraphObject)
    {
      generateNodes();
      generateCode(); 
    };
  }

  void compile()
  {
    // Twice for good measure ;)
    taskGraphObject.applyOptimisation("fusion");
    taskGraphObject.applyOptimisation("fusion");
    taskGraphObject.compile(tg::ICC, false);	
  }

  inline void print() const
  {
    const_cast<tg::tuTaskGraph&>(taskGraphObject).print();
  }

  void execute(const ParameterHolder& parameterHolder)
  {
    parameterHolder.setParameters(taskGraphObject);
    taskGraphObject.execute();
  }

  void accept(TGExpressionNodeVisitor<T_element>& visitor)
  {
    std::for_each(exprVector.begin(), exprVector.end(), boost::bind(applyVisitor, _1, boost::ref(visitor)));
  }

  bool operator==(const TGExpressionGraph& right) const
  {
    if (exprVector.size() != right.exprVector.size())
    {
      return false;
    }
    else
    {
{'fraction_non_alphanumeric': 0.11717038983793254, 'fraction_numerical': 0.0004380201489268506, 'mean_word_length': 4.54247572815534, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2750071', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1459, 'n_words': 256}