34 #ifndef _CnC_H_ALREADY_INCLUDED_ 35 #define _CnC_H_ALREADY_INCLUDED_ 37 #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) 39 # pragma warning (push) 40 # pragma warning (disable: 4251 4275 4290) 43 #include <cnc/internal/tag_collection_base.h> 44 #include <cnc/internal/item_collection_base.h> 45 #include <cnc/internal/context_base.h> 46 #include <cnc/internal/no_range.h> 51 typedef int error_type;
69 template<
typename UserStep,
typename Tuner = step_tuner<> >
85 template<
typename Derived >
87 template<
typename Derived >
89 template<
typename Derived >
91 template<
typename Derived >
93 template<
typename Derived >
99 template<
typename DataTag,
typename Item,
typename ITuner >
103 template<
typename DataTag,
typename Item,
typename ITuner >
107 template<
typename ControlTag,
typename TTuner >
111 const step_type m_userStep;
112 const tuner_type & m_tuner;
113 Internal::distributable_context & m_context;
114 template<
class Tag,
class Step,
class Arg,
class TTuner,
class STuner >
friend class Internal::step_launcher;
130 template<
typename Tag,
typename Tuner = tag_tuner<> >
143 template<
class Derived >
145 template<
class Derived >
147 template<
class Derived >
169 template<
typename UserStep,
typename STuner,
typename Arg >
174 void put(
const Tag & t );
190 void put_range(
const typename Tuner::range_type & r );
191 void put_range(
const Internal::no_range & )
const;
199 const_iterator begin()
const;
204 const_iterator end()
const;
219 typedef typename Internal::tag_collection_base< Tag, Tuner >::callback_type
callback_type;
231 void on_put( callback_type * cb );
234 Internal::tag_collection_base< Tag, Tuner > m_tagCollection;
236 friend struct ::CnC::debug;
263 template<
typename Tag,
typename Item,
typename Tuner = hashmap_tuner >
266 typedef Internal::item_collection_base< Tag, Item, Tuner > base_coll_type;
274 class const_iterator;
282 template<
class Derived >
284 template<
class Derived >
286 template<
class Derived >
296 void set_max(
size_t mx );
301 void put(
const Tag & tag,
const Item & item );
307 void get(
const Tag & tag, Item & item )
const;
321 bool unsafe_get(
const Tag & tag, Item & item )
const;
326 const_iterator begin()
const;
331 const_iterator end()
const;
362 void on_put( callback_type * cb );
365 base_coll_type m_itemCollection;
366 friend struct ::CnC::debug;
367 friend class Internal::step_delayer;
368 friend class const_iterator;
429 class graph :
public Internal::distributable
442 template<
typename Ctxt >
454 void enter_quiescence()
const;
465 void leave_quiescence()
const;
468 virtual void cleanup();
472 virtual void unsafe_reset(
bool dist );
490 void send_msg(
serializer * ser,
int rcver )
const;
500 bool bcast_msg(
serializer *ser ,
const int * rcvers,
int nrecvrs )
const;
511 Internal::context_base & m_context;
516 template<
class T >
class creator;
517 template<
class Index,
class Functor,
class Tuner,
typename Increment >
class pfor_context;
552 template<
class Derived >
553 class context :
protected Internal::context_base
580 virtual void unsafe_reset(
bool );
582 virtual int factory_id();
583 template<
class Range,
class Coll >
584 void divide_and_put( Range & range,
int grain, Coll * coll, Internal::scheduler_i * sched );
585 friend struct ::CnC::debug;
586 friend class ::CnC::Internal::distributor;
587 friend class ::CnC::tuner_base;
588 friend class ::CnC::graph;
589 template<
typename Tag,
bool check_deps,
typename Hasher,
typename Equality >
friend class ::CnC::cancel_tuner;
590 template<
class T >
friend class ::CnC::Internal::creator;
591 template<
class Index,
class Functor,
class Tuner,
typename Increment >
friend class ::CnC::Internal::pfor_context;
592 template<
typename Tag,
typename Tuner >
friend class tag_collection;
593 template<
typename Step,
typename Tuner >
friend class step_collection;
594 template<
typename Tag,
typename Item,
typename Tuner >
friend class item_collection;
608 template<
class Index,
class Functor,
class Tuner,
typename Increment >
609 void parallel_for( Index first, Index last, Increment incr,
const Functor & f,
const Tuner & tuner );
610 template<
class Index,
class Functor,
typename Increment >
611 void parallel_for( Index first, Index last, Increment incr,
const Functor & f );
615 #include <cnc/internal/step_collection.h> 616 #include <cnc/internal/tag_collection.h> 617 #include <cnc/internal/item_collection.h> 618 #include <cnc/internal/graph.h> 619 #include <cnc/internal/context.h> 620 #include <cnc/internal/parallel_for.h> 621 #include <cnc/internal/hash_item_table.h> 622 #include <cnc/internal/vec_item_table.h> 624 #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) 625 # pragma warning (pop) 626 # pragma warning( disable : 4355 ) 627 #endif // warnings 4251 4275 4290 are back, 4355 is hidden 629 #endif // _CnC_H_ALREADY_INCLUDED_ Debugging interface providing tracing and timing capabilities.
step_collection(context< Derived > &ctxt, const std::string &name, const step_type &userStep, const tuner_type &tnr)
constructor which registers collection with given context
void parallel_for(Index first, Index last, Increment incr, const Functor &f, const Tuner &tuner)
Execute f( i ) for every i in {first <= i=first+step*x < last and 0 <= x}.
void controls(CnC::tag_collection< ControlTag, TTuner > &)
Declare this step-collection as controller of given tag-collection.
Tuner::tag_table_type::const_iterator const_iterator
const forward iterator as in STL
Tuner tuner_type
the type of the tuner as provided by the user
A tag collection is a set of tags of the same type. It is used to prescribe steps. By default, tags are not stored.
Internal::tag_collection_base< Tag, Tuner >::callback_type callback_type
virtual void serialize(serializer &)
(distCnC) overload this if default construction on remote processes is not enough.
UserStep step_type
the type of the step as provided by the user
base_coll_type::callback_type callback_type
Base class for defining and using CnC (sub-)graphs.
CnC context bringing together collections (for steps, items and tags).
A step collection is logical set of step instances.
const int CNC_Failure
Steps return CNC_Failure if execution failed.
Item data_type
the data/item type
virtual void flush()
Flush a potentially hidden graph. Usually is a nop. Our reduction uses this to finalize all pending r...
Handles serilialization of data-objects.
void produces(CnC::item_collection< DataTag, Item, ITuner > &)
Declare this step-collecation as producer for given item-collection.
An item collection is a mapping from tags to items.
const int CNC_Success
Steps return CNC_Success if execution was successful.
void consumes(CnC::item_collection< DataTag, Item, ITuner > &)
Declare this step-collecation as consumer of given item-collection.