1{$mode objfpc} 2uses 3 ctypes, cl; 4 5const 6 device_str_info : array[1..5] of record id : dword; name : pchar end = 7 ((id: CL_DEVICE_NAME; name : 'CL_DEVICE_NAME'), 8 (id: CL_DEVICE_VENDOR; name : 'CL_DEVICE_VENDOR'), 9 (id: CL_DEVICE_VERSION; name : 'CL_DEVICE_VERSION'), 10 (id: CL_DEVICE_PROFILE; name : 'CL_DEVICE_PROFILE'), 11 (id: CL_DEVICE_EXTENSIONS; name : 'CL_DEVICE_EXTENSIONS')); 12 13 14 15var 16 err : Integer; // error code returned from api calls 17 platformids : pcl_platform_id; 18 platforms : cl_uint; 19 devices : cl_uint; 20 deviceids : pcl_device_id; 21 i,j,k : Integer; 22 buf : array[0..99999] of char; 23 bufwritten : csize_t; 24 25 26begin 27 err:=clGetPlatformIDs(0,nil,@platforms); 28 if (err <> CL_SUCCESS) then 29 begin 30 writeln('Error: Cannot get number of platforms!'); 31 Halt(1); 32 end; 33 getmem(platformids,platforms*sizeof(cl_platform_id)); 34 err:=clGetPlatformIDs(platforms,platformids,nil); 35 if (err <> CL_SUCCESS) then 36 begin 37 writeln('Error: Cannot get platforms!'); 38 Halt(1); 39 end; 40 writeln(platforms,' platform(s) found'); 41 for i:=0 to platforms-1 do 42 begin 43 writeln('Platform info ',i); 44 err:=clGetPlatformInfo(platformids[i],CL_PLATFORM_PROFILE,sizeof(buf),@buf,bufwritten); 45 writeln('PROFILE: ',buf); 46 err:=clGetPlatformInfo(platformids[i],CL_PLATFORM_VERSION,sizeof(buf),@buf,bufwritten); 47 writeln('VERSION: ',buf); 48 err:=clGetPlatformInfo(platformids[i],CL_PLATFORM_NAME,sizeof(buf),@buf,bufwritten); 49 writeln('NAME: ',buf); 50 err:=clGetPlatformInfo(platformids[i],CL_PLATFORM_VENDOR,sizeof(buf),@buf,bufwritten); 51 writeln('VENDOR: ',buf); 52 err:=clGetPlatformInfo(platformids[i],CL_PLATFORM_EXTENSIONS,sizeof(buf),@buf,bufwritten); 53 writeln('EXTENSIONS: ',buf); 54 55 err:=clGetDeviceIDs(platformids[i],CL_DEVICE_TYPE_ALL,0,nil,@devices); 56 if (err <> CL_SUCCESS) then 57 begin 58 writeln('Error: Cannot get number of devices!'); 59 Halt(1); 60 end; 61 writeln(devices,' device(s) found'); 62 getmem(deviceids,devices*sizeof(cl_device_id)); 63 err:=clGetDeviceIDs(platformids[i],CL_DEVICE_TYPE_ALL,devices,deviceids,nil); 64 for j:=0 to devices-1 do 65 begin 66 writeln('Device info ',j); 67 for k:=low(device_str_info) to high(device_str_info) do 68 begin 69 err:=clGetDeviceInfo(deviceids[j],device_str_info[k].id,sizeof(buf),@buf,bufwritten); 70 writeln(device_str_info[k].name,': ',buf); 71 end; 72 err:=clGetDeviceInfo(deviceids[j],CL_DEVICE_MAX_COMPUTE_UNITS,sizeof(buf),@buf,bufwritten); 73 writeln('CL_DEVICE_MAX_COMPUTE_UNITS: ',pdword(@buf)^); 74 err:=clGetDeviceInfo(deviceids[j],CL_DEVICE_IMAGE3D_MAX_WIDTH,sizeof(buf),@buf,bufwritten); 75 writeln('CL_DEVICE_IMAGE3D_MAX_WIDTH: ',pdword(@buf)^); 76 err:=clGetDeviceInfo(deviceids[j],CL_DEVICE_IMAGE3D_MAX_HEIGHT,sizeof(buf),@buf,bufwritten); 77 writeln('CL_DEVICE_IMAGE3D_MAX_HEIGHT: ',pdword(@buf)^); 78 err:=clGetDeviceInfo(deviceids[j],CL_DEVICE_GLOBAL_MEM_SIZE,sizeof(buf),@buf,bufwritten); 79 writeln('CL_DEVICE_GLOBAL_MEM_SIZE: ',pdword(@buf)^); 80 end; 81 end; 82 freemem(platformids); 83end. 84