mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-30 00:32:01 +08:00

This allows us to do faster native scalar operations. Also updated half/quarter packets to use the native type if available. Benchmark improvement: ``` Comparing ./2910_without_float16 to ./2910_with_float16 Benchmark Time CPU Time Old Time New CPU Old CPU New ------------------------------------------------------------------------------------------------------------------------------------ BM_CalcMat<float>/10000/768/500 -0.0041 -0.0040 58276392 58039442 58273420 58039582 BM_CalcMat<_Float16>/10000/768/500 +0.0073 +0.0073 642506339 647214446 642481384 647188303 BM_CalcMat<Eigen::half>/10000/768/500 -0.3170 -0.3170 92511115 63182101 92506771 63179258 BM_CalcVec<float>/10000/768/500 +0.0022 +0.0022 5198157 5209469 5197913 5209334 BM_CalcVec<_Float16>/10000/768/500 +0.0025 +0.0026 10133324 10159111 10132641 10158507 BM_CalcVec<Eigen::half>/10000/768/500 -0.7760 -0.7760 45337937 10156952 45336532 10156389 OVERALL_GEOMEAN -0.2677 -0.2677 0 0 0 0 ``` Fixes #2910.
24 lines
829 B
C++
24 lines
829 B
C++
#ifndef TEST_PACKET_OSTREAM
|
|
#define TEST_PACKET_OSTREAM
|
|
|
|
#include <type_traits>
|
|
#include <ostream>
|
|
|
|
// Include this header to be able to print Packets while debugging.
|
|
|
|
template <typename Packet,
|
|
typename EnableIf = std::enable_if_t<(Eigen::internal::unpacket_traits<Packet>::vectorizable ||
|
|
Eigen::internal::unpacket_traits<Packet>::size > 1)> >
|
|
std::ostream& operator<<(std::ostream& os, const Packet& packet) {
|
|
using Scalar = typename Eigen::internal::unpacket_traits<Packet>::type;
|
|
Scalar v[Eigen::internal::unpacket_traits<Packet>::size];
|
|
Eigen::internal::pstoreu(v, packet);
|
|
os << "{" << v[0];
|
|
for (int i = 1; i < Eigen::internal::unpacket_traits<Packet>::size; ++i) {
|
|
os << "," << v[i];
|
|
}
|
|
os << "}";
|
|
return os;
|
|
}
|
|
|
|
#endif // TEST_PACKET_OSTREAM
|