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 >
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;
219 typedef typename Internal::tag_collection_base< Tag, Tuner >::callback_type
callback_type;
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 >
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;
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 >
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
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_ void get(const Tag &tag, Item &item) const
get an item
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
item_collection(context< Derived > &ctxt, const std::string &name, const Tuner &tnr)
constructor which registers collection with given context
void put(const Tag &tag, const Item &item)
make copies of the item and the tag and store them in the collection.
error_type wait()
wait until all the steps prescribed by this context have completed execution.
bool unsafe_get(const Tag &tag, Item &item) const
try to get an item and store it in given object (non-blocking)
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....
size_t size()
returns number of elements in collection
Internal::tag_collection_base< Tag, Tuner >::callback_type callback_type
void unsafe_reset()
removes all of the tag instances from the collection
void bcast_msg(serializer *ser) const
broadcast message (in serializer) to all (other) ranks/processes Receiving messages is done in recv_m...
virtual void serialize(serializer &)
(distCnC) overload this if default construction on remote processes is not enough.
graph(CnC::context< Ctxt > &ctxt, const std::string &name="")
A graph requires a context and a name for its initialization.
void flush_gets()
used with the preschedule tuner to finalize 'gets' in the pre-execution of a step
UserStep step_type
the type of the step as provided by the user
tag_collection(context< Derived > &ctxt, const std::string &name, const Tuner &tnr)
constructor which registers collection with given context
size_t size()
returns number of elements in collection
base_coll_type::callback_type callback_type
void unsafe_reset()
removes all of the item instances from the collection
Base class for defining and using CnC (sub-)graphs.
CnC context bringing together collections (for steps, items and tags).
virtual void recv_msg(serializer *)
Overwrite this if you need to exchange messages on distributed memory. Each graph must implement its ...
virtual ~context()
destructor
const_iterator begin() const
returns begin() as in STL containers
const_iterator end() const
returns end() as in STL containers
A step collection is logical set of step instances.
error_type prescribes(const step_collection< UserStep, STuner > &s, Arg &arg)
Declare the prescription relationship between the tag collection and a step collection.
const int CNC_Failure
Steps return CNC_Failure if execution failed.
void send_msg(serializer *ser, int rcver) const
send a message (in serializer) to given recipient Receiving messages is done in recv_msg callback.
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...
void set_max(size_t mx)
Declares the maxium tag value.
Handles serilialization of data-objects.
void produces(CnC::item_collection< DataTag, Item, ITuner > &)
Declare this step-collecation as producer for given item-collection.
bool empty()
returns true if size()==0, false otherwise
void enter_quiescence() const
Tell the runtime that the graph reached (temporary) quiescence.
void on_put(callback_type *cb)
An item collection is a mapping from tags to items.
bool empty()
returns true if size()==0, false otherwise
virtual void unsafe_reset(bool dist)
const int CNC_Success
Steps return CNC_Success if execution was successful.
serializer * new_serializer() const
Get a serializer Caller must pass it to send/bcast or delete it. Receiving messages is done in recv_m...
const_iterator begin() const
returns begin() as in STL containers
const_iterator end() const
returns end() as in STL containers
virtual void cleanup()
cleanup, e.g. collect garbage
void leave_quiescence() const
Tell the runtime that the graph leaves quiescence and goes back to activity. Must be called only with...
void put(const Tag &t)
prescribe the associated step. If we are preserving tags for this collection, make a copy of the tag ...
void consumes(CnC::item_collection< DataTag, Item, ITuner > &)
Declare this step-collecation as consumer of given item-collection.
context()
default constructor
void on_put(callback_type *cb)
void put_range(const typename Tuner::range_type &r)
prescribe an entire range of tags