26 template <
class data_type,
int ytype>
28 const MPI_Comm *comm,
const Attribute *mults) {
31 "Unsupported attribute type");
33 (std::string(
"Incompatible data types between ")+
38 (std::string(
"Numbers of components do not match between ")+
41 std::vector<const Pane*> xpanes, zpanes, mpanes;
42 std::vector<Pane*> ypanes;
48 (std::string(
"Numbers of panes do not match between ")+
51 std::vector<const Pane*>::const_iterator zit, zend, xit;
58 yval =
reinterpret_cast<data_type *
>( yout);
67 (std::string(
"Numbers of panes do not match between ")+
73 (std::string(
"Numbers of items do not match between ")+
75 yval =
reinterpret_cast<data_type *
>( y->
pointer());
84 (std::string(
"Numbers of components do not match between ")+
88 const Pane ** mit=NULL;
93 (std::string(
"Multiplier ")+mults->
fullname()+
94 "must be integer scalars.").c_str());
98 (std::string(
"Numbers of panes do not match between ")+
106 *yval = data_type(0);
110 for (
int i=0;
i<ynum_dims; ++
i) yval[
i] = data_type(0);
114 for( zit=zpanes.begin(), zend=zpanes.end(), xit=xpanes.begin();
115 zit!=zend; ++zit, ++xit, yit+=( ytype!=
BLAS_VOID && yit)) {
118 int zstrd=get_stride<BLAS_VEC2D>(pz);
119 const bool zstg = num_dims!=zstrd;
122 int xstrd = get_stride<BLAS_VEC2D>(px);
124 (std::string(
"Numbers of items do not match between ")+
126 " on pane "+
to_str((*zit)->id())).c_str());
128 const bool xstg = num_dims!=xstrd;
133 py = (*yit)->attribute(y->
id());
137 (std::string(
"Numbers of items do not match between ")+
139 " on pane "+
to_str((*zit)->id())).c_str());
141 yval =
reinterpret_cast<data_type *
>( py->
pointer());
143 if ( py->
stride()==ynum_comp) {
144 for (
int i=0,
ni=ynum_comp*ylen;
i<
ni; ++
i) yval[
i] = data_type(0);
148 for (
int i=0;
i<ynum_comp; ++
i) {
149 Attribute *py_i = ynum_comp>1?(*yit)->attribute( y->
id()+
i+1):py;
150 data_type *yv_i =
reinterpret_cast<data_type*
>(py_i->
pointer());
151 const int strd=get_stride<BLAS_VEC2D>(py_i);
153 for (
int j=0,
nj=ylen*strd;
j<
nj;
j+=strd) yv_i[
j] = data_type(0);
157 int ystrd = get_stride<ytype>(py);
158 const bool ystg = py && (ynum_dims!=num_dims || ynum_dims!=ystrd);
161 if ( mults != NULL) {
162 const Attribute *pm = (*mit)->attribute(mults->
id());
164 (std::string(
"Numbers of items do not match between ")+
166 " on pane "+
to_str((*zit)->id())).c_str());
168 mval =
reinterpret_cast<const int*
>( pm->
pointer());
173 if ( !xstg && !zstg && !ystg && mval == NULL) {
174 const data_type *xval = (
const data_type *)px->
pointer();
175 const data_type *zval = (
const data_type *)pz->
pointer();
178 for(
Size i = 0,
s = length*num_dims;
i<
s; ++
i, ++xval, ++zval)
179 getref<data_type,ytype,0>(yval,
i,0,1) += *xval* *zval;
183 for(
int i = 0;
i < num_dims; ++
i) {
184 const Attribute *pz_i = num_dims==1?pz:(*zit)->attribute(z->
id()+
i+1);
185 const data_type *zval = (
const data_type *)pz_i->
pointer();
186 zstrd=get_stride<BLAS_VEC2D>(pz_i);
188 const Attribute *px_i = num_dims==1?px:(*xit)->attribute(x->
id()+
i+1);
189 const data_type *xval = (
const data_type *)px_i->
pointer();
190 xstrd=get_stride<BLAS_VEC2D>(px_i);
193 Attribute *py_i=ynum_dims==1?py:(*yit)->attribute(y->
id()+
i+1);
194 yval =
reinterpret_cast<data_type *
>( py_i->
pointer());
195 ystrd = get_stride<ytype>( py_i);
200 for(
int j=0;
j<
length; ++
j, xval+=xstrd,zval+=zstrd)
201 getref<data_type,ytype,1>( yval,
j,
i,ystrd) += *xval* *zval / mval[
j];
204 for(
int j=0;
j<
length; ++
j, xval+=xstrd,zval+=zstrd)
205 getref<data_type,ytype,1>( yval,
j,
i,ystrd) += *xval* *zval;
212 int n = (ytype ==
BLAS_VEC) ? num_dims : 1;
217 MPI_Allreduce( &t, yval, n, MPI_INT,
MPI_SUM, *comm);
220 MPI_Allreduce( &t, yval, n, MPI_DOUBLE,
MPI_SUM, *comm);
227 const MPI_Comm *comm,
const Attribute *mults) {
234 calcDot<int,BLAS_SCALAR>(
z,
x,
y, comm, mults);
236 calcDot<int,BLAS_VEC>(
z,
x,
y, comm, mults);
240 calcDot<int,BLAS_SCNE>(
z,
x,
y, comm, mults);
242 calcDot<int,BLAS_VEC2D>(
z,
x,
y, comm, mults);
247 (std::string(
"Unsupported data type in ")+
251 calcDot<double,BLAS_SCALAR>(
z,
x,
y, comm, mults);
253 calcDot<double,BLAS_VEC>(
z,
x,
y, comm, mults);
257 calcDot<double,BLAS_SCNE>(
z,
x,
y, comm, mults);
259 calcDot<double,BLAS_VEC2D>(
z,
x,
y, comm, mults);
265 const MPI_Comm *comm,
const Attribute *mults) {
269 calcDot<int,BLAS_VOID>(
z,
x,
y, comm, mults);
272 (std::string(
"Unsupported data type in ")+
273 x->fullname()).c_str());
274 calcDot<double,BLAS_VOID>(
z,
x,
y, comm, mults);
281 {
dot_MPI( x, y, z, NULL, mults); }
290 {
dot_MPI( x, x, y, NULL, mults); }
299 const MPI_Comm *comm,
const Attribute*mults)
300 {
dot_MPI ( x, x, y, comm, mults); }
304 const MPI_Comm *comm,
const Attribute *mults)
int COM_Type
Indices for derived data types.
A Pane object contains a mesh, pane attribute, and field variables.
static void calcDot(void *zout, const Attribute *x, const Attribute *y, const MPI_Comm *comm=NULL, const Attribute *mults=NULL)
Performs the operation: z = <x, y>
static void nrm2_scalar(const Attribute *x, void *y, const Attribute *mults=NULL)
Wrapper for 2-norm with y as a scalar pointer.
An Attribute object is a data member of a window.
void int int REAL REAL * y
static void nrm2_MPI(const Attribute *x, Attribute *y, const MPI_Comm *comm=NULL, const Attribute *mults=NULL)
Wrapper for 2-norm with MPI.
#define COM_assertion_msg(EX, msg)
bool is_windowed() const
Checks whether the attribute is associated with the window.
static void dot_scalar_MPI(const Attribute *x, const Attribute *y, void *z, const MPI_Comm *comm=NULL, const Attribute *mults=NULL)
Wrapper for 2-norm with z as a scalar pointer.
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.
double length(Vector3D *const v, int n)
const void * pointer() const
Obtain a constant pointer to the physical address.
static void dot_scalar(const Attribute *x, const Attribute *y, void *z, const Attribute *mults=NULL)
Wrapper for 2-norm with z as a scalar pointer.
void int int int REAL REAL REAL * z
int COM_compatible_types(COM_Type type1, COM_Type type2)
int stride() const
Obtain the stride of the attribute in base datatype.
Definition for Rocblas API.
static std::string to_str(int i)
static void nrm2_scalar_MPI(const Attribute *x, void *y, const MPI_Comm *comm, const Attribute *mults=NULL)
Wrapper for 2-norm with y as a scalar pointer with MPI.
void int int REAL REAL REAL *z blockDim dim * ni
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 nrm2(const Attribute *x, Attribute *y, const Attribute *mults=NULL)
Wrapper for 2-norm.
static void dot(const Attribute *x, const Attribute *y, Attribute *z, const Attribute *mults=NULL)
Wrapper for dot product.
void panes(std::vector< int > &ps, int rank=-2)
Obtain all the local panes of the window.
static void dot_MPI(const Attribute *x, const Attribute *y, Attribute *z, const MPI_Comm *comm=NULL, const Attribute *mults=NULL)
Wrapper for dot product.
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 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...
int size_of_components() const
Obtain the number of components in the attribute.