Does __attribute__((packed)) works correctly ?

Does __attribute__((packed)) works correctly ?

Hi,I'm facing a problem, I have the following structure :typedef struct __attribute__((packed)){float Ks;clSpectrum Cs;float exponent;} ShaderParam_plastic;But when I convert it to :typedef struct __attribute__((packed)){float Kd;clSpectrum Cd;float Ks;clSpectrum Cs;float exponent;} ShaderParam_plastic;I got a crash ! I have checked for the data I send and they are aligned correctly !In fact I use this structure :typedef struct __attribute__((packed)){unsigned int shaderId;union __attribute__((packed)){ShaderParam_emitter emitter;ShaderParam_glass glass;ShaderParam_matte matte;ShaderParam_mirror mirror;ShaderParam_plastic plastic;ShaderParam_Textured_emitter Textured_emitter;ShaderParam_Textured_glass Textured_glass;ShaderParam_Textured_matte Textured_matte;ShaderParam_Textured_mirror Textured_mirror;ShaderParam_transmissive transmissive;} params;} ShaderParameters;Even my union is aligned !!! If the syntax is correct ?

12 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

In the OpenCL spec. page 199, they wrote this :

"You may only specify this attribute on the definition of a enum, struct orunion, not on a typedef which does not also define the enumerated type,structure or union."

Does it mean that I cannot pack a "typedef" ? or that I can write :

typedef struct__attribute__((packed)) MyStruct {...};

But not ?

typedef__attribute__((packed))struct MyStruct {...};

NB:I have replace my typedef with a struct, but it still crash !!!

NB2: I cannot use "align" because my OpenCL code is generated at run-time. So, it is difficult to do and error prone :-P (Also, my buffer is generated from a malloc, then filled at run-time with memcpy !!)

Even with this version of my code ... my soft still got a crash !!!

struct __attribute__((packed)) ShaderParam_transmissive
{
float Ks __attribute__((packed));
clSpectrum Cs __attribute__((packed));
float eta __attribute__((packed));
};
struct __attribute__((packed)) ShaderParametersStruct
{
uint shaderId __attribute__((packed));
union __attribute__((packed)) 
{
struct ShaderParam_emitter emitter;
struct ShaderParam_glass glass;
struct ShaderParam_matte matte;
struct ShaderParam_matte_rough matte_rough;
struct ShaderParam_mirror mirror;
struct ShaderParam_plastic plastic;
struct ShaderParam_Textured_emitter Textured_emitter;
struct ShaderParam_Textured_glass Textured_glass;
struct ShaderParam_Textured_matte Textured_matte;
struct ShaderParam_Textured_mirror Textured_mirror;
struct ShaderParam_transmissive transmissive;
} __attribute__((packed)) params __attribute__((packed));
};

Hi,
Thanks for your post.

There is a documented known issue in the current SDK, which prevents the usage of user defined structures as arguments for kernels. This issue might be solved by passing these structures in OpenCL memory objects.

If the bare definition of a packed structure fails, please letme know, soI can file a bug on this issue.

Thanks
Guy

Thanks,In my kernel I use this :__kernel void __attribute__((vec_type_hint(float4))) RenderPath(
...__constantchar* shaderParametersBuffer
...)and later I access it like this :ShaderParameters shaderParams = *((__constantShaderParameters*)(shaderParametersBuffer + offset));where 'offset' is defined in bytes !!!So, maybe it is not related to this issue ?Regards

Hi,Can you enter a new bug please ? It sounds unrelated ! Or maybe you have a solution !Thanks

Hi,

Can I have any news or help please ?
I'm still trying to fix it, but if the problem come from the SDK I just have to help you to fix it :-P

Thanks a lot

Hi,
Thanks again for your post.

It's an interesting issue, apparently it's a bug in our SDK. I'll open a bug report about this issue.

We'll let you know about any progress.

Thanks
Guy Benyei

Thanks a lot Guy,I can provide you my application if necessary (if Intel agree to sign a Non Disclosure Agreement of course).You can contact me on my email.Regards and thanks for your workKrys

Hi
Is it possible to create simple kernel, not full application that cause the same failure?
This can elimiminate the need to involve legal.
Thanks, SHiri

Right Shiri,

Krys, in addition, I encourage you to join The Intel Visual
Adrenaline Software Development Program
. Log into the
program site and see our community and suooirt offering to visual computing
developers.

As this product is in preview stage, support
through forum is what we offer. Looking forward, we will work to expand our support
offering to provide you the level that you need.

Thanks,

Arnon

Hi,I will take a look at your program, thanks for the information.I have test the new SDK and everything works perfectly !! :-D and even faster.Congratulation for your release... good job :-)So, is it possible to be in touch with a "project manager" in order to discuss some "marketing stuffs" ?Regards

Leave a Comment

Please sign in to add a comment. Not a member? Join today