diff --git a/test/unit/grid/src/GridSync.cpp b/test/unit/grid/src/GridSync.cpp index 9be135b69ec..8692ea67134 100644 --- a/test/unit/grid/src/GridSync.cpp +++ b/test/unit/grid/src/GridSync.cpp @@ -54,37 +54,40 @@ TEMPLATE_LIST_TEST_CASE("synchronize", "[gridSync]", alpaka::test::TestAccs) auto const platformAcc = alpaka::Platform{}; auto const devAcc = getDevByIdx(platformAcc, 0u); - - auto const blockThreadExtentMax = alpaka::getAccDevProps(devAcc).m_blockThreadExtentMax; - auto threadsPerBlock = alpaka::elementwise_min( - blockThreadExtentMax, - alpaka::Vec::all(static_cast(GridSyncTestKernel::blockThreadExtentPerDim()))); - - auto elementsPerThread = alpaka::Vec::all(1); - auto blocksPerGrid = alpaka::Vec::all(1); - blocksPerGrid[0] = 200; - - // Allocate memory on the device. - alpaka::Vec, Idx> bufferExtent{ - blocksPerGrid.prod() * threadsPerBlock.prod() * elementsPerThread.prod()}; - auto deviceMemory = alpaka::allocBuf(devAcc, bufferExtent); - - GridSyncTestKernel kernel; - - bool success = false; - - int maxBlocks = alpaka::getMaxActiveBlocks( - devAcc, - kernel, - threadsPerBlock, - elementsPerThread, - &success, - alpaka::getPtrNative(deviceMemory)); - - blocksPerGrid[0] = std::min(static_cast(maxBlocks), blocksPerGrid[0]); - constexpr bool IsCooperative = true; - alpaka::test::KernelExecutionFixture fixture( - alpaka::WorkDivMembers{blocksPerGrid, threadsPerBlock, elementsPerThread}); - - REQUIRE(fixture(kernel, alpaka::getPtrNative(deviceMemory))); + // Check if accelerator supports cooperative launch, don't do anything if it doesn't + if(alpaka::trait::GetAccDevProps::getAccDevProps(devAcc).m_cooperativeLaunch) + { + auto const blockThreadExtentMax = alpaka::getAccDevProps(devAcc).m_blockThreadExtentMax; + auto threadsPerBlock = alpaka::elementwise_min( + blockThreadExtentMax, + alpaka::Vec::all(static_cast(GridSyncTestKernel::blockThreadExtentPerDim()))); + + auto elementsPerThread = alpaka::Vec::all(1); + auto blocksPerGrid = alpaka::Vec::all(1); + blocksPerGrid[0] = 200; + + // Allocate memory on the device. + alpaka::Vec, Idx> bufferExtent{ + blocksPerGrid.prod() * threadsPerBlock.prod() * elementsPerThread.prod()}; + auto deviceMemory = alpaka::allocBuf(devAcc, bufferExtent); + + GridSyncTestKernel kernel; + + bool success = false; + + int maxBlocks = alpaka::getMaxActiveBlocks( + devAcc, + kernel, + threadsPerBlock, + elementsPerThread, + &success, + alpaka::getPtrNative(deviceMemory)); + + blocksPerGrid[0] = std::min(static_cast(maxBlocks), blocksPerGrid[0]); + constexpr bool IsCooperative = true; + alpaka::test::KernelExecutionFixture fixture( + alpaka::WorkDivMembers{blocksPerGrid, threadsPerBlock, elementsPerThread}); + + REQUIRE(fixture(kernel, alpaka::getPtrNative(deviceMemory))); + } }