cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

spectral
Adept II

Unable to send the correct cl::Buffer to my kernel !!!

Hi,

I contact you because, since a few days I have a strange bug with my code. What is really strange is that this code is really old and has not changed !

So, I send several cl::Buffer to a kernel and when I "print" the values of this buffer, they are completely ugly !

Here is the code to send the data :

FilmResponse* curve = &FILM_RESPONSE[_controller->FilmResponse];

clBuffer_FilmResponseR = new cl::Buffer(*_context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, sizeof(float) * FILM_RESPONSE_SIZE, (void*)curve->B_R);

//_queue->enqueueWriteBuffer(*_clBuffer_FilmResponseR->GetBuffer(), CL_TRUE, 0, sizeof(float) * FILM_RESPONSE_SIZE, curve->B_R);

_kernel__ToneMapping->setArg(1, *clBuffer_FilmResponseR);

Here is the signature of my kernel :

__kernel

void kernel__ToneMapping(

          __constant __read_only clFilmSettings* filmSettings,

          __global __read_only float* responseCurveR,

          __global __read_only float* responseCurveG,

          __global __read_only float* responseCurveB,

          __global uchar4* rgba,

          __global clIBAccumItem* ibAccum,

          int workAmount)

What is really strange is that I check the values in curve->B_R before sending it to the kernel... and they are correct, so I suppose that my curve->B_R is not corrupted !

I have test this with Intel SDK/NVidia SDK/AMD SDK and I always have this problem. So, it is NOT a SDK bug but something strange is happening on my side 😛

Does someone has an idea ?

0 Likes
1 Solution
spectral
Adept II

Wow,

I have found... the problem is due to an #include "...xxx.h ""

This header file contains some #pragma push(pack...) that are changing some data alignment in memory 😛

Thx

View solution in original post

0 Likes
1 Reply
spectral
Adept II

Wow,

I have found... the problem is due to an #include "...xxx.h ""

This header file contains some #pragma push(pack...) that are changing some data alignment in memory 😛

Thx

0 Likes