Registered Member
|
Why Matrix Add takes much longer than Matrix-Vector Multiplication?
Matrix Add only costs n^2 add, whereas Matrix-Vector Multiplication takes n*(n-1) add and n^2 multiplication. However, in Eigen, Matrix Add takes twice the time as Matrix-Vector Multiplication does. Does there exists any option to speed up Matrix Add operation in Eigen?
Test 1: Without any optimization: compile command: g++-8 -test.cpp -o test run command: ./test Elapsed time in seconds : 0.323s Elapsed time in seconds : 0.635s Test 2: With -march=native optimization: g++-8 test.cpp -march=native -o test run command: ./test Elapsed time in seconds : 0.21s Elapsed time in seconds : 0.372s Test 3: With -O3 optimization: compile command: g++-8 -test.cpp -O3 -o test run command: ./test Elapsed time in seconds : 0.009s Elapsed time in seconds : 0.016s Test 4: With -march=native, -O3 optimization: compile command: g++-8 -test.cpp -march=native -O3 -o test run command: ./test Elapsed time in seconds : 0.008s Elapsed time in seconds : 0.016s |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]