Templated interfaces for generalized vector reduction/transformation operators in C++.


Classes

class  RTOpPack::ReductTarget
 Abstract base class for all reduction objects. More...
class  RTOpPack::RTOpT< Scalar >
 Templated interface to vector reduction/transformation operators {abstract}. More...

public types

typedef Teuchos::PrimitiveTypeTraits<
Scalar >::primitiveType 
RTOpPack::RTOpT::primitive_value_type
 

Reduction object functions

virtual void RTOpPack::RTOpT::get_reduct_type_num_entries (int *num_values, int *num_indexes, int *num_chars) const
 Get the number of entries of each basic data type in the externalized state for a reduction object for this operator.
virtual Teuchos::RCP< ReductTarget > RTOpPack::RTOpT::reduct_obj_create () const
 Creates a new reduction target object initialized and ready to be used in a reduction.
virtual void RTOpPack::RTOpT::reduce_reduct_objs (const ReductTarget &in_reduct_obj, ReductTarget *inout_reduct_obj) const
 Reduce intermediate reduction target objects.
virtual void RTOpPack::RTOpT::reduct_obj_reinit (ReductTarget *reduct_obj) const
 Reinitialize an already created reduction object.
virtual void RTOpPack::RTOpT::extract_reduct_obj_state (const ReductTarget &reduct_obj, int num_values, primitive_value_type value_data[], int num_indexes, index_type index_data[], int num_chars, char_type char_data[]) const
 Extract the state of an already created reduction object.
virtual void RTOpPack::RTOpT::load_reduct_obj_state (int num_values, const primitive_value_type value_data[], int num_indexes, const index_type index_data[], int num_chars, const char_type char_data[], ReductTarget *reduct_obj) const
 Load the state of an already created reduction object given arrays of primitive objects.

Operator functions

virtual const char * RTOpPack::RTOpT::op_name () const
 Return the name (as a null-terminated C-style string) of the operator.
virtual RTOpT< Scalar > & RTOpPack::RTOpT::operator= (const RTOpT< Scalar > &op)
 Copy the state of another operator object into this one.
virtual void RTOpPack::RTOpT::get_op_type_num_entries (int *num_values, int *num_indexes, int *num_chars) const
 Return the number of entries of each type of basic data type in the externalized state for the operator object.
virtual void RTOpPack::RTOpT::extract_op_state (int num_values, primitive_value_type value_data[], int num_indexes, index_type index_data[], int num_chars, char_type char_data[]) const
 Extract the state of the object in a portable format.
virtual void RTOpPack::RTOpT::load_op_state (int num_values, const primitive_value_type value_data[], int num_indexes, const index_type index_data[], int num_chars, const char_type char_data[])
 Load the state of the object from a portable format.
virtual bool RTOpPack::RTOpT::coord_invariant () const
 Returns true if this operator is coordinate invariant.
virtual void RTOpPack::RTOpT::apply_op (const int num_vecs, const ConstSubVectorView< Scalar > sub_vecs[], const int num_targ_vecs, const SubVectorView< Scalar > targ_sub_vecs[], ReductTarget *reduct_obj) const =0
 Apply the reduction/transformation operator to a set of sub-vectors.

Functions

 RTOpPack::RTOpT::RTOpT (const std::string &op_name_base)
 Constructor that creates an operator name appended with the type.

Variables

std::string RTOpPack::RTOpT::op_name_

Typedef Documentation

template<class Scalar>
typedef Teuchos::PrimitiveTypeTraits<Scalar>::primitiveType RTOpPack::RTOpT< Scalar >::primitive_value_type [inherited]

Reimplemented in RTOpPack::ROpGetSubVector< Scalar >, RTOpPack::TOpSetSubVector< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar, ReductScalar >, RTOpPack::ROpScalarIndexReductionBase< Scalar >, RTOpPack::ROpIndexReductionBase< Scalar >, RTOpPack::ROpScalarTransformationBase< Scalar >, RTOpPack::ROpScalarScalarTransformationBase< Scalar >, RTOpPack::RTOpBoolReduceAndTransform< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar >, and RTOpPack::ROpScalarReductionBase< Scalar, Teuchos::ScalarTraits< Scalar >::magnitudeType >.

Definition at line 165 of file RTOpPack_RTOpTDecl.hpp.


Function Documentation

template<class Scalar>
RTOpPack::RTOpT< Scalar >::RTOpT ( const std::string &  op_name_base  )  [inherited]

Constructor that creates an operator name appended with the type.

Definition at line 41 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
void RTOpPack::RTOpT< Scalar >::get_reduct_type_num_entries ( int *  num_values,
int *  num_indexes,
int *  num_chars 
) const [virtual, inherited]

Get the number of entries of each basic data type in the externalized state for a reduction object for this operator.

Note that a specific reduction object is not passed in as an argument. This is because the structure of a reduction object is completely determined by its associated operator object and this structure can not change as a result of a reduction operation (this is needed to simplify global communication code when used * with MPI).

The default implementation returns zeros for *num_values, *num_indexes and *num_chars (i.e. by default there is no reduction operation performed).

Reimplemented in RTOpPack::ROpGetSubVector< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar, ReductScalar >, RTOpPack::ROpScalarIndexReductionBase< Scalar >, RTOpPack::ROpIndexReductionBase< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar >, and RTOpPack::ROpScalarReductionBase< Scalar, Teuchos::ScalarTraits< Scalar >::magnitudeType >.

Definition at line 48 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
Teuchos::RCP< ReductTarget > RTOpPack::RTOpT< Scalar >::reduct_obj_create (  )  const [virtual, inherited]

Creates a new reduction target object initialized and ready to be used in a reduction.

To delete this object simply let the returned RCP<> object go out of scope.

The default implementation returns return.get()==NULL (i.e. by default there is no reduction operation performed).

Reimplemented in RTOpPack::ROpGetSubVector< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar, ReductScalar >, RTOpPack::ROpScalarIndexReductionBase< Scalar >, RTOpPack::ROpIndexReductionBase< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar >, and RTOpPack::ROpScalarReductionBase< Scalar, Teuchos::ScalarTraits< Scalar >::magnitudeType >.

Definition at line 66 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
void RTOpPack::RTOpT< Scalar >::reduce_reduct_objs ( const ReductTarget in_reduct_obj,
ReductTarget inout_reduct_obj 
) const [virtual, inherited]

Reduce intermediate reduction target objects.

The default implementation does not do anything (i.e. by default there is no reduction operation performed).

Reimplemented in RTOpPack::ROpGetSubVector< Scalar >, RTOpPack::ROpMax< Scalar >, RTOpPack::ROpMaxIndex< Scalar >, RTOpPack::ROpMaxIndexLessThanBound< Scalar >, RTOpPack::ROpMin< Scalar >, RTOpPack::ROpMinIndex< Scalar >, RTOpPack::ROpMinIndexGreaterThanBound< Scalar >, RTOpPack::ROpNormInf< Scalar >, RTOpPack::SUNDIALS_VMinQuotient< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar, ReductScalar >, RTOpPack::ROpIndexReductionBase< Scalar >, RTOpPack::RTOpBoolReduceAndTransform< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar >, and RTOpPack::ROpScalarReductionBase< Scalar, Teuchos::ScalarTraits< Scalar >::magnitudeType >.

Definition at line 72 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
void RTOpPack::RTOpT< Scalar >::reduct_obj_reinit ( ReductTarget reduct_obj  )  const [virtual, inherited]

Reinitialize an already created reduction object.

The default implementation does nothing (i.e. by default there is no reduction operation performed).

Parameters:
reduct_obj [in/out] Reduction object is reinitialized on output.

Reimplemented in RTOpPack::ROpGetSubVector< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar, ReductScalar >, RTOpPack::ROpScalarIndexReductionBase< Scalar >, RTOpPack::ROpIndexReductionBase< Scalar >, RTOpPack::ROpScalarReductionBase< Scalar >, and RTOpPack::ROpScalarReductionBase< Scalar, Teuchos::ScalarTraits< Scalar >::magnitudeType >.

Definition at line 80 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
void RTOpPack::RTOpT< Scalar >::extract_reduct_obj_state ( const ReductTarget reduct_obj,
int  num_values,
primitive_value_type  value_data[],
int  num_indexes,
index_type  index_data[],
int  num_chars,
char_type  char_data[] 
) const [virtual, inherited]

Extract the state of an already created reduction object.

This method allows the state of a reduction target object to be externalized so that it can be passed over a heterogeneous network of computers.

The default implementation does nothing (i.e. by default there is no reduction operation performed).

Definition at line 86 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
void RTOpPack::RTOpT< Scalar >::load_reduct_obj_state ( int  num_values,
const primitive_value_type  value_data[],
int  num_indexes,
const index_type  index_data[],
int  num_chars,
const char_type  char_data[],
ReductTarget reduct_obj 
) const [virtual, inherited]

Load the state of an already created reduction object given arrays of primitive objects.

The default implementation does nothing.

Definition at line 100 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
const char * RTOpPack::RTOpT< Scalar >::op_name (  )  const [virtual, inherited]

Return the name (as a null-terminated C-style string) of the operator.

This name is used to differentiate an operator subclass from all other operator subclasses. This is an important property needed for a client/server or master/slave runtime configuration.

The default implementation uses the value created in the constructor RTOpT().

Reimplemented in RTOpPack::TOpUnaryFuncPtr< Scalar >.

Definition at line 116 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
RTOpT< Scalar > & RTOpPack::RTOpT< Scalar >::operator= ( const RTOpT< Scalar > &  op  )  [virtual, inherited]

Copy the state of another operator object into this one.

This default version uses op->ref extract_op_state() and this->load_op_state() to perform the copy. No override should be needed by subclasses (unless a slightly more efficient implementation is desired).

Definition at line 122 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
void RTOpPack::RTOpT< Scalar >::get_op_type_num_entries ( int *  num_values,
int *  num_indexes,
int *  num_chars 
) const [virtual, inherited]

Return the number of entries of each type of basic data type in the externalized state for the operator object.

The default implementation returns zeros for *num_values, *num_indexes and *num_chars (i.e. the default reduction/transformation operator has no state).

Reimplemented in RTOpPack::ROpGetSubVector< Scalar >, RTOpPack::TOpSetSubVector< Scalar >, RTOpPack::ROpScalarTransformationBase< Scalar >, and RTOpPack::ROpScalarScalarTransformationBase< Scalar >.

Definition at line 145 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
void RTOpPack::RTOpT< Scalar >::extract_op_state ( int  num_values,
primitive_value_type  value_data[],
int  num_indexes,
index_type  index_data[],
int  num_chars,
char_type  char_data[] 
) const [virtual, inherited]

Extract the state of the object in a portable format.

This method allows the state of a reduction/transformation operator to be externalized so that it can be passed over a heterogeneous network of computers.

The default implementation does nothing (i.e. the default reduction/transformation operator has no state).

Parameters:
num_values [in] Value returned from this->get_op_type_num_entries().
value_data [out] Array (size num_values) of floating point data.
num_indexes [in] Value returned from this->get_op_type_num_entries().
index_data [out] Array (size num_indexes) of integral data.
num_chars [in] Value returned from this->get_op_type_num_entries().
char_data [out] Array (size num_chars) of character data.

Definition at line 162 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
void RTOpPack::RTOpT< Scalar >::load_op_state ( int  num_values,
const primitive_value_type  value_data[],
int  num_indexes,
const index_type  index_data[],
int  num_chars,
const char_type  char_data[] 
) [virtual, inherited]

Load the state of the object from a portable format.

This method allows the state of the operator object to be set given an the externalized state as extracted using extract_op_state(...) called on a compatible operator object (possibly on a different heterogeneous computer).

The default implementation does nothing (i.e. the default reduction/transformation operator has no state).

Parameters:
num_values [in] Value returned from this->get_op_type_num_entries().
value_data [out] Array (size num_values) of floating point data.
num_indexes [in] Value returned from this->get_op_type_num_entries().
index_data [out] Array (size num_indexes) of integral data.
num_chars [in] Value returned from this->get_op_type_num_entries().
char_data [out] Array (size num_chars) of character data.

Definition at line 175 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
bool RTOpPack::RTOpT< Scalar >::coord_invariant (  )  const [virtual, inherited]

Returns true if this operator is coordinate invariant.

The default implementation returns true as most vector operators are coordinate invariant.

Reimplemented in RTOpPack::ROpGetSubVector< Scalar >, RTOpPack::ROpMaxIndex< Scalar >, RTOpPack::ROpMaxIndexLessThanBound< Scalar >, RTOpPack::ROpMinIndex< Scalar >, RTOpPack::ROpMinIndexGreaterThanBound< Scalar >, and RTOpPack::TOpSetSubVector< Scalar >.

Definition at line 188 of file RTOpPack_RTOpT.hpp.

template<class Scalar>
virtual void RTOpPack::RTOpT< Scalar >::apply_op ( const int  num_vecs,
const ConstSubVectorView< Scalar >  sub_vecs[],
const int  num_targ_vecs,
const SubVectorView< Scalar >  targ_sub_vecs[],
ReductTarget reduct_obj 
) const [pure virtual, inherited]

Apply the reduction/transformation operator to a set of sub-vectors.

op(sub_vecs[],targ_sub_vecs[]),reduct_obj) -> targ_sub_vecs[],reduct_obj.

This is the bread and butter of the whole design. Through this method, a vector implementation applies a reduction/transformation operator to a set of sub-vectors.

Parameters:
num_vecs [in] Number of non-mutable sub-vectors in sub_vec[].
sub_vecs [in] Array (length num_vecs) of non-mutable vectors to apply the operator over. The ordering of these sub-vectors sub_vecs[k], for k = 0...num_vecs-1, is significant to the this operator object. If num_vecs==0 then sub_vecs can be NULL.
num_targ_vecs [in] Number of mutable sub-vectors in targ_sub_vec[].
targ_sub_vecs [in/out] Array (length num_targ_vecs) of mutable vectors to apply the operator over and be mutated. The ordering of these sub-vectors targ_sub_vecs[k], for k = 0...num_targ_vecs-1, is significant to this operator object. If num_targ_vecs==0 then targ_sub_vecs can be NULL.
reduct_obj [in/out] This reduction object must have been created by a this->reduct_obj_create() call and it may have already passed through one or more other reduction operations (accumulating the reductions along the way). If this->get_reduct_type_num_entries() returns num_values==0, num_indexes==0 and num_chars==0, then reduct_obj should be set to NULL as no reduction will be performed.
Preconditions:

If reduct_obj != NULL then the reduction operation will be accumulated as:

     op(op(sub_vecs[],targ_sub_vecs[]),reduct_obj) -> reduct_obj
   

By allowing an in/out reduct_obj and an accumulation of the reduction, the maximum reuse of memory is achieved. If this->reduct_obj_create() or this->reduct_obj_reinit() (passing in reduct_obj) was called immediately before this function, then on return, reduct_obj will contain only the reduction from this function call.

If num_vecs is incompatible with the underlying operator object then InvalidNumVecs is thrown. If the sub-vectors are not compatible (i.e. global_offset and/or sub_dim not the same) then IncompatibleVecs is thrown.

Implemented in RTOpPack::ROpCountNanInf< Scalar >, RTOpPack::ROpDotProd< Scalar >, RTOpPack::ROpGetSubVector< Scalar >, RTOpPack::ROpMax< Scalar >, RTOpPack::ROpMaxIndex< Scalar >, RTOpPack::ROpMaxIndexLessThanBound< Scalar >, RTOpPack::ROpMin< Scalar >, RTOpPack::ROpMinIndex< Scalar >, RTOpPack::ROpMinIndexGreaterThanBound< Scalar >, RTOpPack::ROpNorm1< Scalar >, RTOpPack::ROpNorm2< Scalar >, RTOpPack::ROpNormInf< Scalar >, RTOpPack::ROpSum< Scalar >, RTOpPack::ROpWeightedNorm2< Scalar >, RTOpPack::SUNDIALS_VProd< Scalar >, RTOpPack::SUNDIALS_VDiv< Scalar >, RTOpPack::SUNDIALS_VScale< Scalar >, RTOpPack::SUNDIALS_VAddConst< Scalar >, RTOpPack::SUNDIALS_VWL2Norm< Scalar >, RTOpPack::SUNDIALS_VWrmsMaskNorm< Scalar >, RTOpPack::SUNDIALS_VConstrMask< Scalar >, RTOpPack::SUNDIALS_VMinQuotient< Scalar >, RTOpPack::SUNDIALS_VInvTest< Scalar >, RTOpPack::SUNDIALS_VCompare< Scalar >, RTOpPack::TOpAbs< Scalar >, RTOpPack::TOpAddScalar< Scalar >, RTOpPack::TOpAssignScalar< Scalar >, RTOpPack::TOpAssignVectors< Scalar >, RTOpPack::TOpAXPY< Scalar >, RTOpPack::TOpEleWiseDivide< Scalar >, RTOpPack::TOpEleWiseProd< Scalar >, RTOpPack::TOpEleWiseProdUpdate< Scalar >, RTOpPack::TOpLinearCombination< Scalar >, RTOpPack::TOpRandomize< Scalar >, RTOpPack::TOpReciprocal< Scalar >, RTOpPack::TOpScaleVector< Scalar >, RTOpPack::TOpSetSubVector< Scalar >, and RTOpPack::TOpUnaryFuncPtr< Scalar >.


Variable Documentation

template<class Scalar>
std::string RTOpPack::RTOpT< Scalar >::op_name_ [private, inherited]

Reimplemented in RTOpPack::TOpUnaryFuncPtr< Scalar >.

Definition at line 434 of file RTOpPack_RTOpTDecl.hpp.


Generated on Tue Oct 20 12:46:17 2009 for RTOp Package Browser (Single Doxygen Collection) by doxygen 1.4.7