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

【静态图性能优化】Share event #55650

Merged
merged 6 commits into from
Jul 26, 2023

Conversation

AndSonder
Copy link
Contributor

@AndSonder AndSonder commented Jul 24, 2023

PR types

Performance optimization

PR changes

Others

Description

Paddle 的 Event 机制主要用于多流之间的同步,在预分析阶段需要根据 op_func_node 去分析相关的信息。对于相同子图的Interpretercore,Event分析的结果可以共享。 本 PR 实现了相同子图Interpretercore之间Event分析信息的共享。

详细介绍见Issue:

@AndSonder AndSonder changed the title Share event 【静态图性能优化】Share event Jul 24, 2023
@paddle-bot paddle-bot bot added the contributor External developers label Jul 24, 2023
// Note(sonder): Share build results don't work for new IR now.
if (type_to_first_id.count(job_type) != 0 &&
!FLAGS_enable_new_ir_in_executor) {
interpretercores_[job_idx]->ShareBuildResultsFrom(
Copy link
Contributor

@From00 From00 Jul 25, 2023

Choose a reason for hiding this comment

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

type_to_first_id[job_type]==job_idx时,interpretercore自己跟自己share,是否会有问题?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

type_to_first_id[job_type]==job_idx时,interpretercore自己跟自己share,是否会有问题?

不会,在ShareBuildResults里有判断

  if (is_shared_results_build_ || !src.IsSharedResultsBuild()) {
    return;
  }

for (size_t i = 1; i < ids.size(); ++i) {
interpretercores_[ids[i]]->ShareBuildResultsFrom(
interpretercores_[ids[0]]);
if (type_to_first_id.count(jobs[job_idx]->Type()) == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

计算type_to_first_id时,是否需要从job_idx=0开始遍历?

Copy link
Contributor Author

@AndSonder AndSonder Jul 25, 2023

Choose a reason for hiding this comment

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

计算type_to_first_id时,是否需要从job_idx=0开始遍历?

有直接将job_idx=0的job_type加入到 unordered_map

type_to_first_id[jobs[0]->Type()] = 0;
    for (size_t job_idx = 1; job_idx < jobs.size(); ++job_idx) {
      interpretercores_[job_idx]->ShareWorkQueueFrom(interpretercores_[0]);
    ...

@AndSonder AndSonder requested a review from From00 July 25, 2023 08:12
Copy link
Contributor

@From00 From00 left a comment

Choose a reason for hiding this comment

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

LGTM

@From00 From00 merged commit 0601c2c into PaddlePaddle:develop Jul 26, 2023
wz1qqx pushed a commit to wz1qqx/Paddle that referenced this pull request Jul 31, 2023
* add sharing event info

* add sharing event info

* fix

* remove const

* add flag

* fix
jinjidejinmuyan pushed a commit to jinjidejinmuyan/Paddle that referenced this pull request Aug 30, 2023
* add sharing event info

* add sharing event info

* fix

* remove const

* add flag

* fix
@AndSonder AndSonder deleted the share_event branch April 23, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants