Skip to content

Commit

Permalink
Fixed MinGW SIMD
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed Sep 3, 2024
1 parent cc4c9f7 commit ecf5aac
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ target_compile_definitions (PluginSearcher PRIVATE
if (NOT MSVC)
target_compile_options (PluginSearcher PRIVATE
-pthread -fPIE)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options (PluginSearcher PRIVATE -g)
endif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
endif (NOT MSVC)
if (MINGW)
target_link_options (PluginSearcher PRIVATE
Expand Down Expand Up @@ -207,6 +210,9 @@ target_compile_definitions (FileRegistrar PRIVATE
if (NOT MSVC)
target_compile_options (FileRegistrar PRIVATE
-pthread -fPIE)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options (FileRegistrar PRIVATE -g)
endif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
endif (NOT MSVC)
if (MINGW)
target_link_options (FileRegistrar PRIVATE
Expand Down Expand Up @@ -243,8 +249,10 @@ target_link_libraries (VocalShaper PRIVATE
)
if (NOT MSVC)
target_compile_options (VocalShaper PRIVATE
-pthread -fPIE
-msse3 -mavx2 -mavx512f)
-pthread -fPIE)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options (VocalShaper PRIVATE -g)
endif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
endif (NOT MSVC)
if (MINGW)
target_link_options (VocalShaper PRIVATE
Expand Down
64 changes: 64 additions & 0 deletions src/audioCore/misc/VMath.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "VMath.h"

#if (!JUCE_MSVC) && (__SSE3__ || __AVX2__ || __AVX512F__)
#include <immintrin.h>
#endif //(!JUCE_MSVC) && (__SSE3__ || __AVX2__ || __AVX512F__)

namespace vMath {
static void copyDataNormal(float* dst, const float* src, int length) {
std::memcpy(dst, src, length * sizeof(float));
Expand All @@ -23,6 +27,7 @@ namespace vMath {
}
}

#if __SSE3__ || JUCE_MSVC
static void copyDataSSE3(float* dst, const float* src, int length) {
int clipSize = sizeof(__m128) / sizeof(float);
int clipNum = length / clipSize;
Expand Down Expand Up @@ -81,6 +86,26 @@ namespace vMath {
averageDataNormal(&(dst[clipMax]), &(src[clipMax]), length - clipMax);
}

#else //__SSE3__ || JUCE_MSVC
static void copyDataSSE3(float* dst, const float* src, int length) {
copyDataNormal(dst, src, length);
}

static void addDataSSE3(float* dst, const float* src, int length) {
addDataNormal(dst, src, length);
}

static void fillDataSSE3(float* dst, float data, int length) {
fillDataNormal(dst, data, length);
}

static void averageDataSSE3(float* dst, const float* src, int length) {
averageDataNormal(dst, src, length);
}

#endif //__SSE3__ || JUCE_MSVC

#if __AVX2__ || JUCE_MSVC
static void copyDataAVX2(float* dst, const float* src, int length) {
int clipSize = sizeof(__m256) / sizeof(float);
int clipNum = length / clipSize;
Expand Down Expand Up @@ -139,6 +164,26 @@ namespace vMath {
averageDataNormal(&(dst[clipMax]), &(src[clipMax]), length - clipMax);
}

#else //__AVX2__ || JUCE_MSVC
static void copyDataAVX2(float* dst, const float* src, int length) {
copyDataSSE3(dst, src, length);
}

static void addDataAVX2(float* dst, const float* src, int length) {
addDataSSE3(dst, src, length);
}

static void fillDataAVX2(float* dst, float data, int length) {
fillDataSSE3(dst, data, length);
}

static void averageDataAVX2(float* dst, const float* src, int length) {
averageDataSSE3(dst, src, length);
}

#endif //__AVX2__ || JUCE_MSVC

#if __AVX512F__ || JUCE_MSVC
static void copyDataAVX512(float* dst, const float* src, int length) {
int clipSize = sizeof(__m512) / sizeof(float);
int clipNum = length / clipSize;
Expand Down Expand Up @@ -197,6 +242,25 @@ namespace vMath {
averageDataNormal(&(dst[clipMax]), &(src[clipMax]), length - clipMax);
}

#else //__AVX512F__ || JUCE_MSVC
static void copyDataAVX512(float* dst, const float* src, int length) {
copyDataAVX2(dst, src, length);
}

static void addDataAVX512(float* dst, const float* src, int length) {
addDataAVX2(dst, src, length);
}

static void fillDataAVX512(float* dst, float data, int length) {
fillDataAVX2(dst, data, length);
}

static void averageDataAVX512(float* dst, const float* src, int length) {
averageDataAVX2(dst, src, length);
}

#endif //__AVX512F__ || JUCE_MSVC

static InsType type = InsType::Normal;
static auto copyData = copyDataNormal;
static auto addData = addDataNormal;
Expand Down

0 comments on commit ecf5aac

Please sign in to comment.