Skip to content

Commit

Permalink
Add base case for wg size
Browse files Browse the repository at this point in the history
Fix bug that was causing infinite loop in helper func
  • Loading branch information
hdelan committed Mar 6, 2024
1 parent 2447fe1 commit 3bf3e2d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/ur/ur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ template <typename T> class Result {
static inline void
roundToHighestFactorOfGlobalSize(size_t &ThreadsPerBlockInDim,
const size_t GlobalWorkSizeInDim) {
while (GlobalWorkSizeInDim % ThreadsPerBlockInDim) {
while (ThreadsPerBlockInDim > 1 &&
GlobalWorkSizeInDim % ThreadsPerBlockInDim) {
--ThreadsPerBlockInDim;
}
}
Expand Down Expand Up @@ -359,8 +360,10 @@ static inline void roundToHighestFactorOfGlobalSizeIn3d(

ThreadsPerBlock[0] = std::min(
GlobalSize[0], MaxBlockSize / (ThreadsPerBlock[1] * ThreadsPerBlock[2]));

// Make the X dim a factor of 2
do {
roundToHighestFactorOfGlobalSize(ThreadsPerBlock[0], GlobalSize[0]);
} while (!isPowerOf2(ThreadsPerBlock[0]));
} while (!isPowerOf2(ThreadsPerBlock[0]) && ThreadsPerBlock[0] > 32 &&
--ThreadsPerBlock[0]);
}

0 comments on commit 3bf3e2d

Please sign in to comment.