Skip to content
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

Add Gloo SendRecv Function #52221

Merged
merged 7 commits into from
Mar 29, 2023
Merged

Add Gloo SendRecv Function #52221

merged 7 commits into from
Mar 29, 2023

Conversation

isky-cd
Copy link
Contributor

@isky-cd isky-cd commented Mar 28, 2023

PR types

New features

PR changes

OPs

Describe

Add Gloo SendRecv Function

@paddle-bot
Copy link

paddle-bot bot commented Mar 28, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

tensor_y = paddle.to_tensor(y)

send_recv_result = paddle.assign(tensor_x)
if rank == 0:
Copy link
Member

Choose a reason for hiding this comment

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

  • Use pg.rank would be better
  • add send from 1 to 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +115 to +125
if pg.rank() == 0:
task = pg.send(tensor_x, 1, True)
else:
task = pg.recv(tensor_y_1, 0, True)
assert np.array_equal(send_recv_result_1, tensor_y_1)

if pg.rank() == 0:
task = pg.recv(tensor_x, 1, True)
assert np.array_equal(send_recv_result_2, tensor_x)
else:
task = pg.send(tensor_y_2, 0, True)
Copy link
Member

Choose a reason for hiding this comment

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

This part can be merged.

const auto slot = gloo::Slot::build(kSendRecvSlotPrefix, opts->tag);

if (context->rank == opts->src) {
in->send((context->rank + 1) % 2, slot);
Copy link
Collaborator

@sneaxiy sneaxiy Mar 29, 2023

Choose a reason for hiding this comment

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

Why (context->rank + 1) % 2? Same below.

Does gloo support P2P communication even if the world size of the process group is larger than 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@sneaxiy sneaxiy left a comment

Choose a reason for hiding this comment

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

LGTM.

@sneaxiy sneaxiy merged commit b885052 into PaddlePaddle:develop Mar 29, 2023
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