Skip to content

Multicolor (independent set) reordering capability on reference executor - #2006

Open
Slaedr wants to merge 11 commits into
ginkgo-project:developfrom
Slaedr:multicoloring
Open

Multicolor (independent set) reordering capability on reference executor#2006
Slaedr wants to merge 11 commits into
ginkgo-project:developfrom
Slaedr:multicoloring

Conversation

@Slaedr

@Slaedr Slaedr commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

The aim is to have a parallel GPU-capable multicolor ordering using the JPL algorithm. This PR only has the sequential reference implementation and corresponding tests.

Currently, CSR and SparsityCSR inputs are supported.

Also adds a "cores per SM" entry for NVIDIA GB10 GPU.

@pratikvn pratikvn 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.

some initial comments

Comment thread core/reorder/multicolor.cpp Outdated
Comment thread core/reorder/multicolor.cpp Outdated
Comment thread core/test/utils/matrix_generator_test.cpp
Comment thread include/ginkgo/core/reorder/multicolor.hpp

@yhmtsai yhmtsai 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.

you also need to modify test_install.cpp

Comment thread core/reorder/multicolor.cpp Outdated
Comment thread core/test/reorder/multicolor.cpp Outdated
Comment thread core/test/reorder/multicolor.cpp Outdated
@Slaedr

Slaedr commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

@yhmtsai None of the other reorder classes are there in test_install.cpp. Should I still add a check for building a Multicolor object there?

@Slaedr
Slaedr requested review from pratikvn and yhmtsai April 30, 2026 15:13

@pratikvn pratikvn 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.

some more comments. But mostly looks good. One general question from my side: Does this reorder setup suit your workflow ? Meaning can you make use of this in your Gauss-Seidel ?

Comment thread core/test/utils/matrix_generator_test.cpp
Comment thread include/ginkgo/core/reorder/multicolor.hpp Outdated
* The first entry is always 0, since the first color always starts at 0.
* The last entry stores the total number of rows.
*/
std::vector<index_type> get_color_pointers() const { return color_ptrs_; }

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.

It might make sense to have this as a gko::array rather than a std::vector.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This makes it explicit that the color_ptrs is always on the host. Do you expect a situation in which someone needs this on the device instead?

@Slaedr Slaedr May 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pratikvn I can change the std::vector to gko::array if you say that is preferable, even though I can't (currently) think of a use case where an application will want the color pointers on the device.

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.

I think keeping all internal arrays as gko::array objects is better than having some as std::vector. But if you need some methods of std::vector, then it should be fine.

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.

one more reason to prefer gko::array to std::vector is that the user can track allocations (through a logger), and switching allocators is easier. For example, using a PoolAllocator like Umpire, once support for that is added. If you need to call std::vector routines, maybe use gko::vector, which is constructible with an executor. See core/base/allocator.hpp:161

Comment thread reference/reorder/multicolor_kernels.cpp Outdated
Comment thread include/ginkgo/core/reorder/multicolor.hpp Outdated
Comment thread include/ginkgo/core/reorder/multicolor.hpp Outdated
Comment on lines +86 to +87
// assert(permutation.end() == permutation.begin() +
// color_ptrs[num_colors]);

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.

I will uncomment this part for checking?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like this was left over from where I initially implemented this a while back. Since permutation is a raw pointer here, it does not make sense. I'll just remove it.

Comment thread reference/test/reorder/multicolor_kernels.cpp Outdated
Comment thread core/test/utils/reordering_test.cpp Outdated
Comment thread include/ginkgo/core/reorder/multicolor.hpp Outdated
Comment thread core/test/reorder/multicolor.cpp Outdated
ASSERT_EQ(this->mc_factory->get_executor(), this->exec);
}

TYPED_TEST(Multicolor, GeneratesCorrectOrderingWithCsrInput)

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.

I think the followings should be in the reference test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since this testing a particular generate, I think it should be in core.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved it to reference; I think you're right that this might make more sense.

@pratikvn

Copy link
Copy Markdown
Member

@Slaedr , does the approach of having Multicolor as a reordering work for the goal of having this within GaussSeidel ?

@Slaedr

Slaedr commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@pratikvn Yes. I'm not sure if it's best offered as an option within the Gauss-Seidel class(es), since the matrix needs to be modified to obey the ordering. The best workflow is probably to reorder the matrix and then generate GaussSeidel on the reordered matrix, passing in the color pointers. If the user does not supply the color pointers, I guess we could compute and store a reordered copy of the matrix in the generate step.

@pratikvn

Copy link
Copy Markdown
Member

@Slaedr , can you please check that you can use reordering as a wrapper for Gauss-Seidel ? If so, then I dont have any other issues with this PR.

Comment thread core/reorder/multicolor.cpp Outdated
Comment on lines +42 to +44
const auto local_nrows = num_vertices;

std::vector<int> color(local_nrows, -1);

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.

If we already know the size beforehand, then we should allocate the vector outside the kernel in core.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, the number of helper vectors needed depends on the backend. The parallel backends need more than one working array (at least for now), though the reference backend needs only one. So, to keep the kernel interface the same, would you say it's best to leave it as it is, or is there a better solution?

* The first entry is always 0, since the first color always starts at 0.
* The last entry stores the total number of rows.
*/
std::vector<index_type> get_color_pointers() const { return color_ptrs_; }

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.

I think keeping all internal arrays as gko::array objects is better than having some as std::vector. But if you need some methods of std::vector, then it should be fine.

@Slaedr
Slaedr requested review from pratikvn and yhmtsai June 2, 2026 12:55

@pratikvn pratikvn 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.

LGTM

@yhmtsai

yhmtsai commented Jun 3, 2026

Copy link
Copy Markdown
Member

@Slaedr do you think anything to check from my side? Otherwise, this PR can be merged after the pipeline are passed. Do you still have access to ginkgo repo? We currently only process CI from ginkgo own repo.

@Slaedr

Slaedr commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

@Slaedr do you think anything to check from my side? Otherwise, this PR can be merged after the pipeline are passed. Do you still have access to ginkgo repo? We currently only process CI from ginkgo own repo.

Looks like I don't have access. The workflows are waiting for approval.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants