Skip to content

Commit

Permalink
Port from x86 intrinsics to CPU native ones using SIMDe
Browse files Browse the repository at this point in the history
  • Loading branch information
pabs3 committed Jul 12, 2022
1 parent 65951d2 commit 4d51f36
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion AnnService/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ add_library (DistanceUtils STATIC
)

if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
target_compile_options(DistanceUtils PRIVATE -mavx2 -mavx -msse -msse2 -mavx512f -mavx512bw -mavx512dq -fPIC)
target_compile_options(DistanceUtils PRIVATE -fPIC -fopenmp-simd -O3)
target_compile_definitions(DistanceUtils PRIVATE SIMDE_ENABLE_NATIVE_ALIASES SIMDE_ENABLE_OPENMP)
endif()

add_library (SPTAGLib SHARED ${SRC_FILES} ${HDR_FILES})
Expand Down
2 changes: 1 addition & 1 deletion AnnService/inc/Core/Common/DistanceUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef _SPTAG_COMMON_DISTANCEUTILS_H_
#define _SPTAG_COMMON_DISTANCEUTILS_H_

#include <xmmintrin.h>
#include <simde/x86/sse.h>
#include <functional>
#include <iostream>

Expand Down
2 changes: 1 addition & 1 deletion AnnService/inc/Core/Common/RelativeNeighborhoodGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef _SPTAG_COMMON_RNG_H_
#define _SPTAG_COMMON_RNG_H_

#include <xmmintrin.h>
#include <simde/x86/sse.h>
#include "NeighborhoodGraph.h"

namespace SPTAG
Expand Down
2 changes: 1 addition & 1 deletion AnnService/inc/Core/Common/SIMDUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef _SPTAG_COMMON_SIMDUTILS_H_
#define _SPTAG_COMMON_SIMDUTILS_H_

#include <xmmintrin.h>
#include <simde/x86/sse.h>
#include <functional>
#include <iostream>

Expand Down
16 changes: 15 additions & 1 deletion AnnService/src/Core/Common/DistanceUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
// Licensed under the MIT License.

#include "inc/Core/Common/DistanceUtils.h"
#include <immintrin.h>
#include <simde/x86/avx.h>
#include <simde/x86/avx2.h>
#include <simde/x86/avx512.h>

#ifndef __mmask32
#define __mmask32 simde__mmask32
#endif

#ifndef __mmask64
#define __mmask64 simde__mmask64
#endif

#ifndef _mm512_setzero_ps
#define _mm512_setzero_ps simde_mm512_setzero_ps
#endif

using namespace SPTAG;
using namespace SPTAG::COMMON;
Expand Down
4 changes: 3 additions & 1 deletion AnnService/src/Core/Common/SIMDUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Licensed under the MIT License.

#include "inc/Core/Common/SIMDUtils.h"
#include <immintrin.h>
#include <simde/x86/avx.h>
#include <simde/x86/avx2.h>
#include <simde/x86/avx512.h>

using namespace SPTAG;
using namespace SPTAG::COMMON;
Expand Down

0 comments on commit 4d51f36

Please sign in to comment.