Skip to content

PMIS coarsening implementation on device - #2037

Open
yhmtsai wants to merge 6 commits into
pmisfrom
pmis_device
Open

PMIS coarsening implementation on device#2037
yhmtsai wants to merge 6 commits into
pmisfrom
pmis_device

Conversation

@yhmtsai

@yhmtsai yhmtsai commented Jun 29, 2026

Copy link
Copy Markdown
Member

This PR follows #2035 to add device implementation.
I also add some potential improvement we can try in the comments.

TODO:

  • refine the test
  • try a different way on the second step of classify (now is multiple write, but multiple read should be correct, too)

@yhmtsai yhmtsai self-assigned this Jun 29, 2026
@ginkgo-bot ginkgo-bot added reg:build This is related to the build system. reg:testing This is related to testing. type:multigrid This is related to multigrid mod:all This touches all Ginkgo modules. labels Jun 29, 2026
@yhmtsai
yhmtsai changed the base branch from develop to pmis June 29, 2026 14:51
@MarcelKoch
MarcelKoch self-requested a review July 6, 2026 12:11

@MarcelKoch MarcelKoch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only small nits

weight[row] = dist(gen);
}
}
GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_TYPE_BASE(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_TYPE_BASE(
GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_TYPE_BASE(



template <typename ValueType>
void initialize_random_weight(std::shared_ptr<const DefaultExecutor> exec,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the next kernel be adapted to use this?

randlib::uniform_rand_vector(gen, num, weight);
randlib::destroy(gen);
}
GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_TYPE_BASE(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_TYPE_BASE(
GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_TYPE_BASE(

});
});
}
GKO_INSTANTIATE_FOR_EACH_NON_COMPLEX_VALUE_TYPE_BASE(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Comment on lines +13 to +15
#include "common/hipda_hip/base/math.hpp"
#include "common/hipda_hip/base/runtime.hpp"
#include "common/hipda_hip/base/types.hpp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace mistake


class Pmis : public CommonTestFixture {
protected:
using Mtx = gko::matrix::Dense<value_type>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

Comment on lines +28 to +34
exec->get_queue()->submit([&](sycl::handler& cgh) {
cgh.parallel_for(sycl::range<1>(n), [=](sycl::item<1> idx) {
std::uint64_t offset = idx.get_linear_id();
oneapi::dpl::minstd_rand engine(seed, offset);
oneapi::dpl::uniform_distribution<device_type<ValueType>> distr(0,
1);
work[idx] = distr(engine);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if this is correct ? I think n should be num ? And work should be weight etc

exec,
[] GKO_KERNEL(auto row, auto tid, auto row_ptrs, auto col_idxs,
auto values) {
auto maxabs = zero(abs(values[0]));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe zero<remove_complex<ValueType>>() instead ?

{
GKO_NOT_IMPLEMENTED;
auto num = trans_strong_dep->get_size()[0];
array<float> random(exec, num);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
array<float> random(exec, num);
array<ValueType> random(exec, num);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:all This touches all Ginkgo modules. reg:build This is related to the build system. reg:testing This is related to testing. type:multigrid This is related to multigrid

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants