コード例 #1
0
void OclResourceServiceImpl::PrintContextInfo() const
{
  // context and devices available
  if( m_ContextCollection->CanProvideContext() )
  {
    oclPrintDeviceInfo( m_ContextCollection->m_Devices[0] );
  }
}
コード例 #2
0
ファイル: OCL.cpp プロジェクト: jansendup/OpenCL
bool OCL::InitializeContext()
{
	cl_int error;
	printf("Initializing OpenCL context...\n");

	if( !oclGetNVIDIAPlatform(&platformId) )
	{
		printf("Failed to get a platform\n");
		return false;
	}
	printf("Got platform...\n");
	oclPrintPlatformInfo(platformId);

	if( !oclGetSomeGPUDevice(&deviceId, platformId, false) )
	{
		printf("Failed to get a GPU device\n");
		return false;
	}
	printf("Got GPU device...\n");
	oclPrintDeviceInfo(deviceId);

	if( !oclCreateSomeContext(&context, deviceId, platformId, false) )
	{
		printf("Failed to create cl context\n");
		return false;
	}
	printf("Created cl context\n");

	commandQueue = clCreateCommandQueue(context,deviceId,NULL, &error);
	if(error != CL_SUCCESS)
	{
		clReleaseContext(context);
		printf("Failed to create command queue with error code %d (%s)",error, oclErrorString(error));
		return false;
	}
	printf("Created command queue.\n");

	initialized = true;
	return true;
}