From 1bff084127fbd671cfd05b26e418bcc539c909b3 Mon Sep 17 00:00:00 2001 From: Tapish Date: Mon, 23 Sep 2024 09:30:13 +0200 Subject: [PATCH] For a single thread acc if the WorkDiv number of threads per block is more than one, throw a runtime error --- include/alpaka/acc/AccCpuOmp2Blocks.hpp | 7 +++++++ include/alpaka/acc/AccCpuSerial.hpp | 7 +++++++ include/alpaka/acc/AccCpuTbbBlocks.hpp | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/include/alpaka/acc/AccCpuOmp2Blocks.hpp b/include/alpaka/acc/AccCpuOmp2Blocks.hpp index df52d90d03bc..27661f58432a 100644 --- a/include/alpaka/acc/AccCpuOmp2Blocks.hpp +++ b/include/alpaka/acc/AccCpuOmp2Blocks.hpp @@ -189,6 +189,13 @@ namespace alpaka TKernelFnObj const& kernelFnObj, TArgs&&... args) { + if(workDiv.m_blockThreadExtent.prod() != static_cast(1u)) + { + throw std::runtime_error( + "The given work division is not valid for a single thread Acc: " + + getAccName>() + ". Threads per block should be 1!"); + } + return TaskKernelCpuOmp2Blocks( workDiv, kernelFnObj, diff --git a/include/alpaka/acc/AccCpuSerial.hpp b/include/alpaka/acc/AccCpuSerial.hpp index 4a4e8f0621a6..e1b223f89158 100644 --- a/include/alpaka/acc/AccCpuSerial.hpp +++ b/include/alpaka/acc/AccCpuSerial.hpp @@ -182,6 +182,13 @@ namespace alpaka TKernelFnObj const& kernelFnObj, TArgs&&... args) { + if(workDiv.m_blockThreadExtent.prod() != static_cast(1u)) + { + throw std::runtime_error( + "The given work division is not valid for a single thread Acc: " + + getAccName>() + ". Threads per block should be 1!"); + } + return TaskKernelCpuSerial( workDiv, kernelFnObj, diff --git a/include/alpaka/acc/AccCpuTbbBlocks.hpp b/include/alpaka/acc/AccCpuTbbBlocks.hpp index 1d2c7aec5a58..d283523e7a5a 100644 --- a/include/alpaka/acc/AccCpuTbbBlocks.hpp +++ b/include/alpaka/acc/AccCpuTbbBlocks.hpp @@ -183,6 +183,13 @@ namespace alpaka TKernelFnObj const& kernelFnObj, TArgs&&... args) { + if(workDiv.m_blockThreadExtent.prod() != static_cast(1u)) + { + throw std::runtime_error( + "The given work division is not valid for a single thread Acc: " + + getAccName>() + ". Threads per block should be 1!"); + } + return TaskKernelCpuTbbBlocks( workDiv, kernelFnObj,