<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic float3 value in struct is reversed when sending to kernel inside structure in OpenCL* for CPU</title>
    <link>https://community.intel.com/t5/OpenCL-for-CPU/float3-value-in-struct-is-reversed-when-sending-to-kernel-inside/m-p/1109233#M5255</link>
    <description>&lt;P&gt;OpenCL 1.2.&lt;/P&gt;

&lt;P&gt;I have this struct on host side&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;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;&lt;/PRE&gt;

&lt;P&gt;In kernel code I've declared it this way&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;typedef struct CamData
{
	int id;
	float3 position;
	float3 direction;
	float max_possible_angle;
} CamData;&lt;/PRE&gt;

&lt;P&gt;Running my code on &lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Intel Core i5 I found that values inside float3 are revesed, so&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13.008px; line-height: 19.512px;"&gt;CamData.position.x == &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;OCLCamData.position.w.&lt;/SPAN&gt;&lt;/PRE&gt;

&lt;P&gt;for example&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;Any ideas?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Aug 2016 08:47:10 GMT</pubDate>
    <dc:creator>mikhail_v_</dc:creator>
    <dc:date>2016-08-24T08:47:10Z</dc:date>
    <item>
      <title>float3 value in struct is reversed when sending to kernel inside structure</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/float3-value-in-struct-is-reversed-when-sending-to-kernel-inside/m-p/1109233#M5255</link>
      <description>&lt;P&gt;OpenCL 1.2.&lt;/P&gt;

&lt;P&gt;I have this struct on host side&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;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;&lt;/PRE&gt;

&lt;P&gt;In kernel code I've declared it this way&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;typedef struct CamData
{
	int id;
	float3 position;
	float3 direction;
	float max_possible_angle;
} CamData;&lt;/PRE&gt;

&lt;P&gt;Running my code on &lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Intel Core i5 I found that values inside float3 are revesed, so&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13.008px; line-height: 19.512px;"&gt;CamData.position.x == &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;OCLCamData.position.w.&lt;/SPAN&gt;&lt;/PRE&gt;

&lt;P&gt;for example&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;Any ideas?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 08:47:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/float3-value-in-struct-is-reversed-when-sending-to-kernel-inside/m-p/1109233#M5255</guid>
      <dc:creator>mikhail_v_</dc:creator>
      <dc:date>2016-08-24T08:47:10Z</dc:date>
    </item>
    <item>
      <title>After removing float3 on host</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/float3-value-in-struct-is-reversed-when-sending-to-kernel-inside/m-p/1109234#M5256</link>
      <description>&lt;P&gt;After removing float3 on host &amp;amp; device sides all works well&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;typedef struct CamData
{
	int id;
	float position_x, position_y, position_z;
	float direction_x, direction_y, direction_z;
	float max_possible_angle;
} CamData;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 08:56:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/float3-value-in-struct-is-reversed-when-sending-to-kernel-inside/m-p/1109234#M5256</guid>
      <dc:creator>mikhail_v_</dc:creator>
      <dc:date>2016-08-24T08:56:59Z</dc:date>
    </item>
  </channel>
</rss>

