50#ifndef _ZOLTAN2_ADAPTER_HPP_
51#define _ZOLTAN2_ADAPTER_HPP_
53#include <Kokkos_Core.hpp>
100template <
typename User>
127 Kokkos::View<const gno_t *, typename node_t::device_type> kokkosIds;
129 ids = kokkosIds.data();
137 typename node_t::device_type> &ids)
const {
141 const gno_t * ptr_ids;
144 typedef Kokkos::View<gno_t *, typename node_t::device_type> view_t;
147 auto host_ids = Kokkos::create_mirror_view(non_const_ids);
149 host_ids(i) = ptr_ids[i];
151 Kokkos::deep_copy(non_const_ids, host_ids);
164 virtual void getWeightsView(
const scalar_t *&wgt,
int &stride,
169 Kokkos::View<scalar_t **, typename node_t::device_type> kokkos_wgts_2d;
170 getWeightsKokkosView(kokkos_wgts_2d);
171 Kokkos::View<scalar_t *, typename node_t::device_type> kokkos_wgts;
172 wgt = Kokkos::subview(kokkos_wgts_2d, Kokkos::ALL, idx).data();
182 virtual void getWeightsKokkosView(Kokkos::View<
scalar_t **,
183 typename node_t::device_type> & wgt)
const {
187 wgt = Kokkos::View<scalar_t **, typename node_t::device_type>(
189 typename Kokkos::View<scalar_t **, typename node_t::device_type>::HostMirror
190 host_wgt = Kokkos::create_mirror_view(wgt);
194 getWeightsView(ptr_wgts, stride, j);
196 for(
size_t n = 0; n < this->
getLocalNumIDs() * stride; n += stride) {
197 host_wgt(i++,j) = ptr_wgts[n];
200 Kokkos::deep_copy(wgt, host_wgt);
235 template <
typename Adapter>
237 const PartitioningSolution<Adapter> &solution)
const {
249 const Teuchos::Comm<int> &comm)
const;
253template <
typename User>
263template <
typename User>
266template <
typename User,
typename UserCoord=User>
274template <
typename User>
276 const char *fileprefix,
277 const Teuchos::Comm<int> &comm
280 int np = comm.getSize();
281 int me = comm.getRank();
283 size_t nLocalIDs = this->getLocalNumIDs();
290 std::string filenamestr = fileprefix;
291 filenamestr = filenamestr +
".graph";
292 const char *filename = filenamestr.c_str();
295 Teuchos::reduceAll(comm, Teuchos::REDUCE_SUM, 1, &nLocalIDs, &nGlobalIDs);
297 int nWgts = this->getNumWeightsPerID();
299 for (
int p = 0; p < np; p++) {
308 fp.open(filename, std::ios::out);
311 fp << nGlobalIDs <<
" " << 0 <<
" "
312 << (nWgts ?
"010" :
"000") <<
" "
313 << (nWgts > 1 ? std::to_string(nWgts) :
" ") << std::endl;
317 fp.open(filename, std::ios::app);
324 int *strides =
new int[nWgts];
325 for (
int n = 0; n < nWgts; n++)
326 getWeightsView(wgts[n], strides[n], n);
329 for (
size_t i = 0; i < nLocalIDs; i++) {
330 for (
int n = 0; n < nWgts; n++)
331 fp << wgts[n][i*strides[n]] <<
" ";
348 std::string filenamestr = fileprefix;
349 filenamestr = filenamestr +
".assign";
350 const char *filename = filenamestr.c_str();
352 for (
int p = 0; p < np; p++) {
361 fp.open(filename, std::ios::out);
365 fp.open(filename, std::ios::app);
369 this->getPartsView(parts);
371 for (
size_t i = 0; i < nLocalIDs; i++) {
372 fp << (parts != NULL ? parts[i] : me) <<
"\n";
#define Z2_THROW_NOT_IMPLEMENTED
Defines the PartitioningSolution class.
Gathering definitions used in software development.
virtual VectorAdapter< UserCoord > * getCoordinateInput() const =0
virtual void setCoordinateInput(VectorAdapter< UserCoord > *coordData)=0
virtual void getCoordinatesKokkosView(Kokkos::View< typename BaseAdapter< User >::scalar_t **, Kokkos::LayoutLeft, typename BaseAdapter< User >::node_t::device_type > &elements) const =0
virtual void getCoordinatesView(const typename BaseAdapter< User >::scalar_t *&coords, int &stride, int coordDim) const =0
BaseAdapter defines methods required by all Adapters.
virtual ~BaseAdapterRoot()
virtual int getNumWeightsPerID() const
Returns the number of weights per object. Number of weights per object should be zero or greater....
virtual size_t getLocalNumIDs() const =0
Returns the number of objects on this process.
InputTraits< User >::node_t node_t
void getPartsView(const part_t *&inputPart) const
Provide pointer to a weight array with stride.
InputTraits< User >::offset_t offset_t
InputTraits< User >::part_t part_t
InputTraits< User >::scalar_t scalar_t
void generateWeightFileOnly(const char *fileprefix, const Teuchos::Comm< int > &comm) const
virtual void getIDsView(const gno_t *&ids) const
Provide a pointer to this process' identifiers.
InputTraits< User >::lno_t lno_t
virtual ~BaseAdapter()
Destructor.
virtual void getIDsKokkosView(Kokkos::View< const gno_t *, typename node_t::device_type > &ids) const
Provide a Kokkos view to this process' identifiers.
virtual enum BaseAdapterType adapterType() const =0
Returns the type of adapter.
void applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
Apply a PartitioningSolution to an input.
InputTraits< User >::gno_t gno_t
VectorAdapter defines the interface for vector input.
Created by mbenlioglu on Aug 31, 2020.
BaseAdapterType
An enum to identify general types of adapters.
@ VectorAdapterType
vector data
@ InvalidAdapterType
unused value
@ GraphAdapterType
graph data
@ MatrixAdapterType
matrix data
@ MeshAdapterType
mesh data
@ IdentifierAdapterType
identifier data, just a list of IDs