krrishnarraj / clpeak

A tool which profiles OpenCL devices to find their peak capacities
Apache License 2.0
404 stars 113 forks source link

Size of buffer is over maxAllocSize #76

Closed MichalMrozek closed 3 years ago

MichalMrozek commented 3 years ago

In compute tests, following pattern is used: https://github.com/krrishnarraj/clpeak/blob/bcc21dcee48a802cb5301df23bf2062d83db1e6b/src/compute_sp.cpp#L24

uint64_t globalWIs = (devInfo.numCUs) (devInfo.computeWgsPerCU) (devInfo.maxWGSize); uint64_t t = MIN((globalWIs * sizeof(cl_float)), devInfo.maxAllocSize) / sizeof(cl_float); globalWIs = roundToMultipleOf(t, devInfo.maxWGSize);

cl::Buffer outputBuf = cl::Buffer(ctx, CL_MEM_WRITE_ONLY, (globalWIs * sizeof(cl_float)));

t is computed as minimal of globalWIs * sizeof(cl_float) and maxAllocSize, let's assume that maxAllocSize is smaller.

in next line globalWIs is rounded to the next multiple of maxWGSize, it means it may be larger then t which is computed using maxAllocSize.

That will cause the buffer creation to fail, as it will be above maxAllocSize.

krrishnarraj commented 3 years ago

roundToMultipleOf() doesn't round to next multiple, it rounds to an exact or previous multiple. say if t=100 & devInfo.maxWGSize=64, roundToMultipleOf(t, devInfo.maxWGSize) would be 64

MichalMrozek commented 3 years ago

ok thanks for confirmation