summaryrefslogtreecommitdiff
path: root/sc/source/core/opencl
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2014-10-31 14:58:43 +0200
committerTor Lillqvist <tml@collabora.com>2014-10-31 15:01:07 +0200
commiteb37bbe5995767fc106912cb5f42758ad331e6af (patch)
tree566562ebedc0eca527994da08f9ba1d9f0b8fe7c /sc/source/core/opencl
parentf49880807ca44d5d0a7b664bd5a40b61a6e615e3 (diff)
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
Diffstat (limited to 'sc/source/core/opencl')
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 161d0b501cba..e77eeb423cc1 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