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

Link cpp test to libpaddle.so/libpaddle.dll #56691

Merged

Conversation

winter-wang
Copy link
Contributor

@winter-wang winter-wang commented Aug 27, 2023

PR types

Bug fixes

PR changes

Others

Description

修复CI流水线中,单测体积过大问题。

目前的很多单测,对Paddle框架通过静态库(.a、.lib)的形式进行链接,导致单个单测的体积过大(超过1G)。在CI流水线编译中,当并发线程过多,就容易因为内存空间不足而使编译失败。

本pr内容如下:

  • 将部分单测修改为对Paddle框架通过动态库(.so、.dll)的形式进行链接。多个单测共享同一份动态库,有效减少内存的占用。

  • 提供了TEST_API宏定义, 在定义了WITH_TESTING的情况下,TEST_API修饰的对象会被编译为动态库的导出符号,方便单测进行使用。

  • 提供了 paddle_test函数, 该函数会自动链接libpaddle.so或者libpaddle.dll动态库。当单个单测体积过大时,建议通过paddle_test链接动态库进行单元测试。

  • 本pr合入前, coverage单测编译后,build目录的大小为 *G, 合入后, build目录的大小为**G。

  • 本pr主要是打通了windows下和linux下同时使用动态库进行测试的道路。后续会逐步将所有大于**M的单测,都改为通过动态库进行链接测试。

Todo:
@risemeup1

  • 将现有的cc_test函数的使用都替换为paddle_test, 移除cc_test函数。

  • 作为对paddle_test函数功能的补充:

    • 提供inference_test函数,自动链接libpaddle_inference.so 或者libpaddle_inference.dll动态库构建单测。
    • 提供inference_c_test函数,自动链接libpaddle_inference_c.so 或者libpaddle_inference_c.dll动态库构建单测。
    • 提供phi_test函数,自动链接libphi.so 或者libphi.dll动态库构建单测。
    • 提供pir_test函数,自动链接libpir.so 或者libpir.dll动态库构建单测。
    • 提供cinn_test函数,自动链接libcinn.so 或者libcinn.dll动态库构建单测。
  • 当单个单测的大小超过**M的时候,通过CI进行拦截。

Other

Pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented Aug 27, 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.

@winter-wang winter-wang force-pushed the fix_compile_kill_9_bug branch 29 times, most recently from 50b5b08 to 50faf51 Compare August 28, 2023 08:52
@winter-wang winter-wang force-pushed the fix_compile_kill_9_bug branch 5 times, most recently from 9d01e92 to dbe9f55 Compare September 25, 2023 08:08
risemeup1
risemeup1 previously approved these changes Sep 25, 2023
Copy link
Contributor

@risemeup1 risemeup1 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@risemeup1 risemeup1 left a comment

Choose a reason for hiding this comment

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

LGTM

@risemeup1 risemeup1 changed the title Fix compile kill 9 bug Link cpp test to libpaddle.so/libpaddle.dll Sep 26, 2023
Copy link
Contributor

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

This file can be deleted

Copy link
Contributor Author

@winter-wang winter-wang Sep 26, 2023

Choose a reason for hiding this comment

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

全局搜索了一下egr::scale符号,这个函数在很多单测文件中进行了大量使用(benchmark_utils.cc、forward_autograd_test.cc、fwd_bwd_joint_test.cc)。直接删除该文件的话,相应的单测也需要修改,不然会编译失败。因此这个文件可能需要动态图相关的同学来帮忙进行删除。

Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

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

LGTM

paddle/phi/core/ddim.h Show resolved Hide resolved
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

paddle/fluid/eager/utils.cc Show resolved Hide resolved
paddle/utils/test_macros.h Show resolved Hide resolved
@winter-wang winter-wang merged commit f68043f into PaddlePaddle:develop Sep 26, 2023
Frida-a pushed a commit to Frida-a/Paddle that referenced this pull request Oct 14, 2023
jiahy0825 pushed a commit to jiahy0825/Paddle that referenced this pull request Oct 16, 2023
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 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.

10 participants