Skip to content

Commit

Permalink
fixes for avx breaking arm
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Sep 16, 2023
1 parent 3e222ac commit 381f36c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 42 deletions.
2 changes: 2 additions & 0 deletions cmake/DetectArchitecture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ endif()
set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}")

set(AVX_NAME "T_fallback")

# This is only supported on x86/x64, it is completely skipped and forced to T_fallback anywhere else
if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64"))

foreach(INSTRUCTION_SET IN LISTS INSTRUCTION_SETS)
Expand Down
89 changes: 47 additions & 42 deletions include/dpp/isa_detection.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@

#if defined _MSC_VER || defined __GNUC__ || defined __clang__

/* Sanity check for cases of broken detection */
#if !defined(__i386__) && !defined(__x86_64__)
#define T_fallback 1
#endif

#ifndef T_fallback
#include <immintrin.h>

Expand All @@ -40,21 +45,21 @@
*/
inline int32_t extract_int32_from_avx(const avx_int& value, int64_t index) {
switch (index) {
case 0: {
return _mm_extract_epi32(value, 0);
}
case 1: {
return _mm_extract_epi32(value, 1);
}
case 2: {
return _mm_extract_epi32(value, 2);
}
case 3: {
return _mm_extract_epi32(value, 3);
}
default: {
return _mm_extract_epi32(value, 0);
}
case 0: {
return _mm_extract_epi32(value, 0);
}
case 1: {
return _mm_extract_epi32(value, 1);
}
case 2: {
return _mm_extract_epi32(value, 2);
}
case 3: {
return _mm_extract_epi32(value, 3);
}
default: {
return _mm_extract_epi32(value, 0);
}
}
}

Expand All @@ -66,33 +71,33 @@
*/
inline int32_t extract_int32_from_avx2(const avx_2_int& value, int64_t index) {
switch (index) {
case 0: {
return _mm256_extract_epi32(value, 0);
}
case 1: {
return _mm256_extract_epi32(value, 1);
}
case 2: {
return _mm256_extract_epi32(value, 2);
}
case 3: {
return _mm256_extract_epi32(value, 3);
}
case 4: {
return _mm256_extract_epi32(value, 4);
}
case 5: {
return _mm256_extract_epi32(value, 5);
}
case 6: {
return _mm256_extract_epi32(value, 6);
}
case 7: {
return _mm256_extract_epi32(value, 7);
}
default: {
return _mm256_extract_epi32(value, 0);
}
case 0: {
return _mm256_extract_epi32(value, 0);
}
case 1: {
return _mm256_extract_epi32(value, 1);
}
case 2: {
return _mm256_extract_epi32(value, 2);
}
case 3: {
return _mm256_extract_epi32(value, 3);
}
case 4: {
return _mm256_extract_epi32(value, 4);
}
case 5: {
return _mm256_extract_epi32(value, 5);
}
case 6: {
return _mm256_extract_epi32(value, 6);
}
case 7: {
return _mm256_extract_epi32(value, 7);
}
default: {
return _mm256_extract_epi32(value, 0);
}
}
}

Expand Down

0 comments on commit 381f36c

Please sign in to comment.