-
Notifications
You must be signed in to change notification settings - Fork 53
Add implementations for the C++ standard library math #551
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
Conversation
|
The corresponding LLVM change is here llvm/llvm-project#140158. |
stanleytsang-amd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexVlx changes look fine to me, but you'll need to rebase your PR/fix merge conflicts for this one as well.
|
Please resolve merge conflicts or close this PR to complete the task of importing PRs from this repo to the monorepo. |
|
Closing the pull request in this repo. Please refer to the migrated pull request for updates. |
The C++ standard library, as well as generic C++ code, use [special compiler builtins](https://gcc.gnu.org/onlinedocs/gcc/Library-Builtins.html) to implement math functions. Some of these have non-trivial lowerings and are not handled in the compiler, which leads to rather opaque arcane errors obtaining when compiling code in `--hipstdpar` mode, wherein they end up directly consumed. This patch adds a header that forwards to the ROCDL implementations via an uniform HIPSTDPAR interface. A corresponding patch in the compiler will handle forwarding the builtins that we cannot directly lower to said uniform HIPSTDPAR interface. With this design, it is possible to provide alternative implementations, and it is also possible for the user to provide their own implementations if e.g. they are compiling with `-nogpuinc` and / or `-nogpulib`. --- 🔁 Imported from [ROCm/rocThrust#551](ROCm/rocThrust#551) 🧑💻 Originally authored by @AlexVlx --------- Co-authored-by: Alex Voicu <[email protected]> Co-authored-by: assistant-librarian[bot] <assistant-librarian[bot]@users.noreply.github.com>
The C++ standard library, as well as generic C++ code, use [special compiler builtins](https://gcc.gnu.org/onlinedocs/gcc/Library-Builtins.html) to implement math functions. Some of these have non-trivial lowerings and are not handled in the compiler, which leads to rather opaque arcane errors obtaining when compiling code in `--hipstdpar` mode, wherein they end up directly consumed. This patch adds a header that forwards to the ROCDL implementations via an uniform HIPSTDPAR interface. A corresponding patch in the compiler will handle forwarding the builtins that we cannot directly lower to said uniform HIPSTDPAR interface. With this design, it is possible to provide alternative implementations, and it is also possible for the user to provide their own implementations if e.g. they are compiling with `-nogpuinc` and / or `-nogpulib`. --- 🔁 Imported from [ROCm/rocThrust#551](ROCm/rocThrust#551) 🧑💻 Originally authored by @AlexVlx --------- Co-authored-by: Alex Voicu <[email protected]> Co-authored-by: assistant-librarian[bot] <assistant-librarian[bot]@users.noreply.github.com>
When compiling in `--hipstdpar` mode, the builtins corresponding to the standard library might end up in code that is expected to execute on the accelerator (e.g. by using the `std::` prefixed functions from `<cmath>`). We do not have uniform handling for this in AMDGPU, and the errors that obtain are quite arcane. Furthermore, the user-space changes required to work around this tend to be rather intrusive. This patch adds an additional `--hipstdpar` specific pass which forwards to the run time component of HIPSTDPAR the intrinsics / libcalls which result from the use of the math builtins, and which are not properly handled. In the long run we will want to stop relying on this and handle things in the compiler, but it is going to be a rather lengthy journey, which makes this medium term escape hatch necessary. The paired change in the run time component is here <ROCm/rocThrust#551>.
When compiling in `--hipstdpar` mode, the builtins corresponding to the standard library might end up in code that is expected to execute on the accelerator (e.g. by using the `std::` prefixed functions from `<cmath>`). We do not have uniform handling for this in AMDGPU, and the errors that obtain are quite arcane. Furthermore, the user-space changes required to work around this tend to be rather intrusive. This patch adds an additional `--hipstdpar` specific pass which forwards to the run time component of HIPSTDPAR the intrinsics / libcalls which result from the use of the math builtins, and which are not properly handled. In the long run we will want to stop relying on this and handle things in the compiler, but it is going to be a rather lengthy journey, which makes this medium term escape hatch necessary. The paired change in the run time component is here <ROCm/rocThrust#551>.
When compiling in `--hipstdpar` mode, the builtins corresponding to the standard library might end up in code that is expected to execute on the accelerator (e.g. by using the `std::` prefixed functions from `<cmath>`). We do not have uniform handling for this in AMDGPU, and the errors that obtain are quite arcane. Furthermore, the user-space changes required to work around this tend to be rather intrusive. This patch adds an additional `--hipstdpar` specific pass which forwards to the run time component of HIPSTDPAR the intrinsics / libcalls which result from the use of the math builtins, and which are not properly handled. In the long run we will want to stop relying on this and handle things in the compiler, but it is going to be a rather lengthy journey, which makes this medium term escape hatch necessary. The paired change in the run time component is here <ROCm/rocThrust#551>.
The C++ standard library, as well as generic C++ code, use special compiler builtins to implement math functions. Some of these have non-trivial lowerings and are not handled in the compiler, which leads to rather opaque arcane errors obtaining when compiling code in
--hipstdparmode, wherein they end up directly consumed. This patch adds a header that forwards to the ROCDL implementations via an uniform HIPSTDPAR interface. A corresponding patch in the compiler will handle forwarding the builtins that we cannot directly lower to said uniform HIPSTDPAR interface.With this design, it is possible to provide alternative implementations, and it is also possible for the user to provide their own implementations if e.g. they are compiling with
-nogpuincand / or-nogpulib.