Results 1 to 5 of 5

Thread: Problems with deinitialization of intel openCL

  1. #1
    Senior Member
    Join Date
    Oct 2012
    Posts
    166

    Problems with deinitialization of intel openCL

    Hi there,

    can anyone tell me, why intels openCL implementation can't be reinitializied? A Sample for clarification first:
    Code :
    for (int run = 0; run < 10; run++)
    {
    	cl_int iError;
    	cl_uint uiPlatformCount;
    	clGetPlatformIDs(0, nullptr, &uiPlatformCount);
    	cl_platform_id* pPlatformIDs = new cl_platform_id[uiPlatformCount];
    	clGetPlatformIDs(uiPlatformCount, pPlatformIDs, nullptr);
    	for (int i = 0; i < (int)uiPlatformCount; i++)
    	{
    		//für alle Plattformen schauen, was wir an Infos bekommen
    		cl_platform_id pID = pPlatformIDs[i];
    		char cPlatformInfo[1024];
    		iError = clGetPlatformInfo(pID, CL_PLATFORM_NAME, sizeof(cPlatformInfo), cPlatformInfo, nullptr);
    		std::wcout << "  Plattform Name:\t" << cPlatformInfo <<  std::endl;
    		cl_uint uiDeviceCount;
    		iError = clGetDeviceIDs(pID, CL_DEVICE_TYPE_ALL, 0, nullptr, &uiDeviceCount);
    		cl_device_id* pDeviceIDs = new cl_device_id[uiDeviceCount];
    		iError = clGetDeviceIDs(pID, CL_DEVICE_TYPE_ALL, uiDeviceCount, pDeviceIDs, &uiDeviceCount);
    		cl_context ctx;
    		cl_context_properties pContextProperties[3] = {CL_CONTEXT_PLATFORM, (cl_context_properties)pID, 0};
    		ctx = clCreateContext(pContextProperties, uiDeviceCount, pDeviceIDs,
    			nullptr, nullptr, &iError);
    		for (int j = 0; j < (int)uiDeviceCount; j++)
    		{
    			cl_device_id dID = pDeviceIDs[j];
    			cl_command_queue queue = clCreateCommandQueue(ctx, dID, CL_QUEUE_PROFILING_ENABLE, &iError);
    			clReleaseCommandQueue(queue);
    		}
    		clReleaseContext(ctx);
    	}
    }
    In the loop, all OpenCL Devices will be initialized multiple times and will be destructed in the end. So it will take some time to run that loop, because intialization on intel will take some time but it should work in my oppinion. Or do i miss anything here?

    After the first loop, the intel platform can't be initialized.

    Can anyone proof that?

    Regards,
    clint3112

  2. #2
    Senior Member
    Join Date
    Oct 2012
    Posts
    166

    Re: Problems with deinitialization of intel openCL

    Funny that it works with nvidia without problems. And it works with intel when you use it like the following

    Code :
    for (int run = 0; run < 10; run++)
    {
    cl_int iError;
    cl_uint uiPlatformCount;
    clGetPlatformIDs(0, nullptr, &uiPlatformCount);
    cl_platform_id* pPlatformIDs = new cl_platform_id[uiPlatformCount];
    clGetPlatformIDs(uiPlatformCount, pPlatformIDs, nullptr);
    for (int i = 0; i < (int)uiPlatformCount; i++)
    {
    	//für alle Plattformen schauen, was wir an Infos bekommen
    	cl_platform_id pID = pPlatformIDs[i];
    	char cPlatformInfo[1024];
    	iError = clGetPlatformInfo(pID, CL_PLATFORM_NAME, sizeof(cPlatformInfo), cPlatformInfo, nullptr);
    	std::wcout << "  Plattform Name:\t" << cPlatformInfo <<  std::endl;
    	char *sIntel = "Intel";
    	if(strstr(cPlatformInfo, sIntel))
    	{
    		//continue;
    	}
     
    	cl_uint uiDeviceCount;
    	iError = clGetDeviceIDs(pID, CL_DEVICE_TYPE_ALL, 0, nullptr, &uiDeviceCount);
    	cl_device_id* pDeviceIDs = new cl_device_id[uiDeviceCount];
    	iError = clGetDeviceIDs(pID, CL_DEVICE_TYPE_ALL, uiDeviceCount, pDeviceIDs, &uiDeviceCount);
    	cl_context ctx;
    	cl_context_properties pContextProperties[3] = {CL_CONTEXT_PLATFORM, (cl_context_properties)pID, 0};
    	ctx = clCreateContext(pContextProperties, uiDeviceCount, pDeviceIDs,
    		nullptr, nullptr, &iError);
     
    	CString sKernel = _T("__kernel void crunch(float f) {\n float x,y,cs,sn,xx,yy;\n x = 1.0f;\n y = 0.0f;\n cs = cos(2.0f);\n sn = sin(2.0f);\n for (int i=0;i<40000;i++){\n xx = cs * x - sn * y;\n yy = cs * y + sn * x;\n x = xx;\n y = yy;\n }\n \n }\n ");
    	size_t szSourceSize = (size_t) sKernel.GetLength();
    	CStringA saCode = sKernel;
    	const char* cpKernel = saCode;
    	cl_program pclProgram = clCreateProgramWithSource(ctx, 1, &cpKernel, &szSourceSize, &iError);
    	char *pOptions = "-Werror";
    	iError = clBuildProgram(pclProgram, uiDeviceCount, pDeviceIDs, /*nullptr*/pOptions, nullptr, nullptr);
    	const char* kernelName = "crunch";
    	cl_kernel pclKernel = clCreateKernel(pclProgram, kernelName, &iError);
     
    	for (int j = 0; j < (int)uiDeviceCount; j++)
    	{
    		cl_device_id dID = pDeviceIDs[j];
    		cl_command_queue queue = clCreateCommandQueue(ctx, dID, CL_QUEUE_PROFILING_ENABLE, &iError);
    		cl_kernel pclKernel = clCreateKernel(pclProgram, kernelName, &iError);
    		float f = 1.f;
    		iError = clSetKernelArg(pclKernel, 0, sizeof(cl_mem), &f);
    		size_t lws[1] = {256};
    		size_t gws[1] = {256};
    		iError = clEnqueueNDRangeKernel(queue, pclKernel, 1, nullptr,
    			gws, lws, 0,nullptr, nullptr);
    		clReleaseKernel(pclKernel);
    		clReleaseProgram(pclProgram);
    		iError = clReleaseCommandQueue(queue);
    	}
    	iError = clReleaseContext(ctx);
    }
    }

  3. #3

    Re: Problems with deinitialization of intel openCL

    The code looks fine to me, and I had no problems running it on my Intel SDK for OpenCL Applications installation. I'm using 64-bit Windows with the 2012 version of the SDK. What are you using?

  4. #4

    Re: Problems with deinitialization of intel openCL

    Also, you might consider posting Intel-specific issues here:

    http://software.intel.com/en-us/foru...el-opencl-sdk/

  5. #5
    Senior Member
    Join Date
    Oct 2012
    Posts
    166

    Re: Problems with deinitialization of intel openCL

    I reinstalled the sdk and the problem was gone. I donn't know if it could be a problem with nvidia + intel or anything else.

Similar Threads

  1. Replies: 2
    Last Post: 05-08-2012, 03:54 AM
  2. OpenCL Intel x86_64 code generation
    By neonator in forum OpenCL
    Replies: 5
    Last Post: 12-22-2010, 10:54 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
  •