summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPan Xiuli <xiuli.pan@intel.com>2016-03-02 08:12:16 +0800
committerYang Rong <rong.r.yang@intel.com>2016-11-08 20:38:22 +0800
commit0b25bed13e1e4e01b1afaa431f83b97c921a81b4 (patch)
treea013ee9eecd930ae7eee6dbeca353e7a7314ea4c
parentffdc32cb9ba63d1787601ec4398f71542e119205 (diff)
Backend: Add Pipe Builtin support
Add pipe builtin functions. v2: Refine type size to be system determined. v3: Remove legacy code. Signed-off-by: Pan Xiuli <xiuli.pan@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--backend/src/backend/context.cpp5
-rw-r--r--backend/src/backend/gen_reg_allocation.cpp3
-rw-r--r--backend/src/backend/program.h1
-rw-r--r--backend/src/ir/function.cpp1
-rw-r--r--backend/src/ir/function.hpp8
-rw-r--r--backend/src/libocl/CMakeLists.txt2
-rw-r--r--backend/src/libocl/include/ocl.h1
-rw-r--r--backend/src/libocl/include/ocl_pipe.h51
-rw-r--r--backend/src/libocl/src/ocl_pipe.cl296
-rw-r--r--backend/src/llvm/llvm_gen_backend.cpp39
-rw-r--r--backend/src/llvm/llvm_gen_ocl_function.hxx5
-rw-r--r--src/cl_command_queue.c5
-rw-r--r--src/cl_kernel.c5
13 files changed, 414 insertions, 8 deletions
diff --git a/backend/src/backend/context.cpp b/backend/src/backend/context.cpp
index 675dc78f..6c90f6a3 100644
--- a/backend/src/backend/context.cpp
+++ b/backend/src/backend/context.cpp
@@ -498,6 +498,11 @@ namespace gbe
kernel->args[argID].type = GBE_ARG_SAMPLER;
kernel->args[argID].size = sizeof(void*);
break;
+ case ir::FunctionArgument::PIPE:
+ kernel->args[argID].type = GBE_ARG_PIPE;
+ kernel->args[argID].size = sizeof(void*);
+ kernel->args[argID].bti = arg.bti;
+ break;
}
}
}
diff --git a/backend/src/backend/gen_reg_allocation.cpp b/backend/src/backend/gen_reg_allocation.cpp
index 4451efb2..6621e108 100644
--- a/backend/src/backend/gen_reg_allocation.cpp
+++ b/backend/src/backend/gen_reg_allocation.cpp
@@ -1522,7 +1522,8 @@ do { \
const ir::FunctionArgument &arg = this->opaque->ctx.getFunction().getArg(subType);
if (arg.type == ir::FunctionArgument::GLOBAL_POINTER ||
arg.type == ir::FunctionArgument::LOCAL_POINTER ||
- arg.type == ir::FunctionArgument::CONSTANT_POINTER)
+ arg.type == ir::FunctionArgument::CONSTANT_POINTER||
+ arg.type == ir::FunctionArgument::PIPE)
regSize = this->opaque->ctx.getPointerSize();
else
regSize = arg.size;
diff --git a/backend/src/backend/program.h b/backend/src/backend/program.h
index 3ffd05d0..3a13a52f 100644
--- a/backend/src/backend/program.h
+++ b/backend/src/backend/program.h
@@ -55,6 +55,7 @@ enum gbe_arg_type {
GBE_ARG_LOCAL_PTR = 3, // __local
GBE_ARG_IMAGE = 4, // image2d_t, image3d_t
GBE_ARG_SAMPLER = 5, // sampler_t
+ GBE_ARG_PIPE = 6, // pipe
GBE_ARG_INVALID = 0xffffffff
};
diff --git a/backend/src/ir/function.cpp b/backend/src/ir/function.cpp
index 184b32fd..29be0a47 100644
--- a/backend/src/ir/function.cpp
+++ b/backend/src/ir/function.cpp
@@ -357,6 +357,7 @@ namespace ir {
out << "structure." << input.size;
break;
case FunctionArgument::IMAGE: out << "image"; break;
+ case FunctionArgument::PIPE: out << "pipe"; break;
default: break;
}
out << " %" << input.reg << " " << input.name << std::endl;
diff --git a/backend/src/ir/function.hpp b/backend/src/ir/function.hpp
index 5c0cea45..c4de52b6 100644
--- a/backend/src/ir/function.hpp
+++ b/backend/src/ir/function.hpp
@@ -170,8 +170,9 @@ namespace ir {
LOCAL_POINTER = 2, // __local
VALUE = 3, // int, float
STRUCTURE = 4, // struct foo
- IMAGE = 5, // image*d_t
- SAMPLER = 6
+ IMAGE = 5, // image*d_t
+ SAMPLER = 6,
+ PIPE = 7 // pipe
};
struct InfoFromLLVM { // All the info about passed by llvm, using -cl-kernel-arg-info
@@ -235,6 +236,9 @@ namespace ir {
isImage2dT() || isImage2dArrayT() || isImage3dT();
}
+ bool isPipeType() const {
+ return typeQual.compare("pipe") == 0;
+ }
};
/*! Create a function input argument */
diff --git a/backend/src/libocl/CMakeLists.txt b/backend/src/libocl/CMakeLists.txt
index 6082d55b..d975ab86 100644
--- a/backend/src/libocl/CMakeLists.txt
+++ b/backend/src/libocl/CMakeLists.txt
@@ -68,7 +68,7 @@ FOREACH(M ${OCL_COPY_MODULES_12})
COPY_THE_SOURCE(OCL_SOURCE_FILES_12 ${M})
ENDFOREACH(M)
-SET (OCL_COPY_MODULES_20 ocl_vload_20 ocl_atom_20)
+SET (OCL_COPY_MODULES_20 ocl_vload_20 ocl_atom ocl_atom_20 ocl_pipe)
FOREACH(M ${OCL_COPY_MODULES_20})
COPY_THE_HEADER(${M})
COPY_THE_SOURCE(OCL_SOURCE_FILES_20 ${M})
diff --git a/backend/src/libocl/include/ocl.h b/backend/src/libocl/include/ocl.h
index 69a47c74..e6f25679 100644
--- a/backend/src/libocl/include/ocl.h
+++ b/backend/src/libocl/include/ocl.h
@@ -99,6 +99,7 @@
#if (__OPENCL_C_VERSION__ >= 200)
#include "ocl_vload_20.h"
#include "ocl_atom_20.h"
+#include "ocl_pipe.h"
#else
#include "ocl_vload.h"
#include "ocl_atom.h"
diff --git a/backend/src/libocl/include/ocl_pipe.h b/backend/src/libocl/include/ocl_pipe.h
new file mode 100644
index 00000000..349b1dd9
--- /dev/null
+++ b/backend/src/libocl/include/ocl_pipe.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2012 - 2014 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#ifndef __OCL_PIPE_H__
+#define __OCL_PIPE_H__
+
+#include "ocl_types.h"
+#include "ocl_work_group.h"
+#include "ocl_simd.h"
+
+/* The pipe read function. */
+int __read_pipe_2(pipe int p, __generic void* dst);
+int __read_pipe_4(pipe int p, reserve_id_t id, uint index, void* dst);
+reserve_id_t __reserve_read_pipe(pipe int p, uint num);
+void __commit_read_pipe(pipe int p, reserve_id_t rid);
+reserve_id_t __work_group_reserve_read_pipe(pipe int p, uint num);
+void __work_group_commit_read_pipe(pipe int p, reserve_id_t rid);
+reserve_id_t __sub_group_reserve_read_pipe(pipe int p, uint num);
+void __sub_group_commit_read_pipe(pipe int p, reserve_id_t rid);
+
+/* The pipe write function. */
+int __write_pipe_2(pipe int p, __generic void* src);
+int __write_pipe_4(pipe int p, reserve_id_t id, uint index, void* src);
+reserve_id_t __reserve_write_pipe(pipe int p, uint num);
+void __commit_write_pipe(pipe int p, reserve_id_t rid);
+reserve_id_t __work_group_reserve_write_pipe(pipe int p, uint num);
+void __work_group_commit_write_pipe(pipe int p, reserve_id_t rid);
+reserve_id_t __sub_group_reserve_write_pipe(pipe int p, uint num);
+void __sub_group_commit_write_pipe(pipe int p, reserve_id_t rid);
+
+/* The reserve_id_t function. */
+bool is_valid_reserve_id(reserve_id_t rid);
+
+/* The pipe query function. */
+uint __get_pipe_num_packets(pipe int p);
+uint __get_pipe_max_packets(pipe int p);
+#endif
diff --git a/backend/src/libocl/src/ocl_pipe.cl b/backend/src/libocl/src/ocl_pipe.cl
new file mode 100644
index 00000000..7bfd3707
--- /dev/null
+++ b/backend/src/libocl/src/ocl_pipe.cl
@@ -0,0 +1,296 @@
+/*
+ * Copyright © 2012 - 2014 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "ocl_pipe.h"
+#include "ocl_atom.h"
+#include "ocl_workitem.h"
+
+#define PIPE_SUCCESS 0
+#define PIPE_EMPTY -2
+#define PIPE_FULL -3
+#define PIPE_HEADER_SZ 128
+#define PIPE_INDEX_OUTRANGE -4
+#define PIPE_RESERVE_FAIL -5
+#define RID_MAGIC 0xDE
+#define RIDT ushort
+#define DEAD_PTR 0xFFFFFFFF
+
+PURE CONST __global void* __gen_ocl_get_pipe(pipe int p);
+PURE CONST ulong __gen_ocl_get_rid(reserve_id_t rid);
+PURE CONST reserve_id_t __gen_ocl_make_rid(ulong rid);
+
+int __read_pipe_2(pipe int p, __generic void* dst)
+{
+ __global int* pheader = (__global int*)__gen_ocl_get_pipe(p);
+ int data_size = atomic_sub(pheader + 6, 1);
+ if(data_size < 0){
+ atomic_add(pheader + 6, 1);
+ return PIPE_EMPTY; //Check if element exist
+ }
+ __global char* psrc = (__global char*)pheader + PIPE_HEADER_SZ;
+ int pack_num = pheader[0];
+ int pack_size = pheader[1];
+ int pipe_size = pack_num * pack_size;
+ int read_ptr = atomic_add(pheader + 3, 1);
+ if(read_ptr == pack_num - 1)
+ atomic_sub(pheader + 3, pack_num);
+ read_ptr = read_ptr % pack_num;
+ for(int i = 0; i < pack_size ; i++)
+ ((char*)dst)[i] = psrc[i + read_ptr*pack_size];
+ return 0;
+}
+
+int __read_pipe_4(pipe int p, reserve_id_t id, uint index, void* dst)
+{
+ __global int* pheader = (__global int*)__gen_ocl_get_pipe(p);
+ __global char* psrc = (__global char*)pheader + PIPE_HEADER_SZ;
+ ulong uid = __gen_ocl_get_rid(id);
+ RIDT* pid = (RIDT*)&uid;
+ RIDT start_pt = pid[0];
+ RIDT reserve_size = pid[1];
+ if(index > reserve_size) return PIPE_INDEX_OUTRANGE;
+ int pack_num = pheader[0];
+ int pack_size = pheader[1];
+ int read_ptr = (start_pt + index) % pack_num;
+ int offset = read_ptr * pack_size;
+ for(int i = 0; i < pack_size ; i++)
+ ((char*)dst)[i] = psrc[i + offset];
+ return 0;
+}
+
+
+int __write_pipe_2(pipe int p, __generic void* src)
+{
+ __global int* pheader = (__global int*)__gen_ocl_get_pipe(p);
+ int pack_num = pheader[0];
+ int data_size = atomic_add(pheader + 6, 1);
+ if(data_size >= pack_num){
+ atomic_sub(pheader + 6, 1);
+ return PIPE_FULL; //Check if pipe full
+ }
+ __global char* psrc = (__global char*)pheader + PIPE_HEADER_SZ;
+ int pack_size = pheader[1];
+ int pipe_size = pack_num * pack_size;
+ int write_ptr = atomic_add(pheader + 2, 1);
+ if(write_ptr == pack_num - 1)
+ atomic_sub(pheader + 2, pack_num);
+ write_ptr = write_ptr % pack_num;
+ for(int i = 0; i < pack_size ; i++)
+ psrc[i + write_ptr * pack_size] = ((char*)src)[i];
+ return 0;
+}
+
+int __write_pipe_4(pipe int p, reserve_id_t id, uint index, void* src)
+{
+ __global int* pheader = __gen_ocl_get_pipe(p);
+ __global char* psrc = (__global char*)pheader + PIPE_HEADER_SZ;
+ ulong uid = __gen_ocl_get_rid(id);
+ RIDT* pid = (RIDT*)&uid;
+ RIDT start_pt = pid[0];
+ RIDT reserve_size = pid[1];
+ if(index > reserve_size) return PIPE_INDEX_OUTRANGE;
+ int pack_num = pheader[0];
+ int pack_size = pheader[1];
+ int write_ptr = (start_pt + index) % pack_num;
+ int offset = write_ptr * pack_size;
+ for(int i = 0; i < pack_size ; i++)
+ psrc[i + offset] = ((char*)src)[i];
+ return pack_size;
+}
+
+reserve_id_t __reserve_read_pipe(pipe int p, uint num)
+{
+ __global int* pheader = (__global int*)__gen_ocl_get_pipe(p);
+ int data_size = atomic_sub(pheader + 6, num);
+ if(data_size < num){
+ atomic_add(pheader + 6, num);
+ return __gen_ocl_make_rid(0l);
+ }
+ int pack_num = pheader[0];
+ int pack_size = pheader[1];
+ int pipe_size = pack_num * pack_size;
+ int read_ptr = atomic_add(pheader + 3, num);
+ if(read_ptr == pack_num - num)
+ atomic_sub(pheader + 3, pack_num);
+ ulong uid = 0l;
+ RIDT* pid = (RIDT*)&uid;
+ pid[0] = read_ptr % pack_num;
+ pid[1] = num;
+ pid[2] = RID_MAGIC ;
+ return __gen_ocl_make_rid(uid);
+}
+
+void __commit_read_pipe(pipe int p, reserve_id_t rid) {}
+
+reserve_id_t __work_group_reserve_read_pipe(pipe int p, uint num)
+{
+ uint rid_ptr = DEAD_PTR;
+ int ret0 = 0;
+ if(get_local_linear_id()==0){
+ __global int* pheader = (__global int*)__gen_ocl_get_pipe(p);
+ int data_size = atomic_sub(pheader + 6, num);
+ if(data_size < num){
+ atomic_add(pheader + 6, num);
+ int ret0 = 1;
+ }
+ int pack_num = pheader[0];
+ int pack_size = pheader[1];
+ int pipe_size = pack_num * pack_size;
+ int read_ptr = atomic_add(pheader + 3, num);
+ if(read_ptr == pack_num - num && !ret0)
+ atomic_sub(pheader + 3, pack_num);
+ if(!ret0)
+ rid_ptr = read_ptr % pack_num;
+ }
+ ulong uid = 0l;
+ RIDT* pid = (RIDT*)&uid;
+ rid_ptr = work_group_broadcast(rid_ptr,0,0,0);
+ pid[0] = rid_ptr;
+ pid[1] = num;
+ pid[2] = RID_MAGIC ;
+ if(rid_ptr == DEAD_PTR)
+ uid = 0l;
+ return __gen_ocl_make_rid(uid);
+}
+
+void __work_group_commit_read_pipe(pipe int p, reserve_id_t rid) {}
+
+reserve_id_t __sub_group_reserve_read_pipe(pipe int p, uint num)
+{
+ __global int* pheader = (__global int*)__gen_ocl_get_pipe(p);
+ int data_size = atomic_sub(pheader + 6, num);
+ if(data_size < num){
+ atomic_add(pheader + 6, num);
+ return __gen_ocl_make_rid(0l);
+ }
+ int pack_num = pheader[0];
+ int pack_size = pheader[1];
+ int pipe_size = pack_num * pack_size;
+ int read_ptr = atomic_add(pheader + 3, num);
+ if(read_ptr == pack_num - num)
+ atomic_sub(pheader + 3, pack_num);
+ ulong uid = 0l;
+ RIDT* pid = (RIDT*)&uid;
+ pid[0] = read_ptr % pack_num;
+ pid[1] = num;
+ pid[2] = RID_MAGIC ;
+ return __gen_ocl_make_rid(uid);
+}
+
+void __sub_group_commit_read_pipe(pipe int p, reserve_id_t rid) {}
+
+reserve_id_t __reserve_write_pipe(pipe int p, uint num)
+{
+ __global int* pheader = (__global int*)__gen_ocl_get_pipe(p);
+ int pack_num = pheader[0];
+ int data_size = atomic_add(pheader + 6, num);
+ if(data_size > pack_num - num){
+ atomic_sub(pheader + 6, num);
+ return __gen_ocl_make_rid(0l);
+ }
+ int pack_size = pheader[1];
+ int pipe_size = pack_num * pack_size;
+ int write_ptr = atomic_add(pheader + 2, num);
+ if(write_ptr == pack_num - num)
+ atomic_sub(pheader + 2, pack_num);
+ ulong uid = 0l;
+ RIDT* pid = (RIDT*)&uid;
+ pid[0] = write_ptr % pack_num;
+ pid[1] = num;
+ pid[2] = RID_MAGIC ;
+ return __gen_ocl_make_rid(uid);
+}
+void __commit_write_pipe(pipe int p, reserve_id_t rid) {}
+
+reserve_id_t __work_group_reserve_write_pipe(pipe int p, uint num)
+{
+ uint rid_ptr = DEAD_PTR;
+ int ret0 = 0;
+ if(get_local_linear_id()==0){
+ __global int* pheader = (__global int*)__gen_ocl_get_pipe(p);
+ int pack_num = pheader[0];
+ int data_size = atomic_add(pheader + 6, num);
+ if(data_size > pack_num - num){
+ atomic_sub(pheader + 6, num);
+ ret0 = 1;
+ }
+ int pack_size = pheader[1];
+ int pipe_size = pack_num * pack_size;
+ int write_ptr = atomic_add(pheader + 2, num);
+ if(write_ptr == pack_num - num && !ret0)
+ atomic_sub(pheader + 2, pack_num);
+ if(!ret0)
+ rid_ptr = write_ptr % pack_num;
+ }
+ ulong uid = 0l;
+ RIDT* pid = (RIDT*)&uid;
+ rid_ptr = work_group_broadcast(rid_ptr,0,0,0);
+ pid[0] = rid_ptr;
+ pid[1] = num;
+ pid[2] = RID_MAGIC ;
+ if(rid_ptr == DEAD_PTR)
+ uid = 0l;
+ return __gen_ocl_make_rid(uid);
+}
+void __work_group_commit_write_pipe(pipe int p, reserve_id_t rid) {}
+
+
+reserve_id_t __sub_group_reserve_write_pipe(pipe int p, uint num)
+{
+ __global int* pheader = (__global int*)__gen_ocl_get_pipe(p);
+ int pack_num = pheader[0];
+ int data_size = atomic_add(pheader + 6, num);
+ if(data_size > pack_num - num){
+ atomic_sub(pheader + 6, num);
+ return __gen_ocl_make_rid(0l);
+ }
+ int pack_size = pheader[1];
+ int pipe_size = pack_num * pack_size;
+ int write_ptr = atomic_add(pheader + 2, num);
+ if(write_ptr == pack_num - num)
+ atomic_sub(pheader + 2, pack_num);
+ ulong uid = 0l;
+ RIDT* pid = (RIDT*)&uid;
+ pid[0] = write_ptr % pack_num;
+ pid[1] = num;
+ pid[2] = RID_MAGIC ;
+ return __gen_ocl_make_rid(uid);
+}
+
+void __sub_group_commit_write_pipe(pipe int p, reserve_id_t rid) {}
+
+bool is_valid_reserve_id(reserve_id_t rid)
+{
+ ulong uid = __gen_ocl_get_rid(rid);
+ RIDT* pid = (RIDT*)&uid;
+ if(pid[1] == 0) return false;
+ if(pid[2] != RID_MAGIC) return false;
+ return true;
+}
+
+/* Query Function */
+uint __get_pipe_max_packets(pipe int p)
+{
+ __global int* pheader = __gen_ocl_get_pipe(p);
+ return pheader[0];
+}
+
+uint __get_pipe_num_packets(pipe int p)
+{
+ __global int* pheader = __gen_ocl_get_pipe(p);
+ return pheader[6];
+}
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index d5531dd6..f57b8810 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -1239,9 +1239,11 @@ namespace gbe
}
MDNode *typeNameNode = NULL;
MDNode *typeBaseNameNode = NULL;
+ MDNode *typeQualNode = NULL;
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
typeNameNode = F.getMetadata("kernel_arg_type");
typeBaseNameNode = F.getMetadata("kernel_arg_base_type");
+ typeQualNode = F.getMetadata("kernel_arg_type_qual");
#else
MDNode *node = getKernelFunctionMetadata(&F);
for(uint j = 0;node && j < node->getNumOperands() - 1; j++) {
@@ -1251,6 +1253,8 @@ namespace gbe
if (!attrName) continue;
if (attrName->getString() == "kernel_arg_type") {
typeNameNode = attrNode;
+ } else if (attrName->getString() == "kernel_arg_type_qual") {
+ typeQualNode = attrNode;
}
if (attrName->getString() == "kernel_arg_base_type") {
typeBaseNameNode = attrNode;
@@ -1272,9 +1276,12 @@ namespace gbe
if(typeBaseNameNode) {
llvmInfo.typeBaseName= (cast<MDString>(typeBaseNameNode->getOperand(opID)))->getString();
}
+ llvmInfo.typeName= (cast<MDString>(typeNameNode->getOperand(opID)))->getString();
+ llvmInfo.typeQual = (cast<MDString>(typeQualNode->getOperand(opID)))->getString();
bool isImage = llvmInfo.isImageType();
- if (I->getType()->isPointerTy() || isImage) {
- BtiMap.insert(std::make_pair(&*I, getNewBti(&*I, isImage)));
+ bool isPipe = llvmInfo.isPipeType();
+ if (I->getType()->isPointerTy() || isImage || isPipe) {
+ BtiMap.insert(std::make_pair(&*I, getNewBti(&*I, isImage || isPipe)));
}
}
@@ -2309,6 +2316,10 @@ namespace gbe
(void)ctx.getFunction().getSamplerSet()->append(reg, &ctx);
continue;
}
+ if(llvmInfo.isPipeType()) {
+ ctx.input(argName, ir::FunctionArgument::PIPE, reg, llvmInfo, getTypeByteSize(unit, type), getAlignmentByte(unit, type), BtiMap.find(&*I)->second);
+ continue;
+ }
if (type->isPointerTy() == false)
ctx.input(argName, ir::FunctionArgument::VALUE, reg, llvmInfo, getTypeByteSize(unit, type), getAlignmentByte(unit, type), 0);
@@ -3906,6 +3917,24 @@ namespace gbe
case GEN_OCL_SUB_GROUP_BLOCK_READ_US_IMAGE8:
this->newRegister(&I);
break;
+ case GEN_OCL_GET_PIPE:
+ {
+ Value *srcValue = I.getOperand(0);
+ if( BtiMap.find(dst) == BtiMap.end())
+ {
+ unsigned tranBti = BtiMap.find(srcValue)->second;
+ BtiMap.insert(std::make_pair(dst, tranBti));
+ }
+ regTranslator.newValueProxy(srcValue, dst);
+ break;
+ }
+ case GEN_OCL_MAKE_RID:
+ case GEN_OCL_GET_RID:
+ {
+ Value *srcValue = I.getOperand(0);
+ regTranslator.newValueProxy(srcValue, dst);
+ break;
+ }
case GEN_OCL_PRINTF:
this->newRegister(&I); // fall through
case GEN_OCL_PUTS:
@@ -5274,6 +5303,12 @@ namespace gbe
this->emitBlockReadWriteImageInst(I, CS, true, 4, ir::TYPE_U16); break;
case GEN_OCL_SUB_GROUP_BLOCK_WRITE_US_IMAGE8:
this->emitBlockReadWriteImageInst(I, CS, true, 8, ir::TYPE_U16); break;
+ case GEN_OCL_GET_PIPE:
+ case GEN_OCL_MAKE_RID:
+ case GEN_OCL_GET_RID:
+ {
+ break;
+ }
default: break;
}
}
diff --git a/backend/src/llvm/llvm_gen_ocl_function.hxx b/backend/src/llvm/llvm_gen_ocl_function.hxx
index 9444f0e8..318a3a8c 100644
--- a/backend/src/llvm/llvm_gen_ocl_function.hxx
+++ b/backend/src/llvm/llvm_gen_ocl_function.hxx
@@ -253,3 +253,8 @@ DECL_LLVM_GEN_FUNCTION(SUB_GROUP_BLOCK_WRITE_US_IMAGE4, __gen_ocl_sub_group_bloc
DECL_LLVM_GEN_FUNCTION(SUB_GROUP_BLOCK_WRITE_US_IMAGE8, __gen_ocl_sub_group_block_write_us_image8)
// common function
DECL_LLVM_GEN_FUNCTION(LRP, __gen_ocl_lrp)
+
+// pipe function
+DECL_LLVM_GEN_FUNCTION(GET_PIPE, __gen_ocl_get_pipe)
+DECL_LLVM_GEN_FUNCTION(GET_RID, __gen_ocl_get_rid)
+DECL_LLVM_GEN_FUNCTION(MAKE_RID, __gen_ocl_make_rid)
diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c
index c16c6ac5..5d527152 100644
--- a/src/cl_command_queue.c
+++ b/src/cl_command_queue.c
@@ -161,7 +161,10 @@ cl_command_queue_bind_surface(cl_command_queue queue, cl_kernel k, cl_gpgpu gpgp
for (i = 0; i < k->arg_n; ++i) {
int32_t offset; // location of the address in the curbe
arg_type = interp_kernel_get_arg_type(k->opaque, i);
- if (!(arg_type == GBE_ARG_GLOBAL_PTR || (arg_type == GBE_ARG_CONSTANT_PTR && ocl_version >= 200)) || !k->args[i].mem)
+ if (!(arg_type == GBE_ARG_GLOBAL_PTR ||
+ (arg_type == GBE_ARG_CONSTANT_PTR && ocl_version >= 200) ||
+ arg_type == GBE_ARG_PIPE) ||
+ !k->args[i].mem)
continue;
offset = interp_kernel_get_curbe_offset(k->opaque, GBE_CURBE_KERNEL_ARGUMENT, i);
if (offset < 0)
diff --git a/src/cl_kernel.c b/src/cl_kernel.c
index 59e6cade..969bebaf 100644
--- a/src/cl_kernel.c
+++ b/src/cl_kernel.c
@@ -164,7 +164,8 @@ cl_kernel_set_arg(cl_kernel k, cl_uint index, size_t sz, const void *value)
return CL_INVALID_SAMPLER;
} else {
// should be image, GLOBAL_PTR, CONSTANT_PTR
- if (UNLIKELY(value == NULL && arg_type == GBE_ARG_IMAGE))
+ if (UNLIKELY(value == NULL && (arg_type == GBE_ARG_IMAGE ||
+ arg_type == GBE_ARG_PIPE)))
return CL_INVALID_ARG_VALUE;
if(value != NULL)
mem = *(cl_mem*)value;
@@ -389,6 +390,8 @@ cl_get_kernel_arg_info(cl_kernel k, cl_uint arg_index, cl_kernel_arg_info param_
type_qual = type_qual | CL_KERNEL_ARG_TYPE_VOLATILE;
if (strstr((char*)ret_info, "restrict"))
type_qual = type_qual | CL_KERNEL_ARG_TYPE_RESTRICT;
+ if (strstr((char*)ret_info, "pipe"))
+ type_qual = CL_KERNEL_ARG_TYPE_PIPE;
*(cl_kernel_arg_type_qualifier *)param_value = type_qual;
return CL_SUCCESS;