KhronosGroup / KhronosGroup/OpenCL-CTS

out of memory error when testing clCopyImage with max_images in 32bit cts binary

Open
#1,183 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
232
Forks
235
Avg merge
8d 7h
Merged PRs (30d)
18

Description

when I tested clCopyImage with max_images param by using 32bit cts binary, the out of memory error always happened.

But nothing happened when using 64bit cts binary. (8G Physical memory)

The cts process consumes over 2 GB memory. However, the remaining memory available for 32-bit applications is only 1.8 GB.

I check the code at max_images branch , I think the current memory protection constraints are not rigorous enough.

for example:
https://github.com/KhronosGroup/OpenCL-CTS/blob/6f2cd12a0b8d3772e155f2a2b4d399bd534fe382/test_conformance/images/clCopyImage/test_copy_3D.cpp#L125

here has no current memory protection constraints . This problem also exists in 1D, 1D array, and 2D image copy, although these small-sized images are unlikely to exceed memory constraints.

https://github.com/KhronosGroup/OpenCL-CTS/blob/6f2cd12a0b8d3772e155f2a2b4d399bd534fe382/test_conformance/images/clCopyImage/test_copy_3D_2D_array.cpp#L331

here has check dstSize < maxAllocSize && dstSize < ( memSize / 3 ) ) && ( srcSize < maxAllocSize && srcSize < ( memSize / 3 )

However, the memory malloc more than once in the code for src or dst, as shown in the following figure

https://github.com/KhronosGroup/OpenCL-CTS/blob/a483255e504fb0c11bfabd02d627567d7774145a/test_conformance/images/clCopyImage/test_copy_generic.cpp#L319

https://github.com/KhronosGroup/OpenCL-CTS/blob/a483255e504fb0c11bfabd02d627567d7774145a/test_conformance/images/clCopyImage/test_copy_generic.cpp#L322

https://github.com/KhronosGroup/OpenCL-CTS/blob/a483255e504fb0c11bfabd02d627567d7774145a/test_conformance/images/clCopyImage/test_copy_generic.cpp#L58

https://github.com/KhronosGroup/OpenCL-CTS/blob/a483255e504fb0c11bfabd02d627567d7774145a/test_conformance/images/clCopyImage/test_copy_generic.cpp#L87
DDK may also malloc memory for images, especially for devices that share global memory, such as mobile phones.

Therefore, I suggest modifying the memory constraints as follows:

cl_ulong dstSize = get_image_size(&dstImageInfo);
cl_ulong srcSize = get_image_size(&srcImageInfo);
cl_ulong totalSize = (srcSize + dstSize ) * 4;
...
if( dstSize < maxAllocSize srcSize < maxAllocSize && totalSize < ( memSize / 3 ) )
{
....
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in test_conformance/images/clCopyImage/test_copy_3D.cpp and compare its max_images memory checks with test_copy_3D_2D_array.cpp. Then inspect the allocations in test_copy_generic.cpp, including the locations around lines 58, 87, 319, and 322. Done means the max_images paths account for the combined source and destination allocations and avoid the reported 32-bit out-of-memory failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.