Skip to content

Commit 87955f6

Browse files
authored
[enh] Add intel compiler support (#131)
1 parent 0e9a9a1 commit 87955f6

File tree

6 files changed

+56
-11
lines changed

6 files changed

+56
-11
lines changed

.github/workflows/c-cpp.yml

+47
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,50 @@ jobs:
179179
run: |
180180
docker run -v $(pwd):/xss quay.io/pypa/manylinux2014_i686 \
181181
/bin/bash -xc "source /xss/.github/workflows/build-test-on-32bit.sh"
182+
183+
SPR-icpx:
184+
185+
runs-on: intel-ubuntu-latest
186+
187+
steps:
188+
- uses: actions/checkout@v3
189+
190+
- name: Install dependencies
191+
run: |
192+
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
193+
sudo add-apt-repository -y "deb https://apt.repos.intel.com/oneapi all main"
194+
sudo apt update --allow-insecure-repositories
195+
sudo apt --allow-unauthenticated -y install intel-oneapi-compiler-dpcpp-cpp libgtest-dev curl git python3-pip
196+
sudo pip3 install meson ninja
197+
198+
- name: Install Intel SDE
199+
run: |
200+
curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/784319/sde-external-9.24.0-2023-07-13-lin.tar.xz
201+
mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/
202+
sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde
203+
204+
- name: Build examples
205+
env:
206+
CXX: icpx
207+
CXXFLAGS: -fp-model=precise
208+
run: |
209+
source /opt/intel/oneapi/setvars.sh
210+
cd examples
211+
make all
212+
213+
- name: Build
214+
env:
215+
CXX: icpx
216+
CXXFLAGS: -fp-model=precise
217+
run: |
218+
make clean
219+
source /opt/intel/oneapi/setvars.sh
220+
icpx --version
221+
meson setup -Dbuild_tests=true --warnlevel 2 --werror --buildtype release builddir
222+
cd builddir
223+
ninja
224+
225+
- name: Run test suite on SPR
226+
run: |
227+
source /opt/intel/oneapi/setvars.sh
228+
sde -spr -- ./builddir/testexe

examples/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CXX ?= g++-12
2-
CFLAGS = -I../src -std=c++17 -O3
2+
CFLAGS = -I../src -std=c++17 -O3 $(if $(CXXFLAGS),$(CXXFLAGS),)
33
EXE = qsort32avx2 argsort kvsort qsortfp16 qsort16 qsort32 qsort64
44

55
default: all

lib/x86simdsort.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ static int check_cpu_feature_support(std::string_view cpufeature)
1010
const char *disable_avx512 = std::getenv("XSS_DISABLE_AVX512");
1111

1212
if ((cpufeature == "avx512_spr") && (!disable_avx512))
13-
#ifdef __FLT16_MAX__
13+
#if defined(__FLT16_MAX__) && !defined(__INTEL_LLVM_COMPILER)
1414
return __builtin_cpu_supports("avx512f")
1515
&& __builtin_cpu_supports("avx512fp16")
1616
&& __builtin_cpu_supports("avx512vbmi2");

src/avx2-32bit-qsort.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,10 @@ struct avx2_vector<float> {
438438
template <int type>
439439
static opmask_t fpclass(reg_t x)
440440
{
441-
if constexpr (type == (0x01 | 0x80)) {
442-
return _mm256_castps_si256(_mm256_cmp_ps(x, x, _CMP_UNORD_Q));
443-
}
444-
else {
441+
if constexpr (type != (0x01 | 0x80)) {
445442
static_assert(type == (0x01 | 0x80), "should not reach here");
446443
}
444+
return _mm256_castps_si256(_mm256_cmp_ps(x, x, _CMP_UNORD_Q));
447445
}
448446
template <int scale>
449447
static reg_t

src/avx2-64bit-qsort.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,10 @@ struct avx2_vector<double> {
454454
template <int type>
455455
static opmask_t fpclass(reg_t x)
456456
{
457-
if constexpr (type == (0x01 | 0x80)) {
458-
return _mm256_castpd_si256(_mm256_cmp_pd(x, x, _CMP_UNORD_Q));
459-
}
460-
else {
457+
if constexpr (type != (0x01 | 0x80)) {
461458
static_assert(type == (0x01 | 0x80), "should not reach here");
462459
}
460+
return _mm256_castpd_si256(_mm256_cmp_pd(x, x, _CMP_UNORD_Q));
463461
}
464462
static ymmi_t seti(int64_t v1, int64_t v2, int64_t v3, int64_t v4)
465463
{

src/xss-common-includes.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565
#define UNLIKELY(x) (x)
6666
#endif
6767

68-
#if __GNUC__ >= 8 and !defined(__SANITIZE_ADDRESS__)
68+
#if defined(__INTEL_COMPILER) and !defined(__SANITIZE_ADDRESS__)
69+
#define X86_SIMD_SORT_UNROLL_LOOP(num) PRAGMA(unroll(num))
70+
#elif __GNUC__ >= 8 and !defined(__SANITIZE_ADDRESS__)
6971
#define X86_SIMD_SORT_UNROLL_LOOP(num) PRAGMA(GCC unroll num)
7072
#else
7173
#define X86_SIMD_SORT_UNROLL_LOOP(num)

0 commit comments

Comments
 (0)