Skip to content

Commit

Permalink
Convert OpenMP target variants of reduction kernels to new interface.
Browse files Browse the repository at this point in the history
Note: A RAJA fix is needed to have this compile.
  • Loading branch information
rhornung67 committed Oct 15, 2024
1 parent 7696a9f commit bd434a5
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/algorithm/ATOMIC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class ATOMIC : public KernelBase
void setOpenMPTuningDefinitions(VariantID vid);
void setCudaTuningDefinitions(VariantID vid);
void setHipTuningDefinitions(VariantID vid);
void setOpenMPTargetTuningDefinitions(VariantID vid);

template < size_t replication >
void runSeqVariantReplicate(VariantID vid);
Expand Down
3 changes: 2 additions & 1 deletion src/algorithm/REDUCE_SUM-OMPTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ void REDUCE_SUM::runOpenMPTargetVariant(VariantID vid, size_t RAJAPERF_UNUSED_AR
RAJA::forall<RAJA::omp_target_parallel_for_exec<threads_per_team>>(
RAJA::RangeSegment(ibegin, iend),
RAJA::expt::Reduce<RAJA::operators::plus>(&tsum),
[=] (Index_type i, Real_type& sum) {
[=] (Index_type i,
RAJA::expt::ValOp<Real_type, RAJA::operators::plus>& sum) {
REDUCE_SUM_BODY;
}
);
Expand Down
3 changes: 2 additions & 1 deletion src/basic/PI_REDUCE-OMPTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ void PI_REDUCE::runOpenMPTargetVariant(VariantID vid, size_t RAJAPERF_UNUSED_ARG
RAJA::forall<RAJA::omp_target_parallel_for_exec<threads_per_team>>(
RAJA::RangeSegment(ibegin, iend),
RAJA::expt::Reduce<RAJA::operators::plus>(&tpi),
[=] (Index_type i, Real_type& pi) {
[=] (Index_type i,
RAJA::expt::ValOp<Real_type, RAJA::operators::plus>& pi) {
PI_REDUCE_BODY;
}
);
Expand Down
7 changes: 5 additions & 2 deletions src/basic/REDUCE3_INT-OMPTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ void REDUCE3_INT::runOpenMPTargetVariant(VariantID vid, size_t RAJAPERF_UNUSED_A
RAJA::expt::Reduce<RAJA::operators::plus>(&tvsum),
RAJA::expt::Reduce<RAJA::operators::minimum>(&tvmin),
RAJA::expt::Reduce<RAJA::operators::maximum>(&tvmax),
[=](Index_type i, Int_type& vsum, Int_type& vmin, Int_type& vmax) {
REDUCE3_INT_BODY;
[=](Index_type i,
RAJA::expt::ValOp<Int_type, RAJA::operators::plus>& vsum,
RAJA::expt::ValOp<Int_type, RAJA::operators::minimum>& vmin,
RAJA::expt::ValOp<Int_type, RAJA::operators::maximum>& vmax) {
REDUCE3_INT_BODY_RAJA;
}
);

Expand Down
12 changes: 8 additions & 4 deletions src/basic/REDUCE_STRUCT-OMPTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ void REDUCE_STRUCT::runOpenMPTargetVariant(VariantID vid, size_t RAJAPERF_UNUSED
RAJA::expt::Reduce<RAJA::operators::minimum>(&tymin),
RAJA::expt::Reduce<RAJA::operators::maximum>(&txmax),
RAJA::expt::Reduce<RAJA::operators::maximum>(&tymax),
[=](Index_type i, Real_type& xsum, Real_type& ysum,
Real_type& xmin, Real_type& ymin,
Real_type& xmax, Real_type& ymax) {
REDUCE_STRUCT_BODY;
[=](Index_type i,
RAJA::expt::ValOp<Real_type, RAJA::operators::plus>& xsum,
RAJA::expt::ValOp<Real_type, RAJA::operators::plus>& ysum,
RAJA::expt::ValOp<Real_type, RAJA::operators::minimum>& xmin,
RAJA::expt::ValOp<Real_type, RAJA::operators::minimum>& ymin,
RAJA::expt::ValOp<Real_type, RAJA::operators::maximum>& xmax,
RAJA::expt::ValOp<Real_type, RAJA::operators::maximum>& ymax ) {
REDUCE_STRUCT_BODY_RAJA;
}
);

Expand Down
3 changes: 2 additions & 1 deletion src/basic/TRAP_INT-OMPTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ void TRAP_INT::runOpenMPTargetVariant(VariantID vid, size_t RAJAPERF_UNUSED_ARG(
RAJA::forall<RAJA::omp_target_parallel_for_exec<threads_per_team>>(
RAJA::RangeSegment(ibegin, iend),
RAJA::expt::Reduce<RAJA::operators::plus>(&tsumx),
[=] (Index_type i, Real_type& sumx) {
[=] (Index_type i,
RAJA::expt::ValOp<Real_type, RAJA::operators::plus>& sumx) {
TRAP_INT_BODY;
}
);
Expand Down
15 changes: 8 additions & 7 deletions src/lcals/FIRST_MIN-OMPTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,23 @@ void FIRST_MIN::runOpenMPTargetVariant(VariantID vid, size_t RAJAPERF_UNUSED_ARG

} else if ( vid == RAJA_OpenMPTarget ) {

using VL_TYPE = RAJA::expt::ValLoc<Real_type>;

startTimer();
for (RepIndex_type irep = 0; irep < run_reps; ++irep) {

VL_TYPE tloc(m_xmin_init, m_initloc);
RAJA::expt::ValLoc<Real_type, RAJA::Index_type> tminloc(m_xmin_init,
m_initloc);

RAJA::forall<RAJA::omp_target_parallel_for_exec<threads_per_team>>(
RAJA::RangeSegment(ibegin, iend),
RAJA::expt::Reduce<RAJA::operators::minimum>(&tloc),
[=](Index_type i, VL_TYPE& loc) {
loc.min(x[i], i);
RAJA::expt::Reduce<RAJA::operators::minimum>(&tminloc),
[=](Index_type i,
RAJA::expt::ValLocOp<Real_type, Index_type,
RAJA::operators::minimum>& minloc) {
minloc.minloc(x[i], i);
}
);

m_minloc = static_cast<Index_type>(tloc.getLoc());
m_minloc = static_cast<Index_type>(tminloc.getLoc());

}
stopTimer();
Expand Down
3 changes: 2 additions & 1 deletion src/stream/DOT-OMPTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ void DOT::runOpenMPTargetVariant(VariantID vid, size_t RAJAPERF_UNUSED_ARG(tune_
RAJA::forall<RAJA::omp_target_parallel_for_exec<threads_per_team>>(
RAJA::RangeSegment(ibegin, iend),
RAJA::expt::Reduce<RAJA::operators::plus>(&tdot),
[=] (Index_type i, Real_type& dot) {
[=] (Index_type i,
RAJA::expt::ValOp<Real_type, RAJA::operators::plus>& dot) {
DOT_BODY;
}
);
Expand Down

0 comments on commit bd434a5

Please sign in to comment.