Bugzilla – Attachment 750 Details for
Bug 1342
Performance regression in Eigen 3.3.0 for sub-vector access
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
This bugzilla service is closed. All entries have been migrated to
https://gitlab.com/libeigen/eigen
updated benchmark
eigen_bench.cpp (text/x-c++src), 2.14 KB, created by
Daniel Vollmer
on 2016-11-18 12:21:09 UTC
(
hide
)
Description:
updated benchmark
Filename:
MIME Type:
Creator:
Daniel Vollmer
Created:
2016-11-18 12:21:09 UTC
Size:
2.14 KB
patch
obsolete
>// Intel(R) Xeon(R) CPU E3-1276 v3 @ 3.60GHz >// g++ 4.9.2 >// g++ -std=c++11 -Wno-deprecated -Ofast -DNDEBUG -fno-finite-math-only -I eigen eigen_bench.cpp >// Eigen 3.2.10: 0.91s >// Eigen 3.2.10: 0.91s (EIGEN_DONT_VECTORIZE) >// Eigen 3.3.0 : 1.35s >// Eigen 3.3.0 : 0.99s (EIGEN_UNALIGNED_VECTORIZE=0) >// Eigen 3.3.0 : 0.91s (EIGEN_DONT_VECTORIZE) > >#include <cmath> > >#include "Eigen/Dense" > >enum PV : int >{ > // state > Density = 0, > MomentumX, > MomentumY, > MomentumZ, > Energy, > NumState, // = 5 > // aug > Pressure = NumState, > Temperature, > IsobaricSpecificHeat, > NumAugState, // = 8 >}; > >using T = double; > >using Vec3d = Eigen::Matrix<T, 3, 1>; >using StateVector = Eigen::Matrix<T, PV::NumState, 1>; >using AugStateVector = Eigen::Matrix<T, PV::NumAugState, 1>; > >// ----- augment ----- > >static const T _gamma = 1.4; >static const T _R = 1.0; >static const T _cP = _gamma / (_gamma - 1.0) * _R; > >template<class In, class Out> >static void Augment(const In &state, Out &aug) >{ > const T &rho = state[PV::Density]; > const auto &rhoV = state.template segment<3>(PV::MomentumX); > const T &rhoE = state[PV::Energy]; > > const T pres = (_gamma - 1.) * (rhoE - 0.5 * rhoV.squaredNorm() / rho); > aug[PV::Pressure] = pres; > aug[PV::Temperature] = pres / (rho * _R); > > aug[PV::IsobaricSpecificHeat] = _cP; >} > >#include <cstdlib> >#include <iostream> >#include <chrono> > >int main (int argc, char const *argv[]) >{ > int num = argc > 1 ? atoi(argv[1]) : 3 * 10000000; > > StateVector sum = StateVector::Zero(); > const auto begin = std::chrono::high_resolution_clock::now(); > for (int i = 0; i < num; ++i) > { > const StateVector state = StateVector::Constant(i+1); > > EIGEN_ASM_COMMENT("begin"); > AugStateVector augState; > augState.head<PV::NumState>() = state; > Augment(augState, augState); > augState.segment<3>(PV::MomentumX) += augState.tail<3>(); > > sum += augState.head<PV::NumState>(); > EIGEN_ASM_COMMENT("end"); > } > const auto end = std::chrono::high_resolution_clock::now(); > std::cout << sum << std::endl; // yes, it's nan > std::cout << std::chrono::duration<double>(end - begin).count() << 's' << std::endl; > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1342
:
749
| 750 |
758