Skip to content

Commit

Permalink
change workdivs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehmet Yusufoglu committed Feb 2, 2024
1 parent 085be5f commit 6f4aca3
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
60 changes: 53 additions & 7 deletions benchmarks/babelstream/src/AlpakaStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ struct InitKernel
template<typename T>
void AlpakaStream<T>::init_arrays(T initA, T initB, T initC)
{
auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = alpaka::getValidWorkDiv(devAcc, arraySize);
auto workdiv = alpaka::getValidWorkDiv<Acc>(
devAcc,
arraySize,
alpaka::Vec<Dim, Idx>::ones(),
false,
alpaka::GridBlockExtentSubDivRestrictions::Unrestricted);

alpaka::exec<Acc>(
queue,
workdiv,
Expand Down Expand Up @@ -85,8 +92,14 @@ struct CopyKernel
template<typename T>
void AlpakaStream<T>::copy()
{
auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = alpaka::getValidWorkDiv(devAcc, arraySize);
auto workdiv = alpaka::getValidWorkDiv<Acc>(
devAcc,
arraySize,
alpaka::Vec<Dim, Idx>::ones(),
false,
alpaka::GridBlockExtentSubDivRestrictions::Unrestricted);
alpaka::exec<Acc>(queue, workdiv, CopyKernel{}, alpaka::getPtrNative(d_a), alpaka::getPtrNative(d_c));
alpaka::wait(queue);
}
Expand All @@ -105,8 +118,14 @@ struct MulKernel
template<typename T>
void AlpakaStream<T>::mul()
{
auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = alpaka::getValidWorkDiv(devAcc, arraySize);
auto workdiv = alpaka::getValidWorkDiv<Acc>(
devAcc,
arraySize,
alpaka::Vec<Dim, Idx>::ones(),
false,
alpaka::GridBlockExtentSubDivRestrictions::Unrestricted);
alpaka::exec<Acc>(queue, workdiv, MulKernel{}, alpaka::getPtrNative(d_b), alpaka::getPtrNative(d_c));
alpaka::wait(queue);
}
Expand All @@ -124,8 +143,14 @@ struct AddKernel
template<typename T>
void AlpakaStream<T>::add()
{
auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = alpaka::getValidWorkDiv(devAcc, arraySize);
auto workdiv = alpaka::getValidWorkDiv<Acc>(
devAcc,
arraySize,
alpaka::Vec<Dim, Idx>::ones(),
false,
alpaka::GridBlockExtentSubDivRestrictions::Unrestricted);
alpaka::exec<Acc>(
queue,
workdiv,
Expand All @@ -150,8 +175,14 @@ struct TriadKernel
template<typename T>
void AlpakaStream<T>::triad()
{
auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = alpaka::getValidWorkDiv(devAcc, arraySize);
auto workdiv = alpaka::getValidWorkDiv<Acc>(
devAcc,
arraySize,
alpaka::Vec<Dim, Idx>::ones(),
false,
alpaka::GridBlockExtentSubDivRestrictions::Unrestricted);
alpaka::exec<Acc>(
queue,
workdiv,
Expand All @@ -176,8 +207,16 @@ struct NstreamKernel
template<typename T>
void AlpakaStream<T>::nstream()
{
auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = WorkDiv{arraySize / blockSize, blockSize, 1};
// auto const workdiv = alpaka::getValidWorkDiv(devAcc, arraySize);

auto workdiv = alpaka::getValidWorkDiv<Acc>(
devAcc,
arraySize,
alpaka::Vec<Dim, Idx>::ones(),
false,
alpaka::GridBlockExtentSubDivRestrictions::Unrestricted);

alpaka::exec<Acc>(
queue,
workdiv,
Expand Down Expand Up @@ -222,8 +261,15 @@ struct DotKernel
template<typename T>
auto AlpakaStream<T>::dot() -> T
{
auto const workdiv = WorkDiv{dotBlockSize, blockSize, 1};
// auto const workdiv = WorkDiv{dotBlockSize, blockSize, 1};
// auto const workdiv = alpaka::getValidWorkDiv(devAcc, dotBlockSize * blockSize);
auto workdiv = alpaka::getValidWorkDiv<Acc>(
devAcc,
arraySize,
alpaka::Vec<Dim, Idx>::ones(),
false,
alpaka::GridBlockExtentSubDivRestrictions::Unrestricted);

alpaka::exec<Acc>(
queue,
workdiv,
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/babelstream/src/AlpakaStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ inline constexpr auto IMPLEMENTATION_STRING = "alpaka";
using Dim = alpaka::DimInt<1>;
using Idx = int;
using Vec = alpaka::Vec<Dim, Idx>;
using Acc = alpaka::ExampleDefaultAcc<Dim, Idx>;
using Acc = alpaka::AccGpuCudaRt<Dim, Idx>;

template<typename T>
struct AlpakaStream : Stream<T>
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/babelstream/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void parseArguments(int argc, char* argv[]);

int main(int argc, char* argv[])
{
#if !defined(ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLED)
// #if !defined(ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLED)
parseArguments(argc, argv);

if(!output_as_csv)
Expand All @@ -102,8 +102,8 @@ int main(int argc, char* argv[])
run<float>();
else
run<double>();
#else
#endif
// #else
// #endif
}

// Run the 5 main kernels
Expand Down

0 comments on commit 6f4aca3

Please sign in to comment.