Skip to content

Commit

Permalink
add raja timers to example
Browse files Browse the repository at this point in the history
  • Loading branch information
artv3 committed Dec 26, 2024
1 parent 91a62c0 commit aa28a3c
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions examples/plugin/raja-caliper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <caliper/cali.h>

#include "RAJA/RAJA.hpp"
#include "RAJA/util/Timer.hpp"

/*
* Daxpy Example
Expand All @@ -36,6 +37,10 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))
CALI_CXX_MARK_FUNCTION;
std::cout << "\n\nRAJA daxpy example...\n";

//
auto timer = RAJA::Timer();


//
// Define vector length
//
Expand Down Expand Up @@ -73,10 +78,14 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))

std::memcpy( a, a0, N * sizeof(double) );
{
CALI_CXX_MARK_SCOPE("Running C-version");
timer.start();
CALI_CXX_MARK_SCOPE("CALI: C-version elapsed time");
for (int i = 0; i < N; ++i) {
a[i] += b[i] * c;
}
timer.stop();
RAJA::Timer::ElapsedType etime = timer.elapsed();
std::cout << "C-version elapsed time : " << etime << " seconds" << std::endl;
}

std::memcpy( aref, a, N* sizeof(double) );
Expand All @@ -102,13 +111,18 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))

std::memcpy( a, a0, N * sizeof(double) );

{
{
timer.reset();
timer.start();
RAJA::forall<RAJA::seq_exec>
(RAJA::RangeSegment(0, N),
RAJA::expt::KernelName("RAJA Seq daxpy Kernel"),
[=] (int i) {
a[i] += b[i] * c;
});
timer.stop();
RAJA::Timer::ElapsedType etime = timer.elapsed();
std::cout << "C-version elapsed time : " << etime << " seconds" << std::endl;
}

checkResult(a, aref, N);
Expand All @@ -121,15 +135,21 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))
// RAJA SIMD version.
//
std::cout << "\n Running RAJA SIMD daxpy...\n";

std::memcpy( a, a0, N * sizeof(double) );
RAJA::forall<RAJA::simd_exec>
(RAJA::RangeSegment(0, N),
RAJA::expt::KernelName("RAJA SIMD daxpy Kernel"),
[=] (int i) {
a[i] += b[i] * c;
});
checkResult(a, aref, N);
{
timer.reset();
timer.start();
RAJA::forall<RAJA::simd_exec>
(RAJA::RangeSegment(0, N),
RAJA::expt::KernelName("RAJA SIMD daxpy Kernel"),
[=] (int i) {
a[i] += b[i] * c;
});
timer.stop();
RAJA::Timer::ElapsedType etime = timer.elapsed();
std::cout << "C-version elapsed time : " << etime << " seconds" << std::endl;
checkResult(a, aref, N);
}
//printResult(a, N);


Expand Down

0 comments on commit aa28a3c

Please sign in to comment.