30 template <
class T_src,
class T_trg>
113 template <
class FuncType,
int ytype>
115 typedef typename FuncType::argument_type argument_type;
116 typedef typename FuncType::result_type result_type;
120 std::vector<Pane*> zpanes;
121 std::vector<Pane*>::iterator zit, zend;
124 std::vector<Pane*> ypanes;
127 argument_type *yval=NULL;
130 yval =
reinterpret_cast<argument_type *
>( yin);
133 operand when processing "+z->
fullname()).c_str());
137 bool type_coercion = compare_types<argument_type,result_type>();
141 (std::string(
"Incompatible data types between ")+
147 (std::string(
"Numbers of panes do not match between ")+
153 std::cout <<
"Rocbals Error: The size-of-items of attribute "
157 attribute, then its number of items must be 1.");
160 yval =
reinterpret_cast<argument_type *
>( y->
pointer());
169 (std::string(
"Numbers of components do not match between ")+
174 (std::string(
"Wrong type of operand")+
176 int zs=get_stride<BLAS_VEC2D>(
z);
177 int ys=get_stride<ytype>(
y);
178 result_type *zval = (result_type *)z->
pointer();
182 (std::string(
"Caught NULL pointer in w-attribute ")+
185 if ( (length==1 || num_dims == zs) && ytype !=
BLAS_VEC) {
186 for (
Size i = 0,
s = num_dims*length;
i <
s; ++
i, ++zval)
187 opp( *zval, getref<argument_type,ytype,0>(yval,
i,0,1));
190 for(
int i = 0;
i < num_dims; ++
i) {
192 zval = (result_type *)z_i->
pointer();
193 zs = get_stride<BLAS_VEC2D>(z_i);
197 yval =
reinterpret_cast<argument_type *
>( y_i->
pointer());
198 ys = get_stride<ytype>( y_i);
202 opp( *zval, getref<argument_type,ytype,1>(yval,
j,i,ys));
209 for( zit=zpanes.begin(), zend=zpanes.end(); zit!=zend;
213 int zstrd=get_stride<BLAS_VEC2D>(pz);
214 const bool zstg = length>1 && num_dims!=zstrd;
217 int ystrd = get_stride<ytype>(py);
218 const bool ystg = py && (ynum_dims!=num_dims || ynum_dims!=ystrd);
221 (std::string(
"Numbers of items do not match between ")+
223 " on pane "+
to_str((*zit)->id())).c_str());
226 if ( !zstg && !ystg && ytype !=
BLAS_VEC &&
228 result_type *zval =
reinterpret_cast<result_type *
>(pz->
pointer());
231 yval =
reinterpret_cast<argument_type *
>(py->
pointer());
234 (std::string(
"Caught NULL pointer in ")+
236 to_str( (*zit)->id())).c_str());
240 for(
int i = 0,
s = length*num_dims;
i <
s; ++
i, ++zval)
241 opp(*zval, getref<argument_type,ytype,0>(yval,
i,0,1));
245 for(
int i = 0;
i < num_dims; ++
i) {
246 Attribute *pz_i = num_dims==1?pz:(*zit)->attribute(z->
id()+
i+1);
247 result_type *zval = (result_type *)pz_i->
pointer();
248 zstrd=get_stride<BLAS_VEC2D>(pz_i);
251 Attribute *py_i=ynum_dims==1?py:(*yit)->attribute(y->
id()+
i+1);
252 yval =
reinterpret_cast<argument_type *
>( py_i->
pointer());
253 ystrd = get_stride<ytype>( py_i);
257 (std::string(
"Caught NULL pointer in ")+
259 to_str( (*zit)->id())).c_str());
262 for(
int j=0;
j <
length; ++
j, zval+=zstrd)
263 opp( *zval, getref<argument_type,ytype,1>(yval,
j,
i,ystrd));
275 "Aggregate attributes for swap must match.");
278 std::vector< Attribute*> x_attrs;
281 std::vector< Attribute*> y_attrs;
285 (std::string(
"Numbers of attributes do not match between ")+
288 for (
int i=x_attrs.size()-1;
i>=0; --
i)
289 swap( x_attrs[
i], y_attrs[i]);
308 (std::string(
"Unsupported data type in ")+
309 x->fullname()).c_str());
320 gen2arg<Op,BLAS_SCALAR>(
z,
const_cast<Attribute*
>(
x), Op());
322 gen2arg<Op,BLAS_VEC>(
z,
const_cast<Attribute*
>(
x), Op());
326 gen2arg<Op,BLAS_SCNE>(
z,
const_cast<Attribute*
>(
x), Op());
328 gen2arg<Op,BLAS_VEC2D>(
z,
const_cast<Attribute*
>(
x), Op());
337 "Aggregate attributes for copy must match.");
340 std::vector< const Attribute*> x_attrs;
343 std::vector< Attribute*> z_attrs;
348 (std::string(
"Numbers of attributes do not match between ")+
351 for (
int i=x_attrs.size()-1;
i>=0; --
i)
352 copy( x_attrs[
i], z_attrs[i]);
367 copy_helper<assn<int,double> >(
x,
z);
369 copy_helper<assn<int,int> >(
x,
z);
373 copy_helper<assn<char,int> >(
x,
z);
375 copy_helper<assn<char,double> >(
x,
z);
377 copy_helper<assn<char,char> >(
x,
z);
381 (std::string(
"Unsupported data type in ")+
383 copy_helper<assn<double,double> >(
x,
z);
392 "Aggregate attributes for copy must match.");
395 std::vector< const Attribute*> x_attrs;
398 std::vector< Attribute*> z_attrs;
403 (std::string(
"Numbers of attributes do not match between ")+
406 for (
int i=x_attrs.size()-1;
i>=0; --
i)
407 rand( x_attrs[
i], z_attrs[i]);
437 (std::string(
"Unsupported data type in ")+
489 (std::string(
"Unsupported data type in ")+
527 (std::string(
"Unsupported data type in ")+
565 (std::string(
"Unsupported data type in ")+
591 gen2arg<assn_int,BLAS_VOID>(
z,
const_cast<void*
>(
x), assn_int());
593 gen2arg<assn_dbl,BLAS_VOID>(
z,
const_cast<void*
>(
x), assn_dbl());
597 (std::string(
"Unsupported data type in ")+
598 z->fullname()).c_str());
599 gen2arg<assn_chr,BLAS_VOID>(
z,
const_cast<void*
>(
x), assn_chr());
611 (std::string(
"Unsupported data type in ")+
612 z->fullname()).c_str());
629 template <
class OP
int,
class OPdbl,
int OPMPI>
631 const MPI_Comm *comm,
int initialI,
double initialD) {
640 gen2arg<OPint,BLAS_SCALAR>(
const_cast<Attribute*
>(
x), z, OPint());
642 gen2arg<OPint,BLAS_VEC>(
const_cast<Attribute*
>(
x), z, OPint());
645 std::vector<int> t((
int*)z->
pointer(), ((
int*)z->
pointer())+zncomp);
646 MPI_Allreduce( &t[0], z->
pointer(), zncomp, MPI_INT,
652 gen2arg<OPint,BLAS_SCNE>(
const_cast<Attribute*
>(
x), z, OPint());
654 gen2arg<OPint,BLAS_VEC2D>(
const_cast<Attribute*
>(
x), z, OPint());
662 gen2arg<OPint,BLAS_SCALAR>(
const_cast<Attribute*
>(
x), z, OPint());
664 gen2arg<OPint,BLAS_VEC>(
const_cast<Attribute*
>(
x), z, OPint());
667 std::vector<char> t((
char*)z->
pointer(), ((
char*)z->
pointer())+zncomp);
668 MPI_Allreduce( &t[0], z->
pointer(), zncomp, MPI_CHAR,
674 gen2arg<OPint,BLAS_SCNE>(
const_cast<Attribute*
>(
x), z, OPint());
676 gen2arg<OPint,BLAS_VEC2D>(
const_cast<Attribute*
>(
x), z, OPint());
681 (std::string(
"Unsupported data type in ")+
687 gen2arg<OPdbl,BLAS_SCALAR>(
const_cast<Attribute*
>(
x), z, OPdbl());
689 gen2arg<OPdbl,BLAS_VEC>(
const_cast<Attribute*
>(
x), z, OPdbl());
692 std::vector<double> t( (
double*)z->
pointer(),
693 ((
double*)z->
pointer())+zncomp);
694 MPI_Allreduce( &t[0], z->
pointer(), zncomp, MPI_DOUBLE,
700 gen2arg<OPdbl,BLAS_SCNE>(
const_cast<Attribute*
>(
x), z, OPdbl());
702 gen2arg<OPdbl,BLAS_VEC2D>(
const_cast<Attribute*
>(
x), z, OPdbl());
710 -0x7FFFFFFF, -HUGE_VAL);
716 0x7FFFFFFF, HUGE_VAL);
725 template <
class OP
int,
class OPdbl,
int OPMPI>
727 const MPI_Comm *comm,
int initialI,
double initialD) {
732 gen2arg<OPint,BLAS_VOID>(
const_cast<Attribute*
>(
x), y, OPint());
736 MPI_Allreduce( &t, y, 1, MPI_INT,
convert2mpiop(OPMPI), *comm);
740 *(
char*)y = initialI;
741 gen2arg<OPint,BLAS_VOID>(
const_cast<Attribute*
>(
x), y, OPint());
745 MPI_Allreduce( &t, y, 1, MPI_CHAR,
convert2mpiop(OPMPI), *comm);
750 (std::string(
"Unsupported data type in ")+
752 *(
double*)y = initialD;
753 gen2arg<OPdbl,BLAS_VOID>(
const_cast<Attribute*
>(
x), y, OPdbl());
756 double t = *(
double*)y;
757 MPI_Allreduce( &t, y, 1, MPI_DOUBLE,
convert2mpiop(OPMPI), *comm);
764 const MPI_Comm* comm) {
766 -0x7FFFFFFF, -HUGE_VAL);
772 const MPI_Comm *comm) {
774 0x7FFFFFFF, HUGE_VAL);
779 const MPI_Comm *comm) {
static void reduce_MPI(const Attribute *x, Attribute *z, const MPI_Comm *comm, int, double)
void operator()(T &x, T &y)
int COM_Type
Indices for derived data types.
void operator()(T &x, const T &y)
A Pane object contains a mesh, pane attribute, and field variables.
bool compare_types< double, double >()
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
void operator()(T &x, const T &y)
void operator()(const T &x, T &y)
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_MAX
An Attribute object is a data member of a window.
void int int REAL REAL * y
#define COM_assertion_msg(EX, msg)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
bool is_windowed() const
Checks whether the attribute is associated with the window.
static void rand(const Attribute *a, Attribute *z)
Generate a random number between 0 and $a$ for each entry in z.
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_MIN
void operator()(const T &x, T &y)
static void max_scalar_MPI(const Attribute *x, void *y, const MPI_Comm *comm=NULL)
Operation wrapper for max (y is a scalar pointer).
void operator()(double &z, const double &a)
bool compare_types< char, char >()
const std::string & name() const
Obtain the window's name.
const Window * window() const
Obtain a constant pointer to the parent window of the attribute.
void operator()(T &z, const T &a)
void attributes(std::vector< Attribute * > &as)
Obtain all the attributes of the pane.
double length(Vector3D *const v, int n)
static void min_MPI(const Attribute *x, Attribute *y, const MPI_Comm *comm=NULL)
Wrapper for min.
static void max_MPI(const Attribute *x, Attribute *y, const MPI_Comm *comm=NULL)
Wrapper for max.
static void acos(const Attribute *x, Attribute *y)
Wrapper for acos (y=acos(x)).
const void * pointer() const
Obtain a constant pointer to the physical address.
void int int int REAL REAL REAL * z
bool compare_types< int, int >()
int COM_compatible_types(COM_Type type1, COM_Type type2)
static void min_scalar_MPI(const Attribute *x, void *y, const MPI_Comm *comm=NULL)
Operation wrapper for min (y is a scalar pointer).
void operator()(T_trg &x, const T_src &y)
static void sum_scalar_MPI(const Attribute *x, void *y, const MPI_Comm *comm=NULL)
Operation wrapper for sum (y is a scalar pointer).
void operator()(const T &x, T &y)
static void sum_MPI(const Attribute *x, Attribute *y, const MPI_Comm *comm=NULL)
Wrapper for sum.
static void reduce_scalar_MPI(const Attribute *x, void *y, const MPI_Comm *comm, int, double)
Definition for Rocblas API.
static void neg(const Attribute *x, Attribute *y)
Wrapper for neg (y=-x).
static std::string to_str(int i)
const Pane * pane() const
Obtain a constant pointer to the owner pane of the attribute.
static void copy_helper(const Attribute *x, Attribute *z)
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
static void gen2arg(Attribute *z, void *yin, FuncType opp)
Performs the operation opp(x, y)
static void copy_scalar(const void *x, Attribute *y)
Operation wrapper for copy (x is a scalar pointer).
void operator()(T &x, const T &y)
static void rand_scalar(const void *a, Attribute *z)
Generate a random number between 0 and $a$ for each entry in z.
static void swap(Attribute *x, Attribute *y)
Wrapper for swap.
static void copy(const Attribute *x, Attribute *y)
Wrapper for copy.
double rand()
Return a random variable between [0,1] with respect to an uniform distribution.
CImg< _cimg_Tfloat > acos(const CImg< T > &instance)
COM_Type data_type() const
Obtain the data type of each component of the attribute.
int id() const
Obtain the id (or index) of the attribute.
static void sqrt(const Attribute *x, Attribute *y)
Wrapper for sqrt (y=sqrt(x)).
void panes(std::vector< int > &ps, int rank=-2)
Obtain all the local panes of the window.
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_SUM
int id() const
Get the ID of the pane.
int size_of_items() const
Obtain the number of items in the attribute.
std::string fullname() const
Obtain the full name of the attribute including window name suitable for printing out error messages...
MPI_Op convert2mpiop(int i)
int size_of_components() const
Obtain the number of components in the attribute.