Skip to content
Snippets Groups Projects

ARM support

Merged Arthur Marius Hennequin requested to merge ahennequ_armSupport into master
Files
15
@@ -66,6 +66,8 @@ namespace LHCb {
}
MagneticFieldGrid::FieldVector MagneticFieldGrid::fieldVectorLinearInterpolation( const Gaudi::XYZPoint& r ) const {
#ifdef __x86_64__
// for x86_64, we use sse vectorization
// Linear interpolate the field on a cube
const float abc0 = ( (float)r.x() - m_min[0] ) * m_invDxyz[0];
@@ -117,7 +119,59 @@ namespace LHCb {
return {bf_V[0], bf_V[1], bf_V[2]};
}
#else
// for other platforms, we fall back to scalar implementation
// Linear interpolate the field on a cube
const std::array<float, 3> abc = {(float)( r.x() - m_min[0] ) * m_invDxyz[0],
(float)( r.y() - m_min[1] ) * m_invDxyz[1],
(float)( r.z() - m_min[2] ) * m_invDxyz[2]};
const auto i = static_cast<IndexType>( abc[0] );
const auto j = static_cast<IndexType>( abc[1] );
const auto k = static_cast<IndexType>( abc[2] );
if ( LIKELY( i >= 0 && i < m_Nxyz[0] - 1 && //
j >= 0 && j < m_Nxyz[1] - 1 && //
k >= 0 && k < m_Nxyz[2] - 1 ) ) {
// auxiliary variables defined at the vertices of the cube that
// contains the (x, y, z) point where the field is interpolated
const auto ijk000 = m_Nxyz[0] * ( m_Nxyz[1] * k + j ) + i;
const auto ijk001 = m_Nxyz[0] * ( m_Nxyz[1] * ( k + 1 ) + j ) + i;
const auto ijk010 = m_Nxyz[0] * ( m_Nxyz[1] * k + j + 1 ) + i;
const auto ijk011 = m_Nxyz[0] * ( m_Nxyz[1] * ( k + 1 ) + j + 1 ) + i;
const auto h1x = abc[0] - i;
const auto h1y = abc[1] - j;
const auto h1z = abc[2] - k;
const auto h0x( 1.0f - h1x );
const auto h0y( 1.0f - h1y );
const auto h0z( 1.0f - h1z );
const auto h00 = h0x * h0y;
const auto h01 = h0x * h1y;
const auto h10 = h1x * h0y;
const auto h11 = h1x * h1y;
return {m_scaleFactor[0] * ( h0z * ( h00 * m_B[ijk000][0] + h10 * m_B[ijk000 + 1][0] + h01 * m_B[ijk010][0] +
h11 * m_B[ijk010 + 1][0] ) +
h1z * ( h00 * m_B[ijk001][0] + h10 * m_B[ijk001 + 1][0] + h01 * m_B[ijk011][0] +
h11 * m_B[ijk011 + 1][0] ) ),
m_scaleFactor[1] * ( h0z * ( h00 * m_B[ijk000][1] + h10 * m_B[ijk000 + 1][1] + h01 * m_B[ijk010][1] +
h11 * m_B[ijk010 + 1][1] ) +
h1z * ( h00 * m_B[ijk001][1] + h10 * m_B[ijk001 + 1][1] + h01 * m_B[ijk011][1] +
h11 * m_B[ijk011 + 1][1] ) ),
m_scaleFactor[2] * ( h0z * ( h00 * m_B[ijk000][2] + h10 * m_B[ijk000 + 1][2] + h01 * m_B[ijk010][2] +
h11 * m_B[ijk010 + 1][2] ) +
h1z * ( h00 * m_B[ijk001][2] + h10 * m_B[ijk001 + 1][2] + h01 * m_B[ijk011][2] +
h11 * m_B[ijk011 + 1][2] ) )};
}
#endif // __x86_64__
// if get here return null vector
return {0, 0, 0};
}
} // namespace LHCb
Loading