From 921c785cc7d76a266dd456be10eb229d7b87cf4e Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 25 Feb 2014 09:09:43 +0000 Subject: [PATCH] * Fixed example so it actually runs (patch by Joao Paulo Schwarz Schuler, bug ID #25768) git-svn-id: trunk@26874 - --- packages/opencl/examples/basicsample.pas | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/opencl/examples/basicsample.pas b/packages/opencl/examples/basicsample.pas index cf6cb58141..6239ec036f 100644 --- a/packages/opencl/examples/basicsample.pas +++ b/packages/opencl/examples/basicsample.pas @@ -92,18 +92,38 @@ var gpu : cl_device_type; tmpd : single; + platformids : Pcl_platform_id; + num_platforms : cl_uint; + begin // Fill our data set with random float values count := DATA_SIZE; for i:=0 to count - 1 do data[i]:= random; + err:=clGetPlatformIDs(0,nil,@num_platforms); + Writeln('clGetPlatformIDs ', num_platforms); + if (err <> CL_SUCCESS) then + begin + writeln('Error: Cannot get number of platforms!'); + Halt(1); + end; + + getmem(platformids,num_platforms*sizeof(cl_platform_id)); + + err := clGetPlatformIDs(num_platforms, platformids, nil); + + if (err <> CL_SUCCESS) then begin + Writeln('Error: Failed to platforms!'); + Halt($FF); + end; + // Connect to a compute device // change CL_DEVICE_TYPE_CPU to CL_DEVICE_TYPE_GPU is you have powerful video (GeForce 8800/8600M or higher) gpu := CL_DEVICE_TYPE_GPU; device_id:=nil; - err := clGetDeviceIDs(nil, gpu, 1, @device_id, nil); + err := clGetDeviceIDs(platformids[0], gpu, 1, @device_id, nil); writeln('clGetDeviceIDs ', err); if (err <> CL_SUCCESS) then begin Writeln('Error: Failed to create a device group!');