Skip to content

Commit 7263323

Browse files
razdoburdinUbuntunapetrov
authored
Add ARM validation to CI (#109)
This PR adds an Ubuntu ARM validation in github workflow. Some minor changes in the codebase are also made for compatibility with ARM. --------- Co-authored-by: Dmitry Razdoburdin <> Co-authored-by: Ubuntu <[email protected]> Co-authored-by: Nikolay Petrov <[email protected]>
1 parent 5a7da98 commit 7263323

File tree

8 files changed

+88
-5
lines changed

8 files changed

+88
-5
lines changed

.github/workflows/build-linux-arm.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright 2025 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Linux Build and Test on ARM
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
pull_request:
22+
23+
permissions:
24+
contents: read
25+
26+
# This allows a subsequently queued workflow run to interrupt previous runs
27+
concurrency:
28+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
29+
cancel-in-progress: true
30+
31+
jobs:
32+
build:
33+
name: ${{ matrix.cxx }}, ${{ matrix.build_type }}
34+
runs-on: ubuntu-22.04-arm
35+
strategy:
36+
matrix:
37+
build_type: [RelWithDebugInfo]
38+
cxx: [g++-11, g++-12, clang++-15]
39+
include:
40+
- cxx: g++-11
41+
cc: gcc-11
42+
- cxx: g++-12
43+
cc: gcc-12
44+
- cxx: clang++-15
45+
cc: clang-15
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Configure build
51+
working-directory: ${{ runner.temp }}
52+
env:
53+
CXX: ${{ matrix.cxx }}
54+
CC: ${{ matrix.cc }}
55+
TEMP_WORKSPACE: ${{ runner.temp }}
56+
run: |
57+
cmake -B${TEMP_WORKSPACE}/build -S${GITHUB_WORKSPACE} \
58+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
59+
-DSVS_BUILD_BINARIES=YES \
60+
-DSVS_BUILD_TESTS=YES \
61+
-DSVS_BUILD_EXAMPLES=YES \
62+
-DSVS_EXPERIMENTAL_LEANVEC=YES
63+
64+
- name: Build Tests and Utilities
65+
working-directory: ${{ runner.temp }}/build
66+
run: make -j$(nproc)
67+
68+
- name: Run tests
69+
env:
70+
CTEST_OUTPUT_ON_FAILURE: 1
71+
working-directory: ${{ runner.temp }}/build/tests
72+
run: ctest -C ${{ matrix.build_type }}

include/svs/core/distance/cosine.h

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <iostream>
3030
#include <memory>
3131
#include <type_traits>
32-
#include <x86intrin.h>
3332

3433
namespace svs::distance {
3534
// Forward declare implementation to allow entry point to be near the top.

include/svs/core/distance/euclidean.h

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <memory>
3232
#include <span>
3333
#include <type_traits>
34-
#include <x86intrin.h>
3534

3635
// Implementation Notes regarding Intel(R) AVX Extentions
3736
// Top most entry in the bulleted list underneath each type pair <T,U> is the preferred

include/svs/core/distance/inner_product.h

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <iostream>
3030
#include <memory>
3131
#include <type_traits>
32-
#include <x86intrin.h>
3332

3433
namespace svs::distance {
3534
// Forward declare implementation to allow entry point to be near the top.

include/svs/core/distance/simd_utils.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#pragma once
1818

19+
#if defined(__i386__) || defined(__x86_64__)
20+
1921
#include <array>
2022
#include <limits>
2123
#include <type_traits>
@@ -369,3 +371,5 @@ template <> struct ConvertForVNNI<int16_t, 32> {
369371

370372
} // namespace simd
371373
} // namespace svs
374+
375+
#endif // __i386__ || __x86_64__

include/svs/lib/prefetch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ template <typename T> void prefetch_l0(const T* ptr) {
3333
}
3434
#else
3535
// Do nothing if prefetch is not-available.
36-
template <typename T> void prefetch_l0(const T* ptr) {}
36+
template <typename T> void prefetch_l0([[maybe_unused]] const T* ptr) {}
3737
#endif
3838

3939
const size_t CACHELINE_BYTES = 64;

include/svs/lib/spinlock.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
namespace svs {
2222

2323
namespace detail {
24-
inline void pause() { __builtin_ia32_pause(); }
24+
inline void pause() {
25+
#if defined(__i386__) || defined(__x86_64__)
26+
__builtin_ia32_pause();
27+
#else // __aarch64__
28+
asm volatile ("yield" ::: "memory");
29+
#endif
30+
}
2531
} // namespace detail
2632

2733
///

tests/svs/core/distances/simd_utils.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
#if defined(__i386__) || defined(__x86_64__)
18+
1719
#include <cstdint>
1820
#include <type_traits>
1921

@@ -61,3 +63,5 @@ CATCH_TEST_CASE("Masks", "[distance]") {
6163
CATCH_REQUIRE(svs::create_mask<16>(svs::lib::MaybeStatic<100>()) == 0xF);
6264
CATCH_REQUIRE(svs::create_mask<16>(svs::lib::MaybeStatic<16>()) == 0xFFFF);
6365
}
66+
67+
#endif // defined(__i386__) || defined(__x86_64__)

0 commit comments

Comments
 (0)