51 #include <Teuchos_DefaultComm.hpp>
52 #include <Teuchos_RCP.hpp>
53 #include <Teuchos_CommHelpers.hpp>
54 #include <Teuchos_TestingHelpers.hpp>
62 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
72 auto kDeviceIdsHost = Kokkos::create_mirror_view(kDeviceIds);
73 Kokkos::deep_copy(kDeviceIdsHost, kDeviceIds);
77 TEUCHOS_TEST_EQUALITY(ids[i], kHostIds(i), std::cout, success);
78 TEUCHOS_TEST_EQUALITY(kHostIds(i), kDeviceIdsHost(i), std::cout, success);
87 auto kDeviceWgtsHost = Kokkos::create_mirror_view(kDeviceWgts);
88 Kokkos::deep_copy(kDeviceWgtsHost, kDeviceWgts);
90 for (
int w = 0; success && w < wdim; w++) {
93 Kokkos::View<zscalar_t **, typename znode_t::device_type> wkgts;
97 TEUCHOS_TEST_EQUALITY(wgts[stride * i], kHostWgts(i, w), std::cout,
99 TEUCHOS_TEST_EQUALITY(wgts[stride * i], kDeviceWgtsHost(i, w), std::cout,
110 auto kHostCoordsMV = Kokkos::create_mirror_view(kHostCoords);
111 Kokkos::deep_copy(kHostCoordsMV, kHostCoords);
113 auto kDeviceCoordsMV = Kokkos::create_mirror_view(kDeviceCoords);
114 Kokkos::deep_copy(kDeviceCoordsMV, kDeviceCoords);
115 for (
int v=0; v < mvdim; v++){
123 TEUCHOS_TEST_EQUALITY(coords[i*stride], kHostCoordsMV(i, v), std::cout, success);
124 TEUCHOS_TEST_EQUALITY(coords[i*stride], kDeviceCoordsMV(i, v), std::cout, success);
130 int main(
int narg,
char *arg[])
132 Tpetra::ScopeGuard tscope(&narg, &arg);
133 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
135 int rank = comm->getRank();
136 int nprocs = comm->getSize();
144 zgno_t myFirstId = rank * numLocalIds;
148 int *weightStrides =
new int [wdim];
154 int *valueStrides =
new int [mvdim];
157 for (
zlno_t i=0; i < numLocalIds; i++){
158 myIds[i] = myFirstId+i;
160 for (
int w=0; w < wdim; w++)
161 weights[w*numLocalIds + i] = w + 1 + nprocs - rank;
163 v_values[i] = numLocalIds-i;
165 for (
int v=0; v < mvdim; v++)
166 mv_values[i*mvdim + v] = (v+1) * (nprocs-rank) / (i+1);
169 for (
int w=0; w < wdim; w++){
170 weightStrides[w] = 1;
171 weightPtrs[w] = weights + numLocalIds*w;
174 for (
int v=0; v < mvdim; v++){
175 valueStrides[v] = mvdim;
176 valuePtrs[v] = mv_values + v;
184 std::vector<const zscalar_t *> weightValues;
185 std::vector<int> strides;
187 weightValues.push_back(weightPtrs[0]);
188 weightValues.push_back(weightPtrs[1]);
189 strides.push_back(1);
190 strides.push_back(1);
194 v_values, 1,
true, weightPtrs[0], 1);
196 catch (std::exception &e){
212 std::vector<const zscalar_t *> weightValues, values;
213 std::vector<int> wstrides, vstrides;
215 for (
int dim=0; dim < wdim; dim++){
216 weightValues.push_back(weightPtrs[dim]);
217 wstrides.push_back(1);
220 for (
int dim=0; dim < mvdim; dim++){
221 values.push_back(valuePtrs[dim]);
222 vstrides.push_back(mvdim);
227 numLocalIds, myIds, values, vstrides, weightValues, wstrides);
229 catch (std::exception &e){
242 std::cout <<
"PASS" << std::endl;
246 delete [] weightStrides;
247 delete [] weightPtrs;
250 delete [] valueStrides;
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > userTypes_t
size_t getLocalNumIDs() const
Returns the number of objects on this process.
void getIDsHostView(typename Base::ConstIdsHostView &ids) const override
void getCoordinatesView(const scalar_t *&elements, int &stride, int idx=0) const override
Kokkos::View< scalar_t **, Kokkos::LayoutLeft, device_t > CoordsDeviceView
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
int main(int narg, char **arg)
void getWeightsHostView(typename Base::WeightsHostView1D &hostWgts, int idx=0) const override
common code used by tests
void getIDsDeviceView(typename Base::ConstIdsDeviceView &ids) const override
Kokkos::View< const gno_t *, device_t > ConstIdsDeviceView
typename WeightsDeviceView::HostMirror WeightsHostView
typename CoordsDeviceView::HostMirror CoordsHostView
void getWeightsView(const scalar_t *&weights, int &stride, int idx) const
Provide pointer to a weight array with stride.
typename ConstIdsDeviceView::HostMirror ConstIdsHostView
void getCoordinatesHostView(typename AdapterWithCoords< User >::CoordsHostView &elements) const override
void getWeightsDeviceView(typename Base::WeightsDeviceView1D &deviceWgts, int idx=0) const override
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 testBasisVector(Zoltan2::BasicVectorAdapter< userTypes_t > *ia, int *valueStrides, int wdim, int mvdim)
Kokkos::View< scalar_t **, device_t > WeightsDeviceView
Defines the BasicVectorAdapter class.
Tpetra::Map::global_ordinal_type zgno_t
void getCoordinatesDeviceView(typename AdapterWithCoords< User >::CoordsDeviceView &elements) const override