Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Source/GmmLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ endif()

if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
set(GMMLIB_MARCH "armv8-a+fp+simd")
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^loongarch")
set(GMMLIB_MARCH "la464")
elseif("${GMMLIB_MARCH}" STREQUAL "")
set(GMMLIB_MARCH "corei7")
endif()
Expand Down Expand Up @@ -443,6 +445,18 @@ include_directories(BEFORE ${PROJECT_SOURCE_DIR})

if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
include_directories(${GFX_DEVELOPMENT_DIR}/third_party/sse2neon)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^loongarch")
find_path(SIMDE_INCLUDE_DIR
NAMES simde/simde-common.h # A key SIMDE header
PATHS /usr/include /usr/local/include # Default paths
DOC "Path to SIMDE headers"
)
if(SIMDE_INCLUDE_DIR)
include_directories(${SIMDE_INCLUDE_DIR})
message(STATUS "Found SIMDE: ${SIMDE_INCLUDE_DIR}")
else()
message(FATAL_ERROR "SIMDE not found. Install it or set SIMDE_INCLUDE_DIR manually.")
endif()
endif()

set(headers
Expand Down
89 changes: 31 additions & 58 deletions Source/GmmLib/Linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,8 @@
# OTHER DEALINGS IN THE SOFTWARE.

#this file should contain only compiler and linker flags
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
SET (GMMLIB_COMPILER_FLAGS_COMMON
#general warnings
#-Wall
-Winit-self
-Winvalid-pch
-Wpointer-arith
-Wno-unused
-Wno-unknown-pragmas
-Wno-comments
-Wno-narrowing
-Wno-overflow
-Wno-parentheses
-Wno-missing-braces
-Wno-sign-compare
-Werror=address
-Werror=format-security
-Werror=return-type

# General optimization options
-march=${GMMLIB_MARCH}
-finline-functions
-fno-short-enums
-Wa,--noexecstack
-fno-strict-aliasing
# Common defines
-DUSE_NEON
# Other common flags
-fstack-protector
-fdata-sections
-ffunction-sections
-fmessage-length=0
-fvisibility=hidden
-fPIC
-g
)
else()
SET (GMMLIB_COMPILER_FLAGS_COMMON
#general warnings
-Wall
SET (GMMLIB_COMPILER_FLAGS_COMMON
-Winit-self
-Winvalid-pch
-Wpointer-arith
Expand All @@ -70,32 +32,16 @@ else()
-Wno-parentheses
-Wno-missing-braces
-Wno-sign-compare
-Wno-enum-compare
-Werror=address
-Werror=format-security
-Werror=return-type

# General optimization options
-march=${GMMLIB_MARCH}
-mpopcnt
-msse
-msse2
-msse3
-mssse3
-msse4
-msse4.1
-msse4.2
-mfpmath=sse
-finline-functions
-fno-short-enums
-Wa,--noexecstack
-fno-strict-aliasing
# Common defines
-DUSE_MMX
-DUSE_SSE
-DUSE_SSE2
-DUSE_SSE3
-DUSE_SSSE3
# Other common flags
-fstack-protector
-fdata-sections
Expand All @@ -104,9 +50,33 @@ else()
-fvisibility=hidden
-fPIC
-g
# -m32 or -m64
-m${GMMLIB_ARCH}
)
)

if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
list(APPEND GMMLIB_COMPILER_FLAGS_COMMON "-DUSE_NEON")
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^loongarch")
list(APPEND GMMLIB_COMPILER_FLAGS_COMMON "-Wno-attributes")
else()
list (APPEND GMMLIB_COMPILER_FLAGS_COMMON
-Wall
-Wno-enum-compare
-mpopcnt
-msse
-msse2
-msse3
-mssse3
-msse4
-msse4.1
-msse4.2
-mfpmath=sse
-DUSE_MMX
-DUSE_SSE
-DUSE_SSE2
-DUSE_SSE3
-DUSE_SSSE3
# -m32 or -m64
-m${GMMLIB_ARCH}
)
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Expand Down Expand Up @@ -177,6 +147,9 @@ endforeach()
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^loongarch")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m${GMMLIB_ARCH}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m${GMMLIB_ARCH}")
Expand Down
12 changes: 11 additions & 1 deletion Source/GmmLib/Utility/CpuSwizzleBlt/CpuSwizzleBlt.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ extern void CpuSwizzleBlt(CPU_SWIZZLE_BLT_SURFACE *pDest, CPU_SWIZZLE_BLT_SURFAC
#include <intrin.h>
#elif defined(__ARM_ARCH)
#include <sse2neon.h>
#elif defined(__loongarch64)
#define SIMDE_X86_SSE2_ENABLE_NATIVE_ALIASES
#include <simde/x86/sse2.h>
#elif((defined __clang__) ||(__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)))
#include <cpuid.h>
#include <x86intrin.h>
Expand Down Expand Up @@ -749,6 +752,9 @@ void CpuSwizzleBlt( // #########################################################
#elif(defined(__ARM_ARCH))
#define MOVNTDQA_R(Reg, Src) ((Reg) = (Reg))
StreamingLoadSupported = 0;
#elif(defined(__loongarch64))
#define MOVNTDQA_R(Reg, Src) ((Reg) = (Reg))
StreamingLoadSupported = 0;
#elif((defined __clang__) || (__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
#define MOVNTDQA_R(Reg, Src) ((Reg) = _mm_stream_load_si128((__m128i *)(Src)))
unsigned int eax, ebx, ecx, edx;
Expand Down Expand Up @@ -1148,7 +1154,11 @@ void CpuSwizzleBlt( // #########################################################

} // foreach(y)

_mm_sfence(); // Flush Non-Temporal Writes
#if(defined(__loongarch64))
__sync_synchronize();
#else
_mm_sfence(); // Flush Non-Temporal Writes
#endif

#if(_MSC_VER)
#pragma warning(pop)
Expand Down