From 01b4afc8279e181956be5b725a3144f6847bd50d Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 15:16:48 +0200 Subject: [PATCH 01/13] build with cuda enabled on ubuntu runner --- .github/workflows/main.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7227a2f1..1941de4d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,8 +11,8 @@ env: INTTEST_URL: https://github.com/SacBase/IntegrationTests.git jobs: - build-ubuntu24: - runs-on: ubuntu-24.04 + build-ubuntu26: + runs-on: nvidia/cuda:13.3.1-devel-ubuntu26.04 steps: - name: Get HEAD and submodules uses: actions/checkout@v6 @@ -27,17 +27,20 @@ jobs: run: | git clone --single-branch --recursive ${SAC2C_URL} sac2c cd sac2c - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RELEASE - cmake --build build -j4 + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RELEASE -DCUDA=ON + cmake --build build --parallel ln -s $PWD/build/sac2c_p /usr/local/bin/sac2c sac2c -V - name: Configure build system run: | - cmake -S . -B build -G Ninja + cmake -S . -B build -G Ninja \ + -DTARGETS="seq;seq_checks;mt_pth;cuda" \ + -DBUILD_EXT=ON \ + -DLINKSETSIZE=200 - name: Build shell: bash run: | - cmake --build build -j4 2>&1 | tee build.log + cmake --build build --parallel 2>&1 | tee build.log if [ ${PIPESTATUS[0]} -ne 0 ]; then echo "!!! ERROR detected in build !!!"; exit 1; @@ -72,16 +75,18 @@ jobs: git clone --single-branch --recursive ${SAC2C_URL} sac2c cd sac2c cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RELEASE - cmake --build build -j3 + cmake --build build --parallel ln -s $PWD/build/sac2c_p /usr/local/bin/sac2c sac2c -V - name: Configure build system run: | - cmake -S . -B build -G Ninja + cmake -S . -B build -G Ninja \ + -DTARGETS="seq;seq_checks;mt_pth" \ + -DBUILD_EXT=ON - name: Build shell: bash run: | - cmake --build build -j3 2>&1 | tee build.log + cmake --build build --parallel 2>&1 | tee build.log if [ ${PIPESTATUS[0]} -ne 0 ]; then echo "!!! ERROR detected in build !!!"; exit 1; From d15d9559e92c33546801e0b5e6a54ac0437f19c4 Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 15:55:12 +0200 Subject: [PATCH 02/13] see if this fixes the cuda error --- src/structures/src/String/Str.c | 4 ++++ src/structures/src/String/Str.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/structures/src/String/Str.c b/src/structures/src/String/Str.c index 9762b5d2..93f38376 100644 --- a/src/structures/src/String/Str.c +++ b/src/structures/src/String/Str.c @@ -14,7 +14,11 @@ string copy_string(string s) return s2; } +#ifdef SAC_BACKEND_CUDA +string free_string(void *s) +#else string free_string(string s) +#endif { free(s); return NULL; diff --git a/src/structures/src/String/Str.h b/src/structures/src/String/Str.h index 648a546a..2c718937 100644 --- a/src/structures/src/String/Str.h +++ b/src/structures/src/String/Str.h @@ -12,7 +12,15 @@ typedef char *string; string copy_string(string s); + +#ifdef SAC_BACKEND_CUDA +// CUDA compiles generated code as C++, where void* may not be implicitly +// converted to char*, so we have to make the argument void* instead. +string free_string(void *s); +#else string free_string(string s); +#endif + string SACtostring(unsigned char *arr, sac_int length); string SACautotostring(SACarg *sarr); From 73a12f909c25d27f04e89656908180a8760981cc Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:02:20 +0200 Subject: [PATCH 03/13] fix github CICD --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1941de4d..f039ed50 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,9 @@ env: jobs: build-ubuntu26: - runs-on: nvidia/cuda:13.3.1-devel-ubuntu26.04 + runs-on: ubuntu26.04 + container: + image: nvidia/cuda:13.3.1-devel-ubuntu26.04 steps: - name: Get HEAD and submodules uses: actions/checkout@v6 From 68dff81fb43292b03a0088cba2f02c4370689e6a Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:03:35 +0200 Subject: [PATCH 04/13] fix github CICD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f039ed50..acd4f822 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ env: jobs: build-ubuntu26: - runs-on: ubuntu26.04 + runs-on: ubuntu-26.04 container: image: nvidia/cuda:13.3.1-devel-ubuntu26.04 steps: From ad89e5ed5f384e9fac5a9b784a52d49025b0adfc Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:11:55 +0200 Subject: [PATCH 05/13] fix github CICD --- .github/workflows/main.yml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index acd4f822..66408239 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,15 +16,20 @@ jobs: container: image: nvidia/cuda:13.3.1-devel-ubuntu26.04 steps: - - name: Get HEAD and submodules - uses: actions/checkout@v6 - with: - fetch-depth: 0 - submodules: 'recursive' - name: Install dependencies run: | - sudo apt update - sudo apt install xsltproc -y + sudo apt-get update + sudo apt-get install -y \ + ca-certificates cmake git ninja-build xsltproc + - name: Get HEAD and submodules + env: + GH_TOKEN: ${{ github.token }} + run: | + git clone --recursive \ + "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \ + "${GITHUB_WORKSPACE}" + cd "${GITHUB_WORKSPACE}" + git checkout "${GITHUB_SHA}" - name: Install sac2c run: | git clone --single-branch --recursive ${SAC2C_URL} sac2c @@ -59,15 +64,15 @@ jobs: build-macos-arm: runs-on: macos-latest steps: + - name: Install dependencies + run: | + brew update + brew install libxslt - name: Get HEAD and submodules uses: actions/checkout@v6 with: fetch-depth: 0 submodules: 'recursive' - - name: Install dependencies - run: | - brew update - brew install libxslt - name: Set XCode version uses: maxim-lobanov/setup-xcode@v1 with: From b3921386c494691a809895e69e2091393edee77b Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:15:21 +0200 Subject: [PATCH 06/13] fix github CICD --- .github/workflows/main.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66408239..7fa8c0d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,18 +18,14 @@ jobs: steps: - name: Install dependencies run: | - sudo apt-get update - sudo apt-get install -y \ + apt-get update + apt-get install -y \ ca-certificates cmake git ninja-build xsltproc - name: Get HEAD and submodules - env: - GH_TOKEN: ${{ github.token }} - run: | - git clone --recursive \ - "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \ - "${GITHUB_WORKSPACE}" - cd "${GITHUB_WORKSPACE}" - git checkout "${GITHUB_SHA}" + uses: actions/checkout@v6 + with: + fetch-depth: 0 + submodules: 'recursive' - name: Install sac2c run: | git clone --single-branch --recursive ${SAC2C_URL} sac2c From 9d49cda9f5093e37cd8210dc69d1052d27cb6629 Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:19:37 +0200 Subject: [PATCH 07/13] fix github CICD --- .github/workflows/main.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7fa8c0d7..9f952b75 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,17 @@ jobs: run: | apt-get update apt-get install -y \ - ca-certificates cmake git ninja-build xsltproc + git \ + cmake \ + ninja-build \ + ca-certificates \ + libhwloc-dev \ + uuid-runtime \ + uuid-dev \ + xsltproc \ + bison \ + flex \ + m4 - name: Get HEAD and submodules uses: actions/checkout@v6 with: From 6825959e6211a45516778602e2c2aa4382a2ba95 Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:33:09 +0200 Subject: [PATCH 08/13] fix github CICD --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f952b75..28fa8a11 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,7 @@ jobs: apt-get install -y \ git \ cmake \ + python3 \ ninja-build \ ca-certificates \ libhwloc-dev \ From 8023fe41a0d834e7af2729f5509e796fdc39c991 Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:44:51 +0200 Subject: [PATCH 09/13] fix github CICD --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28fa8a11..3006cf44 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies run: | apt-get update - apt-get install -y \ + apt-get install --no-install-recommends -y \ git \ cmake \ python3 \ @@ -45,6 +45,8 @@ jobs: cmake --build build --parallel ln -s $PWD/build/sac2c_p /usr/local/bin/sac2c sac2c -V + - name: Configure Git + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Configure build system run: | cmake -S . -B build -G Ninja \ From 03dd6a4b4f1263b194add4abfdf30fe44067cd04 Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:55:06 +0200 Subject: [PATCH 10/13] that macro for the ifdef might not be passed into C --- src/structures/src/String/Str.c | 4 ---- src/structures/src/String/Str.h | 5 ----- 2 files changed, 9 deletions(-) diff --git a/src/structures/src/String/Str.c b/src/structures/src/String/Str.c index 93f38376..125e6e9f 100644 --- a/src/structures/src/String/Str.c +++ b/src/structures/src/String/Str.c @@ -14,11 +14,7 @@ string copy_string(string s) return s2; } -#ifdef SAC_BACKEND_CUDA string free_string(void *s) -#else -string free_string(string s) -#endif { free(s); return NULL; diff --git a/src/structures/src/String/Str.h b/src/structures/src/String/Str.h index 2c718937..30e1c4e8 100644 --- a/src/structures/src/String/Str.h +++ b/src/structures/src/String/Str.h @@ -13,14 +13,9 @@ typedef char *string; string copy_string(string s); -#ifdef SAC_BACKEND_CUDA // CUDA compiles generated code as C++, where void* may not be implicitly // converted to char*, so we have to make the argument void* instead. string free_string(void *s); -#else -string free_string(string s); -#endif - string SACtostring(unsigned char *arr, sac_int length); string SACautotostring(SACarg *sarr); From 3f5b5a9dd6ffdeec4e065dbf151abd44e849f29b Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 17:25:26 +0200 Subject: [PATCH 11/13] does disabling ctype pragma fix it? --- src/structures/String.sac | 2 +- src/structures/src/String/Str.c | 2 +- src/structures/src/String/Str.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/String.sac b/src/structures/String.sac index 1f84cf4c..1a8f73f3 100644 --- a/src/structures/String.sac +++ b/src/structures/String.sac @@ -11,7 +11,7 @@ module String; export all except { indent }; external typedef string; - #pragma ctype "char*" + // #pragma ctype "char*" #pragma copyfun "copy_string" #pragma freefun "free_string" #pragma linkobj "src/String/Str.o" diff --git a/src/structures/src/String/Str.c b/src/structures/src/String/Str.c index 125e6e9f..9762b5d2 100644 --- a/src/structures/src/String/Str.c +++ b/src/structures/src/String/Str.c @@ -14,7 +14,7 @@ string copy_string(string s) return s2; } -string free_string(void *s) +string free_string(string s) { free(s); return NULL; diff --git a/src/structures/src/String/Str.h b/src/structures/src/String/Str.h index 30e1c4e8..0e006343 100644 --- a/src/structures/src/String/Str.h +++ b/src/structures/src/String/Str.h @@ -15,7 +15,7 @@ string copy_string(string s); // CUDA compiles generated code as C++, where void* may not be implicitly // converted to char*, so we have to make the argument void* instead. -string free_string(void *s); +string free_string(string s); string SACtostring(unsigned char *arr, sac_int length); string SACautotostring(SACarg *sarr); From b75b6526e83cf88bcb3740f52c7de74dafdaafd2 Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 17:42:36 +0200 Subject: [PATCH 12/13] move cuda comment to right place --- src/structures/String.sac | 3 +++ src/structures/src/String/Str.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/String.sac b/src/structures/String.sac index 1a8f73f3..0e22d6ad 100644 --- a/src/structures/String.sac +++ b/src/structures/String.sac @@ -10,6 +10,9 @@ module String; export all except { indent }; +// Using `pragma ctype` leads to issues when compiling for CUDA. CUDA compiles +// generated code as C++, where using `ctype` introduces an implicit cast from +// void* to char*, which is not allowed in C++. external typedef string; // #pragma ctype "char*" #pragma copyfun "copy_string" diff --git a/src/structures/src/String/Str.h b/src/structures/src/String/Str.h index 0e006343..648a546a 100644 --- a/src/structures/src/String/Str.h +++ b/src/structures/src/String/Str.h @@ -12,9 +12,6 @@ typedef char *string; string copy_string(string s); - -// CUDA compiles generated code as C++, where void* may not be implicitly -// converted to char*, so we have to make the argument void* instead. string free_string(string s); string SACtostring(unsigned char *arr, sac_int length); From efbe45d39059611baa65f3552f942fb2ce196884 Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Fri, 11 Sep 2026 18:47:39 +0200 Subject: [PATCH 13/13] --parallel causes OOM --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3006cf44..eae05af6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,7 +42,7 @@ jobs: git clone --single-branch --recursive ${SAC2C_URL} sac2c cd sac2c cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RELEASE -DCUDA=ON - cmake --build build --parallel + cmake --build build -j4 ln -s $PWD/build/sac2c_p /usr/local/bin/sac2c sac2c -V - name: Configure Git @@ -56,7 +56,7 @@ jobs: - name: Build shell: bash run: | - cmake --build build --parallel 2>&1 | tee build.log + cmake --build build -j4 2>&1 | tee build.log if [ ${PIPESTATUS[0]} -ne 0 ]; then echo "!!! ERROR detected in build !!!"; exit 1; @@ -91,7 +91,7 @@ jobs: git clone --single-branch --recursive ${SAC2C_URL} sac2c cd sac2c cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RELEASE - cmake --build build --parallel + cmake --build build -j3 ln -s $PWD/build/sac2c_p /usr/local/bin/sac2c sac2c -V - name: Configure build system @@ -102,7 +102,7 @@ jobs: - name: Build shell: bash run: | - cmake --build build --parallel 2>&1 | tee build.log + cmake --build build -j3 2>&1 | tee build.log if [ ${PIPESTATUS[0]} -ne 0 ]; then echo "!!! ERROR detected in build !!!"; exit 1;