[libclc] r316290 - shared: Implement aligned vector loads (vloada_half)

Jan Vesely via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 22 07:21:56 PDT 2017


Author: jvesely
Date: Sun Oct 22 07:21:56 2017
New Revision: 316290

URL: http://llvm.org/viewvc/llvm-project?rev=316290&view=rev
Log:
shared: Implement aligned vector loads (vloada_half)

Passes newly posted piglits on turks and carrizo
v2: add scalar vloada_half
v3: fix typo

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>

Modified:
    libclc/trunk/generic/include/clc/shared/vload.h
    libclc/trunk/generic/lib/shared/vload.cl
    libclc/trunk/generic/lib/shared/vload_half.inc

Modified: libclc/trunk/generic/include/clc/shared/vload.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/shared/vload.h?rev=316290&r1=316289&r2=316290&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/shared/vload.h (original)
+++ libclc/trunk/generic/include/clc/shared/vload.h Sun Oct 22 07:21:56 2017
@@ -12,22 +12,24 @@
   _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __private) \
   _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __local) \
   _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __constant) \
-  _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global) \
+  _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global)
 
 #define _CLC_VECTOR_VLOAD_PRIM1(PRIM_TYPE) \
-  _CLC_VECTOR_VLOAD_PRIM3(, PRIM_TYPE, PRIM_TYPE) \
+  _CLC_VECTOR_VLOAD_PRIM3(, PRIM_TYPE, PRIM_TYPE)
 
-#define _CLC_VECTOR_VLOAD_PRIM() \
-    _CLC_VECTOR_VLOAD_PRIM1(char) \
-    _CLC_VECTOR_VLOAD_PRIM1(uchar) \
-    _CLC_VECTOR_VLOAD_PRIM1(short) \
-    _CLC_VECTOR_VLOAD_PRIM1(ushort) \
-    _CLC_VECTOR_VLOAD_PRIM1(int) \
-    _CLC_VECTOR_VLOAD_PRIM1(uint) \
-    _CLC_VECTOR_VLOAD_PRIM1(long) \
-    _CLC_VECTOR_VLOAD_PRIM1(ulong) \
-    _CLC_VECTOR_VLOAD_PRIM1(float) \
-    _CLC_VECTOR_VLOAD_PRIM3(_half, half, float)
+// Declare vector load prototypes
+_CLC_VECTOR_VLOAD_PRIM1(char)
+_CLC_VECTOR_VLOAD_PRIM1(uchar)
+_CLC_VECTOR_VLOAD_PRIM1(short)
+_CLC_VECTOR_VLOAD_PRIM1(ushort)
+_CLC_VECTOR_VLOAD_PRIM1(int)
+_CLC_VECTOR_VLOAD_PRIM1(uint)
+_CLC_VECTOR_VLOAD_PRIM1(long)
+_CLC_VECTOR_VLOAD_PRIM1(ulong)
+_CLC_VECTOR_VLOAD_PRIM1(float)
+_CLC_VECTOR_VLOAD_PRIM3(_half, half, float)
+// Use suffix to declare aligned vloada_halfN
+_CLC_VECTOR_VLOAD_PRIM3(a_half, half, float)
 
 #ifdef cl_khr_fp64
 #pragma OPENCL EXTENSION cl_khr_fp64: enable
@@ -38,15 +40,19 @@
   _CLC_VECTOR_VLOAD_PRIM1(half)
 #endif
 
-_CLC_VECTOR_VLOAD_PRIM()
-// Plain vload_half also needs to be declared
+// Scalar vload_half also needs to be declared
 _CLC_VLOAD_DECL(_half, half, float, , __constant)
 _CLC_VLOAD_DECL(_half, half, float, , __global)
 _CLC_VLOAD_DECL(_half, half, float, , __local)
 _CLC_VLOAD_DECL(_half, half, float, , __private)
 
+// Scalar vloada_half is not part of the specs but CTS expects it
+_CLC_VLOAD_DECL(a_half, half, float, , __constant)
+_CLC_VLOAD_DECL(a_half, half, float, , __global)
+_CLC_VLOAD_DECL(a_half, half, float, , __local)
+_CLC_VLOAD_DECL(a_half, half, float, , __private)
+
 #undef _CLC_VLOAD_DECL
 #undef _CLC_VECTOR_VLOAD_DECL
 #undef _CLC_VECTOR_VLOAD_PRIM3
 #undef _CLC_VECTOR_VLOAD_PRIM1
-#undef _CLC_VECTOR_VLOAD_PRIM

Modified: libclc/trunk/generic/lib/shared/vload.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/vload.cl?rev=316290&r1=316289&r2=316290&view=diff
==============================================================================
--- libclc/trunk/generic/lib/shared/vload.cl (original)
+++ libclc/trunk/generic/lib/shared/vload.cl Sun Oct 22 07:21:56 2017
@@ -85,15 +85,21 @@ float __clc_vload_half_float_helper__pri
 	VEC_LOAD8(val.lo, AS) \
 	VEC_LOAD8(val.hi, AS)
 
-#define __FUNC(SUFFIX, VEC_SIZE, TYPE, AS) \
+#define __FUNC(SUFFIX, VEC_SIZE, OFFSET_SIZE, TYPE, AS) \
   _CLC_OVERLOAD _CLC_DEF TYPE vload_half##SUFFIX(size_t offset, const AS half *mem) { \
     offset *= VEC_SIZE; \
     TYPE __tmp; \
     VEC_LOAD##VEC_SIZE(__tmp, AS) \
     return __tmp; \
+  } \
+  _CLC_OVERLOAD _CLC_DEF TYPE vloada_half##SUFFIX(size_t offset, const AS half *mem) { \
+    offset *= OFFSET_SIZE; \
+    TYPE __tmp; \
+    VEC_LOAD##VEC_SIZE(__tmp, AS) \
+    return __tmp; \
   }
 
-#define FUNC(SUFFIX, VEC_SIZE, TYPE, AS) __FUNC(SUFFIX, VEC_SIZE, TYPE, AS)
+#define FUNC(SUFFIX, VEC_SIZE, OFFSET_SIZE, TYPE, AS) __FUNC(SUFFIX, VEC_SIZE, OFFSET_SIZE, TYPE, AS)
 
 #define __CLC_BODY "vload_half.inc"
 #include <clc/math/gentype.inc>

Modified: libclc/trunk/generic/lib/shared/vload_half.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/vload_half.inc?rev=316290&r1=316289&r2=316290&view=diff
==============================================================================
--- libclc/trunk/generic/lib/shared/vload_half.inc (original)
+++ libclc/trunk/generic/lib/shared/vload_half.inc Sun Oct 22 07:21:56 2017
@@ -1,13 +1,23 @@
 #if __CLC_FPSIZE == 32
+
 #ifdef __CLC_VECSIZE
-  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __private);
-  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __local);
-  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __global);
-  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __constant);
+
+#if __CLC_VECSIZE == 3
+#  define __CLC_OFFSET 4
 #else
-  FUNC(, 1, __CLC_GENTYPE, __private);
-  FUNC(, 1, __CLC_GENTYPE, __local);
-  FUNC(, 1, __CLC_GENTYPE, __global);
-  FUNC(, 1, __CLC_GENTYPE, __constant);
+#  define __CLC_OFFSET __CLC_VECSIZE
+#endif
+
+  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __private);
+  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __local);
+  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __global);
+  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __constant);
+
+#undef __CLC_OFFSET
+#else
+  FUNC(, 1, 1, __CLC_GENTYPE, __private);
+  FUNC(, 1, 1, __CLC_GENTYPE, __local);
+  FUNC(, 1, 1, __CLC_GENTYPE, __global);
+  FUNC(, 1, 1, __CLC_GENTYPE, __constant);
 #endif
 #endif




More information about the cfe-commits mailing list