-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide new API for Adapters that make use of Kokkos::Views (both Host and Device spaces) #14
Comments
Just the idea:
Example: templte <typename User>
SomeAdapter(const RCP<const User> &input)
{
#ifndef Zoltan2_USE_KOKKOS_REFACTOR
legacyMember_ = copyFromInput(input);
// initialize all (old) members
#else
newMember_ = copyFromInput(input);
// initialize all (new) members
#endif
}
or templte <typename User>
SomeAdapter(const RCP<const User> &input)
{
legacyMember_ = copyFromInput(input);
// initialize all (old) members
#ifdef Zoltan2_USE_KOKKOS_REFACTOR
newMember_ = copyFromInput(input);
// initialize all (new) members
#endif
}
For the time being (untill we fully adapt Kokkos into Zoltan2) I would suggest having this flag to false by default. |
Also, should we care how we return data from Adapters? Adapter (old) API virtual void getIDsView(const gno_t *&ids) const;
virtual void getWeightsView(const scalar_t *&wgt, int &stride, int idx = 0) const;
virtual void getPartsView(const part_t *&inputPart) const; Adapter (new) API virtual void getIDsKokkosView(Kokkos::View<const gno_t *, device_t> &ids) const; // const
virtual void getWeightsKokkosView(Kokkos::View<scalar_t **, device_t> & wgt) const; // non-const!
virtual void getPartsDeviceView(Kokkos::View<part_t*, device_t> &inputPart) const; // non-const! |
As for the Weights getter, I think we could provide both versions:
void getWeightsHostView(WeightsHostView1D& weights, int idx = 0) const;
// example use case (GraphModel):
{
// (...) initialize other members
for (int idx=0; idx < nWeightsPerVertex_; idx++){
const auto useNumNZ = adapter->useDegreeAsWeight(idx);
if (useNumNZ){
WeightsHostView1D weights;
for (size_t i=0; i < nLocalVertices_; i++) {
weights[i] = eOffsets_[i+1] - eOffsets_[i];
}
weightInfo[idx] = weights;
}
else{
WeightsHostView1D weights;
adapter->getWeightsHostView(weights, idx);
weightInfo[idx] = weights;
}
}
}
void getWeightsHostView(WeightsHostView& weights) const
// example use case (CoordinateModel):
{
// (...) initialize other members
WeightsHostView wgts;
if(userNumWeights_ > 0) {
adapter->getWeightsHostView(wgts);
}
} |
Provide new API for Zoltan2's Adapters. New API should consist of new
get
functions (that currently use raw pointers or ArrayViews) that returnKokkos::View
inHost
orDevice
space.Example:
The text was updated successfully, but these errors were encountered: