AnsweredAssumed Answered

Memory-Leak at calling clBuildProgram with Radeon WX9100

Question asked by recoguy on Feb 21, 2018
Latest reply on Sep 3, 2018 by dipak

Running the Code below leads to massive main memory consumption by using Radeon WX9100 with driver Version 18.Q1.

At iteration 1000 my program consumes about 1 GiByte Memory.

I also tested the code with AMD FirePro W8100 and a GTX760 and there was no memory leak.

 

Did I something wrong or can this be a driver bug?

 

 

 

const char szSource[] = "\
    const sampler_t Sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_LINEAR;\n\
    \n\
    __kernel void exampleKernel(\n\
        __read_only image2d_t image,\n\
        __global float* buffer,\n\
        uint4 bufferDim,\n\
        float maxValue,\n\
        float minValue)\n\
    {\n\
        size_t valueX = get_global_id(0);\n\
        size_t valueY = get_global_id(1);\n\
        size_t valueZ = get_global_id(2);\n\
    \n\
        float imageValue = read_imagef(image, Sampler, (float2)(1,1)).x;\n\
    \n\
        size_t index = (valueZ*bufferDim.y+valueY)*bufferDim.x+valueX;\n\
    \n\
        float result = buffer[index];\n\
    \n\
        result = result + imageValue;\n\
        result = clamp(result,minValue,maxValue);\n\
        buffer[index] = result;\n\
    }\n\
    ";

    std::size_t i = 0;
    while(true)
    {
        const char* strings = szSource;
        const size_t lengths = strlen(szSource);
        cl_program program = clCreateProgramWithSource(clContext, 1, &strings, &lengths, &error);

        if(error != CL_SUCCESS || program == NULL)  { std::cerr << "failed to compile program:" << error << std::endl; }

        error = clBuildProgram(program, 1, &clDevice, NULL, NULL, NULL);
        if(error != CL_SUCCESS) { std::cerr << "failed to build program: " << error << std::endl;}

        error = clReleaseProgram(program);
        if(error != CL_SUCCESS)  {std::cerr << "failed to release program: " << error << std::endl; }
        std::cout << i++ << std::endl;
    }










Outcomes