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 taking the address of math constants to known issues #461

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions docs/source/API/core/numerics/mathematical-constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ All constants are defined in the ``Kokkos::numbers::`` namespace since version 4
Notes
-----

.. _KnownIssues: ../../../known-issues.html#mathematical-constants

.. |KnownIssues| replace:: known issues

* The mathematical constants are available in ``Kokkos::Experimental::`` since Kokkos 3.6
* They were "promoted" to the ``Kokkos::numbers`` namespace in 4.0
* Passing mathematical constants by reference or taking their address in device code is not supported by some toolchains and hence not portable. (See |KnownIssues|_)

------------

Expand Down
22 changes: 22 additions & 0 deletions docs/source/known-issues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,25 @@ The using-directive ``using namespace Kokkos;`` is highly discouraged (see
calls to mathematical functions. Instead, prefer explicit qualification
``Kokkos::sqrt`` or an using-declaration ``using Kokkos::sqrt;`` at local
scope.

Mathematical constants
======================

- Avoid taking the address of mathematical constants in device code. It is not supported by some toolchains, hence not portable.

.. code-block:: cpp

#include <Kokkos_Core.hpp>

KOKKOS_FUNCTION void do_math() {
// complex constructor takes scalar arguments by reference!
Kokkos::complex z1(Kokkos::numbers::pi);
// error: identifier "Kokkos::numbers::pi" is undefined in device code

// 1*pi is a temporary
Kokkos::complex z2(1 * Kokkos::numbers::pi); // OK

// copy into a local variable
auto pi = Kokkos::numbers::pi;
Kokkos::complex z3(pi); // OK
}