Results 1 to 4 of 4

Thread: How to get free memory size on the device?

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    3

    How to get free memory size on the device?

    During the execution of my program the user can change the size of data to be allocated on the device. So program crashes on large sizes of data. Access violation(Windows) or Segmentation fault(Linux) errors are appeared during execution following line:

    Code :
    clCreateBuffer(cxGPUContext, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, new_size * sizeof(float), buffer , &ciErrNum);

    I need to know the maximum size of data that can be allocated.
    Is it any way to know the amount of free memory on the device?

  2. #2

    Re: How to get free memory size on the device?

    Running out of device memory should not produce the error messages you are getting. You are sending in CL_MEM_COPY_HOST_PTR to clCreateBuffer. Are you sure that new_size*sizeof(float) bytes can be read from the 'buffer' pointer your are passing as well?

    Regarding the amount of currently free memory, I don't know any way to do that.

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    4

    Re: How to get free memory size on the device?

    There is a function clGetDeviceInfo (http://www.khronos.org/registry/cl/s...eviceInfo.html), which can be called with flags CL_DEVICE_GLOBAL_MEM_SIZE and CL_DEVICE_LOCAL_MEM_SIZE.
    This gives you the max amount of memory available and then you can keep track of what you've allocated so far. Or at least you could estimate what the max size of data you can handle and either split larger data into chunks or not allow users to go over the limit.
    Also setting env variable CL_LOG_ERRORS to "stdout" gives more meaningful error messages/ warning.

  4. #4
    Junior Member
    Join Date
    Aug 2010
    Posts
    3

    Re: How to get free memory size on the device?

    Thanks a lot for your help. My problem has been fixed.

Similar Threads

  1. Command to free Memory
    By luizdrumond in forum OpenCL
    Replies: 4
    Last Post: 01-08-2013, 07:30 AM
  2. Check for free global memory avaiable
    By nachovall in forum OpenCL
    Replies: 6
    Last Post: 03-09-2011, 06:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •