diff --git a/sycl/test-e2e/Reduction/reduction_big_data.cpp b/sycl/test-e2e/Reduction/reduction_big_data.cpp index f317bea555d6c..399fed980ae4c 100644 --- a/sycl/test-e2e/Reduction/reduction_big_data.cpp +++ b/sycl/test-e2e/Reduction/reduction_big_data.cpp @@ -20,7 +20,11 @@ size_t getSafeMaxWGSize(size_t MaxWGSize, size_t MemSize, size_t OneElemSize) { size_t MaxNumElems = MemSize / OneElemSize; if ((MaxNumElems & (MaxNumElems - 1)) != 0) MaxNumElems--; // Need 1 additional element in mem if not pow of 2 - return std::min(MaxNumElems / 2, MaxWGSize); + // Match the runtime's reduGetMaxWGSize() for memory-limited reductions. + size_t WGSize = std::min(MaxNumElems, MaxWGSize); + if (WGSize >= 4 && MaxNumElems < MaxWGSize * 2) + WGSize /= 2; + return WGSize; } template @@ -66,15 +70,16 @@ int test(queue &Q, T Identity) { return checkResults(Q, BOp, NDRange, ComputedOut, CorrectOut); } -template struct BigCustomVec : public CustomVec { +template +struct BigCustomVec : public CustomVec { BigCustomVec() : CustomVec() {} BigCustomVec(T X, T Y) : CustomVec(X, Y) {} BigCustomVec(T V) : CustomVec(V) {} - unsigned char OtherData[512 - sizeof(CustomVec)]; + unsigned char OtherData[Size - sizeof(CustomVec)]; }; -template struct BigCustomVecPlus { - using CV = BigCustomVec; +template struct BigCustomVecPlus { + using CV = BigCustomVec; CV operator()(const CV &A, const CV &B) const { return CV(A.X + B.X, A.Y + B.Y); } @@ -89,6 +94,10 @@ int main() { using BCV = BigCustomVec; NumErrors += test>(Q, BCV(0)); + using CV96 = BigCustomVec; + NumErrors += + test>(Q, CV96(0)); + printFinalStatus(NumErrors); return NumErrors; }