cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

jeanluca
Journeyman III

CL_DEVICE_GLOBAL_MEM_SIZE is only 32 bytes

Hello

I've written a small program which determines my platform and shows device info. Here is my platform and device info

Platform information:
number of platforms:            1
    name:                        ATI Stream
    vendor:                        Advanced Micro Devices, Inc.
    profile:                    FULL_PROFILE
    version:                    OpenCL 1.0 ATI-Stream-v2.0.0
    extensions:                   

Found 1 device

    Intel(R) Atom(TM) CPU Z530   @ 1.60GHz
    CL_DEVICE_ERROR_CORRECTION_SUPPORT:        no
    CL_DEVICE_MAX_WORK_GROUP_SIZE:            1024
    CL_DEVICE_MAX_COMPUTE_UNITS:            2
    CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:        3
    CL_DEVICE_MAX_WORK_ITEM_SIZES:            3
    CL_DEVICE_MAX_WORK_GROUP_SIZE:            1024
    CL_DEVICE_ADDRESS_BITS:                32
    CL_DEVICE_GLOBAL_MEM_SIZE:            32B
    CL_DEVICE_LOCAL_MEM_TYPE:            global
    CL_DEVICE_LOCAL_MEM_SIZE:            32B
    CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:        32B

Because the sizes for memory are defined in 'bytes' I've added the 'B'. However 32 is not much, I have a system with 1GB (and not all memory is in use), so shouldn't this value be a little bit more ?

I guess with a global mem size of 32 bytes you can't do very much Any suggestions how to fix this ?

 

cheers

Luca

0 Likes
4 Replies
nou
Exemplar

i think you have error in your code. try  run CLInfo from SDK samples.

0 Likes

you're right, CLInfo gives the right size. I've rewritten my program a little bit

 

#include <stddef.h>
#include <CL/cl.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>

int main()
{

  cl_platform_id clSelectedPlatformID = NULL;
  cl_uint num_platforms ;
  cl_int ciErrNum = clGetPlatformIDs (1,&clSelectedPlatformID, &num_platforms);

  cl_uint ciDeviceCount;
  cl_device_id device_id;             // compute device id
  cl_int  err ;

  err = clGetDeviceIDs(clSelectedPlatformID, CL_DEVICE_TYPE_CPU, 1, &device_id, &ciDeviceCount);
  if ( err != CL_SUCCESS)
    {
        printf("Error: Failed to create a device group %d!\n", err);
        exit(EXIT_FAILURE);
    }
  printf("number of devices %d\n", ciDeviceCount) ;
  size_t local ;
  clGetDeviceInfo(device_id, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(size_t), &local, NULL);
  printf("\tCL_DEVICE_GLOBAL_MEM_SIZE:\t\t\t%luB\n", local) ;

  return EXIT_SUCCESS ;
}

But now it prints a size of 0. Any comments on the program ? Furthermore, if I leave the platformID NULL in clGetDeviceIDs I get an error. The documentation says you can, any thought on this ?

 

cheers

0 Likes

yes you can. but "If platform is NULL, the behavior is implementation-defined."

second you get only one device with that code. you must first get count of device with this

clGetDeviceIDs(clSelectedPlatformID, CL_DEVICE_TYPE_ALL, 0, NULL, &ciDeviceCount);

then in ciDeviceCount you get how many devices is in system. every GetInfo call can return size if set 0 in param_value_size and NULL in param_value. then functions return count of item or size in bytes.

0 Likes

what does 'implementation-defined' mean ?

I've fixed the code

....

cl_device_id *devices;
if ((devices = (cl_device_id*)malloc(sizeof(cl_device_id) * ciDeviceCount)) == NULL)
   {
      printf("Failed to allocate memory for devices !!!\n\n") ;
      exit(EXIT_FAILURE) ;
   }

  err = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL, ciDeviceCount, devices, &ciDeviceCount);

....

thnx

0 Likes