Hey,
i was trying to get into OpenCl programming. However the call into clBuildProgram (line 36) fails with an invalid floating point operation and crashes the application. According to the debugger this happens somwhere in a submethod called clSetKernelExecInfo. However this part of the code seems to be part of the OpenCl libary. Is there something i am doing worng or is this an issue of the library? Is there a workaround for this problem?
This is the code so far:
program pOpenClTest;
{$mode objfpc}{$H+}
{$APPTYPE CONSOLE}
uses {$IFDEF UNIX} {$IFDEF UseCThreads}
cthreads, {$ENDIF} {$ENDIF}
Classes,
cl,
ctypes;
{$R *.res}
var
platform: cl_platform_id;
device: cl_device_id;
context: cl_context;
prog: cl_program;
num: cl_uint;
err: cl_int;
str: ansistring;
ptr: PAnsiChar;
len: csize_t;
begin
clGetPlatformIDs(1, @platform, @num);
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, @device, @num);
context := clCreateContext(nil, 1, @device, nil, nil, err);
str := '__kernel void test (__global float* x) { const int i = get_global_id (0); x = i;} ' + #0;
ptr := @str[1];
len := Length(str);
prog := clCreateProgramWithSource(context, 1, @ptr, @len, err);
clBuildProgram(prog, 1, @device, nil, nil, nil);
clReleaseProgram(prog);
clReleaseContext(context);
ReadLn;
end.
(Im trying to get this running on a Radeon RX480 under Windows 10 64 bit.)