cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

spectral
Adept II

float3 size ? and transfert from host to kernel ?

Hi,

In my application I have replace the following struct :

typedef struct { float x, y, z; } Point;

with a float3 like this #define Point float3

But now, it does not work anymore.

At the startup I transfert some "Point" in a memory buffer for the kernel.

In C++ I have the same structure (Point) that I setup and after I transfert it to the kernel.

Does anyone know if I can directly transfert a "float3" like structure (here point) from the host to kernel like this ?



 

Thanks

0 Likes
10 Replies
spectral
Adept II

In my C++ code I have the class Point like this now

class Point { float x,y,z,w; };

Because in cl.h I have :

typedef  cl_float4  cl_float3;

#define CL_ALIGNED

typedef union

{

    cl_float  CL_ALIGNED(16) s[4];

}cl_float4;

and in my kernel code, I have : #define Point float3

But it still not work 😞



0 Likes

 

For information, here are the structures I use :

 

The OPEN CL structures :

 

#define Point float3

typedef struct { float x,y,z; } Vector3;

typedef struct { float u, v; } UV;

typedef struct {

Point o;

Vector3 d;

float mint, maxt;

} Ray;

 

typedef struct {

Point pMin, pMax;

} BBox;

 

typedef struct {

Point P;

Normal N;

UV Tex;

} Vertex;

 

typedef struct {

BBox bbox;

unsigned int primitive;

unsigned int skipIndex;

} BVHAccelArrayNode;

The C++ structures :

 

class Point { float x, y, z, w; };

typedef struct { float x,y,z; } Vector3;

class Ray

{

static const float RAY_EPSILON;

Point d;

Vector3 d;

mutable float mint, maxt;

};

 

class BBox {

Point pMin, pMax;

};

 

typedef struct {

Point P;

Normal N;

UV Tex;

} Vertex;

 

struct BVHAccelArrayNode

{

BBox bbox;

unsigned int primitive;

unsigned int skipIndex;

};

class UV { float u,v; }



0 Likes

A float3 is not the same as a struct { float, float, float}. Make sure that you are using cl_float3 as a host side data type to map to the float3 kernel size data type.
0 Likes

Thanks micah,

1 - The C++ definition of cl_float3 is float  s[4]; under windows. So my Point define as class Point { float x,y,z,w; } is the same !!

2 - What is strange is that even when I change my kernel code and my host code to use the 'w' value, I got problems ! Like this

HOST : class Point { float x,y,z,w; }

Kerne : typedef struct { float x,y,z,w; } Point

Maybe I have an alignment problem ? The addition of a float in the 2 structures should change nothing ? Right ?

0 Likes

Hi,

 

Can someone tell me if I have an alignment problem ?

Because, even when I change the 'Point' structure on both side... I got different results in my application !

0 Likes

viewon1,
If you can get a simple test case that shows the problem we can look into it.
0 Likes

Yes, I can do this...

Where should I send the test case please ?

0 Likes

streamdeveloper@amd.com CC: Micah
0 Likes

 

Hi, I have send an email with a test case to :

streamdeveloper@amd.com

0 Likes

viewon01,

Has this issue been resolved?

Can you provide a simple test case. The code you sent was very large and had some files missing. Also please provide the system configuration you are using. CPU,GPU,SDK,Catalyst & OS.

Thanks

0 Likes