[Libreoffice-commits] core.git: 2 commits - sc/source

Tor Lillqvist tml at collabora.com
Fri Oct 31 06:02:43 PDT 2014


 sc/source/core/opencl/formulagroupcl.cxx |   26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

New commits:
commit eb37bbe5995767fc106912cb5f42758ad331e6af
Author: Tor Lillqvist <tml at collabora.com>
Date:   Fri Oct 31 14:58:43 2014 +0200

    Add line numbers to the OpenCL sources being logged
    
    Makes __LINE__ numbers you have inserted in temporary printf() calls in the
    (generated) OpenCL code more useful.
    
    Change-Id: I6da5a6937b924c1378f7f0c25ab7e156b23e1b61

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 161d0b5..e77eeb4 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -65,6 +65,28 @@ using namespace formula;
 
 namespace sc { namespace opencl {
 
+namespace {
+
+#ifdef SAL_DETAIL_ENABLE_LOG_INFO
+std::string linenumberify(const std::string s)
+{
+    std::stringstream ss;
+    int linenumber = 1;
+    size_t start = 0;
+    size_t newline;
+    while ((newline = s.find('\n', start)) != std::string::npos)
+    {
+        ss << "/*" << std::setw(4) << linenumber++ << "*/ " << s.substr(start, newline-start+1);
+        start = newline + 1;
+    }
+    if (start < s.size())
+        ss << "/*" << std::setw(4) << linenumber++ << "*/ " << s.substr(start, std::string::npos);
+    return ss.str();
+}
+#endif
+
+} // anonymous namespace
+
 /// Map the buffer used by an argument and do necessary argument setting
 size_t VectorRef::Marshal( cl_kernel k, int argno, int, cl_program )
 {
@@ -3293,7 +3315,7 @@ public:
             area << "sc.opencl.source." << mKernelSignature.substr(1, std::string::npos);
         else
             area << "sc.opencl.source." << mKernelSignature;
-        SAL_INFO(area.str().c_str(), "Program to be compiled:\n" << mFullProgramSrc);
+        SAL_INFO(area.str().c_str(), "Program to be compiled:\n" << linenumberify(mFullProgramSrc));
 #endif
     }
     /// Produce kernel hash
commit f49880807ca44d5d0a7b664bd5a40b61a6e615e3
Author: Tor Lillqvist <tml at collabora.com>
Date:   Fri Oct 31 14:15:53 2014 +0200

    Move variable inside the ifdef block where it is only used
    
    Change-Id: Ifa9e77b955cea26da6602d409a1c111f45f72587

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 86d8535..161d0b5 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -3287,8 +3287,8 @@ public:
         decl << ") {\n\tint gid0 = get_global_id(0);\n\tresult[gid0] = " <<
             DK->GenSlidingWindowDeclRef(false) << ";\n}\n";
         mFullProgramSrc = decl.str();
-        std::stringstream area;
 #ifdef SAL_DETAIL_ENABLE_LOG_INFO
+        std::stringstream area;
         if (mKernelSignature[0] == '_')
             area << "sc.opencl.source." << mKernelSignature.substr(1, std::string::npos);
         else


More information about the Libreoffice-commits mailing list