From 57cfaafc01c538c414d42cf4a8c06aa633986563 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sun, 9 Nov 2025 19:46:00 +0300 Subject: [PATCH 01/22] ci: add ci for self hosted runner --- .github/workflows/build.yml | 57 ++++++---------- .github/workflows/clang-format.yml | 11 +-- .github/workflows/deploy-test.yml | 10 ++- .github/workflows/deploy.yml | 8 +-- .github/workflows/self-hosted.yml | 106 +++++++++++++++++++++++++++++ .github/workflows/ubuntu.yml | 104 ++++++++++++++++++++++++++++ run_tests.py | 16 ++++- tests/CMakeLists.txt | 8 ++- tests/test_opencl.cpp | 88 +++++++++++++++++++++--- tests/test_opencl_merge.cpp | 40 +++++++++-- 10 files changed, 374 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/self-hosted.yml create mode 100644 .github/workflows/ubuntu.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 34cf397b9..fe87ad18b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,7 @@ on: - main - release - pre-release + - self-hosted-runner paths: - '.github/**' - 'deps/**' @@ -21,17 +22,16 @@ on: branches: [ main ] env: - build_dir: "build" + build-dir: "build" config: "Release" artifact: "native" nt: "4" jobs: - windows: - runs-on: windows-2019 + runs-on: windows-2022 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true fetch-depth: 0 @@ -43,44 +43,22 @@ jobs: arch: amd64 - name: Configure CMake - run: cmake . -G Ninja -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} + run: | + cmake . -G Ninja -B ${{ env.build-dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DSPLA_BUILD_OPENCL=OFF - name: Build library sources - run: cmake --build ${{ env.build_dir }} + run: cmake --build ${{ env.build-dir }} --verbose -j ${{ env.nt }} - name: Upload binary uses: actions/upload-artifact@v4 with: name: windows-${{env.artifact}} - path: ${{env.build_dir}}/spla_x64.dll - - - ubuntu: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - fetch-depth: 0 - - - uses: seanmiddleditch/gha-setup-ninja@master - - - name: Configure CMake - run: cmake . -G Ninja -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} - - - name: Build library sources - run: cmake --build ${{ env.build_dir }} - - - name: Upload binary - uses: actions/upload-artifact@v4 - with: - name: linux-${{env.artifact}} - path: ${{env.build_dir}}/libspla_x64.so + path: ${{env.build-dir}}/spla_x64.dll macos: runs-on: macos-14 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true fetch-depth: 0 @@ -88,23 +66,28 @@ jobs: - uses: seanmiddleditch/gha-setup-ninja@master - name: Configure CMake x64 - run: cmake . -G Ninja -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCMAKE_OSX_ARCHITECTURES=x86_64 + run: cmake . -G Ninja -B ${{ env.build-dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCMAKE_OSX_ARCHITECTURES=x86_64 - name: Build library sources x64 - run: cmake --build ${{ env.build_dir }} + run: cmake --build ${{ env.build-dir }} - name: Configure CMake arm64 - run: cmake . -G Ninja -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCMAKE_OSX_ARCHITECTURES=arm64 + run: | + cmake . -G Ninja \ + -B ${{ env.build-dir }} \ + -DCMAKE_BUILD_TYPE=${{ env.config }} \ + -DCMAKE_OSX_ARCHITECTURES=arm64 \ + -DSPLA_BUILD_OPENCL=OFF env: BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - name: Build library sources arm64 - run: cmake --build ${{ env.build_dir }} + run: cmake --build ${{ env.build-dir }} --verbose -j ${{ env.nt }} - name: Upload binary uses: actions/upload-artifact@v4 with: name: macos-${{env.artifact}} path: | - ${{env.build_dir}}/libspla_x64.dylib - ${{env.build_dir}}/libspla_arm64.dylib + ${{env.build-dir}}/libspla_x64.dylib + ${{env.build-dir}}/libspla_arm64.dylib \ No newline at end of file diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 61f697d55..628b814b5 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -2,7 +2,7 @@ name: Clang Format on: push: - branches: [ main ] + branches: [ main, self-hosted-runner ] paths: - '.github/**' - 'include/**' @@ -26,9 +26,10 @@ jobs: - 'tests' - 'examples' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 + - name: Run clang-format style check - uses: jidicula/clang-format-action@v4.10.1 + uses: jidicula/clang-format-action@v4.15.0 with: - clang-format-version: '15' - check-path: ${{ matrix.path }} + clang-format-version: '20' + check-path: ${{ matrix.path }} \ No newline at end of file diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml index e22cd7855..c7f1ed82b 100644 --- a/.github/workflows/deploy-test.yml +++ b/.github/workflows/deploy-test.yml @@ -2,7 +2,7 @@ name: Python Package (Test) on: workflow_run: - workflows: [ "Build" ] + workflows: [ Build ] branches: [ "pre-release" ] types: - completed @@ -14,10 +14,8 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: '3.8' @@ -27,7 +25,7 @@ jobs: pip install setuptools wheel twine - name: Download artifact - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v5 with: workflow: build.yml workflow_conclusion: success @@ -42,4 +40,4 @@ jobs: run: | python setup.py sdist bdist_wheel twine upload --verbose --repository testpypi dist/* - working-directory: python + working-directory: python \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 026492987..d772c6fa5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,10 +14,10 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: '3.8' @@ -27,7 +27,7 @@ jobs: pip install setuptools wheel twine - name: Download artifact - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v5 with: workflow: build.yml workflow_conclusion: success @@ -42,4 +42,4 @@ jobs: run: | python setup.py sdist bdist_wheel twine upload --verbose dist/* - working-directory: python + working-directory: python \ No newline at end of file diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml new file mode 100644 index 000000000..1d6533175 --- /dev/null +++ b/.github/workflows/self-hosted.yml @@ -0,0 +1,106 @@ +name: Self-Hosted + +on: + push: + branches: + - main + - release + - pre-release + - self-hosted-runner + paths: + - '.github/**' + - 'deps/**' + - 'include/**' + - 'src/**' + - 'tests/**' + - 'examples/**' + - 'python/**' + - '.gitignore' + - '.gitmodules' + - 'CMakeLists.txt' + pull_request: + branches: [ main ] + +env: + build-dir: "build" + +jobs: + build: + name: Build ${{ matrix.os }} + runs-on: self-hosted + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + env: + config: "Release" + nt: "4" + + steps: + - uses: actions/checkout@v5 + with: + submodules: true + fetch-depth: 0 + + - name: Configure CMake + run: | + cmake . -G Ninja \ + -B ${{ env.build-dir }} \ + -DCMAKE_BUILD_TYPE=${{ env.config }} \ + -DSPLA_BUILD_TESTS=ON + + - name: Build library sources + run: | + cmake --build ${{ env.build-dir }} \ + --target all \ + --verbose \ + -j ${{ env.nt }} + + test: + name: Test GPU ${{ matrix.gpu }} + needs: build + runs-on: self-hosted + strategy: + fail-fast: false + matrix: + include: + - gpu: NVIDIA-GeForce-GT-1030 + platform: 2 + device: 0 + - gpu: AMD-Radeon-RX-6750-XT + platform: 1 + device: 0 + + env: + test-file: ${{ matrix.gpu }}_tests.log + + steps: + - name: Run tests + run: | + python3 ./run_tests.py --build-dir=${{ env.build-dir }} \ + --platform=${{ matrix.platform }} \ + --device=${{ matrix.device }} \ + | tee ${{ env.test-file }} + + - name: Upload tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.test-file }} + path: ${{ env.test-file }} + + - name: Check for tests results + run: | + ! grep -q "FAILED" ${{ env.test-file }} + + clean: + name: Cleanup workspace + needs: test + if: always() + runs-on: self-hosted + + steps: + - name: Cleanup workspace + run: | + rm -rf ${{ github.workspace }}/* + rm -rf ${{ github.workspace }}/.* \ No newline at end of file diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 000000000..bac479e37 --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,104 @@ +name: Ubuntu + +on: + push: + branches: + - main + - release + - pre-release + - self-hosted-runner + paths: + - '.github/**' + - 'deps/**' + - 'include/**' + - 'src/**' + - 'tests/**' + - 'examples/**' + - 'python/**' + - '.gitignore' + - '.gitmodules' + - 'CMakeLists.txt' + pull_request: + branches: [ main ] + +env: + build-dir: "build" + config: "Release" + artifact: "spla-ubuntu-build.tar.xz" + nt: "4" + +jobs: + ubuntu: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v5 + with: + submodules: true + fetch-depth: 0 + + - uses: seanmiddleditch/gha-setup-ninja@master + + - name: Configure CMake + run: | + cmake . -G Ninja \ + -B ${{ env.build-dir }} \ + -DCMAKE_BUILD_TYPE=${{ env.config }} \ + -DSPLA_BUILD_TESTS=ON \ + -DSPLA_BUILD_OPENCL=OFF + + - name: Build library sources + run: | + cmake --build ${{ env.build-dir }} --verbose -j ${{ env.nt }} + + - name: Prepare upload binary + run: | + tar cfz ${{ env.artifact }} ${{ env.build-dir }} + + - name: Upload binary + uses: actions/upload-artifact@v4 + with: + name: ${{env.artifact}} + path: ${{env.artifact}} + + test: + name: Test CPU ${{ matrix.cpu }} + needs: ubuntu + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + cpu: AMD-EPYC-7763 + + env: + test-file: cpu_tests.log + + steps: + - uses: actions/checkout@v5 + with: + submodules: true + fetch-depth: 0 + + - uses: actions/download-artifact@v5 + with: + name: ${{ env.artifact }} + + - name: Unarchive artifact + run: | + tar xzf ${{ env.artifact }} + rm ${{ env.artifact }} + + - name: Run tests + run: | + python3 ./run_tests.py --build-dir=${{ env.build-dir }} | tee ${{ env.test-file }} + + - name: Upload tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.test-file }} + path: ${{ env.test-file }} + + - name: Check for tests results + run: | + ! grep -q "FAILED" ${{ env.test-file }} \ No newline at end of file diff --git a/run_tests.py b/run_tests.py index ad738fdea..ca1e1b5f0 100644 --- a/run_tests.py +++ b/run_tests.py @@ -29,6 +29,7 @@ import argparse import subprocess import re +import os def test_names(test_src_path): @@ -41,18 +42,27 @@ def test_names(test_src_path): def main(): parser = argparse.ArgumentParser() parser.add_argument("--build-dir", default="build") + parser.add_argument("--platform", default="0") + parser.add_argument("--device", default="0") args = parser.parse_args() + os.environ["SPLA_OPENCL_PLATFORM"] = args.platform + os.environ["SPLA_OPENCL_DEVICE"] = args.device + tests_dir = shared.ROOT / args.build_dir / "tests" print(f"Searching for unit-tests in `{tests_dir}` folder") failed_tests = [] + skipped_tests = [] all_tests = test_names(shared.ROOT / "tests") for test_name in all_tests: full_test_name = str(tests_dir / test_name) print(f"Exec unit-test: `{full_test_name}`") try: subprocess.check_call(full_test_name) + except FileNotFoundError: + skipped_tests.append(test_name) + print(f"Skipped: `{test_name}`") except subprocess.CalledProcessError as err: failed_tests.append(test_name) print(f"Failed: `{err.output}`") @@ -60,10 +70,14 @@ def main(): all_tests_string = '\n\t'.join(all_tests) print(f"All executed tests: \n\t{all_tests_string}") + if skipped_tests: + skipped_tests_string = '\n\t'.join(skipped_tests) + print(f"Skipped tests: \n\t{skipped_tests_string}") + if failed_tests: failed_tests_string = '\n\t'.join(failed_tests) raise Exception(f"Some tests have not been passed: \n\t{failed_tests_string}") if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d642b2fe0..e20657a89 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,7 +15,9 @@ spla_test_target(test_mxmT) spla_test_target(test_mxv) spla_test_target(test_vxm) spla_test_target(test_op) -spla_test_target(test_opencl) -spla_test_target(test_opencl_merge) +if (SPLA_BUILD_OPENCL) + spla_test_target(test_opencl) + spla_test_target(test_opencl_merge) +endif () spla_test_target(test_schedule) -spla_test_target(test_vector) +spla_test_target(test_vector) \ No newline at end of file diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index 5e5e43696..703f40fc1 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -26,6 +26,7 @@ /**********************************************************************************/ #include "test_common.hpp" +#include #define CL_HPP_MINIMUM_OPENCL_VERSION 120 #define CL_HPP_TARGET_OPENCL_VERSION 120 @@ -37,14 +38,27 @@ #include #include -TEST(opencl, basic_gpu) { +TEST(opencl, basic) { std::vector platforms; cl::Platform::get(&platforms); - cl::Platform platform = platforms.front(); + if (platforms.empty()) { + GTEST_SKIP() << "No platforms found"; + } + + const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + + cl::Platform platform = platforms[platform_index]; std::vector devices; platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); - cl::Device device = devices.front(); + if (devices.empty()) { + GTEST_SKIP() << "No devices found"; + } + + const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context); @@ -87,11 +101,24 @@ TEST(opencl, basic_gpu) { TEST(opencl, bitonic_sort_local) { std::vector platforms; cl::Platform::get(&platforms); - cl::Platform platform = platforms.front(); + if (platforms.empty()) { + GTEST_SKIP() << "No platforms found"; + } + + const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + + cl::Platform platform = platforms[platform_index]; std::vector devices; platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); - cl::Device device = devices.front(); + if (devices.empty()) { + GTEST_SKIP() << "No devices found"; + } + + const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context); @@ -137,11 +164,24 @@ TEST(opencl, bitonic_sort_local) { TEST(opencl, bitonic_sort_global) { std::vector platforms; cl::Platform::get(&platforms); - cl::Platform platform = platforms.front(); + if (platforms.empty()) { + GTEST_SKIP() << "No platforms found"; + } + + const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + + cl::Platform platform = platforms[platform_index]; std::vector devices; platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); - cl::Device device = devices.front(); + if (devices.empty()) { + GTEST_SKIP() << "No devices found"; + } + + const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context); @@ -188,11 +228,24 @@ TEST(opencl, bitonic_sort_global) { TEST(opencl, custom_value) { std::vector platforms; cl::Platform::get(&platforms); - cl::Platform platform = platforms.front(); + if (platforms.empty()) { + GTEST_SKIP() << "No platforms found"; + } + + const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + + cl::Platform platform = platforms[platform_index]; std::vector devices; platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); - cl::Device device = devices.front(); + if (devices.empty()) { + GTEST_SKIP() << "No devices found"; + } + + const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context); @@ -236,11 +289,24 @@ TEST(opencl, custom_value) { TEST(opencl, reduce_by_key_small) { std::vector platforms; cl::Platform::get(&platforms); - cl::Platform platform = platforms.front(); + if (platforms.empty()) { + GTEST_SKIP() << "No platforms found"; + } + + const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + + cl::Platform platform = platforms[platform_index]; std::vector devices; platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); - cl::Device device = devices.front(); + if (platforms.empty()) { + GTEST_SKIP() << "No platforms found"; + } + + const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context, CL_QUEUE_PROFILING_ENABLE); diff --git a/tests/test_opencl_merge.cpp b/tests/test_opencl_merge.cpp index 53916196e..005bc5196 100644 --- a/tests/test_opencl_merge.cpp +++ b/tests/test_opencl_merge.cpp @@ -412,7 +412,14 @@ void cl_merge_v2(const cl::CommandQueue& queue, TEST(opencl_merge, merge_path_v1) { std::vector platforms; cl::Platform::get(&platforms); - cl::Platform platform = platforms.back(); + if (platforms.empty()) { + GTEST_SKIP() << "No platforms found"; + } + + const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + + cl::Platform platform = platforms[platform_index]; std::cout << "Platforms: " << std::endl; for (auto& it : platforms) { @@ -422,8 +429,14 @@ TEST(opencl_merge, merge_path_v1) { std::cout << "Current platform: " << platform.getInfo() << std::endl; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); - cl::Device device = devices[0]; + platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); + if (devices.empty()) { + GTEST_SKIP() << "No devices found"; + } + + const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; std::cout << "Devices: " << std::endl; for (auto& it : devices) { @@ -502,7 +515,14 @@ TEST(opencl_merge, merge_path_v1) { TEST(opencl_merge, merge_path_v2) { std::vector platforms; cl::Platform::get(&platforms); - cl::Platform platform = platforms.back(); + if (platforms.empty()) { + GTEST_SKIP() << "No platforms found"; + } + + const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + + cl::Platform platform = platforms[platform_index]; std::cout << "Platforms: " << std::endl; for (auto& it : platforms) { @@ -512,8 +532,14 @@ TEST(opencl_merge, merge_path_v2) { std::cout << "Current platform: " << platform.getInfo() << std::endl; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); - cl::Device device = devices[0]; + platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); + if (devices.empty()) { + GTEST_SKIP() << "No devices found"; + } + + const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; std::cout << "Devices: " << std::endl; for (auto& it : devices) { @@ -590,4 +616,4 @@ TEST(opencl_merge, merge_path_v2) { std::cout << "Time taken for Merge Cpu: " << (result_time_cpu / N_RUNS).count() << " ms\n"; } -SPLA_GTEST_MAIN +SPLA_GTEST_MAIN \ No newline at end of file From ef82c0251b8f006b0c63cba95ee84efc8e1970d1 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sun, 9 Nov 2025 20:19:08 +0300 Subject: [PATCH 02/22] style: changes accoeding to clang formatter --- run_tests.py | 4 ++-- src/opencl/cl_accelerator.cpp | 9 +++++++-- tests/test_opencl.cpp | 30 +++++++++++++++--------------- tests/test_opencl_merge.cpp | 12 ++++++------ 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/run_tests.py b/run_tests.py index ca1e1b5f0..c569dd6db 100644 --- a/run_tests.py +++ b/run_tests.py @@ -57,12 +57,12 @@ def main(): all_tests = test_names(shared.ROOT / "tests") for test_name in all_tests: full_test_name = str(tests_dir / test_name) - print(f"Exec unit-test: `{full_test_name}`") try: subprocess.check_call(full_test_name) + print(f"Exec unit-test: `{full_test_name}`") except FileNotFoundError: skipped_tests.append(test_name) - print(f"Skipped: `{test_name}`") + print(f"Skipped: `{full_test_name}`") except subprocess.CalledProcessError as err: failed_tests.append(test_name) print(f"Failed: `{err.output}`") diff --git a/src/opencl/cl_accelerator.cpp b/src/opencl/cl_accelerator.cpp index 9d8962162..3d90240b7 100644 --- a/src/opencl/cl_accelerator.cpp +++ b/src/opencl/cl_accelerator.cpp @@ -42,10 +42,15 @@ namespace spla { Status CLAccelerator::init() { m_description = "no platform or device"; - if (set_platform(0) != Status::Ok) + const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + + if (set_platform(platform_index) != Status::Ok) return Status::PlatformNotFound; - if (set_device(0) != Status::Ok) + if (set_device(device_index) != Status::Ok) return Status::DeviceNotFound; if (set_queues_count(1) != Status::Ok) diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index 703f40fc1..956be924b 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -46,7 +46,7 @@ TEST(opencl, basic) { } const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); - int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -57,8 +57,8 @@ TEST(opencl, basic) { } const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); - int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); - cl::Device device = devices[device_index]; + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context); @@ -106,7 +106,7 @@ TEST(opencl, bitonic_sort_local) { } const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); - int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -117,8 +117,8 @@ TEST(opencl, bitonic_sort_local) { } const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); - int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); - cl::Device device = devices[device_index]; + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context); @@ -169,7 +169,7 @@ TEST(opencl, bitonic_sort_global) { } const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); - int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -180,8 +180,8 @@ TEST(opencl, bitonic_sort_global) { } const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); - int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); - cl::Device device = devices[device_index]; + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context); @@ -233,7 +233,7 @@ TEST(opencl, custom_value) { } const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); - int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -244,8 +244,8 @@ TEST(opencl, custom_value) { } const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); - int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); - cl::Device device = devices[device_index]; + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context); @@ -294,7 +294,7 @@ TEST(opencl, reduce_by_key_small) { } const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); - int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -305,8 +305,8 @@ TEST(opencl, reduce_by_key_small) { } const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); - int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); - cl::Device device = devices[device_index]; + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; cl::Context context(device); cl::CommandQueue queue(context, CL_QUEUE_PROFILING_ENABLE); diff --git a/tests/test_opencl_merge.cpp b/tests/test_opencl_merge.cpp index 005bc5196..8c879a83f 100644 --- a/tests/test_opencl_merge.cpp +++ b/tests/test_opencl_merge.cpp @@ -417,7 +417,7 @@ TEST(opencl_merge, merge_path_v1) { } const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); - int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -435,8 +435,8 @@ TEST(opencl_merge, merge_path_v1) { } const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); - int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); - cl::Device device = devices[device_index]; + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; std::cout << "Devices: " << std::endl; for (auto& it : devices) { @@ -520,7 +520,7 @@ TEST(opencl_merge, merge_path_v2) { } const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); - int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -538,8 +538,8 @@ TEST(opencl_merge, merge_path_v2) { } const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); - int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); - cl::Device device = devices[device_index]; + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + cl::Device device = devices[device_index]; std::cout << "Devices: " << std::endl; for (auto& it : devices) { From 51d637b65c9511ec2b7509d6dc54dba4274e6d45 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sun, 9 Nov 2025 20:52:16 +0300 Subject: [PATCH 03/22] test: add intel gpu --- .github/workflows/self-hosted.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 1d6533175..ebcf0d0b5 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -71,6 +71,9 @@ jobs: - gpu: AMD-Radeon-RX-6750-XT platform: 1 device: 0 + - gpu: Intel-Core-i7-4790 + platform: 0 + device: 0 env: test-file: ${{ matrix.gpu }}_tests.log From 18fe4fbd790499cfee030ae23d25a8b3c2627363 Mon Sep 17 00:00:00 2001 From: Vladimir Kutuev Date: Tue, 19 Aug 2025 14:21:55 +0300 Subject: [PATCH 04/22] gh-235: add pocl cpu support --- src/opencl/cl_accelerator.cpp | 48 ++++++++++++++++++++--------------- src/opencl/cl_accelerator.hpp | 10 +++++--- tests/test_opencl.cpp | 2 +- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/opencl/cl_accelerator.cpp b/src/opencl/cl_accelerator.cpp index 3d90240b7..e0350b4b9 100644 --- a/src/opencl/cl_accelerator.cpp +++ b/src/opencl/cl_accelerator.cpp @@ -110,35 +110,42 @@ namespace spla { m_max_local_mem = m_device.getInfo(); m_addr_align = m_device.getInfo() / 8;// from bits to bytes + m_is_pocl = false; m_is_nvidia = false; m_is_amd = false; m_is_intel = false; m_is_img = false; - if (m_vendor_name.find("Intel") != std::string::npos || - m_vendor_name.find("intel") != std::string::npos || - m_vendor_name.find("INTEL") != std::string::npos || - m_vendor_id == 32902) { + auto dev_type = m_device.getInfo(); + + if (m_vendor_id == 0x10006 && + dev_type == CL_DEVICE_TYPE_CPU) { + m_vendor_code = VENDOR_CODE_POCL_CPU; + m_default_wgs = 64; + m_wave_size = 1; + m_is_pocl = true; + } else if (m_vendor_name.find("Intel") != std::string::npos || + m_vendor_name.find("intel") != std::string::npos || + m_vendor_name.find("INTEL") != std::string::npos || + m_vendor_id == 32902) { m_vendor_code = VENDOR_CODE_INTEL; m_default_wgs = 64; m_wave_size = 8; m_is_intel = true; - } - if (m_vendor_name.find("Nvidia") != std::string::npos || - m_vendor_name.find("nvidia") != std::string::npos || - m_vendor_name.find("NVIDIA") != std::string::npos || - m_vendor_id == 4318) { + } else if (m_vendor_name.find("Nvidia") != std::string::npos || + m_vendor_name.find("nvidia") != std::string::npos || + m_vendor_name.find("NVIDIA") != std::string::npos || + m_vendor_id == 4318) { m_vendor_code = VENDOR_CODE_NVIDIA; m_default_wgs = 64; m_wave_size = 32; m_is_nvidia = true; - } - if (m_vendor_name.find("Amd") != std::string::npos || - m_vendor_name.find("amd") != std::string::npos || - m_vendor_name.find("AMD") != std::string::npos || - m_vendor_name.find("Advanced Micro Devices") != std::string::npos || - m_vendor_name.find("advanced micro devices") != std::string::npos || - m_vendor_name.find("ADVANCED MICRO DEVICES") != std::string::npos) { + } else if (m_vendor_name.find("Amd") != std::string::npos || + m_vendor_name.find("amd") != std::string::npos || + m_vendor_name.find("AMD") != std::string::npos || + m_vendor_name.find("Advanced Micro Devices") != std::string::npos || + m_vendor_name.find("advanced micro devices") != std::string::npos || + m_vendor_name.find("ADVANCED MICRO DEVICES") != std::string::npos) { m_vendor_code = VENDOR_CODE_AMD; m_default_wgs = 64; m_wave_size = 64; @@ -146,11 +153,10 @@ namespace spla { // Likely, it is an integrated amd device if (m_max_wgs <= 256 || m_max_cu == 1) m_wave_size = 16; - } - if (m_vendor_name.find("Imagination Technologies") != std::string::npos || - m_vendor_name.find("IMG") != std::string::npos || - m_vendor_name.find("img") != std::string::npos || - m_vendor_id == 0x1010) { + } else if (m_vendor_name.find("Imagination Technologies") != std::string::npos || + m_vendor_name.find("IMG") != std::string::npos || + m_vendor_name.find("img") != std::string::npos || + m_vendor_id == 0x1010) { m_vendor_code = VENDOR_CODE_IMG; m_default_wgs = 32; m_wave_size = 32; diff --git a/src/opencl/cl_accelerator.hpp b/src/opencl/cl_accelerator.hpp index f39d9e521..d9741d1f9 100644 --- a/src/opencl/cl_accelerator.hpp +++ b/src/opencl/cl_accelerator.hpp @@ -46,10 +46,11 @@ #define CL_HPP_TARGET_OPENCL_VERSION 120 #include -#define VENDOR_CODE_NVIDIA "nvidia" -#define VENDOR_CODE_INTEL "intel" -#define VENDOR_CODE_AMD "amd" -#define VENDOR_CODE_IMG "img" +#define VENDOR_CODE_NVIDIA "nvidia" +#define VENDOR_CODE_INTEL "intel" +#define VENDOR_CODE_AMD "amd" +#define VENDOR_CODE_IMG "img" +#define VENDOR_CODE_POCL_CPU "pocl_cpu" namespace spla { @@ -122,6 +123,7 @@ namespace spla { uint m_default_wgs = 64; uint m_wave_size = 32; uint m_num_of_mem_banks = 32; + bool m_is_pocl = false; bool m_is_nvidia = false; bool m_is_amd = false; bool m_is_intel = false; diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index 956be924b..790e299e3 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -433,4 +433,4 @@ TEST(opencl, reduce_by_key_small) { } } -SPLA_GTEST_MAIN \ No newline at end of file +SPLA_GTEST_MAIN From 08c85015f0891aa82a34f695e2a545409bab7a27 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 10 Nov 2025 12:10:40 +0300 Subject: [PATCH 05/22] fix: change vendor id for pocl --- src/opencl/cl_accelerator.cpp | 2 +- src/opencl/cl_accelerator.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/opencl/cl_accelerator.cpp b/src/opencl/cl_accelerator.cpp index e0350b4b9..7bbe7226e 100644 --- a/src/opencl/cl_accelerator.cpp +++ b/src/opencl/cl_accelerator.cpp @@ -118,7 +118,7 @@ namespace spla { auto dev_type = m_device.getInfo(); - if (m_vendor_id == 0x10006 && + if (m_vendor_id == 65538 && dev_type == CL_DEVICE_TYPE_CPU) { m_vendor_code = VENDOR_CODE_POCL_CPU; m_default_wgs = 64; diff --git a/src/opencl/cl_accelerator.hpp b/src/opencl/cl_accelerator.hpp index d9741d1f9..979f95d21 100644 --- a/src/opencl/cl_accelerator.hpp +++ b/src/opencl/cl_accelerator.hpp @@ -99,6 +99,7 @@ namespace spla { [[nodiscard]] bool is_amd() const { return m_is_amd; } [[nodiscard]] bool is_intel() const { return m_is_intel; } [[nodiscard]] bool is_img() const { return m_is_img; } + [[nodiscard]] bool is_pocl() const { return m_is_pocl; } private: cl::Platform m_platform; From c487ce1313981132f4e783081cd70146b097de0f Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Mon, 10 Nov 2025 14:49:31 +0300 Subject: [PATCH 06/22] ref: changes in env variable name --- run_tests.py | 7 +++++-- src/opencl/cl_accelerator.cpp | 11 ++++++++--- src/opencl/cl_accelerator.hpp | 3 +++ tests/test_kron.cpp | 2 +- tests/test_mxm.cpp | 2 +- tests/test_mxmT.cpp | 2 +- tests/test_mxv.cpp | 2 +- tests/test_opencl.cpp | 22 ++++++++++++---------- tests/test_opencl_merge.cpp | 10 ++++++---- tests/test_vector.cpp | 2 +- tests/test_vxm.cpp | 2 +- 11 files changed, 40 insertions(+), 25 deletions(-) diff --git a/run_tests.py b/run_tests.py index c569dd6db..0e8befbc2 100644 --- a/run_tests.py +++ b/run_tests.py @@ -46,8 +46,11 @@ def main(): parser.add_argument("--device", default="0") args = parser.parse_args() - os.environ["SPLA_OPENCL_PLATFORM"] = args.platform - os.environ["SPLA_OPENCL_DEVICE"] = args.device + spla_opencl_platform = "SPLA_OPENCL_PLATFORM" + spla_opencl_device = "SPLA_OPENCL_DEVICE" + + os.environ[spla_opencl_platform] = args.platform + os.environ[spla_opencl_device] = args.device tests_dir = shared.ROOT / args.build_dir / "tests" print(f"Searching for unit-tests in `{tests_dir}` folder") diff --git a/src/opencl/cl_accelerator.cpp b/src/opencl/cl_accelerator.cpp index 7bbe7226e..776f65d03 100644 --- a/src/opencl/cl_accelerator.cpp +++ b/src/opencl/cl_accelerator.cpp @@ -42,8 +42,8 @@ namespace spla { Status CLAccelerator::init() { m_description = "no platform or device"; - const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); - const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + const char* spla_opencl_platform = std::getenv(SPLA_OPENCL_PLATFORM); + const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); @@ -117,8 +117,13 @@ namespace spla { m_is_img = false; auto dev_type = m_device.getInfo(); + auto m_platform_name = m_platform.getInfo(); - if (m_vendor_id == 65538 && + if ((m_vendor_id == 65538 || + m_vendor_name.find("pocl") != std::string::npos || + m_vendor_name.find("POCL") != std::string::npos || + m_vendor_name.find("PoCL") != std::string::npos || + m_platform_name.find("Portable Computing Language") != std::string::npos) && dev_type == CL_DEVICE_TYPE_CPU) { m_vendor_code = VENDOR_CODE_POCL_CPU; m_default_wgs = 64; diff --git a/src/opencl/cl_accelerator.hpp b/src/opencl/cl_accelerator.hpp index 979f95d21..32ae44871 100644 --- a/src/opencl/cl_accelerator.hpp +++ b/src/opencl/cl_accelerator.hpp @@ -52,6 +52,9 @@ #define VENDOR_CODE_IMG "img" #define VENDOR_CODE_POCL_CPU "pocl_cpu" +#define SPLA_OPENCL_PLATFORM "SPLA_OPENCL_PLATFORM" +#define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" + namespace spla { /** diff --git a/tests/test_kron.cpp b/tests/test_kron.cpp index 22040d795..e0839b605 100644 --- a/tests/test_kron.cpp +++ b/tests/test_kron.cpp @@ -92,4 +92,4 @@ TEST(kron, naive) { } } -SPLA_GTEST_MAIN_WITH_FINALIZE_PLATFORM(1) +SPLA_GTEST_MAIN diff --git a/tests/test_mxm.cpp b/tests/test_mxm.cpp index 879415cd4..b727975ab 100644 --- a/tests/test_mxm.cpp +++ b/tests/test_mxm.cpp @@ -129,4 +129,4 @@ TEST(mxm, perf_zero) { } } -SPLA_GTEST_MAIN_WITH_FINALIZE_PLATFORM(1) +SPLA_GTEST_MAIN diff --git a/tests/test_mxmT.cpp b/tests/test_mxmT.cpp index 64c05b6dc..fbec06677 100644 --- a/tests/test_mxmT.cpp +++ b/tests/test_mxmT.cpp @@ -140,4 +140,4 @@ TEST(mxmT_masked, perf_zero) { } -SPLA_GTEST_MAIN_WITH_FINALIZE_PLATFORM(1) \ No newline at end of file +SPLA_GTEST_MAIN \ No newline at end of file diff --git a/tests/test_mxv.cpp b/tests/test_mxv.cpp index 9c1c6de29..21e6f4877 100644 --- a/tests/test_mxv.cpp +++ b/tests/test_mxv.cpp @@ -129,4 +129,4 @@ TEST(mxv_masked, perf) { std::cout << std::endl; } -SPLA_GTEST_MAIN_WITH_FINALIZE_PLATFORM(1) \ No newline at end of file +SPLA_GTEST_MAIN \ No newline at end of file diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index 790e299e3..396b382ee 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -31,6 +31,8 @@ #define CL_HPP_MINIMUM_OPENCL_VERSION 120 #define CL_HPP_TARGET_OPENCL_VERSION 120 #define CL_HPP_ENABLE_EXCEPTIONS +#define SPLA_OPENCL_PLATFORM "SPLA_OPENCL_PLATFORM" +#define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" #include #include @@ -45,7 +47,7 @@ TEST(opencl, basic) { GTEST_SKIP() << "No platforms found"; } - const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + const char* spla_opencl_platform = std::getenv(SPLA_OPENCL_PLATFORM); int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -56,7 +58,7 @@ TEST(opencl, basic) { GTEST_SKIP() << "No devices found"; } - const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); cl::Device device = devices[device_index]; @@ -105,7 +107,7 @@ TEST(opencl, bitonic_sort_local) { GTEST_SKIP() << "No platforms found"; } - const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + const char* spla_opencl_platform = std::getenv(SPLA_OPENCL_PLATFORM); int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -116,7 +118,7 @@ TEST(opencl, bitonic_sort_local) { GTEST_SKIP() << "No devices found"; } - const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); cl::Device device = devices[device_index]; @@ -168,7 +170,7 @@ TEST(opencl, bitonic_sort_global) { GTEST_SKIP() << "No platforms found"; } - const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + const char* spla_opencl_platform = std::getenv(SPLA_OPENCL_PLATFORM); int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -179,7 +181,7 @@ TEST(opencl, bitonic_sort_global) { GTEST_SKIP() << "No devices found"; } - const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); cl::Device device = devices[device_index]; @@ -232,7 +234,7 @@ TEST(opencl, custom_value) { GTEST_SKIP() << "No platforms found"; } - const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + const char* spla_opencl_platform = std::getenv(SPLA_OPENCL_PLATFORM); int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -243,7 +245,7 @@ TEST(opencl, custom_value) { GTEST_SKIP() << "No devices found"; } - const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); cl::Device device = devices[device_index]; @@ -293,7 +295,7 @@ TEST(opencl, reduce_by_key_small) { GTEST_SKIP() << "No platforms found"; } - const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + const char* spla_opencl_platform = std::getenv(SPLA_OPENCL_PLATFORM); int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -304,7 +306,7 @@ TEST(opencl, reduce_by_key_small) { GTEST_SKIP() << "No platforms found"; } - const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); cl::Device device = devices[device_index]; diff --git a/tests/test_opencl_merge.cpp b/tests/test_opencl_merge.cpp index 8c879a83f..2ba2f21e1 100644 --- a/tests/test_opencl_merge.cpp +++ b/tests/test_opencl_merge.cpp @@ -30,6 +30,8 @@ #define CL_HPP_MINIMUM_OPENCL_VERSION 120 #define CL_HPP_TARGET_OPENCL_VERSION 120 #define CL_HPP_ENABLE_EXCEPTIONS +#define SPLA_OPENCL_PLATFORM "SPLA_OPENCL_PLATFORM" +#define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" #include #include @@ -416,7 +418,7 @@ TEST(opencl_merge, merge_path_v1) { GTEST_SKIP() << "No platforms found"; } - const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + const char* spla_opencl_platform = std::getenv(SPLA_OPENCL_PLATFORM); int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -434,7 +436,7 @@ TEST(opencl_merge, merge_path_v1) { GTEST_SKIP() << "No devices found"; } - const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); cl::Device device = devices[device_index]; @@ -519,7 +521,7 @@ TEST(opencl_merge, merge_path_v2) { GTEST_SKIP() << "No platforms found"; } - const char* spla_opencl_platform = std::getenv("SPLA_OPENCL_PLATFORM"); + const char* spla_opencl_platform = std::getenv(SPLA_OPENCL_PLATFORM); int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); cl::Platform platform = platforms[platform_index]; @@ -537,7 +539,7 @@ TEST(opencl_merge, merge_path_v2) { GTEST_SKIP() << "No devices found"; } - const char* spla_opencl_device = std::getenv("SPLA_OPENCL_DEVICE"); + const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); cl::Device device = devices[device_index]; diff --git a/tests/test_vector.cpp b/tests/test_vector.cpp index 22763c5a2..4bd310b43 100644 --- a/tests/test_vector.cpp +++ b/tests/test_vector.cpp @@ -497,4 +497,4 @@ TEST(vector, map) { } } -SPLA_GTEST_MAIN_WITH_FINALIZE_PLATFORM(1) +SPLA_GTEST_MAIN diff --git a/tests/test_vxm.cpp b/tests/test_vxm.cpp index 14394b55c..58c31e55c 100644 --- a/tests/test_vxm.cpp +++ b/tests/test_vxm.cpp @@ -186,4 +186,4 @@ TEST(vxm_masked, perf_and_or) { std::cout << std::endl; } -SPLA_GTEST_MAIN_WITH_FINALIZE_PLATFORM(1) \ No newline at end of file +SPLA_GTEST_MAIN \ No newline at end of file From 580e2cdc096d8bf98d07cd1ab92b40cabb27c6e3 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Mon, 10 Nov 2025 15:02:49 +0300 Subject: [PATCH 07/22] style: changes according to clang formatter --- .github/workflows/deploy.yml | 2 +- .github/workflows/docs-cpp.yml | 6 +++--- .github/workflows/docs-python.yml | 8 ++++---- src/opencl/cl_accelerator.cpp | 16 ++++++++-------- src/opencl/cl_accelerator.hpp | 2 +- tests/test_opencl.cpp | 2 +- tests/test_opencl_merge.cpp | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d772c6fa5..0cc6b6879 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v6 with: - python-version: '3.8' + python-version: '3.12.5' - name: Install dependencies run: | diff --git a/.github/workflows/docs-cpp.yml b/.github/workflows/docs-cpp.yml index bd557537f..f89432a91 100644 --- a/.github/workflows/docs-cpp.yml +++ b/.github/workflows/docs-cpp.yml @@ -17,13 +17,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: Generate documentation - uses: mattnotmitt/doxygen-action@v1.3.1 + uses: mattnotmitt/doxygen-action@v1.12.0 - name: Publish to Github Pages - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./html/ diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index 5a288db1e..6c0130487 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -14,12 +14,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ 3.8 ] + python-version: [ 3.12.5 ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} @@ -32,7 +32,7 @@ jobs: SPLA_DOCS: true - name: Publish to Github Pages - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./pydocs/ diff --git a/src/opencl/cl_accelerator.cpp b/src/opencl/cl_accelerator.cpp index 776f65d03..70620d8e4 100644 --- a/src/opencl/cl_accelerator.cpp +++ b/src/opencl/cl_accelerator.cpp @@ -43,9 +43,9 @@ namespace spla { m_description = "no platform or device"; const char* spla_opencl_platform = std::getenv(SPLA_OPENCL_PLATFORM); - const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); - int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); - int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); + const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE); + int platform_index = (spla_opencl_platform ? std::atoi(spla_opencl_platform) : 0); + int device_index = (spla_opencl_device ? std::atoi(spla_opencl_device) : 0); if (set_platform(platform_index) != Status::Ok) return Status::PlatformNotFound; @@ -116,14 +116,14 @@ namespace spla { m_is_intel = false; m_is_img = false; - auto dev_type = m_device.getInfo(); + auto dev_type = m_device.getInfo(); auto m_platform_name = m_platform.getInfo(); if ((m_vendor_id == 65538 || - m_vendor_name.find("pocl") != std::string::npos || - m_vendor_name.find("POCL") != std::string::npos || - m_vendor_name.find("PoCL") != std::string::npos || - m_platform_name.find("Portable Computing Language") != std::string::npos) && + m_vendor_name.find("pocl") != std::string::npos || + m_vendor_name.find("POCL") != std::string::npos || + m_vendor_name.find("PoCL") != std::string::npos || + m_platform_name.find("Portable Computing Language") != std::string::npos) && dev_type == CL_DEVICE_TYPE_CPU) { m_vendor_code = VENDOR_CODE_POCL_CPU; m_default_wgs = 64; diff --git a/src/opencl/cl_accelerator.hpp b/src/opencl/cl_accelerator.hpp index 32ae44871..d809398c3 100644 --- a/src/opencl/cl_accelerator.hpp +++ b/src/opencl/cl_accelerator.hpp @@ -53,7 +53,7 @@ #define VENDOR_CODE_POCL_CPU "pocl_cpu" #define SPLA_OPENCL_PLATFORM "SPLA_OPENCL_PLATFORM" -#define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" +#define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" namespace spla { diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index 396b382ee..f51dd07c6 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -32,7 +32,7 @@ #define CL_HPP_TARGET_OPENCL_VERSION 120 #define CL_HPP_ENABLE_EXCEPTIONS #define SPLA_OPENCL_PLATFORM "SPLA_OPENCL_PLATFORM" -#define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" +#define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" #include #include diff --git a/tests/test_opencl_merge.cpp b/tests/test_opencl_merge.cpp index 2ba2f21e1..2716d1964 100644 --- a/tests/test_opencl_merge.cpp +++ b/tests/test_opencl_merge.cpp @@ -31,7 +31,7 @@ #define CL_HPP_TARGET_OPENCL_VERSION 120 #define CL_HPP_ENABLE_EXCEPTIONS #define SPLA_OPENCL_PLATFORM "SPLA_OPENCL_PLATFORM" -#define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" +#define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" #include #include From c8807220bd4455aaf0bed171627430084def1029 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Mon, 10 Nov 2025 15:24:15 +0300 Subject: [PATCH 08/22] test: run in debug mode --- .github/workflows/self-hosted.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index ebcf0d0b5..0de9843fa 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -34,7 +34,7 @@ jobs: include: - os: ubuntu-24.04 env: - config: "Release" + config: "Debug" nt: "4" steps: From 17ae0edfafb050c6a9203157196c768f07d8715d Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Mon, 10 Nov 2025 15:45:54 +0300 Subject: [PATCH 09/22] ci: run all in debug mode --- .github/workflows/build.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe87ad18b..65024d043 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ on: env: build-dir: "build" - config: "Release" + config: "Debug" artifact: "native" nt: "4" diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index bac479e37..4a0d8c08b 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -23,7 +23,7 @@ on: env: build-dir: "build" - config: "Release" + config: "Debug" artifact: "spla-ubuntu-build.tar.xz" nt: "4" From c17a6f65ba1595d1d90f649020641f243a4bee84 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Mon, 10 Nov 2025 15:47:09 +0300 Subject: [PATCH 10/22] ci: delete trigger branch --- .github/workflows/build.yml | 1 - .github/workflows/clang-format.yml | 2 +- .github/workflows/self-hosted.yml | 1 - .github/workflows/ubuntu.yml | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65024d043..5b489990d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,6 @@ on: - main - release - pre-release - - self-hosted-runner paths: - '.github/**' - 'deps/**' diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 628b814b5..77c7dc77f 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -2,7 +2,7 @@ name: Clang Format on: push: - branches: [ main, self-hosted-runner ] + branches: [ main ] paths: - '.github/**' - 'include/**' diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 0de9843fa..bb7e21da4 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -6,7 +6,6 @@ on: - main - release - pre-release - - self-hosted-runner paths: - '.github/**' - 'deps/**' diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 4a0d8c08b..b8de9b6b7 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -6,7 +6,6 @@ on: - main - release - pre-release - - self-hosted-runner paths: - '.github/**' - 'deps/**' From d7e613882a772fe6fb7c6f5a4f23d161b783b9cb Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Mon, 10 Nov 2025 16:32:51 +0300 Subject: [PATCH 11/22] ref: change name of job in ubuntu --- .github/workflows/ubuntu.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index b8de9b6b7..9597348d6 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -27,8 +27,14 @@ env: nt: "4" jobs: - ubuntu: - runs-on: ubuntu-24.04 + build: + name: Build ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 steps: - uses: actions/checkout@v5 with: From 81fc94b2f8da49884c118d05273e0df4dfc4590f Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Mon, 10 Nov 2025 16:33:44 +0300 Subject: [PATCH 12/22] fix: add correct job name --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 9597348d6..42eaab0a2 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -67,7 +67,7 @@ jobs: test: name: Test CPU ${{ matrix.cpu }} - needs: ubuntu + needs: build runs-on: ${{ matrix.os }} strategy: fail-fast: false From 96d165ce0c508b822131cb6f8da984bda6f80a15 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Wed, 12 Nov 2025 20:38:00 +0300 Subject: [PATCH 13/22] ci: run github hosted runners in release mode --- .github/workflows/build.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b489990d..633e22470 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ on: env: build-dir: "build" - config: "Debug" + config: "Release" artifact: "native" nt: "4" diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 42eaab0a2..02f756a8b 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -22,7 +22,7 @@ on: env: build-dir: "build" - config: "Debug" + config: "Release" artifact: "spla-ubuntu-build.tar.xz" nt: "4" From a7659f14d8efb95057275fd819a9ff884d250c90 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Wed, 12 Nov 2025 20:40:09 +0300 Subject: [PATCH 14/22] style: add newlines in the end of files --- .github/workflows/build.yml | 2 +- .github/workflows/clang-format.yml | 2 +- .github/workflows/deploy-test.yml | 2 +- .github/workflows/deploy.yml | 2 +- .github/workflows/docs-python.yml | 2 +- .github/workflows/self-hosted.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 633e22470..58534199a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,4 +89,4 @@ jobs: name: macos-${{env.artifact}} path: | ${{env.build-dir}}/libspla_x64.dylib - ${{env.build-dir}}/libspla_arm64.dylib \ No newline at end of file + ${{env.build-dir}}/libspla_arm64.dylib diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 77c7dc77f..76e2c460d 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -32,4 +32,4 @@ jobs: uses: jidicula/clang-format-action@v4.15.0 with: clang-format-version: '20' - check-path: ${{ matrix.path }} \ No newline at end of file + check-path: ${{ matrix.path }} diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml index c7f1ed82b..ae0c00869 100644 --- a/.github/workflows/deploy-test.yml +++ b/.github/workflows/deploy-test.yml @@ -40,4 +40,4 @@ jobs: run: | python setup.py sdist bdist_wheel twine upload --verbose --repository testpypi dist/* - working-directory: python \ No newline at end of file + working-directory: python diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0cc6b6879..a689e31d0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -42,4 +42,4 @@ jobs: run: | python setup.py sdist bdist_wheel twine upload --verbose dist/* - working-directory: python \ No newline at end of file + working-directory: python diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index 6c0130487..26782bd6d 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -36,4 +36,4 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./pydocs/ - destination_dir: docs-python \ No newline at end of file + destination_dir: docs-python diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index bb7e21da4..65921b865 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -105,4 +105,4 @@ jobs: - name: Cleanup workspace run: | rm -rf ${{ github.workspace }}/* - rm -rf ${{ github.workspace }}/.* \ No newline at end of file + rm -rf ${{ github.workspace }}/.* diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 02f756a8b..61ba467c3 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -106,4 +106,4 @@ jobs: - name: Check for tests results run: | - ! grep -q "FAILED" ${{ env.test-file }} \ No newline at end of file + ! grep -q "FAILED" ${{ env.test-file }} From 57197d79d8a3bb52a7929f60bd79155f854c21a2 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Wed, 12 Nov 2025 22:08:45 +0300 Subject: [PATCH 15/22] fix: change type to cpu --- .github/workflows/self-hosted.yml | 2 +- tests/test_opencl.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 65921b865..186e47cbf 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -33,7 +33,7 @@ jobs: include: - os: ubuntu-24.04 env: - config: "Debug" + config: "Release" nt: "4" steps: diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index f51dd07c6..b03f21f04 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -53,7 +53,7 @@ TEST(opencl, basic) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); + platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } @@ -113,7 +113,7 @@ TEST(opencl, bitonic_sort_local) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); + platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } @@ -176,7 +176,7 @@ TEST(opencl, bitonic_sort_global) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); + platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } @@ -240,7 +240,7 @@ TEST(opencl, custom_value) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); + platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } @@ -301,7 +301,7 @@ TEST(opencl, reduce_by_key_small) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); + platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); if (platforms.empty()) { GTEST_SKIP() << "No platforms found"; } From 4e0e8146bd0683ef9ebe0877c018b31d448a5706 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sat, 15 Nov 2025 05:37:25 +0300 Subject: [PATCH 16/22] fix: change number --- tests/test_mxv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mxv.cpp b/tests/test_mxv.cpp index 21e6f4877..b9f3d5843 100644 --- a/tests/test_mxv.cpp +++ b/tests/test_mxv.cpp @@ -89,7 +89,7 @@ TEST(mxv_masked, naive) { } TEST(mxv_masked, perf) { - const int N = 1000000; + const int N = 980000; const int K = 256; const int S = 10; const int NITER = 10; From f0eed1cd0a859edfa4ea001a776656ba608040ba Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sat, 15 Nov 2025 05:45:30 +0300 Subject: [PATCH 17/22] ci: add check for failed in all cases --- .github/workflows/self-hosted.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 186e47cbf..76cb266a0 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -93,7 +93,7 @@ jobs: - name: Check for tests results run: | - ! grep -q "FAILED" ${{ env.test-file }} + ! grep -qi "FAILED" ${{ env.test-file }} clean: name: Cleanup workspace diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 61ba467c3..6828c3d40 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -106,4 +106,4 @@ jobs: - name: Check for tests results run: | - ! grep -q "FAILED" ${{ env.test-file }} + ! grep -qi "FAILED" ${{ env.test-file }} From 1c9cee0866f7fc84b888e5f5ac264f30049e58cd Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sat, 15 Nov 2025 16:39:28 +0300 Subject: [PATCH 18/22] Revert "gh-235: add pocl cpu support" This reverts commit 18fe4fbd790499cfee030ae23d25a8b3c2627363. --- src/opencl/cl_accelerator.cpp | 53 ++++++++++++++--------------------- src/opencl/cl_accelerator.hpp | 10 +++---- tests/test_opencl.cpp | 2 +- 3 files changed, 26 insertions(+), 39 deletions(-) diff --git a/src/opencl/cl_accelerator.cpp b/src/opencl/cl_accelerator.cpp index 70620d8e4..0310fabff 100644 --- a/src/opencl/cl_accelerator.cpp +++ b/src/opencl/cl_accelerator.cpp @@ -110,47 +110,35 @@ namespace spla { m_max_local_mem = m_device.getInfo(); m_addr_align = m_device.getInfo() / 8;// from bits to bytes - m_is_pocl = false; m_is_nvidia = false; m_is_amd = false; m_is_intel = false; m_is_img = false; - auto dev_type = m_device.getInfo(); - auto m_platform_name = m_platform.getInfo(); - - if ((m_vendor_id == 65538 || - m_vendor_name.find("pocl") != std::string::npos || - m_vendor_name.find("POCL") != std::string::npos || - m_vendor_name.find("PoCL") != std::string::npos || - m_platform_name.find("Portable Computing Language") != std::string::npos) && - dev_type == CL_DEVICE_TYPE_CPU) { - m_vendor_code = VENDOR_CODE_POCL_CPU; - m_default_wgs = 64; - m_wave_size = 1; - m_is_pocl = true; - } else if (m_vendor_name.find("Intel") != std::string::npos || - m_vendor_name.find("intel") != std::string::npos || - m_vendor_name.find("INTEL") != std::string::npos || - m_vendor_id == 32902) { + if (m_vendor_name.find("Intel") != std::string::npos || + m_vendor_name.find("intel") != std::string::npos || + m_vendor_name.find("INTEL") != std::string::npos || + m_vendor_id == 32902) { m_vendor_code = VENDOR_CODE_INTEL; m_default_wgs = 64; m_wave_size = 8; m_is_intel = true; - } else if (m_vendor_name.find("Nvidia") != std::string::npos || - m_vendor_name.find("nvidia") != std::string::npos || - m_vendor_name.find("NVIDIA") != std::string::npos || - m_vendor_id == 4318) { + } + if (m_vendor_name.find("Nvidia") != std::string::npos || + m_vendor_name.find("nvidia") != std::string::npos || + m_vendor_name.find("NVIDIA") != std::string::npos || + m_vendor_id == 4318) { m_vendor_code = VENDOR_CODE_NVIDIA; m_default_wgs = 64; m_wave_size = 32; m_is_nvidia = true; - } else if (m_vendor_name.find("Amd") != std::string::npos || - m_vendor_name.find("amd") != std::string::npos || - m_vendor_name.find("AMD") != std::string::npos || - m_vendor_name.find("Advanced Micro Devices") != std::string::npos || - m_vendor_name.find("advanced micro devices") != std::string::npos || - m_vendor_name.find("ADVANCED MICRO DEVICES") != std::string::npos) { + } + if (m_vendor_name.find("Amd") != std::string::npos || + m_vendor_name.find("amd") != std::string::npos || + m_vendor_name.find("AMD") != std::string::npos || + m_vendor_name.find("Advanced Micro Devices") != std::string::npos || + m_vendor_name.find("advanced micro devices") != std::string::npos || + m_vendor_name.find("ADVANCED MICRO DEVICES") != std::string::npos) { m_vendor_code = VENDOR_CODE_AMD; m_default_wgs = 64; m_wave_size = 64; @@ -158,10 +146,11 @@ namespace spla { // Likely, it is an integrated amd device if (m_max_wgs <= 256 || m_max_cu == 1) m_wave_size = 16; - } else if (m_vendor_name.find("Imagination Technologies") != std::string::npos || - m_vendor_name.find("IMG") != std::string::npos || - m_vendor_name.find("img") != std::string::npos || - m_vendor_id == 0x1010) { + } + if (m_vendor_name.find("Imagination Technologies") != std::string::npos || + m_vendor_name.find("IMG") != std::string::npos || + m_vendor_name.find("img") != std::string::npos || + m_vendor_id == 0x1010) { m_vendor_code = VENDOR_CODE_IMG; m_default_wgs = 32; m_wave_size = 32; diff --git a/src/opencl/cl_accelerator.hpp b/src/opencl/cl_accelerator.hpp index d809398c3..d116daefc 100644 --- a/src/opencl/cl_accelerator.hpp +++ b/src/opencl/cl_accelerator.hpp @@ -46,11 +46,10 @@ #define CL_HPP_TARGET_OPENCL_VERSION 120 #include -#define VENDOR_CODE_NVIDIA "nvidia" -#define VENDOR_CODE_INTEL "intel" -#define VENDOR_CODE_AMD "amd" -#define VENDOR_CODE_IMG "img" -#define VENDOR_CODE_POCL_CPU "pocl_cpu" +#define VENDOR_CODE_NVIDIA "nvidia" +#define VENDOR_CODE_INTEL "intel" +#define VENDOR_CODE_AMD "amd" +#define VENDOR_CODE_IMG "img" #define SPLA_OPENCL_PLATFORM "SPLA_OPENCL_PLATFORM" #define SPLA_OPENCL_DEVICE "SPLA_OPENCL_DEVICE" @@ -127,7 +126,6 @@ namespace spla { uint m_default_wgs = 64; uint m_wave_size = 32; uint m_num_of_mem_banks = 32; - bool m_is_pocl = false; bool m_is_nvidia = false; bool m_is_amd = false; bool m_is_intel = false; diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index b03f21f04..6f8f49735 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -435,4 +435,4 @@ TEST(opencl, reduce_by_key_small) { } } -SPLA_GTEST_MAIN +SPLA_GTEST_MAIN \ No newline at end of file From 1ab53597b87a872fa0384740ae0094c93f45f283 Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sat, 15 Nov 2025 16:43:16 +0300 Subject: [PATCH 19/22] fix: full remove pocl support --- .github/workflows/self-hosted.yml | 3 --- src/opencl/cl_accelerator.cpp | 2 +- tests/test_opencl.cpp | 10 +++++----- tests/test_opencl_merge.cpp | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 76cb266a0..b15d036e5 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -70,9 +70,6 @@ jobs: - gpu: AMD-Radeon-RX-6750-XT platform: 1 device: 0 - - gpu: Intel-Core-i7-4790 - platform: 0 - device: 0 env: test-file: ${{ matrix.gpu }}_tests.log diff --git a/src/opencl/cl_accelerator.cpp b/src/opencl/cl_accelerator.cpp index 0310fabff..6a7a0517a 100644 --- a/src/opencl/cl_accelerator.cpp +++ b/src/opencl/cl_accelerator.cpp @@ -88,7 +88,7 @@ namespace spla { } Status CLAccelerator::set_device(int index) { std::vector available_devices; - m_platform.getDevices(CL_DEVICE_TYPE_ALL, &available_devices); + m_platform.getDevices(CL_DEVICE_TYPE_GPU, &available_devices); if (available_devices.empty()) { LOG_MSG(Status::DeviceNotFound, "no device in selected platform, check your OpenCL runtime"); diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index 6f8f49735..5237d94ea 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -53,7 +53,7 @@ TEST(opencl, basic) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); + platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } @@ -113,7 +113,7 @@ TEST(opencl, bitonic_sort_local) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); + platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } @@ -176,7 +176,7 @@ TEST(opencl, bitonic_sort_global) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); + platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } @@ -240,7 +240,7 @@ TEST(opencl, custom_value) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); + platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } @@ -301,7 +301,7 @@ TEST(opencl, reduce_by_key_small) { cl::Platform platform = platforms[platform_index]; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); + platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); if (platforms.empty()) { GTEST_SKIP() << "No platforms found"; } diff --git a/tests/test_opencl_merge.cpp b/tests/test_opencl_merge.cpp index 2716d1964..2d139ef2b 100644 --- a/tests/test_opencl_merge.cpp +++ b/tests/test_opencl_merge.cpp @@ -431,7 +431,7 @@ TEST(opencl_merge, merge_path_v1) { std::cout << "Current platform: " << platform.getInfo() << std::endl; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); + platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } @@ -534,7 +534,7 @@ TEST(opencl_merge, merge_path_v2) { std::cout << "Current platform: " << platform.getInfo() << std::endl; std::vector devices; - platform.getDevices(CL_DEVICE_TYPE_ALL, &devices); + platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); if (devices.empty()) { GTEST_SKIP() << "No devices found"; } From adc56e88507b402a0a1480e47c023d077854b2dc Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sat, 15 Nov 2025 16:50:18 +0300 Subject: [PATCH 20/22] style: add newlines in the end of files --- src/opencl/cl_accelerator.hpp | 1 - tests/test_array.cpp | 2 +- tests/test_library.cpp | 2 +- tests/test_matrix.cpp | 2 +- tests/test_mxmT.cpp | 2 +- tests/test_mxv.cpp | 2 +- tests/test_op.cpp | 2 +- tests/test_opencl.cpp | 2 +- tests/test_vxm.cpp | 2 +- 9 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/opencl/cl_accelerator.hpp b/src/opencl/cl_accelerator.hpp index d116daefc..52a0497e1 100644 --- a/src/opencl/cl_accelerator.hpp +++ b/src/opencl/cl_accelerator.hpp @@ -101,7 +101,6 @@ namespace spla { [[nodiscard]] bool is_amd() const { return m_is_amd; } [[nodiscard]] bool is_intel() const { return m_is_intel; } [[nodiscard]] bool is_img() const { return m_is_img; } - [[nodiscard]] bool is_pocl() const { return m_is_pocl; } private: cl::Platform m_platform; diff --git a/tests/test_array.cpp b/tests/test_array.cpp index 51278a5dc..31f6c131a 100644 --- a/tests/test_array.cpp +++ b/tests/test_array.cpp @@ -99,4 +99,4 @@ TEST(array, read) { } } -SPLA_GTEST_MAIN \ No newline at end of file +SPLA_GTEST_MAIN diff --git a/tests/test_library.cpp b/tests/test_library.cpp index 7eba89e93..114f8db1b 100644 --- a/tests/test_library.cpp +++ b/tests/test_library.cpp @@ -66,4 +66,4 @@ TEST(library, default_accelerator_info) { std::cout << "Info: " << acc_info << std::endl; } -SPLA_GTEST_MAIN \ No newline at end of file +SPLA_GTEST_MAIN diff --git a/tests/test_matrix.cpp b/tests/test_matrix.cpp index 2246b38e9..14ecc4e17 100644 --- a/tests/test_matrix.cpp +++ b/tests/test_matrix.cpp @@ -271,4 +271,4 @@ TEST(matrix, emult) { } } -SPLA_GTEST_MAIN_WITH_FINALIZE \ No newline at end of file +SPLA_GTEST_MAIN_WITH_FINALIZE diff --git a/tests/test_mxmT.cpp b/tests/test_mxmT.cpp index fbec06677..2fa385494 100644 --- a/tests/test_mxmT.cpp +++ b/tests/test_mxmT.cpp @@ -140,4 +140,4 @@ TEST(mxmT_masked, perf_zero) { } -SPLA_GTEST_MAIN \ No newline at end of file +SPLA_GTEST_MAIN diff --git a/tests/test_mxv.cpp b/tests/test_mxv.cpp index b9f3d5843..1d7e9d168 100644 --- a/tests/test_mxv.cpp +++ b/tests/test_mxv.cpp @@ -129,4 +129,4 @@ TEST(mxv_masked, perf) { std::cout << std::endl; } -SPLA_GTEST_MAIN \ No newline at end of file +SPLA_GTEST_MAIN diff --git a/tests/test_op.cpp b/tests/test_op.cpp index c439c29a5..a1d915891 100644 --- a/tests/test_op.cpp +++ b/tests/test_op.cpp @@ -61,4 +61,4 @@ TEST(op_binary, custom) { display_op_info(custom_plus); } -SPLA_GTEST_MAIN_WITH_FINALIZE \ No newline at end of file +SPLA_GTEST_MAIN_WITH_FINALIZE diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index 5237d94ea..f51dd07c6 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -435,4 +435,4 @@ TEST(opencl, reduce_by_key_small) { } } -SPLA_GTEST_MAIN \ No newline at end of file +SPLA_GTEST_MAIN diff --git a/tests/test_vxm.cpp b/tests/test_vxm.cpp index 58c31e55c..615aa8c30 100644 --- a/tests/test_vxm.cpp +++ b/tests/test_vxm.cpp @@ -186,4 +186,4 @@ TEST(vxm_masked, perf_and_or) { std::cout << std::endl; } -SPLA_GTEST_MAIN \ No newline at end of file +SPLA_GTEST_MAIN From 1b39efee6170d382e5e4e83e5a816ec83edb250f Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sat, 15 Nov 2025 16:52:00 +0300 Subject: [PATCH 21/22] style: add newline in opencl merge --- tests/test_opencl_merge.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_opencl_merge.cpp b/tests/test_opencl_merge.cpp index 2d139ef2b..8700f6ddf 100644 --- a/tests/test_opencl_merge.cpp +++ b/tests/test_opencl_merge.cpp @@ -618,4 +618,4 @@ TEST(opencl_merge, merge_path_v2) { std::cout << "Time taken for Merge Cpu: " << (result_time_cpu / N_RUNS).count() << " ms\n"; } -SPLA_GTEST_MAIN \ No newline at end of file +SPLA_GTEST_MAIN From e81f9a4fc49d99a70e2c331330dc8b8d86bbdd9f Mon Sep 17 00:00:00 2001 From: Kostya Oreshin Date: Sat, 15 Nov 2025 17:16:06 +0300 Subject: [PATCH 22/22] fix: change platforms to devices --- tests/test_opencl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_opencl.cpp b/tests/test_opencl.cpp index f51dd07c6..0fd362822 100644 --- a/tests/test_opencl.cpp +++ b/tests/test_opencl.cpp @@ -302,8 +302,8 @@ TEST(opencl, reduce_by_key_small) { std::vector devices; platform.getDevices(CL_DEVICE_TYPE_GPU, &devices); - if (platforms.empty()) { - GTEST_SKIP() << "No platforms found"; + if (devices.empty()) { + GTEST_SKIP() << "No devices found"; } const char* spla_opencl_device = std::getenv(SPLA_OPENCL_DEVICE);