sc/qa/unit/data/ods/tdf149940.ods |binary sc/qa/unit/opencl-test-2.cxx | 27 +++++++++++++++++++++++++++ sc/source/core/opencl/op_spreadsheet.cxx | 4 +++- 3 files changed, 30 insertions(+), 1 deletion(-)
New commits: commit 91ba7d22b0df33a3ca4102bc77869fe89921c34e Author: dholden <dhiraj.hol...@gmail.com> AuthorDate: Mon Jan 22 02:25:11 2024 -0600 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 23 08:57:47 2024 +0100 tdf#149940 Fix vlookup result with OpenCL This patch fixes the vlookup result in sorted order using OpenCl. The issue was that the loop unrolling would cause the loop to exit early. This has been fixed to only happen in unsorted mode. Change-Id: I7aba7b301c87061bc33128c8930ef3c55dc3c386 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162363 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/qa/unit/data/ods/tdf149940.ods b/sc/qa/unit/data/ods/tdf149940.ods new file mode 100644 index 000000000000..5e117ac469f7 Binary files /dev/null and b/sc/qa/unit/data/ods/tdf149940.ods differ diff --git a/sc/qa/unit/opencl-test-2.cxx b/sc/qa/unit/opencl-test-2.cxx index 4c7fbdbcb96d..910e09b87ec3 100644 --- a/sc/qa/unit/opencl-test-2.cxx +++ b/sc/qa/unit/opencl-test-2.cxx @@ -1844,6 +1844,33 @@ CPPUNIT_TEST_FIXTURE(ScOpenCLTest2, testStatisticalFormulaStDevPA1) } } +CPPUNIT_TEST_FIXTURE(ScOpenCLTest2, testTdf149940_VLookup) +{ + initTestEnv(u"ods/tdf149940.ods"); + ScDocument* pDoc = getScDoc2(); + ScDocument* pDocRes = getScDoc(); + pDoc->CalcAll(); + + for (SCROW i = 4; i <= 12; ++i) + { + double fLibre = pDoc->GetValue(ScAddress(1,i,1)); + double fExcel = pDocRes->GetValue(ScAddress(1,i,1)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.00001)); + } + for (SCROW i = 4; i <= 12; ++i) + { + double fLibre = pDoc->GetValue(ScAddress(2,i,1)); + double fExcel = pDocRes->GetValue(ScAddress(2,i,1)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.00001)); + } + for (SCROW i = 4; i <= 12; ++i) + { + double fLibre = pDoc->GetValue(ScAddress(3,i,1)); + double fExcel = pDocRes->GetValue(ScAddress(3,i,1)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.00001)); + } +} + ScOpenCLTest2::ScOpenCLTest2() : ScModelTestBase( "sc/qa/unit/data" ) { diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx index db99a1e7cf74..815f95b1f39f 100644 --- a/sc/source/core/opencl/op_spreadsheet.cxx +++ b/sc/source/core/opencl/op_spreadsheet.cxx @@ -171,7 +171,9 @@ void OpVLookup::GenSlidingWindowFunction(outputstream &ss, } ss << " } "; - ss << " if(rowNum!=-1) "; + ss << " if(rowNum!=-1 && tmp"; + ss << 3 + (secondParaWidth - 1); + ss << " == 0) "; ss << " { "; for (int j = 0; j < secondParaWidth; j++) {