|Re: [eigen] Multi-threading in array operation|
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
|Hi Ghislain. Here are some tips from a neighbor.|
MatrixXd A = MatrixXd::Zero(100,100);
Those operations will most likely bound my memory allocation (time to do a malloc and time for the “first touch” of the array). Most likely, you won’t gain anything from multithreading.
MatrixXd C = A.array() + B.array(); // element-wise addition
Those operations are memory bound. On most computer, you won’t gain anything from multithreading. Suppose that the array is so big that it does not fit into the last level of cache (L3). On a laptop:
- Bandwidth: 25GB/s, so (assuming you are using doubles), you can feed (25 / (2 * 8) = 1.5 billion elements per second).
- Computing power: One core at 2 GHz can issue 2 billion addition per second (1 per cycle)
So, you’ll be bandwidth limited, and multi-threading will be useless. And I did not even count the access to C.
On a workstation, with dual socket, it will be useful to use multithreading, but with careful threads pining. One thing which can be useful with large arrays would be to use streaming stores to C (which does not use the bandwidth for C).
MatrixXd D = A.array() / B.array(); // element-wise division
Here, you might benefit from multithreading as division is a slow operation.
Founder & Consultant - Inside Loop
Applied Mathematics & High Performance Computing
Tel: +33 (0)6 01 44 06 93
|Mail converted by MHonArc 2.6.19+||http://listengine.tuxfamily.org/|