AnsweredAssumed Answered

opencl clEnqueueNDRangeKernel caused memory leak

Question asked by j0hnny on Jul 20, 2018
Latest reply on Jul 23, 2018 by dipak

Hi, anyone who cares

      I meet with memory leak when calling clEnqueueNDRangeKernel in a deadloop using amd card, below case I used an empty kernel,  but I think this issue is not because of my empty kernel, I ever use matrix add/mul kernel and kernel execution results are right but still meet memory leak.

 

my code looks as below:

      -----------------------------------------code  start------------------------------------------------------------------

      do {

        for (i = 0; i < ciDeviceCount; ++i) {

            ciErrNum = clEnqueueNDRangeKernel(commandQueue[i], matrixEqual, 2, 0, globalWorkSize, localWorkSize,

                   0, NULL, &GPUExecution[i]);

            oclCheckError(ciErrNum, CL_SUCCESS);

            ciErrNum = clFinish(commandQueue[i]);

            oclCheckError(ciErrNum, CL_SUCCESS);

        }

    } while(1);

    -----------------------------------------code  end----------------------------------------------------------------------

 

    and my kernel is an empty kernel

 

-----------------------------------------code  start------------------------------------------------------------------

     __kernel void

     matrixEqual(int m, int n)

     {

         m = n;

     }

  -----------------------------------------code  end----------------------------------------------------------------------

 

     after run many loops, my process's memory consuming rising to 7g and finally killed by the linux kernel.

 

     In /var/log/syslog, it showed that kernel kill the process because out of memory.

     snd kernel: [ 8779.289654] Out of memory: Kill process 5239 (myprocess) score 917 or sacrifice child

 

OS version:

Linux snd 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

 

Part of clinfo:

Platform Version: OpenCL 2.0 AMD-APP (2482.3)

 

  Platform ID: 0x7f19c67e1098

  Name: Ellesmere

  Vendor: Advanced Micro Devices, Inc.

  Device OpenCL C version: OpenCL C 1.2

  Driver version: 2482.3

  Profile: FULL_PROFILE

  Version: OpenCL 1.2 AMD-APP (2482.3)

 

  Device Type: CL_DEVICE_TYPE_GPU

  Vendor ID: 1002h

  Board name: Radeon RX 570 Series

 

Hardware

2 cores Intel(R) Celeron(R) CPU G3930 @ 2.90GHz

8 cards Radeon RX 570 Series

 

I also attach the full code to the post.

Attachments

Outcomes