Skip to content

Use event to handle distributed row gatherer#1882

Merged
yhmtsai merged 12 commits into
developfrom
event_row_gatherer
Nov 27, 2025
Merged

Use event to handle distributed row gatherer#1882
yhmtsai merged 12 commits into
developfrom
event_row_gatherer

Conversation

@yhmtsai

@yhmtsai yhmtsai commented Jul 8, 2025

Copy link
Copy Markdown
Member

With the current distributed row gatherer , we does the following:
local row gatherer (prepare data for mpi) -> synchronize (it is required by mpi) -> submit mpi ialltoallv -> submit local spmv
Ginkgo will do local spmv and mpi ialltoallv.
However, the local spmv is forced to wait for synchronize() and then submit its kernel, which lead the gap between gpu activity.

Another approach is introduced in this pr to use event
local row gatherer -> record event -> submit local spmv -> wait the event -> submit mpi ialltoallv.
the submission local spmv does not need to wait for local row gatherer to finish, but it will give additional overhead during record event.

For those does not support AsyncEvent, we just synchronize when creating it.

something from the profiler
image

The local spmv starts earlier (yellow box for gpu activity and gree for cpu). The MPI communication starts later now (pink box). It gives better performance because local spmv still covers the mpi communication. If mpi communication is not covered by the local spmv, this will give slower performance. I will say it is okay-ish now. This situation means it is network bandwidth bound now, which is slow compared to other bandwidth.
We can improve it by introducing thread but it will lead another discussion whether we allow thread in ReferenceExecutor.

There are two approach might also help this situation - stream-aware mpi or async execution.
stream-aware mpi needs more study like using isend/irecv implement all_to_all_v + row gatherer.
async execution I have done something for async schwarz which touching some design question on executor, so it lead larger and longer discussion. Thus, I do not touch it here.

@yhmtsai yhmtsai requested a review from MarcelKoch July 8, 2025 14:41
@yhmtsai yhmtsai self-assigned this Jul 8, 2025
@ginkgo-bot ginkgo-bot added reg:build This is related to the build system. reg:testing This is related to testing. reg:benchmarking This is related to benchmarking. mod:all This touches all Ginkgo modules. labels Jul 8, 2025
@yhmtsai yhmtsai force-pushed the event_row_gatherer branch from 2daf422 to a3f291a Compare July 8, 2025 16:45
@yhmtsai yhmtsai added the 1:ST:ready-for-review This PR is ready for review label Jul 10, 2025
@yhmtsai yhmtsai force-pushed the event_row_gatherer branch 2 times, most recently from 846d8d4 to d65428b Compare July 11, 2025 13:49
@yhmtsai yhmtsai force-pushed the event_row_gatherer branch from d65428b to 85dfc7b Compare August 14, 2025 22:19
@MarcelKoch MarcelKoch added this to the Ginkgo 1.11 milestone Nov 13, 2025
ptr_param<LinOp> x,
array<char>& workspace) const;

std::shared_ptr<const Event> apply_prepare(ptr_param<const LinOp> b,

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.

Note: make these protected and add the distributed matrix as a friend.

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

I would suggest changing the arguments to apply_prepare.

Comment thread core/distributed/row_gatherer.cpp Outdated
Comment thread core/distributed/row_gatherer.cpp
Comment thread test/mpi/distributed/row_gatherer.cpp Outdated
Comment on lines +377 to +382
auto ev = apply_prepare(this->rg.get(), b, x, workspace);
// we modify the workspace to all 0
workspace.fill(static_cast<char>(0));
this->exec->synchronize();
auto req = apply_finalize(this->rg.get(), b, x, ev, workspace);
req.wait();

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.

Just for my understanding, this tests that the send buffer can be overwritten after the apply_prepare, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes (but require on the same stream). It checks the apply finalize indeed uses the workspace

Comment thread core/distributed/matrix.cpp
Comment thread core/base/executor.cpp Outdated
Comment thread cuda/base/executor.cpp
@yhmtsai yhmtsai requested a review from MarcelKoch November 26, 2025 08:40
Comment thread core/base/executor.cpp
@yhmtsai yhmtsai force-pushed the event_row_gatherer branch 2 times, most recently from 4bd5529 to f13e720 Compare November 26, 2025 12:31
@yhmtsai yhmtsai added 1:ST:ready-to-merge This PR is ready to merge. and removed 1:ST:ready-for-review This PR is ready for review labels Nov 26, 2025
@yhmtsai yhmtsai merged commit 57d59b4 into develop Nov 27, 2025
13 of 17 checks passed
@yhmtsai yhmtsai deleted the event_row_gatherer branch November 27, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1:ST:ready-to-merge This PR is ready to merge. mod:all This touches all Ginkgo modules. reg:benchmarking This is related to benchmarking. reg:build This is related to the build system. reg:testing This is related to testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants