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

Fixup absolute value of floating points in Kokkos complex #3882

Merged
merged 2 commits into from
Mar 25, 2021

Conversation

dalg24
Copy link
Member

@dalg24 dalg24 commented Mar 24, 2021

As in #3880 motivated by removing SYCL specific preprocessor directives in <Kokkos_Complex.hpp>

In the process discovered that we are using std::fabs in device functions which is not allowed with SYCL.

core/src/Kokkos_Complex.hpp Outdated Show resolved Hide resolved
Comment on lines 802 to 808
#ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_SYCL
using sycl::abs;
using sycl::fabs;
using sycl::sqrt;
#else
using std::abs;
using std::fabs;
using std::sqrt;
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this just be

  using Kokkos::Experimental::fabs;
  using Kokkos::Experimental::sqrt;

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixing in upcoming PR that will pull all the #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_SYCL

return Kokkos::complex<RealType>(t, i < RealType() ? -t : t);
} else {
RealType t = sqrt(2 * (abs(x) + abs(r)));
RealType t = sqrt(2 * (abs(x) + fabs(r)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
RealType t = sqrt(2 * (abs(x) + fabs(r)));
RealType t = sqrt(2 * (fabs(x) + fabs(r)));

?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. I did the same mistake before. x is a Kokkos::complex.

Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

Looks OK to me.

@dalg24 dalg24 force-pushed the kokkos_complex_prefer_fabs branch from 502865f to 90fca96 Compare March 25, 2021 01:48
@dalg24
Copy link
Member Author

dalg24 commented Mar 25, 2021

No changes. Just rebased with autosquash

@dalg24 dalg24 merged commit a3c36bc into kokkos:develop Mar 25, 2021
@dalg24 dalg24 deleted the kokkos_complex_prefer_fabs branch March 25, 2021 02:50
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.

None yet

2 participants