ocl: fix buffer pool small allocations issue (fixes #5815)

pull/5817/head
Alexander Alekhin 9 years ago
parent b2bb7d075a
commit 6f2632ca2e
  1. 10
      modules/core/src/ocl.cpp

@ -3902,7 +3902,7 @@ protected:
if (e.capacity_ >= size) if (e.capacity_ >= size)
{ {
size_t diff = e.capacity_ - size; size_t diff = e.capacity_ - size;
if (diff < size / 8 && (result_pos == reservedEntries_.end() || diff < minDiff)) if (diff < std::max((size_t)4096, size / 8) && (result_pos == reservedEntries_.end() || diff < minDiff))
{ {
minDiff = diff; minDiff = diff;
result_pos = i; result_pos = i;
@ -3941,12 +3941,8 @@ protected:
inline size_t _allocationGranularity(size_t size) inline size_t _allocationGranularity(size_t size)
{ {
// heuristic values // heuristic values
if (size < 1024) if (size < 1024*1024)
return 16; return 4096; // don't work with buffers smaller than 4Kb (hidden allocation overhead issue)
else if (size < 64*1024)
return 64;
else if (size < 1024*1024)
return 4096;
else if (size < 16*1024*1024) else if (size < 16*1024*1024)
return 64*1024; return 64*1024;
else else

Loading…
Cancel
Save