[Beignet] [PATCH 1/2] add built-in function "shuffle2"

Yang, Rong R rong.r.yang at intel.com
Tue Jul 23 19:19:21 PDT 2013


Hi, Homer,

   For shuffle and shuffle2 function, 
gentypen shuffle (gentypem x, ugentypen mask)
gentypen shuffle2 (gentypem x, gentypem y, ugentypen mask)

Is it that x and y's vector size is not relative with return vector's size, for example:
uint4 mask;
float8 a;
float4 b;
b = shuffle(a, mask);

It is legal.

-----Original Message-----
From: beignet-bounces+rong.r.yang=intel.com at lists.freedesktop.org [mailto:beignet-bounces+rong.r.yang=intel.com at lists.freedesktop.org] On Behalf Of Homer Hsing
Sent: Thursday, July 18, 2013 2:48 PM
To: beignet at lists.freedesktop.org
Subject: [Beignet] [PATCH 1/2] add built-in function "shuffle2"


Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
 backend/src/ocl_stdlib.h | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/backend/src/ocl_stdlib.h b/backend/src/ocl_stdlib.h index e0ae5cc..336b789 100644
--- a/backend/src/ocl_stdlib.h
+++ b/backend/src/ocl_stdlib.h
@@ -5539,6 +5539,46 @@ DEF(float)
 #undef DEC4
 #undef DEC8
 #undef DEC16
+
+#define DEC4(TYPE) \
+  INLINE_OVERLOADABLE TYPE##4 shuffle2(TYPE##2 x, TYPE##2 y, uint4 mask) { \
+    TYPE##4 z; \
+    z.s01 = x; \
+    z.s23 = y; \
+    return shuffle(z, mask); \
+  }
+
+#define DEC8(TYPE) \
+  INLINE_OVERLOADABLE TYPE##8 shuffle2(TYPE##4 x, TYPE##4 y, uint8 mask) { \
+    TYPE##8 z; \
+    z.s0123 = x; \
+    z.s4567 = y; \
+    return shuffle(z, mask); \
+  }
+
+#define DEC16(TYPE) \
+  INLINE_OVERLOADABLE TYPE##16 shuffle2(TYPE##8 x, TYPE##8 y, uint16 mask) { \
+    TYPE##16 z; \
+    z.s01234567 = x; \
+    z.s89abcdef = y; \
+    return shuffle(z, mask); \
+  }
+#define DEF(TYPE) \
+  DEC4(TYPE) \
+  DEC8(TYPE) \
+  DEC16(TYPE)
+DEF(char)
+DEF(uchar)
+DEF(short)
+DEF(ushort)
+DEF(int)
+DEF(uint)
+DEF(float)
+#undef DEF
+#undef DEC4
+#undef DEC8
+#undef DEC16
+
 /////////////////////////////////////////////////////////////////////////////
 // Vector loads and stores
 /////////////////////////////////////////////////////////////////////////////
--
1.8.1.2

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list