[Beignet] [PATCH] GBE: fix some get kernel arg info bugs.
Zhigang Gong
zhigang.gong at intel.com
Sun Jun 22 18:30:10 PDT 2014
Still can't handle the sampler_t which is not used actually.
Access qualifier seems broken with llvm 3.3.
Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
backend/src/ir/sampler.cpp | 1 +
backend/src/llvm/llvm_gen_backend.cpp | 6 ++++++
backend/src/ocl_stdlib.tmpl.h | 8 +++++++-
src/cl_kernel.c | 2 +-
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/backend/src/ir/sampler.cpp b/backend/src/ir/sampler.cpp
index 1406ff6..7e8355f 100644
--- a/backend/src/ir/sampler.cpp
+++ b/backend/src/ir/sampler.cpp
@@ -53,6 +53,7 @@ namespace ir {
// type here. Once we switch to the LLVM and use the new data type sampler_t, we can remove this
// work around.
arg->type = ir::FunctionArgument::SAMPLER;
+ arg->info.typeName = "sampler_t";
int32_t id = ctx->getFunction().getArgID(arg);
GBE_ASSERT(id < (1 << __CLK_SAMPLER_ARG_BITS));
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index a5aa038..e6aff27 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -1173,6 +1173,12 @@ namespace gbe
llvmInfo.addrSpace = (cast<ConstantInt>(addrSpaceNode->getOperand(1 + argID)))->getZExtValue();
llvmInfo.typeName = (cast<MDString>(typeNameNode->getOperand(1 + argID)))->getString();
+ if (llvmInfo.typeName.find("image") != std::string::npos &&
+ llvmInfo.typeName.find("*") != std::string::npos) {
+ uint32_t start = llvmInfo.typeName.find("image");
+ uint32_t end = llvmInfo.typeName.find("*");
+ llvmInfo.typeName = llvmInfo.typeName.substr(start, end - start);
+ }
llvmInfo.accessQual = (cast<MDString>(accessQualNode->getOperand(1 + argID)))->getString();
llvmInfo.typeQual = (cast<MDString>(typeQualNode->getOperand(1 + argID)))->getString();
llvmInfo.argName = (cast<MDString>(argNameNode->getOperand(1 + argID)))->getString();
diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
index 32d87f4..60cb8ff 100755
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -85,6 +85,8 @@ DEF(double);
#define __texture __attribute__((address_space(4)))
struct _image1d_t;
typedef __texture struct _image1d_t* __image1d_t;
+struct _image1d_buffer_t;
+typedef __texture struct _image1d_buffer_t* __image1d_buffer_t;
struct _image1d_array_t;
typedef __texture struct _image1d_array_t* __image1d_array_t;
struct _image2d_t;
@@ -96,7 +98,7 @@ typedef __texture struct _image3d_t* __image3d_t;
typedef const ushort __sampler_t;
typedef size_t __event_t;
#define image1d_t __image1d_t
-#define image1d_buffer_t __image1d_t
+#define image1d_buffer_t __image1d_buffer_t
#define image1d_array_t __image1d_array_t
#define image2d_t __image2d_t
#define image2d_array_t __image2d_array_t
@@ -4757,9 +4759,13 @@ INLINE_OVERLOADABLE int __gen_compute_array_index(int index, image2d_array_t ima
DECL_IMAGE(GEN_FIX_1, image1d_t, int4, i)
DECL_IMAGE(GEN_FIX_1, image1d_t, uint4, ui)
DECL_IMAGE(0, image1d_t, float4, f)
+DECL_IMAGE(GEN_FIX_1, image1d_buffer_t, int4, i)
+DECL_IMAGE(GEN_FIX_1, image1d_buffer_t, uint4, ui)
+DECL_IMAGE(0, image1d_buffer_t, float4, f)
// 1D Info
DECL_IMAGE_INFO_COMMON(image1d_t)
+DECL_IMAGE_INFO_COMMON(image1d_buffer_t)
#undef EXPEND_READ_COORD
#undef EXPEND_READ_COORDF
diff --git a/src/cl_kernel.c b/src/cl_kernel.c
index 64ffd5f..5d0b36e 100644
--- a/src/cl_kernel.c
+++ b/src/cl_kernel.c
@@ -227,7 +227,7 @@ cl_get_kernel_arg_info(cl_kernel k, cl_uint arg_index, cl_kernel_arg_info param_
if (!param_value) return CL_SUCCESS;
if ((ulong)ret_info == 0) {
*(cl_kernel_arg_address_qualifier *)param_value = CL_KERNEL_ARG_ADDRESS_PRIVATE;
- } else if ((ulong)ret_info == 1) {
+ } else if ((ulong)ret_info == 1 || (ulong)ret_info == 4) {
*(cl_kernel_arg_address_qualifier *)param_value = CL_KERNEL_ARG_ADDRESS_GLOBAL;
} else if ((ulong)ret_info == 2) {
*(cl_kernel_arg_address_qualifier *)param_value = CL_KERNEL_ARG_ADDRESS_CONSTANT;
--
1.8.3.2
More information about the Beignet
mailing list