16 #include <Teuchos_DefaultComm.hpp>
17 #include <Teuchos_RCP.hpp>
18 #include <Teuchos_CommHelpers.hpp>
19 #include <Teuchos_TestingHelpers.hpp>
27 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
37 auto kDeviceIdsHost = Kokkos::create_mirror_view(kDeviceIds);
38 Kokkos::deep_copy(kDeviceIdsHost, kDeviceIds);
42 TEUCHOS_TEST_EQUALITY(ids[i], kHostIds(i), std::cout, success);
43 TEUCHOS_TEST_EQUALITY(kHostIds(i), kDeviceIdsHost(i), std::cout, success);
52 auto kDeviceWgtsHost = Kokkos::create_mirror_view(kDeviceWgts);
53 Kokkos::deep_copy(kDeviceWgtsHost, kDeviceWgts);
55 for (
int w = 0; success && w < wdim; w++) {
58 Kokkos::View<zscalar_t **, typename znode_t::device_type> wkgts;
62 TEUCHOS_TEST_EQUALITY(wgts[stride * i], kHostWgts(i, w), std::cout,
64 TEUCHOS_TEST_EQUALITY(wgts[stride * i], kDeviceWgtsHost(i, w), std::cout,
75 auto kHostCoordsMV = Kokkos::create_mirror_view(kHostCoords);
76 Kokkos::deep_copy(kHostCoordsMV, kHostCoords);
78 auto kDeviceCoordsMV = Kokkos::create_mirror_view(kDeviceCoords);
79 Kokkos::deep_copy(kDeviceCoordsMV, kDeviceCoords);
80 for (
int v=0; v < mvdim; v++){
88 TEUCHOS_TEST_EQUALITY(coords[i*stride], kHostCoordsMV(i, v), std::cout, success);
89 TEUCHOS_TEST_EQUALITY(coords[i*stride], kDeviceCoordsMV(i, v), std::cout, success);
95 int main(
int narg,
char *arg[])
97 Tpetra::ScopeGuard tscope(&narg, &arg);
98 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
100 int rank = comm->getRank();
101 int nprocs = comm->getSize();
109 zgno_t myFirstId = rank * numLocalIds;
113 int *weightStrides =
new int [wdim];
119 int *valueStrides =
new int [mvdim];
122 for (
zlno_t i=0; i < numLocalIds; i++){
123 myIds[i] = myFirstId+i;
125 for (
int w=0; w < wdim; w++)
126 weights[w*numLocalIds + i] = w + 1 + nprocs - rank;
128 v_values[i] = numLocalIds-i;
130 for (
int v=0; v < mvdim; v++)
131 mv_values[i*mvdim + v] = (v+1) * (nprocs-rank) / (i+1);
134 for (
int w=0; w < wdim; w++){
135 weightStrides[w] = 1;
136 weightPtrs[w] = weights + numLocalIds*w;
139 for (
int v=0; v < mvdim; v++){
140 valueStrides[v] = mvdim;
141 valuePtrs[v] = mv_values + v;
149 std::vector<const zscalar_t *> weightValues;
150 std::vector<int> strides;
152 weightValues.push_back(weightPtrs[0]);
153 weightValues.push_back(weightPtrs[1]);
154 strides.push_back(1);
155 strides.push_back(1);
159 v_values, 1,
true, weightPtrs[0], 1);
161 catch (std::exception &e){
177 std::vector<const zscalar_t *> weightValues, values;
178 std::vector<int> wstrides, vstrides;
180 for (
int dim=0; dim < wdim; dim++){
181 weightValues.push_back(weightPtrs[dim]);
182 wstrides.push_back(1);
185 for (
int dim=0; dim < mvdim; dim++){
186 values.push_back(valuePtrs[dim]);
187 vstrides.push_back(mvdim);
192 numLocalIds, myIds, values, vstrides, weightValues, wstrides);
194 catch (std::exception &e){
207 std::cout <<
"PASS" << std::endl;
211 delete [] weightStrides;
212 delete [] weightPtrs;
215 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