const input_buffer = c.clCreateBuffer(context, c.CL_MEM_READ_ONLY, array_size * @sizeOf(c.cl_int), null, &ret);
try handle_error(ret);
defer _ = c.clReleaseMemObject(input_buffer);
const output_buffer = c.clCreateBuffer(context, c.CL_MEM_WRITE_ONLY, array_size * @sizeOf(c.cl_int), null, &ret);
try handle_error(ret);
defer _ = c.clReleaseMemObject(output_buffer);
ret = c.clEnqueueWriteBuffer(
command_queue,
input_buffer,
c.CL_TRUE,
0,
array_size * @sizeOf(c.cl_int),
input_array,
0,
null,
null,
);
// FIXME: input_buffer valid here
try handle_error(ret);
ret = c.clSetKernelArg(kernel, 0, @sizeOf(c.cl_mem), input_buffer);
// FIXME: input_buffer invalid here
std.log.debug("{d}: {s}", .{
ret,
@tagName(@as(CLErrorCode, @enumFromInt(-ret))),
});
if (ret != c.CL_SUCCESS) {
return CLError.SetKernelArgFailed;
}
ret = c.clSetKernelArg(kernel, 1, @sizeOf(c.cl_mem), output_buffer);
// FIXME: output_buffer invalid
try handle_error(ret);
this is the problematic code that is creating the invalid mem objects
I am running on Nixos 24.05 with an intel i3-8145U
I have looked in the docs and this should work but it doesn’t
What am I doing wrong
2