Skip to content

Fix for OpenMP offloading compilation error with GNU++20 option when using complex header #115306

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

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions clang/lib/Headers/openmp_wrappers/complex_cmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ template <class _Tp> __DEVICE__ _Tp norm(const std::complex<_Tp> &__c) {
}

// conj

template <class _Tp> std::complex<_Tp> conj(const std::complex<_Tp> &__c) {
#ifdef _GLIBCXX20_CONSTEXPR
#define CXX20_CONSTEXPR_DEVICE __DEVICE__
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why this is not constexpr in C++20 but __DEVICE__ instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shiltian I followed the existing approach used to define constexpr for handling OpenMP offloading in this wrapper. The DEVICE macro indeed looks better suited with GPU offloading environments.

#else
#define CXX20_CONSTEXPR_DEVICE
#endif
template <class _Tp>
CXX20_CONSTEXPR_DEVICE std::complex<_Tp> conj(const std::complex<_Tp> &__c) {
return std::complex<_Tp>(__c.real(), -__c.imag());
}

Expand Down
Loading