Results 1 to 7 of 7

Thread: Unexpected output clGetContextInfo

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    6

    Unexpected output clGetContextInfo

    Hi,

    The spec doesn't seem to be clear on this, so I thought I would ask here:

    I have created a context using clCreateContextFromType and CL_DEVICE_TYPE_ALL which returns a non zero context and CL_SUCCESS.

    When querying this context for all devices using clGetContextInfo with CL_CONTEXT_DEVICES i also get CL_SUCCESS, however the returned size and device list do not appear to be correct.

    The problem is:
    The returned data is 32 bit, not 64 and the data is not a valid device.

    The size is 4 bytes, which is half a word on my 64 bit MacBook Pro running Mac OSX Snow Leopard. The size given by sizeof(cl_device_id) is of course 8 bytes. So arguably this is invalid, or the implementation is made for a 32bit machine...? However, if I ignore this, there should be 2 devices returned (CPU+GPU), which queries on the platform indicate. Also ignoring this, the value of the data is always 0x2, which when treated like a device seems to be invalid also (although I was not thorough).

    Has anyone else come across this? Or am I missing something obvious? Perhaps it is a problem with the implementation or current spec?

    Other OpenCL code seems to work, but I would like to be able to query the context like this.

    Platform:
    Name = "Apple";
    Vendor = "Apple";
    Version = "OpenCL 1.0 (May 28 2009 16:54:15)";

    GPU:
    Name = "GeForce 9400M";
    Vendor = "NVIDIA";
    Version = "OpenCL 1.0";

    CPU:
    Name = "Intel(R) Core(TM)2 Duo CPU T9550 @ 2.66GHz";
    Vendor = "Intel";
    Version = "OpenCL 1.0";

  2. #2
    Senior Member
    Join Date
    Sep 2002
    Location
    Santa Clara
    Posts
    105

    Re: Unexpected output clGetContextInfo

    Can you post your test example source that shows this problem?

  3. #3
    Junior Member
    Join Date
    Sep 2009
    Posts
    6

    Re: Unexpected output clGetContextInfo

    This isn't the original code, but a cut down version which exhibits the same behaviour, and with a bit of tracing information.

    Code :
    #include <OpenCL/OpenCL.h>
     
    int main(int argc, char *argv[])
    {
    	cl_int errcode;
     
    	cl_context context = clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL, NULL, NULL, &errcode);
     
    	if (!context)
    	{
    		return errcode;
    	}
     
    	if (errcode != CL_SUCCESS)
    	{
    		clReleaseContext(context);
    		return errcode;
    	}
     
    	size_t devices_size;
    	errcode  = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &devices_size);
     
    	if (errcode != CL_SUCCESS)
    	{
    		clReleaseContext(context);
    		return errcode;
    	}
     
    	printf("sizeof(cl_device_id): %u\n", (unsigned) sizeof(cl_device_id));
    	printf("devices_size: %u\n", (unsigned) devices_size);
     
    	size_t devices_size_ret;
    	cl_device_id * devices = alloca(devices_size);
    	errcode  = clGetContextInfo(context, CL_CONTEXT_DEVICES, devices_size, devices, &devices_size_ret);
     
    	if (errcode != CL_SUCCESS)
    	{
    		clReleaseContext(context);
    		return errcode;
    	}
     
    	printf("devices_size_ret: %u\n", (unsigned) devices_size_ret);
     
    	printf("device data: ");
    	for (unsigned i=0; i<devices_size_ret; ++i)
    	{
    		printf("%X", ((char*)devices)[i]);
    	}
    	printf("\n");
     
    	cl_device_id word = (void*) 2;
    	printf("comparative cl_device_id: ");
    	for (unsigned i=0; i<sizeof(cl_device_id); ++i)
    	{
    		printf("%X", ((char*)&word)[i]);
    	}
    	printf("\n");	
     
    	return 0;
    }

    This is the output from running that code on my machine:
    Code :
    sizeof(cl_device_id): 8
    devices_size: 4
    devices_size_ret: 4
    device data: 2000
    comparative cl_device_id: 20000000

  4. #4
    Junior Member
    Join Date
    Sep 2009
    Posts
    6

    Re: Unexpected output clGetContextInfo

    The addition of this code:
    Code :
    	size_t param_value_size_ret;
    	errcode = clGetDeviceInfo((cl_device_id)((int*)devices)[0], CL_DEVICE_NAME, 0, NULL, &param_value_size_ret);
    	if (errcode == CL_INVALID_DEVICE)
    	{
    		printf("Invalid device: %p", (cl_device_id)((int*)devices)[0]);
    	}
     
    	clReleaseContext(context);

    Provides the following output, (as well as a few expected compiler warnings):
    Code :
    sizeof(cl_device_id): 8
    devices_size: 4
    devices_size_ret: 4
    device data: 2000
    comparative cl_device_id: 20000000
    Invalid device: 0x2

  5. #5
    Senior Member
    Join Date
    Sep 2002
    Location
    Santa Clara
    Posts
    105

    Re: Unexpected output clGetContextInfo

    I ran the posted test source on my MacBook Pro and got the following:

    sizeof(cl_device_id): 8
    devices_size: 16
    devices_size_ret: 16
    device data: 02622000004210000
    comparative cl_device_id: 20000000

    I was unable to reproduce your problem so am wondering what is the version of SnowLeopard you are running. BTW if you have an Apple Developer account, do please file a bug using your ADC account.

  6. #6
    Junior Member
    Join Date
    Sep 2009
    Posts
    6

    Re: Unexpected output clGetContextInfo

    Thanks for trying anyway,

    Snow Leopard build 10A380 until I can find a dual layer DVD to update.

    I have installed XCode Xcode 3.1 2199 from that DVD (snowleopard_10a432_userdvd) dmg.

    However (before I lost my HDD) I had similar problems with the update prior to 10a432, I can't remember the build number.

    The OpenCL version is given from clGetPlatformInfo in my original post as "OpenCL 1.0 (May 28 2009 16:54:15)".

    I have an ADC account and if the problem persists after I update I will submit a bug report. I was hoping it was my error, and not a problem with the build so I could continue work.

  7. #7
    Junior Member
    Join Date
    Sep 2009
    Posts
    6

    Re: Unexpected output clGetContextInfo

    I managed to install the latest build by restoring my Snow Leopard dmg to a spare partition using Disk Utility. Suffice to say that worked, and now the unexpected behaviour I have described has stopped. Yay me for finding a bug, if only it was still relevant.

    Thanks for your help affie.

Posting Permissions

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