From ae01c05e184c62601521e785f733daf4a425b1c0 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 31 Mar 2015 15:19:57 +0200 Subject: [PATCH] Fix computeProductBlockingSizes with m==0, and add respective unit test. --- .../Core/products/GeneralBlockPanelKernel.h | 3 +- test/product_extra.cpp | 33 +++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/Eigen/src/Core/products/GeneralBlockPanelKernel.h index d32377a00..428527820 100644 --- a/Eigen/src/Core/products/GeneralBlockPanelKernel.h +++ b/Eigen/src/Core/products/GeneralBlockPanelKernel.h @@ -249,10 +249,9 @@ void evaluateProductBlockingSizesHeuristic(Index& k, Index& m, Index& n, Index n actual_lm = l2; max_mc = 576; } - Index mc = (std::min)(actual_lm/(3*k*sizeof(LhsScalar)), max_mc); if (mc > Traits::mr) mc -= mc % Traits::mr; - + else if (mc==0) return; m = (m%mc)==0 ? mc : (mc - Traits::mr * ((mc/*-1*/-(m%mc))/(Traits::mr*(m/mc+1)))); } diff --git a/test/product_extra.cpp b/test/product_extra.cpp index 1b4c6c33c..67ea13568 100644 --- a/test/product_extra.cpp +++ b/test/product_extra.cpp @@ -134,7 +134,7 @@ void zero_sized_objects(const MatrixType& m) } } - +template void bug_127() { // Bug 127 @@ -159,6 +159,7 @@ void bug_127() a*b; } +template void unaligned_objects() { // Regression test for the bug reported here: @@ -188,6 +189,29 @@ void unaligned_objects() } } +template +EIGEN_DONT_INLINE +Index test_compute_block_size(Index m, Index n, Index k) +{ + Index mc(m), nc(n), kc(k); + internal::computeProductBlockingSizes(kc, mc, nc); + return kc+mc+nc; +} + +template +Index compute_block_size() +{ + Index ret = 0; + ret += test_compute_block_size(0,1,1); + ret += test_compute_block_size(1,0,1); + ret += test_compute_block_size(1,1,0); + ret += test_compute_block_size(0,0,1); + ret += test_compute_block_size(0,1,0); + ret += test_compute_block_size(1,0,0); + ret += test_compute_block_size(0,0,0); + return ret; +} + void test_product_extra() { for(int i = 0; i < g_repeat; i++) { @@ -198,6 +222,9 @@ void test_product_extra() CALL_SUBTEST_4( product_extra(MatrixXcd(internal::random(1,EIGEN_TEST_MAX_SIZE/2), internal::random(1,EIGEN_TEST_MAX_SIZE/2))) ); CALL_SUBTEST_1( zero_sized_objects(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); } - CALL_SUBTEST_5( bug_127() ); - CALL_SUBTEST_6( unaligned_objects() ); + CALL_SUBTEST_5( bug_127<0>() ); + CALL_SUBTEST_6( unaligned_objects<0>() ); + CALL_SUBTEST_7( compute_block_size() ); + CALL_SUBTEST_7( compute_block_size() ); + CALL_SUBTEST_7( compute_block_size >() ); }