perf(hex8): packetize ordered gradient and geometric contractions
This commit is contained in:
@@ -111,6 +111,10 @@ VectorPair Load(const PairPacket& value) {
|
||||
_mm256_setr_pd(value.values[0].low, value.values[1].low,
|
||||
value.values[2].low, value.values[3].low)};
|
||||
}
|
||||
/// @brief Replicates one raw first product without changing either component.
|
||||
VectorPair Splat(PacketPair value) {
|
||||
return {_mm256_set1_pd(value.high), _mm256_set1_pd(value.low)};
|
||||
}
|
||||
/// @brief Stores raw high/low fields without rounding or lane reduction.
|
||||
PairPacket Store(VectorPair value) {
|
||||
double high[4];
|
||||
@@ -251,6 +255,20 @@ void EvaluateMaterialPacketAvx2(const MaterialPacketInput& input,
|
||||
*output = Store(Add(Load(input.accumulated),
|
||||
Multiply(material, Load(weight)), true));
|
||||
}
|
||||
void EvaluateGeometryPacketAvx2(const GeometryPacketInput& input,
|
||||
GeometryPacketOutput* output) {
|
||||
VectorPair dot{_mm256_setzero_pd(), _mm256_setzero_pd()};
|
||||
for (std::size_t i = 0; i < 3; ++i)
|
||||
dot = Add(dot, Multiply(Splat(input.gradient_a[i]),
|
||||
Load(input.gradient_b[i])), true);
|
||||
VectorPair geo{_mm256_setzero_pd(), _mm256_setzero_pd()};
|
||||
for (std::size_t j = 0; j < 3; ++j)
|
||||
for (std::size_t l = 0; l < 3; ++l)
|
||||
geo = Add(geo, Multiply(Splat(input.gradient_stress[j][l]),
|
||||
Load(input.gradient_b[l])), true);
|
||||
output->gradient_dot = Store(dot);
|
||||
output->weighted_geometric = Store(Multiply(geo, Splat(input.weight)));
|
||||
}
|
||||
} // namespace fesa::hex8_internal
|
||||
#else
|
||||
namespace fesa::hex8_internal {
|
||||
@@ -258,5 +276,9 @@ void EvaluateMaterialPacketAvx2(const MaterialPacketInput& input,
|
||||
PairPacket* output) {
|
||||
EvaluateMaterialPacketScalar(input, output);
|
||||
}
|
||||
void EvaluateGeometryPacketAvx2(const GeometryPacketInput& input,
|
||||
GeometryPacketOutput* output) {
|
||||
EvaluateGeometryPacketScalar(input, output);
|
||||
}
|
||||
} // namespace fesa::hex8_internal
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user