Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix avx issues on arm #860

Merged
merged 12 commits into from
Sep 16, 2023
22 changes: 13 additions & 9 deletions cmake/DetectArchitecture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,25 @@ 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)
string(REPLACE "?" ";" CURRENT_LIST "${INSTRUCTION_SET}")
list(GET CURRENT_LIST 0 INSTRUCTION_SET_NAME)
list(GET CURRENT_LIST 1 INSTRUCTION_SET_FLAG)
string(REPLACE "." ";" INSTRUCTION_SET_FLAG "${INSTRUCTION_SET_FLAG}")
list(GET CURRENT_LIST 2 INSTRUCTION_SET_INTRINSIC)
string(REPLACE "#" ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}")
check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_FLAG}" "${INSTRUCTION_SET_INTRINSIC}")
endforeach()
foreach(INSTRUCTION_SET IN LISTS INSTRUCTION_SETS)
string(REPLACE "?" ";" CURRENT_LIST "${INSTRUCTION_SET}")
list(GET CURRENT_LIST 0 INSTRUCTION_SET_NAME)
list(GET CURRENT_LIST 1 INSTRUCTION_SET_FLAG)
string(REPLACE "." ";" INSTRUCTION_SET_FLAG "${INSTRUCTION_SET_FLAG}")
list(GET CURRENT_LIST 2 INSTRUCTION_SET_INTRINSIC)
string(REPLACE "#" ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}")
check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_FLAG}" "${INSTRUCTION_SET_INTRINSIC}")
endforeach()

string(REPLACE "T_" "" AVX_DISPLAY ${AVX_NAME})
message(STATUS "Detected ${CMAKE_SYSTEM_PROCESSOR} SSE type: ${AVX_DISPLAY}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE}")
else()
message(STATUS "SSE not supported by architecture ${CMAKE_SYSTEM_PROCESSOR} ${AVX_NAME}")
set(AVX_NAME "T_fallback")
set(AVX_TYPE "T_fallback")
endif()
1 change: 0 additions & 1 deletion include/dpp/discordvoiceclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <dpp/dispatcher.h>
#include <dpp/cluster.h>
#include <dpp/discordevents.h>
#include <dpp/isa_detection.h>
#include <dpp/socket.h>
#include <queue>
#include <thread>
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
1 change: 1 addition & 0 deletions src/dpp/discordvoiceclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <algorithm>
#include <cmath>
#include <dpp/exception.h>
#include <dpp/isa_detection.h>
#include <dpp/discordvoiceclient.h>
#include <dpp/cache.h>
#include <dpp/cluster.h>
Expand Down