Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "DeviceContextCL.h"
00032
00033 #include <System/Exception.h>
00034
00035 cmtk::DeviceContextCL::DeviceContextCL()
00036 {
00037 cl_int error = CL_SUCCESS;
00038 this->m_Context = clCreateContextFromType( 0, CL_DEVICE_TYPE_ALL, NULL, NULL, &error );
00039
00040 if ( error != CL_SUCCESS )
00041 {
00042 throw Exception( "clCreateContextFromType() failed" );
00043 }
00044
00045 size_t nDevices = 0;
00046 error = clGetContextInfo( this->m_Context, CL_CONTEXT_DEVICES, 0, NULL, &nDevices );
00047 if ( error != CL_SUCCESS )
00048 {
00049 throw Exception( "clGetContextInfo() failed" );
00050 }
00051
00052 this->m_DeviceIDs.resize( nDevices );
00053
00054 error = clGetContextInfo( this->m_Context, CL_CONTEXT_DEVICES, nDevices, &this->m_DeviceIDs[0], NULL );
00055 if ( error != CL_SUCCESS )
00056 {
00057 throw Exception( "clGetContextInfo() failed" );
00058 }
00059 }
00060
00061 cmtk::DeviceContextCL::~DeviceContextCL()
00062 {
00063 clReleaseContext( this->m_Context );
00064 }