Hi,
In my application I have an OpenCL kernel that search for intersection between a ray and a set of triangles.
I pass the list of triangles as a pointer, (I have up to 100.000 triangles now and can have more...)
But, is there a way to avoid to send all the triangles at each kernel call ?
Theses datas are statics for a same object (I have several objects that contains a set of triangles).
Thanks
You don't have to send the triangles to the device each time you are executing a kernel.
Create a read-only buffer on device and enqueue write data to it only once, then you can re-use that buffer as your input triangle source as many times as you want.
You can also use a constant buffer which may be cached.
Thanks for your answer,
And how can I :
A) create a read-only buffer and access the read only buffer ?
B) create a constant buffer and access the constant buffer ?
Thx
Thanks for the information,
I have try this change and when I allocate the buffer with CL_MEM_READ_ONLY I got an "Invalid Host" error...
When using CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR all is fine.
So, what is the difference ? I use the same pointer !
Thanks
you must use CL_MEM_*_PTR if you pass own pointer to CreateBuffer(); when you do not specify pointer (NULL) then you can not use CL_MEM_*_PTR flag. everything is in the spec. so read it.
It is what I do, I pass a pointer... to my datas !
It sounds that using "CL_MEM_COPY_HOST_PTR" is mandatory... it is not what the specs tell !
When you use CL_MEM_READ_ONLY,CL_MEM_READ_WRITE, CL_MEM_WRITE_ONLY flags, you don't have to specifity a host ptr in clCreateBuffer function. The host_ptr argument should be NULL in that case.
You need to explicitly write data from host_ptr to that buffer by using clEnqueueWriteBuffer function in this case.
The flags which have 'HOST' in it : CL_MEM_USE_HOST_PTR, CL_MEM_COPY_HOST_PTR, CL_MEM_ALLOC_HOST_PTR require a valid data pointer in host memory to allocate a buffer on device.
Thanks a lot for the information and for your help
Regards