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 xpu2 compiler #37254

Merged
merged 49 commits into from
Jan 29, 2022
Merged

Conversation

Liu-xiandong
Copy link
Member

@Liu-xiandong Liu-xiandong commented Nov 16, 2021

PR types

New features

PR changes

Others

Describe

This PR adds the source code compilation mode of XPU2, and the compilation commands are as follows:

cmake .. -DPY_VERSION=3.7 -DWITH_XPU_KP=ON -DWITH_GPU=OFF -DWITH_TESTING=ON -DCMAKE_BUILD_TYPE=Release

Its realization mainly involves the following aspects:

1. Support source code compilation mode of XPU2 code:

Mainly related to the modification of cmake, the main files involved are: cmake/generic.cmake cmake/operators.cmake cmake/xpu_kp.cmake
The specific calling process is as follows:
image

2. Compatible operator mapping mode and source code compilation mode

After adding the source code compilation mode, there are two XPU kernels for the same OP.
In order to be compatible with the two modes, three aspects of work have been done.

  • Added a new library_type to distinguish the original mode.
    The main files involved are: paddle/fluid/framework/library_type.h

  • In order to dynamically select the kernel at runtime, the flag and the list involved in the KP mode are added.
    The main files involved are: paddle/fluid/platform/flags.cc paddle/fluid/platform/device/xpu/xpu_op_kpfirst_list.h paddle/fluid/platform/device/xpu/xpu_op_list.cc

  • Increase specific runtime control methods
    The main files involved are:
    paddle/fluid/framework/operator.cc (static graph)
    paddle/fluid/imperative/prepared_operator.cc (dynamic graph)

The control graph of runtime is as follows:
image

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot-old
Copy link

paddle-bot-old bot commented Dec 4, 2021

Sorry to inform you that d473766's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@paddle-bot-old
Copy link

Sorry to inform you that bdaa02c's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

cmake/xpu_kp.cmake Outdated Show resolved Hide resolved
cmake/xpu_kp.cmake Outdated Show resolved Hide resolved
paddle/fluid/platform/aligned_vector.h Outdated Show resolved Hide resolved
paddle/fluid/platform/device/xpu/xpu_op_kpfirst_list.h Outdated Show resolved Hide resolved
paddle/fluid/platform/device/xpu/xpu_op_kpfirst_list.h Outdated Show resolved Hide resolved
cmake/xpu_kp.cmake Outdated Show resolved Hide resolved
xingfeng01
xingfeng01 previously approved these changes Jan 28, 2022
lanxianghit
lanxianghit previously approved these changes Jan 28, 2022
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

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

LGTM for operator.h

@xingfeng01 xingfeng01 merged commit 92da505 into PaddlePaddle:develop Jan 29, 2022
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.

5 participants