@@ -172,25 +172,44 @@ void init_array(DATA_TYPE* A, DATA_TYPE* B, DATA_TYPE* C, DATA_TYPE* D)
172172
173173
174174void cl_initialization ()
175- {
175+ {
176+ /* Grigori Fursin added support for CK widgets */
177+ int gpgpu_platform_id = 0 ;
178+ int gpgpu_device_id = 0 ;
179+
180+ cl_platform_id * platforms ;
181+ cl_device_id * devices ;
182+
183+ cl_device_id device ;
184+
185+ if (getenv ("CK_GPGPU_PLATFORM_ID" )!= NULL ) gpgpu_platform_id = atol (getenv ("CK_GPGPU_PLATFORM_ID" ));
186+ if (getenv ("CK_GPGPU_DEVICE_ID" )!= NULL ) gpgpu_device_id = atol (getenv ("CK_GPGPU_DEVICE_ID" ));
187+
188+ platforms = (cl_platform_id * ) malloc (sizeof (cl_platform_id ) * gpgpu_platform_id + 1 );
189+ devices = (cl_device_id * ) malloc (sizeof (cl_device_id ) * gpgpu_device_id + 1 );
190+
176191 // Get platform and device information
177- err_code = clGetPlatformIDs (1 , & platform_id , & num_platforms );
192+ err_code = clGetPlatformIDs (15 , platforms , & num_platforms );
178193 if (err_code == CL_SUCCESS ) printf ("number of platforms is %d\n" ,num_platforms );
179194 else printf ("Error getting platform IDs\n" );
180195
181- err_code = clGetPlatformInfo (platform_id ,CL_PLATFORM_NAME , sizeof (str_temp ), str_temp ,NULL );
196+ platform_id = platforms [gpgpu_platform_id ];
197+
198+ err_code = clGetPlatformInfo (platform_id , CL_PLATFORM_NAME , sizeof (str_temp ), str_temp ,NULL );
182199 if (err_code == CL_SUCCESS ) printf ("platform name is %s\n" ,str_temp );
183200 else printf ("Error getting platform name\n" );
184201
185202 err_code = clGetPlatformInfo (platform_id , CL_PLATFORM_VERSION , sizeof (str_temp ), str_temp ,NULL );
186203 if (err_code == CL_SUCCESS ) printf ("platform version is %s\n" ,str_temp );
187204 else printf ("Error getting platform version\n" );
188205
189- err_code = clGetDeviceIDs ( platform_id , CL_DEVICE_TYPE_GPU , 1 , & device_id , & num_devices );
206+ err_code = clGetDeviceIDs (platform_id , CL_DEVICE_TYPE_ALL , 15 , devices , & num_devices );
190207 if (err_code == CL_SUCCESS ) printf ("number of devices is %d\n" , num_devices );
191208 else printf ("Error getting device IDs\n" );
192209
193- err_code = clGetDeviceInfo (device_id ,CL_DEVICE_NAME , sizeof (str_temp ), str_temp ,NULL );
210+ device_id = devices [gpgpu_device_id ];
211+
212+ err_code = clGetDeviceInfo (device_id , CL_DEVICE_NAME , sizeof (str_temp ), str_temp ,NULL );
194213 if (err_code == CL_SUCCESS ) printf ("device name is %s\n" ,str_temp );
195214 else printf ("Error getting device name\n" );
196215
0 commit comments