OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1663 Discussions

float3 value in struct is reversed when sending to kernel inside structure

mikhail_v_
Beginner
172 Views

OpenCL 1.2.

I have this struct on host side

typedef struct OCLCamData
{
	cl_int id;
	cl_float3 position;
	cl_float3 direction;
	cl_float max_possible_angle;

	OCLCamData(): id(0), position(), direction(), max_possible_angle(0) {}
	OCLCamData(int id_, Point3f position_, Point3f direction_, float max_possible_angle_): id(id_), max_possible_angle(max_possible_angle_) 
	{
		position.x = position_.x; position.y = position_.y; position.z = position_.z; position.w = -1;
		direction.x = direction_.x; direction.y = direction_.y; direction.z = direction_.z; direction.w = -1;
	}
} OCLCamData;

In kernel code I've declared it this way

typedef struct CamData
{
	int id;
	float3 position;
	float3 direction;
	float max_possible_angle;
} CamData;

Running my code on Intel Core i5 I found that values inside float3 are revesed, so 

CamData.position.x == OCLCamData.position.w.

for example

Any ideas?

0 Kudos
1 Reply
mikhail_v_
Beginner
172 Views

After removing float3 on host & device sides all works well

typedef struct CamData
{
	int id;
	float position_x, position_y, position_z;
	float direction_x, direction_y, direction_z;
	float max_possible_angle;
} CamData;

 

Reply