This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Dgemm and set_is_malloc_allowed

Tags: None
(comma "," separated)
mathieuc
Registered Member
Posts
4
Karma
0

Dgemm and set_is_malloc_allowed

Fri Mar 02, 2018 10:39 am
Hello

I recently ran the benchmark trying to remove as much as possible heap allocation performing a matrix matrix product

Here is the google benchmark test I ran

Code: Select all
static void BM_mapTest(benchmark::State& state)
{
    MatrixXd X = MatrixXd::Random(state.range(0), 2 * state.range(1)),
            W = MatrixXd::Zero(state.range(0), state.range(0));
    Map<MatrixXd> Xin(X.data() + state.range(0), state.range(0), state.range(1)),
            Xout(X.data() + state.range(0) * state.range(1), state.range(0), state.range(1));
    Eigen::internal::set_is_malloc_allowed(false);
    for (auto _ : state)
        Xout.noalias() = W * Xin;
    Eigen::internal::set_is_malloc_allowed(true);
}
BENCHMARK(BM_mapTest)->Ranges({{5, 2 << 7}, {5, 2 << 10}});


and here is the console output

-----------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------
BM_mapTest/5/5 6532 ns 6516 ns 105293
BM_mapTest/8/5 4315 ns 4311 ns 158353
BM_mapTest/64/5 171043 ns 169677 ns 4439
BM_mapTest/256/5 2641710 ns 2637701 ns 254
BM_mapTest/5/8 9923 ns 9884 ns 69055
BM_mapTest/8/8 6247 ns 6242 ns 117683
BM_mapTest/64/8 245930 ns 245347 ns 2804
BM_mapTest/256/8 4059939 ns 4040261 ns 176
BM_mapTest/5/64 21753 ns 21689 ns 31693
BM_mapTest/8/64 39649 ns 39603 ns 16636
BM_mapTest/64/64 1746182 ns 1745396 ns 399
Assertion failed: (is_malloc_allowed() && "heap allocation is forbidden (EIGEN_RUNTIME_NO_MALLOC is defined and g_is_malloc_allowed is false)"), function check_that_malloc_is_allowed, file /Users/mathieu/Documents/Work/ADAGOS/Products/deepROMcpp/src/../../AdagosUtils/eigen/Eigen/src/Core/util/Memory.h, line 143.

It seems that the test with blocks of size 256*64 triggers a heap allocation in GeneralMatrixMatrix.h
[l.162] ei_declare_aligned_stack_constructed_variable(LhsScalar, blockA, sizeA, blocking.blockA());

What is the explanation of such a behaviour ?

Thanks

Mathieu


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]