Skip to content

Commit

Permalink
add comment for complex casting and C++ standard
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed May 19, 2021
1 parent c8666d1 commit 1a12300
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions omp/components/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ template <typename ValueType,
std::enable_if_t<is_complex<ValueType>()> * = nullptr>
void atomic_add(ValueType &out, ValueType val)
{
// The C++ standard explicitly allows casting complex<double>* to double*
// [complex.numbers.general]
auto values = reinterpret_cast<gko::remove_complex<ValueType> *>(&out);
#pragma omp atomic
values[0] += real(val);
Expand Down

0 comments on commit 1a12300

Please sign in to comment.