2020#pragma once
2121#include " math/simd/vector/float.hpp"
2222
23+ #if defined(MATH_SIMD_SUPPORT_AVX2)
2324namespace math
2425{
2526
@@ -45,7 +46,7 @@ struct [[nodiscard]] alignas(8) f16x4
4546 */
4647 f16x4 () noexcept
4748 {
48- #if defined(__F16C__ )
49+ #if defined(MATH_SIMD_SUPPORT_AVX2 )
4950 data = 0 ;
5051 #elif defined(MATH_SIMD_SUPPORT_NEON)
5152 data = vdup_n_f16 (0 .0f );
@@ -59,7 +60,7 @@ struct [[nodiscard]] alignas(8) f16x4
5960 */
6061 explicit f16x4 (half xyzw) noexcept
6162 {
62- #if defined(__F16C__ )
63+ #if defined(MATH_SIMD_SUPPORT_AVX2 )
6364 _mm_storel_epi64 ((__m128i*)&data, _mm_cvtps_ph (_mm_set1_ps (xyzw), _MM_FROUND_TO_NEAREST_INT));
6465 #elif defined(MATH_SIMD_SUPPORT_NEON)
6566 data = vdup_n_f16 (xyzw);
@@ -77,7 +78,7 @@ struct [[nodiscard]] alignas(8) f16x4
7778 */
7879 f16x4 (half x, half y, half z, half w) noexcept
7980 {
80- #if defined(__F16C__ )
81+ #if defined(MATH_SIMD_SUPPORT_AVX2 )
8182 _mm_storel_epi64 ((__m128i*)&data, _mm_cvtps_ph (_mm_set_ps (w, z, y, x), _MM_FROUND_TO_NEAREST_INT));
8283 #elif defined(MATH_SIMD_SUPPORT_NEON)
8384 data = (float16x4_t ){ x, y, z, w };
@@ -95,7 +96,7 @@ struct [[nodiscard]] alignas(8) f16x4
9596 */
9697 f16x4 (half x, half y, half z) noexcept
9798 {
98- #if defined(__F16C__ )
99+ #if defined(MATH_SIMD_SUPPORT_AVX2 )
99100 _mm_storel_epi64 ((__m128i*)&data, _mm_cvtps_ph (_mm_set_ps (z, z, y, x), _MM_FROUND_TO_NEAREST_INT));
100101 #elif defined(MATH_SIMD_SUPPORT_NEON)
101102 data = (float16x4_t ){ x, y, z, z };
@@ -118,7 +119,7 @@ struct [[nodiscard]] alignas(8) f16x4
118119 */
119120 explicit f16x4 (f32x4 v) noexcept
120121 {
121- #if defined(__F16C__ )
122+ #if defined(MATH_SIMD_SUPPORT_AVX2 )
122123 _mm_storel_epi64 ((__m128i*)&data, _mm_cvtps_ph (v.data , _MM_FROUND_TO_NEAREST_INT));
123124 #elif defined(MATH_SIMD_SUPPORT_NEON)
124125 data = vcvt_f16_f32 (v.data );
@@ -188,7 +189,7 @@ struct [[nodiscard]] alignas(8) f16x4
188189 */
189190 explicit operator f32x4 () const noexcept
190191 {
191- #if defined(__F16C__ )
192+ #if defined(MATH_SIMD_SUPPORT_AVX2 )
192193 return _mm_cvtph_ps (_mm_loadl_epi64 ((__m128i*)&data));
193194 #elif defined(MATH_SIMD_SUPPORT_NEON)
194195 return vcvt_f32_f16 (data);
@@ -200,4 +201,5 @@ struct [[nodiscard]] alignas(8) f16x4
200201 // TODO: math functions after adding AVX512 support.
201202};
202203
203- } // namespace math
204+ } // namespace math
205+ #endif // MATH_SIMD_SUPPORT_AVX2
0 commit comments