Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
88c57b4
made lib compare
Gitubrr Apr 21, 2026
f6c9ff1
added more comparison points
Gitubrr Apr 25, 2026
7419e16
added list of dependences
Gitubrr Apr 28, 2026
21279b0
CI -> +
Gitubrr Apr 29, 2026
e2a2ad1
Just formatting changes to README
Gitubrr Apr 29, 2026
2ed3b03
added config params info
Gitubrr May 4, 2026
fc33885
added config structure
Gitubrr May 4, 2026
d680949
formatting only
Gitubrr May 4, 2026
de27aa7
added performance parameter
Gitubrr May 4, 2026
e0c9b47
formatting only
Gitubrr May 4, 2026
0b8ca49
formatting
Gitubrr May 5, 2026
b880e9e
added 2 libs, removed 'Пакетные менеджеры'
Gitubrr May 5, 2026
e0c730b
added SPLA usage scenarios
Gitubrr May 11, 2026
b5b7580
making defolt scenario
Gitubrr May 19, 2026
af09acd
added 1 question about errors
Gitubrr May 19, 2026
627b027
added new scenaries
Gitubrr Jun 1, 2026
c1b7f2d
added manual
Gitubrr Jul 9, 2026
8c9ddff
Fixed the incorrect format name in 1 example in CONFIGURATION FALE se…
Gitubrr Jul 10, 2026
c90f185
add parsers
Gitubrr Jul 26, 2026
82028eb
fixed formatting errors
Gitubrr Jul 26, 2026
464aaa0
changed cli parser, file parser, made validate
Gitubrr Jul 28, 2026
f8cea29
changed init
Gitubrr Jul 28, 2026
0af1432
made apply() and started changing cl_accelerator.cpp,.hpp + added num…
Gitubrr Jul 29, 2026
73045f1
removed apply(), changed init() -> init(conf)
Gitubrr Jul 29, 2026
a28e55e
for formatter only
Gitubrr Jul 29, 2026
8e333d8
add configuration mechanism
Gitubrr Aug 31, 2026
c9b84f3
made UserManual and UserGuide
Gitubrr Sep 8, 2026
3e87443
unnecessary changes
Gitubrr Sep 8, 2026
aa11385
fixed
Gitubrr Sep 20, 2026
60ecdff
for formatter and ubuntu build
Gitubrr Sep 20, 2026
53fb6c4
changed make file
Gitubrr Sep 20, 2026
5aa6e52
changed deps in make file
Gitubrr Sep 20, 2026
54b10b1
! grep -qE \[ FAILED \]
Gitubrr Sep 20, 2026
24dcab7
CL_TARGET_OPENCL_VERSION=300
Gitubrr Sep 20, 2026
2291458
made verbosity
Gitubrr Sep 22, 2026
3082114
added MIT license back
Gitubrr Sep 23, 2026
0b14b37
add MIT license to cl_configure
Gitubrr Sep 23, 2026
48613f8
made new user guide
Gitubrr Sep 24, 2026
ac5f337
chanjed config structure
Gitubrr Sep 25, 2026
60f09aa
added new params to cnfig
Gitubrr Sep 27, 2026
7586978
fixed build err
Gitubrr Sep 27, 2026
ec9897a
CL_TARGET_OPENCL_VERSION=300 -> 120 back
Gitubrr Sep 27, 2026
788e7b4
fixed CL_HPP_MINIMUM_OPENCL_VERSION
Gitubrr Sep 28, 2026
b895cd9
for deps
Gitubrr Sep 28, 2026
3e7f817
for formatter
Gitubrr Sep 28, 2026
17ec47a
removed base from UserGuide
Gitubrr Oct 3, 2026
73a39f6
removed "configs" and "current_config"
Gitubrr Oct 6, 2026
103f80e
added about how to run with user conf
Gitubrr Oct 7, 2026
4f9309f
fixed ci scenar
Gitubrr Oct 7, 2026
e6a8c45
Запуск с -> Запуск ci с
Gitubrr Oct 7, 2026
0dc7fba
added new configuration func
Gitubrr Oct 13, 2026
ae1209d
removed comment
Gitubrr Oct 13, 2026
2b2448e
fix for windows
Gitubrr Oct 13, 2026
66f1a3a
deleted and renamed files
Gitubrr Oct 13, 2026
14c6bf1
cl_config_status.hpp -> config_status.hpp
Gitubrr Oct 13, 2026
e31094b
chanjed ci back
Gitubrr Oct 13, 2026
0a82109
chanjed lang to english
Gitubrr Oct 13, 2026
6042947
chacged logs
Gitubrr Oct 14, 2026
c190a0c
chacged logic
Gitubrr Oct 23, 2026
7edb644
fixed sources
Gitubrr Oct 23, 2026
010b864
win error
Gitubrr Oct 23, 2026
3a3277c
removed unnecessary
Gitubrr Oct 24, 2026
7461633
for clang
Gitubrr Oct 24, 2026
bbb1b6f
fixed docs
Gitubrr Oct 24, 2026
bfa3d4b
fixed softcheck
Gitubrr Oct 25, 2026
7c1b83c
traceback
Gitubrr Oct 25, 2026
b0ecfa0
simplifyed configure
Gitubrr Oct 26, 2026
d15257b
removed accelerator status
Gitubrr Oct 26, 2026
8cc1cac
format
Gitubrr Oct 26, 2026
dd0d04d
removed unnecessary from bridge
Gitubrr Oct 26, 2026
7772bc5
for traceback
Gitubrr Oct 26, 2026
f4be1dd
format
Gitubrr Oct 26, 2026
6c47e3b
cmake
Gitubrr Oct 26, 2026
006d90c
added opencl_cpu
Gitubrr Oct 26, 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
55 changes: 53 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
project(spla LANGUAGES CXX)

######################################################################
## Package version
## python/VERSION.md is the single source of truth for the version:
## python/setup.py reads it for the PyPI package and the C++ library
## gets it as the SPLA_VERSION compile definition.

file(READ "${CMAKE_CURRENT_LIST_DIR}/python/VERSION.md" SPLA_VERSION_RAW)
string(STRIP "${SPLA_VERSION_RAW}" SPLA_VERSION)
message(STATUS "SPLA package version: ${SPLA_VERSION}")

######################################################################
## public options

option(SPLA_BUILD_TESTS "Build test folder with modules tests" YES)
option(SPLA_BUILD_EXAMPLES "Build library example applications with algorithms" YES)
set(SPLA_BUILD_TOOLS YES)
option(SPLA_BUILD_OPENCL "Build library with opencl backend" YES)

######################################################################
Expand Down Expand Up @@ -178,6 +189,22 @@ endfunction()
add_subdirectory(deps/robin_hood)
add_subdirectory(deps/svector)

message(STATUS "Add CLI11 as CLI/ENV parser")
include(FetchContent)

FetchContent_Declare(CLI11
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
GIT_TAG v2.4.2
)
FetchContent_MakeAvailable(CLI11)

message(STATUS "Add nlohmann/json as JSON parser")
FetchContent_Declare(nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
)
FetchContent_MakeAvailable(nlohmann_json)

if (SPLA_BUILD_OPENCL)
if (SPLA_TARGET_MACOSX)
message(STATUS "Add standard Apple OpenCL package")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why these changes required?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

My code requirs newer OpenCL headers. Apple removed them from macOS SDKs, so find_package fails. I bundle Khronos headers to build new code, while linking the system framework for macOS compatibility

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Your code? Your code just configure existing library. Why it requires newer OpenCL?

Expand All @@ -200,8 +227,6 @@ if (SPLA_BUILD_OPENCL)
set(OPENCL_ICD_LOADER_BUILD_TESTING OFF CACHE BOOL "" FORCE)
add_subdirectory(deps/opencl-icd-loader)
endif ()


message(STATUS "Add Khronos OpenCL HPP bindings")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It made to prevent linking against the Apple framework on Linux/Windows

add_library(HeadersCpp INTERFACE)
add_library(OpenCL::HeadersCpp ALIAS HeadersCpp)
Expand Down Expand Up @@ -297,6 +322,9 @@ add_library(spla SHARED
include/spla/vector.hpp
src/core/accelerator.hpp
src/core/common.hpp
src/core/config_status.hpp
src/core/configure.cpp
src/core/configure.hpp
src/core/dispatcher.cpp
src/core/dispatcher.hpp
src/core/logger.cpp
Expand Down Expand Up @@ -368,9 +396,13 @@ target_include_directories(spla PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src)

set_target_properties(spla PROPERTIES OUTPUT_NAME "spla_${SPLA_ARCH}")
target_compile_definitions(spla PRIVATE SPLA_EXPORTS)
target_compile_definitions(spla PRIVATE SPLA_VERSION="${SPLA_VERSION}")

target_link_libraries(spla PRIVATE robin_hood)
target_link_libraries(spla PRIVATE svector)
target_link_libraries(spla PRIVATE CLI11::CLI11)
target_link_libraries(spla PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(spla PRIVATE ${CMAKE_DL_LIBS})

if (SPLA_BUILD_OPENCL)
target_link_libraries(spla PUBLIC OpenCL)
Expand All @@ -383,6 +415,13 @@ spla_target_compile_definitions(spla)
spla_target_compile_options(spla)
spla_target_link_options(spla)

set(SPLA_CONF_SRC "${CMAKE_CURRENT_LIST_DIR}/python/pyspla/spla_conf.json")
set(SPLA_CONF_DST "${CMAKE_BINARY_DIR}/spla_conf.json")
add_custom_command(TARGET spla POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${SPLA_CONF_SRC}" "${SPLA_CONF_DST}"
COMMENT "Copying shipped configuration file spla_conf.json next to the library")

######################################################################
## Add examples directory

Expand All @@ -404,6 +443,18 @@ if (SPLA_BUILD_EXAMPLES)
spla_example_application(convert)
endif ()

######################################################################
## Add command line tools

if (SPLA_BUILD_TOOLS)
message(STATUS "Add command line tools to build")

add_executable(spla_cli tools/soft_check.cpp)
target_link_libraries(spla_cli PRIVATE spla)
target_link_libraries(spla_cli PRIVATE CLI11::CLI11)
set_target_properties(spla_cli PROPERTIES OUTPUT_NAME spla)
endif ()

######################################################################
## Add unit-tests directory

Expand Down
258 changes: 258 additions & 0 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
# User Guide
Comment thread
gsvgit marked this conversation as resolved.
Resolved

The user guide for the spla library. Contains usage scenarios for the configuration mechanism: from a quick start without configuration to running tests in CI. The complete reference of all parameters, flags and environment variables is given in the [User Manual](UserManual.md).

## Contents

1. [Environment check](#environment-check)
2. [Scenario 1. Quick start without configuration](#scenario-1-quick-start-without-configuration)
3. [Scenario 2. Choosing between CPU and GPU without specifying indexes](#scenario-2-choosing-between-cpu-and-gpu-without-specifying-indexes)
4. [Scenario 3. Multiple devices and modes in one file](#scenario-3-multiple-devices-and-modes-in-one-file)
5. [Scenario 4. Running in CI with a file from the repository](#scenario-4-running-in-ci-with-a-file-from-the-repository)
6. [Priority of configuration sources](#priority-of-configuration-sources)
7. [Where the configuration files are located](#where-the-configuration-files-are-located)

## Environment check

After installation, run the command that confirms the library is ready to use:

```bash
./program spla --softcheck
```

The command:

1. Reads the configuration file shipped with the library.
2. Initializes OpenCL, selects the platform and device.
3. Runs a simple test task `2 + 3`.
4. Reports the status.

Example of successful output:

```bash
$ s./program spla --softcheck
[spla:check] Starting sanity check...
[spla:check] Initializing OpenCL...
[spla:check] Selected accelerator: OpenCL NVIDIA CUDA | device: NVIDIA GeForce RTX 3070 Laptop GPU | vendor: nvidia | mcu: 40 | wave: 32 | mwgs: 1024
[spla:check] Running test task: 2 + 3 = ...
[spla:check] Result: 5 (expected 5)
[spla:check] SUCCESS - spla works correctly
```

## Scenario 1. Quick start without configuration

You want a working application without configuration - nothing needs to be configured. The library uses the default parameters from the configuration file shipped with the library.

```bash
./program
```

The scenario works the same on Linux, macOS and Windows. If OpenCL acceleration is unavailable, the library automatically switches to the pure native CPU by default (the `if_opencl_unavailable: "use_cpu"` parameter), reporting it.

Before the first run it is recommended to run [`spla --softcheck`](#environment-check) to make sure that everything required for spla is installed.

## Scenario 2. Choosing between CPU and GPU without specifying indexes

You want to control the device type, but not specify concrete OpenCL platform and device indexes.

The device type is set by the `backend` parameter in the configuration file:

```json
{
"gpu_only": { "backend": "opencl_gpu" },
"cpu_only": { "backend": "cpu" }
}
```

- `"opencl_gpu"` - use the first available OpenCL GPU,
- `"cpu"` - use the pure native CPU without touching OpenCL.

The `platform_index` and `device_index` indexes are ignored with these values.

### Behavior when OpenCL is unavailable

If `backend: "opencl_gpu"` is selected, but no OpenCL GPU is available, the behavior is defined by the `if_opencl_unavailable` parameter:

```json
{
"gpu_or_cpu": {
"backend": "opencl_gpu",
"if_opencl_unavailable": "use_cpu"
},
"gpu_only": {
"backend": "opencl_gpu",
"if_opencl_unavailable": "abort"
}
}
```

- `"use_cpu"` - the library switches to the pure native CPU and continues working,
- `"abort"` - the library fails initialization and the process exits with the error status.

Running the required configuration:

```bash
./program --spla-config=gpu_or_cpu
./program --spla-config=gpu_only
```

`if_opencl_unavailable` is applied with `backend: "opencl_gpu"` and `"by_index"`. With `backend: "cpu"` the parameter is ignored.

## Scenario 3. Multiple devices and modes in one file

You regularly run the same program on different GPUs and in different modes - for example, on GPU 0 and 1, in debug mode and in performance measurement mode. Instead of several configuration files, you describe everything in one.

```json
{
"default": { "backend": "opencl_gpu", "verbosity": 2 },

"gpu0": {
"extends": ["default"],
"backend": "by_index",
"platform_index": 0,
"device_index": 0
},
"gpu1": {
"extends": ["default"],
"backend": "by_index",
"platform_index": 0,
"device_index": 1
},

"debug": {
"extends": ["default"],
"verbosity": 3,
"profiling": true
},
"bench": {
"extends": ["default"],
"verbosity": 0
},

"debug_gpu1": { "extends": ["debug", "gpu1"] },
"bench_gpu0": { "extends": ["bench", "gpu0"] }
}
```

Running:

```bash
./program --spla-config=gpu1
./program --spla-config=debug
./program --spla-config=debug_gpu1
./program --spla-config=bench_gpu0
```

Configurations inherited through `extends` are applied in order: each next parent overrides the previous one, and the parameters of the configuration itself override all parents. Circular inheritance is detected and results in an error.

## Scenario 4. Running in CI with a file from the repository

You need to run tests in CI with a separate configuration file.

In a CI environment it is inconvenient and undesirable to touch the system and user configuration files, and the test configurations must live in the repository. Therefore the configurations are described in a separate file inside the repository and its path is given at launch together with the configuration name - these are the command line arguments `--spla-config-file` and `--spla-config`.

```
my_project/
├── .github/
│ └── workflows/
│ ├── ci.yml
│ └── ci_spla_conf.json
├── src/
└── tests/
```

### ci_spla_conf.json

```json
{
"test_cpu": {
"backend": "cpu",
"queues_count": 1,
"profiling": false,
"allocator_type": "general",
"verbosity": 1
},
"test_gpu0": {
"backend": "by_index",
"platform_index": 0,
"device_index": 0,
"if_opencl_unavailable": "abort",
"queues_count": 2,
"profiling": false,
"allocator_type": "general",
"verbosity": 0
},
"test_gpu1": {
"backend": "by_index",
"platform_index": 0,
"device_index": 1,
"if_opencl_unavailable": "abort",
"queues_count": 2,
"profiling": false,
"allocator_type": "linear",
"linear_alloc_size": 8,
"verbosity": 0
}
}
```

### ci.yml

```yml
name: CI

on: [push, pull_request]

jobs:
test:
name: Test (${{ matrix.config }})
runs-on: [self-hosted, gpu]

strategy:
fail-fast: false
matrix:
config: [test_cpu, test_gpu0, test_gpu1]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyspla pytest

- name: Run tests
run: python src/my_app.py --spla-config-file=.github/workflows/ci_spla_conf.json --spla-config=${{ matrix.config }}
```

The file path and the configuration name are passed at launch as command arguments, not through environment variables - in CI this makes the launch command self-contained and reproducible.

## Priority of configuration sources

Sources are applied in descending priority order: parameters from a higher-priority source override lower-priority ones. This matters for the scenarios: any flag or environment variable overrides values from files.

| # | Source |
|---:|:---|
| 1 | Command line arguments (`--spla-*`) |
| 2 | Environment variables (`SPLA_*`) |
| 3 | File with an explicitly specified path (`--spla-config-file`) |
| 4 | User configuration file |
| 5 | System configuration file |
| 6 | Configuration file shipped with the library |

If the configuration name is not specified, the `"default"` configuration from the file shipped with the library is used. For details on the collection order and merging of sources, see the [User Manual](UserManual.md#configuration-mechanism-overview).

## Where the configuration files are located

- **Shipped with the library** - next to the library file (in the pyspla package - inside the installed package).
- **System** - Linux: `/etc/spla/spla_conf.json`.
- **User** - Linux: `~/.config/spla/spla_conf.json`.
- **Explicit** - any path via `--spla-config-file`.

Paths for macOS and Windows and the rules for "file missing / file cannot be opened" are in the [User Manual](UserManual.md#configuration-files).
Loading
Loading