[06/19] OCL20: Add generic address space memcpy and memset.

Submitted by Yang, Rong R on Nov. 28, 2016, 11:32 a.m.

Details

Message ID 1480332765-3271-6-git-send-email-rong.r.yang@intel.com
State New
Headers show
Series "Series without cover letter" ( rev: 2 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Yang, Rong R Nov. 28, 2016, 11:32 a.m.
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
---
 backend/src/libocl/src/ocl_memcpy.cl         | 15 +++++++++++++++
 backend/src/libocl/src/ocl_memset.cl         |  3 +++
 backend/src/llvm/llvm_bitcode_link.cpp       | 22 ++++++++++++++++++++++
 backend/src/llvm/llvm_intrinsic_lowering.cpp |  2 ++
 4 files changed, 42 insertions(+)

Patch hide | download patch | download mbox

diff --git a/backend/src/libocl/src/ocl_memcpy.cl b/backend/src/libocl/src/ocl_memcpy.cl
index 85f490f..131574d 100644
--- a/backend/src/libocl/src/ocl_memcpy.cl
+++ b/backend/src/libocl/src/ocl_memcpy.cl
@@ -37,13 +37,28 @@  void __gen_memcpy_ ##NAME (DST_SPACE uchar* dst, SRC_SPACE uchar* src, size_t si
   } \
 }
 
+#if (__OPENCL_C_VERSION__ >= 200)
 #define DECL_ONE_SPACE_MEMCOPY_FN(NAME, DST_SPACE) \
   DECL_TWO_SPACE_MEMCOPY_FN( NAME## g, DST_SPACE, __global) \
   DECL_TWO_SPACE_MEMCOPY_FN( NAME## l, DST_SPACE, __local) \
   DECL_TWO_SPACE_MEMCOPY_FN( NAME## p, DST_SPACE, __private) \
+  DECL_TWO_SPACE_MEMCOPY_FN( NAME## n, DST_SPACE, __generic) \
   DECL_TWO_SPACE_MEMCOPY_FN( NAME## c, DST_SPACE, __constant)
 
 DECL_ONE_SPACE_MEMCOPY_FN(g, __global)
 DECL_ONE_SPACE_MEMCOPY_FN(l, __local)
 DECL_ONE_SPACE_MEMCOPY_FN(p, __private)
+DECL_ONE_SPACE_MEMCOPY_FN(n, __generic)
+#else
+#define DECL_ONE_SPACE_MEMCOPY_FN(NAME, DST_SPACE) \
+  DECL_TWO_SPACE_MEMCOPY_FN( NAME## g, DST_SPACE, __global) \
+  DECL_TWO_SPACE_MEMCOPY_FN( NAME## l, DST_SPACE, __local) \
+  DECL_TWO_SPACE_MEMCOPY_FN( NAME## p, DST_SPACE, __private) \
+  DECL_TWO_SPACE_MEMCOPY_FN( NAME## c, DST_SPACE, __constant)
+
+DECL_ONE_SPACE_MEMCOPY_FN(g, __global)
+DECL_ONE_SPACE_MEMCOPY_FN(l, __local)
+DECL_ONE_SPACE_MEMCOPY_FN(p, __private)
+
+#endif
 
diff --git a/backend/src/libocl/src/ocl_memset.cl b/backend/src/libocl/src/ocl_memset.cl
index d8bc5df..dda7e55 100644
--- a/backend/src/libocl/src/ocl_memset.cl
+++ b/backend/src/libocl/src/ocl_memset.cl
@@ -41,4 +41,7 @@  void __gen_memset_ ##NAME (DST_SPACE uchar* dst, uchar val, size_t size) { \
 DECL_MEMSET_FN(g, __global)
 DECL_MEMSET_FN(l, __local)
 DECL_MEMSET_FN(p, __private)
+#if (__OPENCL_C_VERSION__ >= 200)
+DECL_MEMSET_FN(n, __generic)
+#endif
 
diff --git a/backend/src/llvm/llvm_bitcode_link.cpp b/backend/src/llvm/llvm_bitcode_link.cpp
index 0b01929..934dd2e 100644
--- a/backend/src/llvm/llvm_bitcode_link.cpp
+++ b/backend/src/llvm/llvm_bitcode_link.cpp
@@ -182,6 +182,28 @@  namespace gbe
     builtinFuncs.push_back("__gen_memcpy_gc_align");
     builtinFuncs.push_back("__gen_memcpy_lc_align");
 
+    if (oclVersion >= 200) {
+      builtinFuncs.push_back("__gen_memcpy_gn");
+      builtinFuncs.push_back("__gen_memcpy_pn");
+      builtinFuncs.push_back("__gen_memcpy_ln");
+      builtinFuncs.push_back("__gen_memcpy_ng");
+      builtinFuncs.push_back("__gen_memcpy_np");
+      builtinFuncs.push_back("__gen_memcpy_nl");
+      builtinFuncs.push_back("__gen_memcpy_nc");
+      builtinFuncs.push_back("__gen_memcpy_nn");
+      builtinFuncs.push_back("__gen_memset_n");
+
+      builtinFuncs.push_back("__gen_memcpy_gn_align");
+      builtinFuncs.push_back("__gen_memcpy_pn_align");
+      builtinFuncs.push_back("__gen_memcpy_ln_align");
+      builtinFuncs.push_back("__gen_memcpy_ng_align");
+      builtinFuncs.push_back("__gen_memcpy_np_align");
+      builtinFuncs.push_back("__gen_memcpy_nl_align");
+      builtinFuncs.push_back("__gen_memcpy_nc_align");
+      builtinFuncs.push_back("__gen_memcpy_nn_align");
+      builtinFuncs.push_back("__gen_memset_n_align");
+    }
+
     for (Module::iterator SF = mod->begin(), E = mod->end(); SF != E; ++SF) {
       if (SF->isDeclaration()) continue;
       if (!isKernelFunction(*SF)) continue;
diff --git a/backend/src/llvm/llvm_intrinsic_lowering.cpp b/backend/src/llvm/llvm_intrinsic_lowering.cpp
index c26e96a..f01bb51 100644
--- a/backend/src/llvm/llvm_intrinsic_lowering.cpp
+++ b/backend/src/llvm/llvm_intrinsic_lowering.cpp
@@ -54,6 +54,8 @@  namespace gbe {
             return 'c';
           case 3:
             return 'l';
+          case 4:
+            return 'n';
           default:
             assert(0 && "Non support address space");
             return '\0';