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
5 changes: 5 additions & 0 deletions .github/workflows/01-ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ jobs:
os: ubuntu-24.04
compiler: clang

build-and-test-linux-riscv64:
name: Build & Test (linux-riscv64)
needs: lint
uses: ./.github/workflows/07-linux-riscv-build.yml

build-android:
name: Build & Test (android)
needs: [lint, clang-tidy]
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/03-macos-linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ permissions:
contents: read

jobs:
# Build and test matrix (parallel execution)
build-and-test:
name: Build & Test (${{ inputs.platform }})
runs-on: ${{ inputs.os }}
Expand All @@ -32,7 +31,7 @@ jobs:
include:
- os: ${{ inputs.os }}
platform: ${{ inputs.platform }}
arch_flag: "" # Use appropriate architecture
arch_flag: ""

steps:
- name: Checkout code
Expand Down Expand Up @@ -61,7 +60,6 @@ jobs:

- name: Set up environment variables
run: |
# Set number of processors for parallel builds
if [[ "${{ matrix.platform }}" == "macos-arm64" ]]; then
NPROC=$(sysctl -n hw.ncpu 2>/dev/null || echo 2)
else
Expand All @@ -70,19 +68,18 @@ jobs:
echo "NPROC=$NPROC" >> $GITHUB_ENV
echo "Using $NPROC parallel jobs for builds"

# Set compiler when clang is requested
if [[ "${{ inputs.compiler }}" == "clang" ]]; then
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
fi

# Add Python user base bin to PATH for pip-installed CLI tools
echo "$(python -c 'import site; print(site.USER_BASE)')/bin" >> $GITHUB_PATH
shell: bash

- name: Install dependencies
run: |
python -m pip install --upgrade pip \
python -m pip install --upgrade pip
python -m pip install \
pybind11==3.0 \
cmake==3.30.0 \
ninja==1.11.1 \
Expand Down Expand Up @@ -138,4 +135,4 @@ jobs:
./c_api_field_schema_example
./c_api_index_example
./c_api_optimized_example
shell: bash
shell: bash
219 changes: 219 additions & 0 deletions .github/workflows/07-linux-riscv-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
name: Linux RISC-V Build

on:
workflow_call:

permissions:
contents: read

env:
RISE_PYPI: https://gitlab.com/api/v4/projects/56254198/packages/pypi/simple

jobs:
build:
name: Build (linux-riscv64)
runs-on: ubuntu-24.04-riscv

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: recursive

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pybind11 pybind11-dev
shell: bash

- name: Build from source
run: |
cd "$GITHUB_WORKSPACE"
NPROC=$(nproc 2>/dev/null || echo 2)
echo "Using $NPROC parallel jobs for builds"
cmake -S . -B build \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TOOLS=ON \
-DBUILD_PYTHON_BINDINGS=ON
make -C build -j"$NPROC"
shell: bash

- name: Archive entire workspace
run: |
cd "$GITHUB_WORKSPACE"
tar -cf linux-riscv64-workspace.tar .
shell: bash

- name: Upload workspace artifacts
uses: actions/upload-artifact@v7
with:
name: linux-riscv64-workspace
path: ${{ github.workspace }}/linux-riscv64-workspace.tar
if-no-files-found: error

cpp-tests:
name: C++ Tests
runs-on: ubuntu-24.04-riscv
needs: build

steps:
- name: Install test dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pybind11 pybind11-dev libgtest-dev liburing-dev
shell: bash

- name: Download workspace artifacts
uses: actions/download-artifact@v8
with:
name: linux-riscv64-workspace
path: ${{ github.workspace }}

- name: Extract workspace
run: |
cd "$GITHUB_WORKSPACE"
tar -xf linux-riscv64-workspace.tar
shell: bash

- name: Reconfigure build directory
run: |
cd "$GITHUB_WORKSPACE"
cmake -S . -B build \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TOOLS=ON \
-DBUILD_PYTHON_BINDINGS=ON
shell: bash

- name: Run C++ Tests
run: |
cd "$GITHUB_WORKSPACE/build"
NPROC=$(nproc 2>/dev/null || echo 2)
make unittest -j"$NPROC"
shell: bash

python-tests:
name: Python Tests
runs-on: ubuntu-24.04-riscv
needs: build

steps:
- name: Select Python
run: |
python3.10 --version
echo "PYTHON=python3.10" >> "$GITHUB_ENV"
shell: bash

- name: Download workspace artifacts
uses: actions/download-artifact@v8
with:
name: linux-riscv64-workspace
path: ${{ github.workspace }}

- name: Extract workspace
run: |
cd "$GITHUB_WORKSPACE"
tar -xf linux-riscv64-workspace.tar
echo "$($PYTHON -c 'import site; print(site.USER_BASE)')/bin" >> "$GITHUB_PATH"
shell: bash

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtest-dev liburing-dev
$PYTHON -m pip install --upgrade pip
$PYTHON -m pip install numpy==2.2.2 cmake==3.30.0 ninja==1.11.1.1 --index-url "$RISE_PYPI"
$PYTHON -m pip install pybind11==3.0 pytest scikit-build-core setuptools_scm
shell: bash

- name: Reconfigure build directory
run: |
cd "$GITHUB_WORKSPACE"
cmake -S . -B build \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TOOLS=ON \
-DBUILD_PYTHON_BINDINGS=ON
shell: bash

- name: Install from existing build directory
run: |
cd "$GITHUB_WORKSPACE"
NPROC=$(nproc 2>/dev/null || echo 2)
export SKBUILD_BUILD_DIR="$GITHUB_WORKSPACE/build"
CMAKE_GENERATOR="Unix Makefiles" \
CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \
$PYTHON -m pip install -v . \
--no-build-isolation \
--config-settings='cmake.define.BUILD_TOOLS="ON"'
shell: bash

- name: Run Python Tests
run: |
cd "$GITHUB_WORKSPACE"
$PYTHON -m pytest python/tests/
shell: bash

cpp-examples:
name: C++ Examples
runs-on: ubuntu-24.04-riscv
needs: build

steps:
- name: Download workspace artifacts
uses: actions/download-artifact@v8
with:
name: linux-riscv64-workspace
path: ${{ github.workspace }}

- name: Extract workspace
run: |
cd "$GITHUB_WORKSPACE"
tar -xf linux-riscv64-workspace.tar
shell: bash

- name: Run C++ Examples
run: |
cd "$GITHUB_WORKSPACE/examples/c++"
NPROC=$(nproc 2>/dev/null || echo 2)
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j "$NPROC"
./db-example
./core-example
./ailego-example
shell: bash

c-examples:
name: C Examples
runs-on: ubuntu-24.04-riscv
needs: build

steps:
- name: Download workspace artifacts
uses: actions/download-artifact@v8
with:
name: linux-riscv64-workspace
path: ${{ github.workspace }}

- name: Extract workspace
run: |
cd "$GITHUB_WORKSPACE"
tar -xf linux-riscv64-workspace.tar
shell: bash

- name: Run C Examples
run: |
cd "$GITHUB_WORKSPACE/examples/c"
NPROC=$(nproc 2>/dev/null || echo 2)
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j "$NPROC"
./c_api_basic_example
./c_api_collection_schema_example
./c_api_doc_example
./c_api_field_schema_example
./c_api_index_example
./c_api_optimized_example
shell: bash
8 changes: 5 additions & 3 deletions src/ailego/internal/cpu_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

#if defined(_MSC_VER)
#include <intrin.h>
#elif !defined(__ARM_ARCH)
#endif

#if (defined(__x86_64__) || defined(__i386__)) && !defined(_MSC_VER)
#include <cpuid.h>
#endif

Expand All @@ -34,7 +36,7 @@ namespace internal {

CpuFeatures::CpuFlags CpuFeatures::flags_;

#if defined(_MSC_VER)
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
CpuFeatures::CpuFlags::CpuFlags(void)
: L1_ECX(0), L1_EDX(0), L7_EBX(0), L7_ECX(0), L7_EDX(0) {
int l1[4] = {0, 0, 0, 0};
Expand All @@ -48,7 +50,7 @@ CpuFeatures::CpuFlags::CpuFlags(void)
L7_ECX = l7[2];
L7_EDX = l7[3];
}
#elif !defined(__ARM_ARCH)
#elif defined(__x86_64__) || defined(__i386__)
CpuFeatures::CpuFlags::CpuFlags(void)
: L1_ECX(0), L1_EDX(0), L7_EBX(0), L7_ECX(0), L7_EDX(0) {
uint32_t eax, ebx, ecx, edx;
Expand Down
Loading