LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: Incorrect parameters OpenCL  (Read 172 times)

Evan407

  • Newbie
  • *
  • Offline Offline
  • Posts: 42
Incorrect parameters OpenCL
« on: May 28, 2017, 06:10:22 »

Quote
./com/evanstools/opencl/demo/Platform.java:63: error: no suitable method found for clCreateBuffer(long,int,int,ByteBuffer,IntBuffer)
    p.buffer = clCreateBuffer(p.context,CL_MEM_USE_HOST_PTR,size,host_ptr,errcode_ret);
               ^
    method CL10.clCreateBuffer(long,long,double[],int[]) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,float[],int[]) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,int[],int[]) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,short[],int[]) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,ByteBuffer,int[]) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,DoubleBuffer,IntBuffer) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,FloatBuffer,IntBuffer) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,IntBuffer,IntBuffer) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,ShortBuffer,IntBuffer) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,ByteBuffer,IntBuffer) is not applicable
      (actual and formal argument lists differ in length)
    method CL10.clCreateBuffer(long,long,long,IntBuffer) is not applicable
      (actual and formal argument lists differ in length)
1 error
http://evansgame.com/openCL/constant-values.html#org.lwjgl.opencl.CL10.CL_MEM_USE_HOST_PTR
It's not a long it's an int / It's not an int it's a long
Non of them even have 5 parameters.

http://evansgame.com/openCL/opencl-2.2.pdf
From the specification
Quote
5.2 Buffer Objects
A buffer object stores a one-dimensional collection of elements. Elements of a buffer object can be a scalar data type (such
as an int, float), vector data type, or a user-defined structure.
5.2.1 Creating Buffer Objects
A buffer object is created using the following function
Code: [Select]
cl_mem clCreateBuffer(cl_context context,
cl_mem_flags flags,
size_t size,
void *host_ptr,
cl_int *errcode_ret)
...If clCreateBuffer is called with a pointer returned by clSVMAlloc as its host_ptr argument, and
CL_MEM_USE_HOST_PTR is set in its flags argument, clCreateBuffer will succeed and return a valid non-zero buffer
object as long as the size argument to clCreateBuffer is no larger than the size argument passed in the original
clSVMAlloc call.
Logged

spasi

  • Administrator
  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 1852
Re: Incorrect parameters OpenCL
« Reply #1 on: May 28, 2017, 09:04:36 »

The size argument is derived automatically from the data buffer you pass. Such buffers are called auto-sized buffers in LWJGL. All bindings work this way and the benefit is less bugs, less crashes and less things for the developer to worry about.

Functions that do such signature transformations are also exposed with an 'n' prefix (the 'n' means "unsafe") and perfectly match the native signature (with pointer types replaced by Java long of course). So if you need raw access to the native function, it is possible in LWJGL.

You can read more information in the Bindings FAQ of the LWJGL wiki.
Logged