summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@intel.com>2014-06-20 19:09:35 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-06-23 10:33:42 +0800
commit369518b08e58668d8d2b8047dfcca9c4d16d26a6 (patch)
tree0a272240013949559fbdecb982e1c659690b8d98
parent019b690a35907a196f2943699291b35a6b8ea6ab (diff)
downloadbeignet-369518b08e58668d8d2b8047dfcca9c4d16d26a6.tar.gz
GBE: fix some get kernel arg info bugs.
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@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--backend/src/ir/sampler.cpp1
-rw-r--r--backend/src/llvm/llvm_gen_backend.cpp6
-rwxr-xr-xbackend/src/ocl_stdlib.tmpl.h8
-rw-r--r--kernels/test_get_arg_info.cl2
-rw-r--r--src/cl_kernel.c2
5 files changed, 16 insertions, 3 deletions
diff --git a/backend/src/ir/sampler.cpp b/backend/src/ir/sampler.cpp
index 1406ff65..7e8355fd 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 a5aa038b..e6aff278 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 32d87f4b..60cb8ffe 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/kernels/test_get_arg_info.cl b/kernels/test_get_arg_info.cl
index b9201a4f..43a804bc 100644
--- a/kernels/test_get_arg_info.cl
+++ b/kernels/test_get_arg_info.cl
@@ -3,6 +3,6 @@ typedef struct _test_arg_struct {
int b;
}test_arg_struct;
-kernel void test_get_arg_info(global float const volatile *src, local int *dst, test_arg_struct extra) {
+kernel void test_get_arg_info(read_only global float const volatile *src, read_write local int read_only *dst, test_arg_struct extra) {
}
diff --git a/src/cl_kernel.c b/src/cl_kernel.c
index 64ffd5f4..5d0b36e1 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;