[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sc/source

Tor Lillqvist tml at collabora.com
Tue Jun 28 03:37:16 UTC 2016


 sc/source/core/opencl/formulagroupcl.cxx |   13 +++++++++++++
 1 file changed, 13 insertions(+)

New commits:
commit bc34f5bae1ffc42fb848b2341020fc3fa52afbe2
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Jun 27 12:36:22 2016 +0300

    tdf#98515: Bail out early if kernel would have ridiculously many parameters
    
    The Right Thing to do would be to compare the accumulated kernel
    parameter size against the CL_DEVICE_MAX_PARAMETER_SIZE of the device,
    but let's just do this sanity check for now. Bail out if the kernel
    would have more than 50 parameters.
    
    Calculating the accumulated kernel parameter size would be more
    complicated and I don't want to touch this code more than
    necessary. The kernel compilation will fail anyway if the size of
    parameters exceeds the limit and this sanity check is just to make us
    bail out a bit earlier.
    
    In tdf#98515 the slowness seems to indeed be caused by the OpenCL code
    generation , and there the number of parameters was 999, so this
    sanity check does fix the slow loading issue (I checked).
    
    (cherry picked from commit a48aefcae40663b63005d49a04fc7b89a473d613)
    
    Change-Id: Iead6dfb94ec8e7b2968ffed9423f0f9522a10ce9
    Reviewed-on: https://gerrit.libreoffice.org/26703
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 49360df..8055ecf 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2630,6 +2630,19 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
                     const formula::DoubleVectorRefToken* pDVR =
                         static_cast<const formula::DoubleVectorRefToken*>(pChild);
 
+                    // FIXME: The Right Thing to do would be to compare the accumulated kernel
+                    // parameter size against the CL_DEVICE_MAX_PARAMETER_SIZE of the device, but
+                    // let's just do this sanity check for now. The kernel compilation will
+                    // hopefully fail anyway if the size of parameters exceeds the limit and this
+                    // sanity check is just to make us bail out a bit earlier.
+
+                    // The number 50 comes from the fact that the minimum size of
+                    // CL_DEVICE_MAX_PARAMETER_SIZE is 256, which for 32-bit code probably means 64
+                    // of them. Round down a bit.
+
+                    if (pDVR->GetArrays().size() > 50)
+                        throw UnhandledToken(pChild, ("Kernel would have ridiculously many parameters (" + std::to_string(2 + pDVR->GetArrays().size()) + ")").c_str());
+
                     for (size_t j = 0; j < pDVR->GetArrays().size(); ++j)
                     {
                         SAL_INFO("sc.opencl", "i=" << i << " j=" << j <<


More information about the Libreoffice-commits mailing list