50 #ifndef _ZOLTAN2_ADAPTER_HPP_
51 #define _ZOLTAN2_ADAPTER_HPP_
53 #include <Kokkos_Core.hpp>
100 template <
typename User>
124 Kokkos::View<gno_t *> kokkosIds;
126 ids = kokkosIds.data();
147 virtual void getWeightsView(
const scalar_t *&wgt,
int &stride,
149 Kokkos::View<scalar_t *> tempWeightsView;
150 getWeightsKokkosView(tempWeightsView, idx);
151 wgt = tempWeightsView.data();
162 virtual void getWeightsKokkosView(Kokkos::View<scalar_t *> &,
176 void getPartsView(
const part_t *&inputPart)
const {
199 template <
typename Adapter>
200 void applyPartitioningSolution(
const User &in, User *&out,
201 const PartitioningSolution<Adapter> &solution)
const {
212 void generateWeightFileOnly(
const char* fileprefix,
213 const Teuchos::Comm<int> &comm)
const;
217 template <
typename User>
218 void BaseAdapter<User>::generateWeightFileOnly(
219 const char *fileprefix,
220 const Teuchos::Comm<int> &comm
223 int np = comm.getSize();
224 int me = comm.getRank();
226 size_t nLocalIDs = this->getLocalNumIDs();
233 std::string filenamestr = fileprefix;
234 filenamestr = filenamestr +
".graph";
235 const char *filename = filenamestr.c_str();
238 Teuchos::reduceAll(comm, Teuchos::REDUCE_SUM, 1, &nLocalIDs, &nGlobalIDs);
240 int nWgts = this->getNumWeightsPerID();
242 for (
int p = 0; p < np; p++) {
251 fp.open(filename, std::ios::out);
254 fp << nGlobalIDs <<
" " << 0 <<
" "
255 << (nWgts ?
"010" :
"000") <<
" "
256 << (nWgts > 1 ? std::to_string(nWgts) :
" ") << std::endl;
260 fp.open(filename, std::ios::app);
266 const scalar_t **wgts =
new const scalar_t *[nWgts];
267 int *strides =
new int[nWgts];
268 for (
int n = 0; n < nWgts; n++)
269 getWeightsView(wgts[n], strides[n], n);
272 for (
size_t i = 0; i < nLocalIDs; i++) {
273 for (
int n = 0; n < nWgts; n++)
274 fp << wgts[n][i*strides[n]] <<
" ";
291 std::string filenamestr = fileprefix;
292 filenamestr = filenamestr +
".assign";
293 const char *filename = filenamestr.c_str();
295 for (
int p = 0; p < np; p++) {
304 fp.open(filename, std::ios::out);
308 fp.open(filename, std::ios::app);
312 this->getPartsView(parts);
314 for (
size_t i = 0; i < nLocalIDs; i++) {
315 fp << (parts != NULL ? parts[i] : me) <<
"\n";