Skip to content

[SYCL] Don't include <cmath> from <sycl/sycl.hpp> #11274

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 5 commits into from
Sep 25, 2023

Conversation

aelovikov-intel
Copy link
Contributor

This follows #11196 that did the same with before. We still want to support std:: math functions in user code (as part of sycl/doc/extensions/supported/C-CXX-StandardLibrary.rst). Also, often times STL implements math functions support somewhat like this:

extern "C" {
 extern double cos (double __x) noexcept (true);
}
extern "C++"
{
namespace std __attribute__ ((__visibility__ ("default")))
{
 using ::cos;
}
}

As such, we still want to let the compiler know which symbols in the global namespace are known (e.g. ::cos) and which aren't and need an error ( SYCL kernel cannot call an undefined function without SYCL_EXTERNAL attribute).

One option to implement that is to recognize those functions as builtins in the front end (which #11014 tries to do). Another approach, taken in this PR, is to keep providing declaration in SYCL headers but only do so when customer included <cmath> explicitly (via #include_next, similarly to <complex> support added in #11196).

This follows intel#11196 that did the same with <complex> before. We still want to
support `std::` math functions in user code (as part of
`sycl/doc/extensions/supported/C-CXX-StandardLibrary.rst`). Also, often times
STL implements math functions support somewhat like this:

```
extern "C" {
 extern double cos (double __x) noexcept (true);
}
extern "C++"
{
namespace std __attribute__ ((__visibility__ ("default")))
{
 using ::cos;
}
}
```

As such, we still want to let the compiler know which symbols in the global
namespace are known (e.g. `::cos`) and which aren't and need an error ( `SYCL
kernel cannot call an undefined function without SYCL_EXTERNAL attribute`).

One option to implement that is to recognize those functions as builtins in the
front end (which intel#11014 tries to do). Another approach, taken in this PR, is to
keep providing declaration in SYCL headers but only do so when customer included
`<cmath>` explicitly (via `#include_next`, similarly to `<complex>` support
added in intel#11196).
@aelovikov-intel aelovikov-intel temporarily deployed to WindowsCILock September 22, 2023 20:04 — with GitHub Actions Inactive
@aelovikov-intel aelovikov-intel temporarily deployed to WindowsCILock September 22, 2023 21:20 — with GitHub Actions Inactive
@aelovikov-intel aelovikov-intel temporarily deployed to WindowsCILock September 25, 2023 08:00 — with GitHub Actions Inactive
Copy link
Contributor

@dkhaldi dkhaldi left a comment

Choose a reason for hiding this comment

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

JM part LGTM

@aelovikov-intel
Copy link
Contributor Author

HIP:

Memory access fault by GPU node-1 (Agent handle: 0x1b53670) on address 0x7f19ca200000. Reason: Page not present or supervisor privilege.

Win, infrastructure issue:

Post Register cleanup after job is finished

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

Since we can still consider #11014 with this in, I am okay with the solution.

@aelovikov-intel aelovikov-intel merged commit 9bbbc77 into intel:sycl Sep 25, 2023
@aelovikov-intel aelovikov-intel deleted the no-cmath branch September 25, 2023 16:57
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Sep 27, 2023
…RMANT_APIS

intel#11274 and
intel#11196 could break customers code that
relied on implicit inclusion of those headers. Don't break it before the
next ABI breaking window.
steffenlarsen pushed a commit that referenced this pull request Sep 28, 2023
…RMANT_APIS (#11326)

#11274 and
#11196 could break customers code that
relied on implicit inclusion of those headers. Don't break it before the
next ABI breaking window.
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.

3 participants