diff --git a/source/ur/ur.hpp b/source/ur/ur.hpp index cf84bb437d..2cddd11ff7 100644 --- a/source/ur/ur.hpp +++ b/source/ur/ur.hpp @@ -352,7 +352,8 @@ static inline void roundToHighestFactorOfGlobalSizeIn3d( size_t *ThreadsPerBlock, const size_t *GlobalSize, const size_t *MaxBlockDim, const size_t MaxBlockSize, const size_t WorkDim) { - ThreadsPerBlock[0] = std::min(GlobalSize[0], MaxBlockDim[0]); + ThreadsPerBlock[0] = + std::min(GlobalSize[0], std::min(MaxBlockSize, MaxBlockDim[0])); // Make the X dim a factor of 2 do { roundToHighestFactorOfGlobalSize(ThreadsPerBlock[0], GlobalSize[0]);