From 9d9a04a912f0c465446d2673644c1c4fde4a0466 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 20 May 2026 15:14:11 -0700 Subject: [PATCH] Add placeholder for new kernel --- src/CMakeLists.txt | 2 + src/apps/CMakeLists.txt | 2 + src/apps/TRANSPORT3DMC-Seq.cpp | 100 +++++++++++++++++++++++++++++++++ src/apps/TRANSPORT3DMC.cpp | 82 +++++++++++++++++++++++++++ src/apps/TRANSPORT3DMC.hpp | 65 +++++++++++++++++++++ src/common/RAJAPerfSuite.cpp | 7 +++ src/common/RAJAPerfSuite.hpp | 1 + 7 files changed, 259 insertions(+) create mode 100644 src/apps/TRANSPORT3DMC-Seq.cpp create mode 100644 src/apps/TRANSPORT3DMC.cpp create mode 100644 src/apps/TRANSPORT3DMC.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cd2fc0dfe..aa2a488f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,6 +47,8 @@ blt_add_executable( NAME raja-perf-omptarget.exe SOURCES RAJAPerfSuiteDriver.cpp apps/AppsData.cpp + apps/TRANSPORT3DMC.cpp + apps/TRANSPORT3DMC-Seq.cpp apps/CONVECTION3DPA.cpp apps/CONVECTION3DPA-Seq.cpp apps/DEL_DOT_VEC_2D.cpp diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index b2b32cce2..d4006abe6 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -10,6 +10,8 @@ blt_add_library( NAME apps SOURCES AppsData.cpp + TRANSPORT3DMC.cpp + TRANSPORT3DMC-Seq.cpp CONVECTION3DPA.cpp CONVECTION3DPA-Cuda.cpp CONVECTION3DPA-Hip.cpp diff --git a/src/apps/TRANSPORT3DMC-Seq.cpp b/src/apps/TRANSPORT3DMC-Seq.cpp new file mode 100644 index 000000000..69e8da99d --- /dev/null +++ b/src/apps/TRANSPORT3DMC-Seq.cpp @@ -0,0 +1,100 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) Lawrence Livermore National Security, LLC and other +// RAJA Project Developers. See top-level LICENSE and COPYRIGHT +// files for dates and other details. No copyright assignment is required +// to contribute to RAJA Performance Suite. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#include "TRANSPORT3DMC.hpp" + +#include "RAJA/RAJA.hpp" + +#include + +namespace rajaperf +{ +namespace apps +{ + + +void TRANSPORT3DMC::runSeqVariant(VariantID vid) +{ + const Index_type run_reps = getRunReps(); + const Index_type ibegin = 0; + const Index_type iend = getActualProblemSize(); + + TRANSPORT3DMC_DATA_SETUP; + +#if defined(RUN_RAJA_SEQ) + auto transport3dmc_lam = [=](Index_type i) { + TRANSPORT3DMC_BODY; + }; +#endif + + switch ( vid ) { + + case Base_Seq : { + + startTimer(); + // Loop counter increment uses macro to quiet C++20 compiler warning + for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) { + + for (Index_type i = ibegin; i < iend; ++i ) { + TRANSPORT3DMC_BODY; + } + + } + stopTimer(); + + break; + } + +#if defined(RUN_RAJA_SEQ) + case Lambda_Seq : { + + startTimer(); + // Loop counter increment uses macro to quiet C++20 compiler warning + for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) { + + for (Index_type i = ibegin; i < iend; ++i ) { + transport3dmc_lam(i); + } + + } + stopTimer(); + + break; + } + + case RAJA_Seq : { + + auto res{getHostResource()}; + + startTimer(); + // Loop counter increment uses macro to quiet C++20 compiler warning + for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) { + + RAJA::forall( res, + RAJA::RangeSegment(ibegin, iend), transport3dmc_lam); + + } + stopTimer(); + + break; + } +#endif // RUN_RAJA_SEQ + + default : { + getCout() << "\n TRANSPORT3DMC : Unknown variant id = " << vid << std::endl; + } + + } + +} + +RAJAPERF_DEFAULT_TUNING_DEFINE_BOILERPLATE(TRANSPORT3DMC, Seq, Base_Seq, Lambda_Seq, RAJA_Seq) + +} // end namespace apps +} // end namespace rajaperf diff --git a/src/apps/TRANSPORT3DMC.cpp b/src/apps/TRANSPORT3DMC.cpp new file mode 100644 index 000000000..91cb0222a --- /dev/null +++ b/src/apps/TRANSPORT3DMC.cpp @@ -0,0 +1,82 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) Lawrence Livermore National Security, LLC and other +// RAJA Project Developers. See top-level LICENSE and COPYRIGHT +// files for dates and other details. No copyright assignment is required +// to contribute to RAJA Performance Suite. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#include "TRANSPORT3DMC.hpp" + +#include "RAJA/RAJA.hpp" + +#include "common/DataUtils.hpp" + +namespace rajaperf +{ +namespace apps +{ + + +TRANSPORT3DMC::TRANSPORT3DMC(const RunParams& params) + : KernelBase(rajaperf::Apps_TRANSPORT3DMC, params) +{ + setDefaultProblemSize(1000000); + setDefaultReps(1000); + + setSize(params.getTargetSize(getDefaultProblemSize()), + params.getReps(getDefaultReps())); + + setChecksumConsistency(ChecksumConsistency::ConsistentPerVariantTuning); + setChecksumTolerance(ChecksumTolerance::tight); + + setComplexity(Complexity::N); + + setMaxPerfectLoopDimensions(1); + setProblemDimensionality(1); + + setUsesFeature(Forall); + + addVariantTunings(); +} + +void TRANSPORT3DMC::setSize(Index_type target_size, Index_type target_reps) +{ + setActualProblemSize( target_size ); + setRunReps( target_reps ); + + setItsPerRep( getActualProblemSize() ); + setKernelsPerRep(1); + + setBytesAllocatedPerRep( 2*sizeof(Real_type) * getActualProblemSize() ); // in, out + setBytesReadPerRep( 1*sizeof(Real_type) * getActualProblemSize() ); // in + setBytesWrittenPerRep( 1*sizeof(Real_type) * getActualProblemSize() ); // out + setBytesModifyWrittenPerRep( 0 ); + setBytesAtomicModifyWrittenPerRep( 0 ); + setFLOPsPerRep( 0 ); +} + +TRANSPORT3DMC::~TRANSPORT3DMC() +{ +} + +void TRANSPORT3DMC::setUp(VariantID vid, size_t RAJAPERF_UNUSED_ARG(tune_idx)) +{ + allocAndInitData(m_in, getActualProblemSize(), vid); + allocAndInitDataConst(m_out, getActualProblemSize(), 0.0, vid); +} + +void TRANSPORT3DMC::updateChecksum(VariantID vid, size_t RAJAPERF_UNUSED_ARG(tune_idx)) +{ + addToChecksum(m_out, getActualProblemSize(), vid); +} + +void TRANSPORT3DMC::tearDown(VariantID vid, size_t RAJAPERF_UNUSED_ARG(tune_idx)) +{ + deallocData(m_in, vid); + deallocData(m_out, vid); +} + +} // end namespace apps +} // end namespace rajaperf diff --git a/src/apps/TRANSPORT3DMC.hpp b/src/apps/TRANSPORT3DMC.hpp new file mode 100644 index 000000000..571a6794e --- /dev/null +++ b/src/apps/TRANSPORT3DMC.hpp @@ -0,0 +1,65 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) Lawrence Livermore National Security, LLC and other +// RAJA Project Developers. See top-level LICENSE and COPYRIGHT +// files for dates and other details. No copyright assignment is required +// to contribute to RAJA Performance Suite. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +/// +/// TRANSPORT3DMC placeholder reference implementation: +/// +/// for (Index_type i = ibegin; i < iend; ++i ) { +/// out[i] = in[i]; +/// } +/// + +#ifndef RAJAPerf_Apps_TRANSPORT3DMC_HPP +#define RAJAPerf_Apps_TRANSPORT3DMC_HPP + + +#define TRANSPORT3DMC_DATA_SETUP \ + Real_ptr in = m_in; \ + Real_ptr out = m_out; + +// Placeholder body. Replace this statement with the target kernel operation. +#define TRANSPORT3DMC_BODY \ + out[i] = in[i]; + + +#include "common/KernelBase.hpp" + +namespace rajaperf +{ +class RunParams; + +namespace apps +{ + +class TRANSPORT3DMC : public KernelBase +{ +public: + + TRANSPORT3DMC(const RunParams& params); + + ~TRANSPORT3DMC(); + + void setSize(Index_type target_size, Index_type target_reps); + void setUp(VariantID vid, size_t tune_idx); + void updateChecksum(VariantID vid, size_t tune_idx); + void tearDown(VariantID vid, size_t tune_idx); + + void defineSeqVariantTunings(); + + void runSeqVariant(VariantID vid); + +private: + Real_ptr m_in; + Real_ptr m_out; +}; + +} // end namespace apps +} // end namespace rajaperf + +#endif // closing endif for header file include guard diff --git a/src/common/RAJAPerfSuite.cpp b/src/common/RAJAPerfSuite.cpp index 2c21d4645..015dc53ee 100644 --- a/src/common/RAJAPerfSuite.cpp +++ b/src/common/RAJAPerfSuite.cpp @@ -83,6 +83,7 @@ // // Apps kernels... // +#include "apps/TRANSPORT3DMC.hpp" #include "apps/CONVECTION3DPA.hpp" #include "apps/DEL_DOT_VEC_2D.hpp" #include "apps/DIFFUSION3DPA.hpp" @@ -243,6 +244,7 @@ static const std::string KernelNames [] = // // Apps kernels... // + std::string("Apps_TRANSPORT3DMC"), std::string("Apps_CONVECTION3DPA"), std::string("Apps_DEL_DOT_VEC_2D"), std::string("Apps_DIFFUSION3DPA"), @@ -1158,6 +1160,11 @@ KernelBase* getKernelObject(KernelID kid, // // Apps kernels... // + case Apps_TRANSPORT3DMC : { + kernel = new apps::TRANSPORT3DMC(run_params); + break; + } + case Apps_CONVECTION3DPA : { kernel = new apps::CONVECTION3DPA(run_params); break; diff --git a/src/common/RAJAPerfSuite.hpp b/src/common/RAJAPerfSuite.hpp index 315e20d46..8506dab57 100644 --- a/src/common/RAJAPerfSuite.hpp +++ b/src/common/RAJAPerfSuite.hpp @@ -143,6 +143,7 @@ enum KernelID { // // Apps kernels... // + Apps_TRANSPORT3DMC, Apps_CONVECTION3DPA, Apps_DEL_DOT_VEC_2D, Apps_DIFFUSION3DPA,