Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
951cac7
simd-backends: inital commit, added sleef and svml
tretre91 Apr 17, 2025
c4cb086
simd-backends: Make the library installable
tretre91 Apr 18, 2025
5fe50d1
simd-backends: add license headers
tretre91 Apr 18, 2025
e1811bb
simd-backends: add a README
tretre91 Apr 18, 2025
45fd12d
Fix a typo in the README
tretre91 May 21, 2025
70c71cc
Update README.md
tretre91 May 21, 2025
1e4e43c
Rename the Kokkos_* macros and options to CEXA_*
tretre91 Mar 3, 2026
4d6af24
Update the README
tretre91 Mar 6, 2026
44a28f2
Add comments explaining why some functions are ccommented out
tretre91 Mar 11, 2026
444f3f1
Update the copyright notice
tretre91 Mar 14, 2026
a3476a4
Overhaul the CMake files
tretre91 Mar 14, 2026
00da541
Include Kokkos_Macros instead of Kokkos_Core in the sleef wrapper
tretre91 Mar 14, 2026
001246e
Update the README
tretre91 Mar 14, 2026
1a6aef7
Add a CI
tretre91 Mar 14, 2026
90875f0
ci: fix some paths
tretre91 Mar 14, 2026
a8b494e
ci: Install sleef from source as the version from apt is too old
tretre91 Mar 14, 2026
73813ed
Mention the sleef version requirement in the README
tretre91 Mar 14, 2026
54e28f6
ci: cache sleef
tretre91 Mar 14, 2026
0a84af9
Link to the right sleef target
tretre91 Mar 14, 2026
7e9148d
ci: get the sleef libdir using find
tretre91 Mar 14, 2026
ff65bf5
ci: use quotes in the find argument
tretre91 Mar 14, 2026
2c395c9
ci: use Ninja as CMake generator
tretre91 Mar 14, 2026
88a80db
ci: add a find_package call when patching kokkos
tretre91 Mar 14, 2026
264f451
Don't use the CONFIG mode for find_package
tretre91 Mar 14, 2026
07550ac
Undef internal macros after their use
tretre91 Mar 31, 2026
dba1595
Update the accuracy test based on suggestions from review
tretre91 Mar 31, 2026
0ab44fd
Apply suggestions from review
tretre91 Apr 1, 2026
571a28f
Remove the `CEXA_SIMD_ENABLE_INSTALL` option
tretre91 Apr 1, 2026
812e0af
Use a more explicit ci step name than "Patch Kokkos"
tretre91 Apr 1, 2026
cf4b06f
Set the min kokkos version to 4.6
tretre91 Apr 1, 2026
e52c9eb
ci: checkout code before restoring the cache
tretre91 Apr 1, 2026
6a42646
Update the README
tretre91 Apr 1, 2026
f9a1342
ci: add a job running the Kokkos SIMD perf tests
tretre91 Apr 1, 2026
213e49b
ci: fix a path in the perf test job
tretre91 Apr 1, 2026
3bcf138
ci: activate the venv before running the comapre script
tretre91 Apr 1, 2026
7602685
ci: filter benchmarks to only run math functions
tretre91 Apr 1, 2026
be742a8
Update the README
tretre91 Apr 2, 2026
c22bf00
ci: exclude scalar benchmarks and increase the number of iterations
tretre91 Apr 2, 2026
a906d59
Fix a typo in th src CMakeLists
tretre91 Apr 2, 2026
ea5b136
ci: reorder the cmake configure arguments
tretre91 Apr 2, 2026
ddbc37b
ci: limit the number of parallel cmake jobs to `nproc`
tretre91 Apr 2, 2026
0a664ae
Guard exp, log and cbrt if using an intel compiler
tretre91 Apr 3, 2026
879bc5a
Apply suggestions from review
tretre91 Apr 3, 2026
8b7bf1d
Remove the AOCL header
tretre91 Apr 3, 2026
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
112 changes: 112 additions & 0 deletions .github/workflows/simd-backends.yml
Comment thread
tretre91 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# SPDX-FileCopyrightText: 2026 CExA-project
# SPDX-License-Identifier: MIT or Apache-2.0 with LLVM-exception

name: SIMD Backends Tests

on:
pull_request:
paths:
- '.github/workflows/simd-backends.yml'
- 'simd-backends/**'
- '!simd-backends/README.md'
push:
branches:
- main

concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
simd-backends-ci:
continue-on-error: true

runs-on: ubuntu-latest

env:
CMAKE_GENERATOR: Ninja
Kokkos_ROOT: ${{ github.workspace }}/opt/kokkos
sleef_ROOT: ${{ github.workspace }}/opt/sleef
CexaSimdBackends_ROOT: ${{ github.workspace }}/simd-backends/install
steps:
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
id: cache-sleef
with:
path: opt/sleef
key: simd-backends-sleef-ubuntu-latest
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Checkout Sleef
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: steps.cache-sleef.outputs.cache-hit != 'true'
with:
repository: shibatch/sleef
ref: 3.9.0
path: sleef
- name: Install Sleef
if: steps.cache-sleef.outputs.cache-hit != 'true'
run: |
cmake -S sleef -B sleef/build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_INSTALL_PREFIX="$sleef_ROOT" \
-DSLEEF_BUILD_GNUABI_LIBS=OFF \
-DSLEEF_BUILD_TESTS=OFF \
-DSLEEF_ENABLE_TLFLOAT=OFF \
-DSLEEF_ENABLE_FFTW=OFF \
-DSLEEF_ENABLE_MPFR=OFF
cmake --build sleef/build -j --target install
- name: Checkout Kokkos
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: kokkos/kokkos
ref: 5.0.2
path: kokkos
- name: Install kokkos
run: |
cmake -S kokkos -B kokkos/build \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX="$Kokkos_ROOT" \
-DKokkos_ARCH_NATIVE=ON
cmake --build kokkos/build -j --target install
- name: Configure
working-directory: ${{ github.workspace }}/simd-backends
run:
cmake -S . -B build
-DCMAKE_CXX_COMPILER=g++
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DCMAKE_INSTALL_PREFIX="$CexaSimdBackends_ROOT"
-DCEXA_SIMD_ENABLE_SLEEF=ON
-DCEXA_SIMD_ENABLE_TESTS=ON
- name: Build
working-directory: ${{ github.workspace }}/simd-backends
run: cmake --build build -j
- name: Install
working-directory: ${{ github.workspace }}/simd-backends
run: cmake --install build
- name: Test install
working-directory: ${{ github.workspace }}/simd-backends/test/install_test
run: |
cmake -S . -B build \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build -j
./build/main
- name: Patch Kokkos
working-directory: ${{ github.workspace }}/kokkos/simd/unit_tests
run: |
cp "$CexaSimdBackends_ROOT/include/CEXA_SIMD_SLEEF.hpp" include
sed -i '/kokkos_add_executable_and_test/a find_package(sleef REQUIRED)\ntarget_link_libraries(Kokkos_UnitTest_SIMD PRIVATE sleef::sleef)' CMakeLists.txt
sed -i '/include <Kokkos_SIMD.hpp>/a #include <CEXA_SIMD_SLEEF.hpp>' include/TestSIMD_MathOps.hpp
Comment thread
tretre91 marked this conversation as resolved.
Outdated
- name: Build and run Kokkos SIMD unit test
working-directory: ${{ github.workspace }}/kokkos
run: |
cmake -S . -B build \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DKokkos_ARCH_NATIVE=ON \
-DKokkos_ENABLE_TESTS=ON
cmake --build build -j --target Kokkos_UnitTest_SIMD
ctest --test-dir build --output-on-failure -R SIMD
92 changes: 92 additions & 0 deletions simd-backends/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# SPDX-FileCopyrightText: 2026 CExA-project
# SPDX-License-Identifier: MIT or Apache-2.0 with LLVM-exception

cmake_minimum_required(VERSION 3.23)

project(simd-backends VERSION 0.1.0)

find_package(Kokkos 4.5 REQUIRED)
Comment thread
Adrien-Tab marked this conversation as resolved.
Outdated

option(
CEXA_SIMD_ENABLE_SLEEF
"Use the sleef library to implement the simd math functions"
OFF
)
option(CEXA_SIMD_ENABLE_SVML "Use the svml to implement the simd math functions" OFF)
option(CEXA_SIMD_ENABLE_TESTS "Enable accuracy tests" OFF)
option(CEXA_SIMD_ENABLE_INSTALL "Enable installation of the library" ON)

if(CEXA_SIMD_ENABLE_SLEEF AND CEXA_SIMD_ENABLE_SVML)
message(FATAL_ERROR "Only one backend can be enabled at a time")
endif()

Comment on lines +10 to +21

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No AOCL-libm?

if(CEXA_SIMD_ENABLE_SLEEF)
find_package(sleef 3.6 QUIET)
if(NOT sleef_FOUND)
include(FetchContent)

set(SLEEF_BUILD_GNUABI_LIBS OFF)
set(SLEEF_BUILD_TESTS OFF)
set(SLEEF_ENABLE_TLFLOAT OFF)
set(SLEEF_ENABLE_FFTW OFF)
set(SLEEF_ENABLE_MPFR OFF)
list(APPEND CMAKE_MESSAGE_INDENT "[sleef] ")
FetchContent_Declare(
sleef
URL https://github.com/shibatch/sleef/archive/refs/tags/3.9.0.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
DOWNLOAD_NO_PROGRESS TRUE
)
FetchContent_MakeAvailable(sleef)
list(POP_BACK CMAKE_MESSAGE_INDENT)
endif()
endif()

if(CEXA_SIMD_ENABLE_SVML AND NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL IntelLLVM)
message(
FATAL_ERROR
"The SVML simd backend is only available with Intel compilers"
)
endif()

add_subdirectory(src)

if(CEXA_SIMD_ENABLE_TESTS)
add_subdirectory(test)
endif()

if(CEXA_SIMD_ENABLE_INSTALL)
Comment thread
tretre91 marked this conversation as resolved.
Outdated
include(GNUInstallDirs)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
CexaSimdBackendsConfigVersion.cmake
COMPATIBILITY AnyNewerVersion
)

install(
TARGETS simd-backends
EXPORT CexaSimdBackends
FILE_SET HEADERS
)

install(
EXPORT CexaSimdBackends
FILE CexaSimdBackendsTargets.cmake
NAMESPACE cexa::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CexaSimdBackends"
)

configure_package_config_file(
cmake/CexaSimdBackendsConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/CexaSimdBackendsConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CexaSimdBackends"
)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/CexaSimdBackendsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/CexaSimdBackendsConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CexaSimdBackends"
)
endif()
61 changes: 61 additions & 0 deletions simd-backends/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!--
SPDX-FileCopyrightText: 2026 CExA-project

SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
-->

# SIMD backends

This header only library provides an interface to replace the Kokkos math functions for SIMD types with calls to different external libraries.

## Build

The available cmake configuration options are:
- `CEXA_SIMD_ENABLE_SLEEF`: use the sleef library
- `CEXA_SIMD_ENABLE_SVML`: use the Intel SVML library (only available with intel compilers)
- `CEXA_SIMD_ENABLE_TESTS`: build the tests
- `CEXA_SIMD_ENABLE_INSTALL`: enable the installation target

The sleef backend requires sleef v3.6.0 or later.

## Usage

### Manual

As the library is header only, you can include the header for your library of choice
directly in your code.
Comment thread
tretre91 marked this conversation as resolved.
Outdated

### CMake

With CMake, you can use the `find_package` command as shown in the
example below. If not installed to a system location, you should provide the
path to the library using the `-DCexaSimdBackends_ROOT=<path to the install location>`
option.

```cmake
cmake_minimum_required(VERSION 3.16)

project(test)

find_package(Kokkos 5.0 REQUIRED)
find_package(CexaSimdBackends 0.1 REQUIRED)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE Kokkos::kokkos cexa::simd-backends)
```

You can then include `CEXA_SIMD_Backends.hpp` in your code and use the Kokkos simd math
functions as usual.

```
#include <Kokkos_Core.hpp>
#include <Kokkos_SIMD.hpp>
#include <CEXA_SIMD_Backends.hpp>

int main(int argc, char* argv[]) {
Kokkos::ScopeGuard kokkos_scope(argc, argv);

Kokkos::Experimental::simd<float> vec(1.f);
vec = Kokkos::exp(vec);
}
```
17 changes: 17 additions & 0 deletions simd-backends/cmake/CexaSimdBackendsConfig.cmake.in
Comment thread
tretre91 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2026 CExA-project
# SPDX-License-Identifier: MIT or Apache-2.0 with LLVM-exception

@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

find_dependency(Kokkos 4.5 REQUIRED)
Comment thread
tretre91 marked this conversation as resolved.
Outdated

set(CEXA_SIMD_ENABLE_SLEEF @CEXA_SIMD_ENABLE_SLEEF@)
if(CEXA_SIMD_ENABLE_SLEEF)
find_dependency(sleef 3.6 REQUIRED)
Comment thread
tretre91 marked this conversation as resolved.
Outdated
endif()

include("${CMAKE_CURRENT_LIST_DIR}/CexaSimdBackendsTargets.cmake")

check_required_components(CexaSimdBackends)
Loading