-
Notifications
You must be signed in to change notification settings - Fork 407
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
OpenMPTarget: Fix reduction bug in parallel_reduce for TeamPolicy. #4491
OpenMPTarget: Fix reduction bug in parallel_reduce for TeamPolicy. #4491
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rgayatri23 @dalg24 |
Below is the piece of code that triggers it in Kokkos Kernels, for a reproducer I suggest adding template <class RV, class XMV, class SizeType = typename XMV::size_type>
struct MV_Nrm1_Right_FunctorVector {
typedef typename XMV::execution_space execution_space;
typedef SizeType size_type;
typedef typename XMV::non_const_value_type xvalue_type;
typedef Kokkos::ArithTraits<xvalue_type> XAT;
typedef Kokkos::ArithTraits<typename XAT::mag_type> MAT;
typedef typename XAT::mag_type value_type[];
size_type value_count;
typename XMV::const_type m_x;
MV_Nrm1_Right_FunctorVector(const XMV& x) : value_count(x.extent(1)), m_x(x) {
static_assert(Kokkos::Impl::is_view<RV>::value,
"KokkosBlas::Impl::MV_Nrm1_Right_FunctorVector: "
"R is not a Kokkos::View.");
static_assert(Kokkos::Impl::is_view<XMV>::value,
"KokkosBlas::Impl::MV_Nrm1_Right_FunctorVector: "
"X is not a Kokkos::View.");
static_assert(std::is_same<typename RV::value_type,
typename RV::non_const_value_type>::value,
"KokkosBlas::Impl::MV_Nrm1_Right_FunctorVector: "
"R is const. It must be nonconst, because it is an output "
"argument (we must be able to write to its entries).");
static_assert(RV::rank == 1 && XMV::rank == 2,
"KokkosBlas::Impl::MV_Nrm1_Right_FunctorVector: "
"RV must have rank 1 and XMV must have rank 2.");
}
KOKKOS_INLINE_FUNCTION void operator()(const size_type i,
value_type sum) const {
const size_type numVecs = value_count;
#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
#pragma ivdep
#endif
#ifdef KOKKOS_ENABLE_PRAGMA_VECTOR
#pragma vector always
#endif
for (size_type j = 0; j < numVecs; ++j) {
xvalue_type val = m_x(i, j);
sum[j] += MAT::abs(XAT::real(val)) + MAT::abs(XAT::imag(val));
}
}
KOKKOS_INLINE_FUNCTION void join(volatile value_type update,
const volatile value_type source) const {
const size_type numVecs = value_count;
#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
#pragma ivdep
#endif
#ifdef KOKKOS_ENABLE_PRAGMA_VECTOR
#pragma vector always
#endif
for (size_type j = 0; j < numVecs; ++j) {
update[j] += source[j];
}
}
KOKKOS_INLINE_FUNCTION void join(value_type update,
const value_type source) const {
const size_type numVecs = value_count;
#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
#pragma ivdep
#endif
#ifdef KOKKOS_ENABLE_PRAGMA_VECTOR
#pragma vector always
#endif
for (size_type j = 0; j < numVecs; ++j) {
update[j] += source[j];
}
}
};
template <class RV, class XMV, class SizeType>
void MV_Nrm1_Invoke(const RV& r, const XMV& X) {
typedef typename XMV::execution_space execution_space;
const SizeType numRows = static_cast<SizeType>(X.extent(0));
Kokkos::RangePolicy<execution_space, SizeType> policy(0, numRows);
// If the input multivector (2-D View) has only one column, invoke
// the single-vector version of the kernel.
if (X.extent(1) > 1) {
typedef MV_Nrm1_Right_FunctorVector<RV, XMV, SizeType> functor_type;
functor_type op(X);
Kokkos::parallel_reduce("KokkosBlas1::Nrm1::S1", policy, op, r);
}
} |
In general I would suggest looking at what tests are disabled in Kokkos Core when |
Issue is not resolved and no new unit test is enabled
Yes I need to do the similar changes for the |
Fixed the bug in RangePolicy parallel_reduce for array reductions and enabled corresponding tests. |
@lucbv please review the PR update |
…d in jenkins but pass with llvm-13.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rgayatri23 for the changes. It fixes some issues but I now have more build problem with the execute_init_join
method. I have to comment it's implementation to build without failures in Kokkos Kernels. We can tackle that in another PR in my opinion.
@lucbv What issues are you facing in the |
@rgayatri23 |
The PR fixes a bug in the OpenMPTarget backend for array reduction.