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

optimization of max_pool3d forward #45820

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

s5u13b
Copy link
Contributor

@s5u13b s5u13b commented Sep 7, 2022

PR types

Performance optimization

PR changes

OPs

Describe

  • Environment:
    • V100-32G, CUDA 11.2, cuDNN 8
  • Feature:
    • replace the div and mod operation with fast_divmod operation
    • replace 1d gpu launch with 3d gpu launch
  • Performance (OP Benchmark):
Paddle Kernel Config ID Performance Before Performance After Improvement
KernelMaxPool3DWithIdx 1 1103.2us 966.28us 14.16%

@CLAassistant
Copy link

CLAassistant commented Sep 7, 2022

CLA assistant check
All committers have signed the CLA.

@paddle-bot
Copy link

paddle-bot bot commented Sep 7, 2022

你的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.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Sep 7, 2022
@JamesLim-sy
Copy link
Contributor

I think it is better to list the perf value with a table.

if (ele <
input_data_cur[(d * input_height + h) * input_width + w]) {
max_index = (d * input_height + h) * input_width + w;
ele = input_data_cur[max_index];
Copy link
Contributor

Choose a reason for hiding this comment

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

Formula (d * input_height + h) * input_width + w has appeard twice, would it be better to assign this formula to a local data, example below:

T1  cur_data = input_data_cur[(d * input_height + h) * input_width + w];
ele = ele < cur_data] ?  cur_data: ele;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because max_index should be assigned only when the condition ele < input_data_cur[(d * input_height + h) * input_width + w] is true and it would be used at the end of funciton for return mask_data, so I should assign the value to max_index inside the if statement and therefore formula (d * input_height + h) * input_width + w appears twice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will time cost of formula (d * input_height + h) * input_width + w shrink with code below ?

        for (int w = wstart; w < wend; ++w) {
          max_index = (d * input_height + h) * input_width + w;
          if (ele < input_data[max_index]) {
            ele = input_data[max_index];
          }
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The max_index cannot be calculated correctly with this codes, and consequently the mask_data return in the function would be incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

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

okay

@s5u13b
Copy link
Contributor Author

s5u13b commented Sep 7, 2022

I think it is better to list the perf value with a table.

Thanks for your advice, I have modified description to present the perf value in the form of table.

int blocks = (nthreads + thread_num - 1) / thread_num;
dim3 threads(thread_num, 1);
dim3 grid(blocks, 1);
int thread_x = 32;
Copy link
Contributor

Choose a reason for hiding this comment

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

@fengxiaoshuai hi, this PR deletes code for NV_JETSON about threads config, however the thread_num is 256 in all which is under the limitation for NV_JETSON.
Can this PR be merged?

Copy link
Contributor

Choose a reason for hiding this comment

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

jetson系列中比较低端的GPU寄存器很少,有时候会出现资源不足,kernel launch失败,这个QA后台有CE监控

Copy link
Contributor

@JamesLim-sy JamesLim-sy left a comment

Choose a reason for hiding this comment

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

LGTM

@JamesLim-sy JamesLim-sy merged commit 2632d77 into PaddlePaddle:develop Sep 9, 2022
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.

7 participants