Skip to content

Commit

Permalink
arrange compile options.
Browse files Browse the repository at this point in the history
  • Loading branch information
aikiriao committed Jun 30, 2024
1 parent 88b271f commit 01c081e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ add_library(${DECODER_LIB_NAME}
$<TARGET_OBJECTS:bit_stream>
)

# SIMD命令をどこまで使うか?
set(USE_SIMD_INTRINSICS "" CACHE STRING "Using SIMD operations (SSE41 or AVX2)")
if("${USE_SIMD_INTRINSICS}" STREQUAL "SSE41")
add_compile_definitions(SRLA_USE_SSE41)
if(NOT MSVC)
add_compile_options(-msse4.1)
endif()
elseif("${USE_SIMD_INTRINSICS}" STREQUAL "AVX2")
add_compile_definitions(SRLA_USE_AVX2)
if(MSVC)
add_compile_options(/arch:AVX2)
else()
add_compile_options(-msse4.1 -mavx2)
endif()
endif()

# 最適化オプション
if(MSVC)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /Ot /Oy /GL")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
endif()

# 依存するプロジェクト
add_subdirectory(libs)

Expand Down
8 changes: 0 additions & 8 deletions libs/srla_decoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,3 @@ set_target_properties(${LIB_NAME}
C_STANDARD 90 C_EXTENSIONS OFF
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
)

# SIMD命令をどこまで使うか?
set(USE_SIMD_INTRINSICS "" CACHE STRING "Using SIMD operations (SSE41 or AVX2)")
if("${USE_SIMD_INTRINSICS}" STREQUAL "SSE41")
add_compile_definitions(SRLADECODER_USE_SSE41)
elseif("${USE_SIMD_INTRINSICS}" STREQUAL "AVX2")
add_compile_definitions(SRLADECODER_USE_AVX2)
endif()
4 changes: 2 additions & 2 deletions libs/srla_decoder/src/srla_lpc_synthesize.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "srla_utility.h"

/* LPC係数により合成(in-place) */
#if defined(SRLADECODER_USE_SSE41)
#if defined(SRLA_USE_SSE41)
#ifdef _MSC_VER
#include <intrin.h>
#define DECLALIGN(x) __declspec(align(x))
Expand Down Expand Up @@ -104,7 +104,7 @@ void SRLALPC_Synthesize(
data[smpl] -= (predict >> coef_rshift);
}
}
#elif defined(SRLADECODER_USE_AVX2)
#elif defined(SRLA_USE_AVX2)
#ifdef _MSC_VER
#include <immintrin.h>
#define DECLALIGN(x) __declspec(align(x))
Expand Down
8 changes: 0 additions & 8 deletions libs/srla_encoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,3 @@ set_target_properties(${LIB_NAME}
C_STANDARD 90 C_EXTENSIONS OFF
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
)

# SIMD命令をどこまで使うか?
set(USE_SIMD_INTRINSICS "" CACHE STRING "Using SIMD operations (SSE41 or AVX2)")
if("${USE_SIMD_INTRINSICS}" STREQUAL "SSE41")
add_compile_definitions(SRLAENCODER_USE_SSE41)
elseif("${USE_SIMD_INTRINSICS}" STREQUAL "AVX2")
add_compile_definitions(SRLAENCODER_USE_AVX2)
endif()
4 changes: 2 additions & 2 deletions libs/srla_encoder/src/srla_lpc_predict.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "srla_internal.h"

/* LPC係数により予測/誤差出力 */
#if defined(SRLAENCODER_USE_SSE41)
#if defined(SRLA_USE_SSE41)
#ifdef _MSC_VER
#include <intrin.h>
#define DECLALIGN(x) __declspec(align(x))
Expand Down Expand Up @@ -107,7 +107,7 @@ void SRLALPC_Predict(
residual[smpl] += (predict >> coef_rshift);
}
}
#elif defined(SRLAENCODER_USE_AVX2)
#elif defined(SRLA_USE_AVX2)
#ifdef _MSC_VER
#include <immintrin.h>
#define DECLALIGN(x) __declspec(align(x))
Expand Down

0 comments on commit 01c081e

Please sign in to comment.