Skip to content

l_capacity test from basic conformance tests causes CL_OUT_OF_HOST_MEMORY on devices with large CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE #2699

Description

@Zeppopa

Good day!
Encountered this bug when i was testing ROCm OpenCL implementation with Radeon RX 7900 XTX GPU (24 gb)
The l_capacity test in test_progvar.cpp attempts to create a program with a global array of size max_size that is equal to CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE.

err = clGetDeviceInfo(device, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE,
                      sizeof(*max_size_ret), max_size_ret, &return_size);

err |= l_capacity(device, context, queue, max_size);

"uchar var[%zu];"

On devices with very large video memory (e.g., 24GB GPUs), this value can exceed 17 GB.

CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE = 18239350368 bytes (17394.40 MB, 16.99 GB)

When the OpenCL compiler tries to compile a kernel containing: "uchar var[18239350368];" it fails with CL_OUT_OF_HOST_MEMORY during "clCreateKernel" because the compiler cannot handle such a large static array declaration, even though the device theoretically supports it.

$ /usr/bin/test_conformance/basic/test_basic progvar_prog_scope_misc

progvar_prog_scope_misc...

     l_capacity...ERROR: Unable to create kernel! (CL_OUT_OF_HOST_MEMORY from kernelHelpers.cpp:995)

     ERROR: Failed to create program for capacity test! (CL_OUT_OF_HOST_MEMORY from test_progvar.cpp:1618)

When i tried to limit the max_size to 1gb, test passed correctly.

const size_t max_reasonable_size = 1024 * 1024 * 1024;
if (max_size > max_reasonable_size) {
    log_info("max_size (%zu bytes) is too large, running the l_capacity test with the reasonable max_size",max_size);
    err |= l_capacity(device, context, queue, max_reasonable_size); 
} else {
    err |= l_capacity(device, context, queue, max_size);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions