[Beignet] [PATCH 04/14] Backend: Refine sub group broadcast code for spec
Xiuli Pan
xiuli.pan at intel.com
Wed Oct 12 08:56:34 UTC 2016
From: Pan Xiuli <xiuli.pan at intel.com>
Sub group has only one index with uint type.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
backend/src/libocl/tmpl/ocl_simd.tmpl.cl | 12 ++----------
backend/src/libocl/tmpl/ocl_simd.tmpl.h | 30 +++++++-----------------------
backend/src/llvm/llvm_gen_backend.cpp | 1 +
3 files changed, 10 insertions(+), 33 deletions(-)
diff --git a/backend/src/libocl/tmpl/ocl_simd.tmpl.cl b/backend/src/libocl/tmpl/ocl_simd.tmpl.cl
index 8e22015..245ce8a 100644
--- a/backend/src/libocl/tmpl/ocl_simd.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_simd.tmpl.cl
@@ -38,17 +38,9 @@ uint get_sub_group_size(void)
/* broadcast */
#define BROADCAST_IMPL(GEN_TYPE) \
- OVERLOADABLE GEN_TYPE __gen_ocl_sub_group_broadcast(GEN_TYPE a, size_t local_id); \
- OVERLOADABLE GEN_TYPE sub_group_broadcast(GEN_TYPE a, size_t local_id) { \
+ OVERLOADABLE GEN_TYPE __gen_ocl_sub_group_broadcast(GEN_TYPE a, uint local_id); \
+ OVERLOADABLE GEN_TYPE sub_group_broadcast(GEN_TYPE a, uint local_id) { \
return __gen_ocl_sub_group_broadcast(a, local_id); \
- } \
- OVERLOADABLE GEN_TYPE __gen_ocl_sub_group_broadcast(GEN_TYPE a, size_t local_id_x, size_t local_id_y); \
- OVERLOADABLE GEN_TYPE sub_group_broadcast(GEN_TYPE a, size_t local_id_x, size_t local_id_y) { \
- return __gen_ocl_sub_group_broadcast(a, local_id_x, local_id_y); \
- } \
- OVERLOADABLE GEN_TYPE __gen_ocl_sub_group_broadcast(GEN_TYPE a, size_t local_id_x, size_t local_id_y, size_t local_id_z); \
- OVERLOADABLE GEN_TYPE sub_group_broadcast(GEN_TYPE a, size_t local_id_x, size_t local_id_y, size_t local_id_z) { \
- return __gen_ocl_sub_group_broadcast(a, local_id_x, local_id_y, local_id_z); \
}
BROADCAST_IMPL(int)
diff --git a/backend/src/libocl/tmpl/ocl_simd.tmpl.h b/backend/src/libocl/tmpl/ocl_simd.tmpl.h
index ae3b379..e8dc6f4 100644
--- a/backend/src/libocl/tmpl/ocl_simd.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_simd.tmpl.h
@@ -35,29 +35,13 @@ uint get_sub_group_id(void);
uint get_sub_group_local_id(void);
/* broadcast */
-OVERLOADABLE int sub_group_broadcast(int a, size_t local_id);
-OVERLOADABLE uint sub_group_broadcast(uint a, size_t local_id);
-OVERLOADABLE long sub_group_broadcast(long a, size_t local_id);
-OVERLOADABLE ulong sub_group_broadcast(ulong a, size_t local_id);
-OVERLOADABLE half sub_group_broadcast(half a, size_t local_id);
-OVERLOADABLE float sub_group_broadcast(float a, size_t local_id);
-OVERLOADABLE double sub_group_broadcast(double a, size_t local_id);
-
-OVERLOADABLE int sub_group_broadcast(int a, size_t local_id_x, size_t local_id_y);
-OVERLOADABLE uint sub_group_broadcast(uint a, size_t local_id_x, size_t local_id_y);
-OVERLOADABLE long sub_group_broadcast(long a, size_t local_id_x, size_t local_id_y);
-OVERLOADABLE ulong sub_group_broadcast(ulong a, size_t local_id_x, size_t local_id_y);
-OVERLOADABLE half sub_group_broadcast(half a, size_t local_id_x, size_t local_id_y);
-OVERLOADABLE float sub_group_broadcast(float a, size_t local_id_x, size_t local_id_y);
-OVERLOADABLE double sub_group_broadcast(double a, size_t local_id_x, size_t local_id_y);
-
-OVERLOADABLE int sub_group_broadcast(int a, size_t local_id_x, size_t local_id_y, size_t local_id_z);
-OVERLOADABLE uint sub_group_broadcast(uint a, size_t local_id_x, size_t local_id_y, size_t local_id_z);
-OVERLOADABLE long sub_group_broadcast(long a, size_t local_id_x, size_t local_id_y, size_t local_id_z);
-OVERLOADABLE ulong sub_group_broadcast(ulong a, size_t local_id_x, size_t local_id_y, size_t local_id_z);
-OVERLOADABLE half sub_group_broadcast(half a, size_t local_id_x, size_t local_id_y, size_t local_id_z);
-OVERLOADABLE float sub_group_broadcast(float a, size_t local_id_x, size_t local_id_y, size_t local_id_z);
-OVERLOADABLE double sub_group_broadcast(double a, size_t local_id_x, size_t local_id_y, size_t local_id_z);
+OVERLOADABLE int sub_group_broadcast(int a,uint local_id);
+OVERLOADABLE uint sub_group_broadcast(uint a, uint local_id);
+OVERLOADABLE long sub_group_broadcast(long a, uint local_id);
+OVERLOADABLE ulong sub_group_broadcast(ulong a, uint local_id);
+OVERLOADABLE half sub_group_broadcast(half a, uint local_id);
+OVERLOADABLE float sub_group_broadcast(float a, uint local_id);
+OVERLOADABLE double sub_group_broadcast(double a, uint local_id);
/* reduce add */
OVERLOADABLE int sub_group_reduce_add(int x);
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index 0570766..43c7c4c 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -4047,6 +4047,7 @@ namespace gbe
ctx.SUBGROUP(opcode, getRegister(&I), srcTuple, 1, ir::TYPE_S32);
} else if (opcode == ir::WORKGROUP_OP_BROADCAST) {
int argNum = CS.arg_size();
+ GBE_ASSERT(argNum == 2);
std::vector<ir::Register> src(argNum);
for (int i = 0; i < argNum; i++) {
src[i] = this->getRegister(*(AI++));
--
2.7.4
More information about the Beignet
mailing list