From 10165a56e3b8b681f5778a89e348322662692c05 Mon Sep 17 00:00:00 2001 From: Tapish Date: Mon, 23 Sep 2024 09:30:13 +0200 Subject: [PATCH 1/2] 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, From 70aca453c16f9d6bf686d0b3d0e126dda0571339 Mon Sep 17 00:00:00 2001 From: Tapish Date: Mon, 23 Sep 2024 15:07:59 +0200 Subject: [PATCH 2/2] Remove old exception throw --- include/alpaka/kernel/TaskKernelCpuOmp2Blocks.hpp | 4 ---- include/alpaka/kernel/TaskKernelCpuSerial.hpp | 5 ----- include/alpaka/kernel/TaskKernelCpuTbbBlocks.hpp | 5 ----- 3 files changed, 14 deletions(-) diff --git a/include/alpaka/kernel/TaskKernelCpuOmp2Blocks.hpp b/include/alpaka/kernel/TaskKernelCpuOmp2Blocks.hpp index d1e5f4b0574b..d3e1d396ddd6 100644 --- a/include/alpaka/kernel/TaskKernelCpuOmp2Blocks.hpp +++ b/include/alpaka/kernel/TaskKernelCpuOmp2Blocks.hpp @@ -826,10 +826,6 @@ namespace alpaka // The number of blocks in the grid. TIdx const numBlocksInGrid(gridBlockExtent.prod()); - if(blockThreadExtent.prod() != static_cast(1u)) - { - throw std::runtime_error("Only one thread per block allowed in the OpenMP 2.0 block accelerator!"); - } // Get the OpenMP schedule information for the given kernel and parameter types auto const schedule = std::apply( diff --git a/include/alpaka/kernel/TaskKernelCpuSerial.hpp b/include/alpaka/kernel/TaskKernelCpuSerial.hpp index 2889ac3d2a19..a9a370d1cbba 100644 --- a/include/alpaka/kernel/TaskKernelCpuSerial.hpp +++ b/include/alpaka/kernel/TaskKernelCpuSerial.hpp @@ -79,11 +79,6 @@ namespace alpaka *static_cast const*>(this), blockSharedMemDynSizeBytes); - if(blockThreadExtent.prod() != static_cast(1u)) - { - throw std::runtime_error("A block for the serial accelerator can only ever have one single thread!"); - } - // Execute the blocks serially. meta::ndLoopIncIdx( gridBlockExtent, diff --git a/include/alpaka/kernel/TaskKernelCpuTbbBlocks.hpp b/include/alpaka/kernel/TaskKernelCpuTbbBlocks.hpp index 0bc578ccc5a1..4ca90dd5d3f4 100644 --- a/include/alpaka/kernel/TaskKernelCpuTbbBlocks.hpp +++ b/include/alpaka/kernel/TaskKernelCpuTbbBlocks.hpp @@ -83,11 +83,6 @@ namespace alpaka // The number of blocks in the grid. TIdx const numBlocksInGrid = gridBlockExtent.prod(); - if(blockThreadExtent.prod() != static_cast(1u)) - { - throw std::runtime_error("A block for the TBB accelerator can only ever have one single thread!"); - } - tbb::this_task_arena::isolate( [&] {