[Libclc-dev] [PATCH 2/3] vstore: Add vstore(half) and fixup vstore_half
Jan Vesely via Libclc-dev
libclc-dev at lists.llvm.org
Fri Sep 1 17:31:12 PDT 2017
Add missing undefs
Make helpers amdgpu specific (NVPTX uses different numbering for private AS)
Use clang builtins on clang >= 6
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
needs [PATCH 1/3] Add halfN types and enable fp16 when generating
builtin declarations from Aaron
clang builtins require https://reviews.llvm.org/D37231
Passes vstore_half piglits on turks (clang-6)
Passes vstore_half and vstore(*,half) piglits on carrizo (clang-5)
amdgpu/lib/SOURCES_4.0 | 1 +
amdgpu/lib/SOURCES_5.0 | 1 +
.../lib/shared/vstore_half_helpers.ll | 0
generic/include/clc/shared/vstore.h | 11 +++++-
generic/lib/SOURCES | 1 -
generic/lib/shared/vstore.cl | 43 +++++++++++++++++-----
6 files changed, 45 insertions(+), 12 deletions(-)
create mode 100644 amdgpu/lib/SOURCES_4.0
create mode 100644 amdgpu/lib/SOURCES_5.0
rename {generic => amdgpu}/lib/shared/vstore_half_helpers.ll (100%)
diff --git a/amdgpu/lib/SOURCES_4.0 b/amdgpu/lib/SOURCES_4.0
new file mode 100644
index 0000000..5851798
--- /dev/null
+++ b/amdgpu/lib/SOURCES_4.0
@@ -0,0 +1 @@
+shared/vstore_half_helpers.ll
diff --git a/amdgpu/lib/SOURCES_5.0 b/amdgpu/lib/SOURCES_5.0
new file mode 100644
index 0000000..5851798
--- /dev/null
+++ b/amdgpu/lib/SOURCES_5.0
@@ -0,0 +1 @@
+shared/vstore_half_helpers.ll
diff --git a/generic/lib/shared/vstore_half_helpers.ll b/amdgpu/lib/shared/vstore_half_helpers.ll
similarity index 100%
rename from generic/lib/shared/vstore_half_helpers.ll
rename to amdgpu/lib/shared/vstore_half_helpers.ll
diff --git a/generic/include/clc/shared/vstore.h b/generic/include/clc/shared/vstore.h
index b450491..0e3f694 100644
--- a/generic/include/clc/shared/vstore.h
+++ b/generic/include/clc/shared/vstore.h
@@ -29,7 +29,6 @@
_CLC_VECTOR_VSTORE_PRIM3(_half, half, float)
#ifdef cl_khr_fp64
-#pragma OPENCL EXTENSION cl_khr_fp64: enable
_CLC_VECTOR_VSTORE_PRIM1(double)
_CLC_VECTOR_VSTORE_PRIM3(_half, half, double)
_CLC_VSTORE_DECL(_half, half, double, , __private)
@@ -37,7 +36,17 @@
_CLC_VSTORE_DECL(_half, half, double, , __global)
#endif
+#ifdef cl_khr_fp16
+ _CLC_VECTOR_VSTORE_PRIM1(half)
+#endif
+
_CLC_VECTOR_VSTORE_PRIM()
_CLC_VSTORE_DECL(_half, half, float, , __private)
_CLC_VSTORE_DECL(_half, half, float, , __local)
_CLC_VSTORE_DECL(_half, half, float, , __global)
+
+#undef _CLC_VSTORE_DECL
+#undef _CLC_VECTOR_VSTORE_DECL
+#undef _CLC_VECTOR_VSTORE_PRIM3
+#undef _CLC_VECTOR_VSTORE_PRIM1
+#undef _CLC_VECTOR_VSTORE_PRIM
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 8297480..f665ce2 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -147,7 +147,6 @@ shared/max.cl
shared/min.cl
shared/vload.cl
shared/vstore.cl
-shared/vstore_half_helpers.ll
workitem/get_global_id.cl
workitem/get_global_size.cl
image/get_image_dim.cl
diff --git a/generic/lib/shared/vstore.cl b/generic/lib/shared/vstore.cl
index 2838384..3343c16 100644
--- a/generic/lib/shared/vstore.cl
+++ b/generic/lib/shared/vstore.cl
@@ -50,23 +50,34 @@ VSTORE_TYPES()
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
VSTORE_ADDR_SPACES(double)
#endif
+#ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+ VSTORE_ADDR_SPACES(half)
+#endif
/* vstore_half are legal even without cl_khr_fp16 */
-#define DECLARE_HELPER(STYPE, AS) void __clc_vstore_half_##STYPE##_helper##AS(STYPE, AS half *);
+#if __clang_major__ < 6
+#define DECLARE_HELPER(STYPE, AS, builtin) void __clc_vstore_half_##STYPE##_helper##AS(STYPE, AS half *);
+#else
+#define DECLARE_HELPER(STYPE, AS, __builtin) \
+inline void __clc_vstore_half_##STYPE##_helper##AS(STYPE s, AS half *d) \
+{ \
+ __builtin(s, d); \
+}
+#endif
-DECLARE_HELPER(float, __private);
-DECLARE_HELPER(float, __global);
-DECLARE_HELPER(float, __local);
+DECLARE_HELPER(float, __private, __builtin_store_halff);
+DECLARE_HELPER(float, __global, __builtin_store_halff);
+DECLARE_HELPER(float, __local, __builtin_store_halff);
#ifdef cl_khr_fp64
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-DECLARE_HELPER(double, __private);
-DECLARE_HELPER(double, __global);
-DECLARE_HELPER(double, __local);
+DECLARE_HELPER(double, __private, __builtin_store_half);
+DECLARE_HELPER(double, __global, __builtin_store_half);
+DECLARE_HELPER(double, __local, __builtin_store_half);
#endif
-
#define VEC_STORE1(STYPE, AS, val) __clc_vstore_half_##STYPE##_helper##AS (val, &mem[offset++]);
+
#define VEC_STORE2(STYPE, AS, val) \
VEC_STORE1(STYPE, AS, val.lo) \
VEC_STORE1(STYPE, AS, val.hi)
@@ -94,4 +105,16 @@ DECLARE_HELPER(double, __local);
#define __CLC_BODY "vstore_half.inc"
#include <clc/math/gentype.inc>
-
+#undef __CLC_BODY
+#undef FUNC
+#undef __FUNC
+#undef VEC_LOAD16
+#undef VEC_LOAD8
+#undef VEC_LOAD4
+#undef VEC_LOAD3
+#undef VEC_LOAD2
+#undef VEC_LOAD1
+#undef DECLARE_HELPER
+#undef VSTORE_TYPES
+#undef VSTORE_ADDR_SPACES
+#undef VSTORE_VECTORIZE
--
2.13.5
More information about the Libclc-dev
mailing list