16 #include <Teuchos_DefaultComm.hpp>
17 #include <Teuchos_RCP.hpp>
18 #include <Teuchos_CommHelpers.hpp>
29 bool strideOne =
false;
31 if (valueStrides == NULL) strideOne =
true;
44 for (
int i=0; !fail && i < len; i++)
45 if (!fail && idList[i] != ids[i])
48 for (
int v=0; !fail && v < mvdim; v++){
50 int correctStride = (strideOne ? 1 : valueStrides[v]);
55 if (!fail && stride != correctStride)
58 for (
int i=0; !fail && i < len; i++){
65 for (
int w=0; !fail && w < wdim; w++){
71 if (!fail && stride != weightStrides[w])
74 for (
int i=0; !fail && i < len; i++){
75 if (wgts[stride*i] != weights[w][weightStrides[w]*i])
84 int main(
int narg,
char *arg[])
86 Tpetra::ScopeGuard tscope(&narg, &arg);
87 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
89 int rank = comm->getRank();
90 int nprocs = comm->getSize();
98 zgno_t myFirstId = rank * numLocalIds;
102 int *weightStrides =
new int [wdim];
108 int *valueStrides =
new int [mvdim];
111 for (
zlno_t i=0; i < numLocalIds; i++){
112 myIds[i] = myFirstId+i;
114 for (
int w=0; w < wdim; w++)
115 weights[w*numLocalIds + i] = w + 1 + nprocs - rank;
117 v_values[i] = numLocalIds-i;
119 for (
int v=0; v < mvdim; v++)
120 mv_values[i*mvdim + v] = (v+1) * (nprocs-rank) / (i+1);
123 for (
int w=0; w < wdim; w++){
124 weightStrides[w] = 1;
125 weightPtrs[w] = weights + numLocalIds*w;
128 for (
int v=0; v < mvdim; v++){
129 valueStrides[v] = mvdim;
130 valuePtrs[v] = mv_values + v;
138 std::vector<const zscalar_t *> weightValues;
139 std::vector<int> strides;
145 catch (std::exception &e){
152 myIds, 1, valuePtrs, NULL, 0, NULL, NULL);
162 std::vector<const zscalar_t *> weightValues;
163 std::vector<int> strides;
165 weightValues.push_back(weightPtrs[0]);
166 weightValues.push_back(weightPtrs[1]);
167 strides.push_back(1);
168 strides.push_back(1);
172 v_values, 1,
true, weightPtrs[0], 1);
174 catch (std::exception &e){
181 myIds, 1, valuePtrs, NULL, 1, weightPtrs, weightStrides);
191 std::vector<const zscalar_t *> weightValues, values;
192 std::vector<int> wstrides, vstrides;
194 for (
int dim=0; dim < mvdim; dim++){
195 values.push_back(valuePtrs[dim]);
196 vstrides.push_back(mvdim);
202 numLocalIds, myIds, values, vstrides, weightValues, wstrides);
204 catch (std::exception &e){
211 myIds, mvdim, valuePtrs, valueStrides, 0, NULL, NULL);
221 std::vector<const zscalar_t *> weightValues, values;
222 std::vector<int> wstrides, vstrides;
224 for (
int dim=0; dim < wdim; dim++){
225 weightValues.push_back(weightPtrs[dim]);
226 wstrides.push_back(1);
229 for (
int dim=0; dim < mvdim; dim++){
230 values.push_back(valuePtrs[dim]);
231 vstrides.push_back(mvdim);
236 numLocalIds, myIds, values, vstrides, weightValues, wstrides);
239 catch (std::exception &e){
246 myIds, mvdim, valuePtrs, valueStrides,
247 wdim, weightPtrs, weightStrides);
255 std::cout <<
"PASS" << std::endl;
259 delete [] weightStrides;
260 delete [] weightPtrs;
263 delete [] valueStrides;
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > userTypes_t
size_t getLocalNumIDs() const
Returns the number of objects on this process.
int main(int narg, char **arg)
common code used by tests
int getNumEntriesPerID() const
Return the number of vectors.
void getWeightsView(const scalar_t *&weights, int &stride, int idx) const
Provide pointer to a weight array with stride.
BasicVectorAdapter represents a vector (plus optional weights) supplied by the user as pointers to st...
Tpetra::Map::local_ordinal_type zlno_t
static const std::string fail
#define TEST_FAIL_AND_RETURN_VALUE(comm, ok, s, rc)
void getIDsView(const gno_t *&ids) const
Provide a pointer to this process' identifiers.
int getNumWeightsPerID() const
Returns the number of weights per object. Number of weights per object should be zero or greater...
void getEntriesView(const scalar_t *&entries, int &stride, int idx=0) const
Provide a pointer to the elements of the specified vector.
Defines the BasicVectorAdapter class.
Tpetra::Map::global_ordinal_type zgno_t