[pocl] 02/11: cherry-pick upstream c9d2cd15, a flatten/force-inline fix

Andreas Beckmann anbe at moszumanska.debian.org
Mon Dec 18 08:15:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

anbe pushed a commit to branch master
in repository pocl.

commit 30931d5f77e8f0f5f34003fd1fb1840edb2fe589
Author: Andreas Beckmann <anbe at debian.org>
Date:   Thu Dec 14 03:05:51 2017 +0100

    cherry-pick upstream c9d2cd15, a flatten/force-inline fix
---
 debian/changelog                                   |  8 +++
 ...n-switch-back-to-force-inlining-only-some.patch | 77 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 86 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index c107000..77330a1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+pocl (0.14-3) UNRELEASED; urgency=medium
+
+  * Cherry-pick upstream [c9d2cd15] "llvm/Flatten: switch back to
+    force-inlining only some funcs", fixing kernel/test_convert_type_* failing
+    on i386 with LLC_HOST_CPU=i686.
+
+ -- Andreas Beckmann <anbe at debian.org>  Thu, 14 Dec 2017 02:55:27 +0100
+
 pocl (0.14-2) experimental; urgency=medium
 
   * Cherry-pick upstream [62b74d6f] "Fix malloc size in tests/runtime/
diff --git a/debian/patches/0002-llvm-Flatten-switch-back-to-force-inlining-only-some.patch b/debian/patches/0002-llvm-Flatten-switch-back-to-force-inlining-only-some.patch
new file mode 100644
index 0000000..3c3097e
--- /dev/null
+++ b/debian/patches/0002-llvm-Flatten-switch-back-to-force-inlining-only-some.patch
@@ -0,0 +1,77 @@
+From c9d2cd1518a6f6578bb784c843f9269213838946 Mon Sep 17 00:00:00 2001
+From: Michal Babej <michal.babej at tut.fi>
+Date: Fri, 19 May 2017 17:46:11 +0200
+Subject: [PATCH] llvm/Flatten: switch back to force-inlining only some funcs
+
+The new code in Flatten added AlwaysInline attr to everything
+except kernel.
+
+This switches Flatten back to its original code (adding AlwaysInline
+only to users of global variables); additionally it adds AlwaysInline
+on barrier().
+
+The problem with flattening all code is that OpenCL spec requires
+maximum number of image arguments to a kernel to be at least 127.
+write_imagef() is relatively heavy on stack, and AlwaysInline on a
+kernel with 127 images and 127 calls to write_imagef() will require
+a giant stack, if we force inlining of all write_imagef() calls.
+---
+ lib/llvmopencl/Flatten.cc   | 15 +++++++++++++--
+ lib/llvmopencl/Workgroup.cc |  1 +
+ 2 files changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/lib/llvmopencl/Flatten.cc b/lib/llvmopencl/Flatten.cc
+index fde069b8..a6248462 100644
+--- a/lib/llvmopencl/Flatten.cc
++++ b/lib/llvmopencl/Flatten.cc
+@@ -61,7 +61,7 @@ static RegisterPass<Flatten> X("flatten", "Kernel function flattening pass");
+ 
+ //#define DEBUG_FLATTEN
+ 
+-#define INLINE_ALL_NON_KERNEL
++//#define INLINE_ALL_NON_KERNEL
+ 
+ #ifdef INLINE_ALL_NON_KERNEL
+ 
+@@ -153,7 +153,7 @@ Flatten::runOnModule(Module &M)
+     for (Value::use_iterator i = v->use_begin(), e = v->use_end();
+          i != e; ++i) {
+       llvm::User *user = i->getUser();
+-      if (Instruction *ci = dyn_cast<Instruction>(user) {
++      if (Instruction *ci = dyn_cast<Instruction>(user)) {
+         // Prevent infinite looping on recursive functions
+         // (though OpenCL does not allow this?)
+         Function *f = ci->getParent()->getParent();;
+@@ -175,6 +175,17 @@ Flatten::runOnModule(Module &M)
+     (*i)->addFnAttr(Attribute::AlwaysInline);
+   }
+ 
++  StringRef barrier("_Z7barrierj");
++  for (llvm::Module::iterator i = M.begin(), e = M.end(); i != e; ++i) {
++    llvm::Function *f = &*i;
++    if (f->isDeclaration())
++      continue;
++    if (f->getName().equals(barrier)) {
++      f->removeFnAttr(Attribute::NoInline);
++      f->addFnAttr(Attribute::AlwaysInline);
++    }
++  }
++
+   return true;
+ }
+ 
+diff --git a/lib/llvmopencl/Workgroup.cc b/lib/llvmopencl/Workgroup.cc
+index 946c8323..e029a288 100644
+--- a/lib/llvmopencl/Workgroup.cc
++++ b/lib/llvmopencl/Workgroup.cc
+@@ -214,6 +214,7 @@ Workgroup::runOnModule(Module &M)
+     Function *L = createLauncher(M, &*i);
+ 
+     L->addFnAttr(Attribute::NoInline);
++    L->removeFnAttr(Attribute::AlwaysInline);
+ 
+     privatizeContext(M, L);
+ 
+-- 
+2.15.1
+
diff --git a/debian/patches/series b/debian/patches/series
index 3e770fb..58b26d6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,4 +1,5 @@
 0001-Fix-malloc-size-in-tests-runtime-test_clBuildProgram.patch
+0002-llvm-Flatten-switch-back-to-force-inlining-only-some.patch
 os-compat.patch
 typos.patch
 glibc-2.23.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/pocl.git



More information about the Pkg-opencl-commits mailing list