Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/grouped-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ name: "Reusable Grouped Tests Workflow (test_groups.toml)"
on:
workflow_call:
inputs:
linux-x86-pocl-workers:
description: "Maximum PoCL CPU workers for 32-bit Linux Julia. Zero uses the existing configuration."
default: 0
required: false
type: number
group-env-name:
description: "Environment variable name the package's runtests.jl reads its group from (default GROUP)"
default: "GROUP"
Expand Down Expand Up @@ -120,6 +125,7 @@ jobs:
runner: ${{ toJson(matrix.runner) }}
timeout-minutes: ${{ matrix.timeout }}
num-threads: "${{ matrix.num_threads }}"
linux-x86-pocl-workers: ${{ inputs.linux-x86-pocl-workers }}
continue-on-error: ${{ matrix.continue_on_error }}
check-bounds: "${{ inputs.check-bounds }}"
allow-reresolve: ${{ inputs.allow-reresolve }}
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ on:
default: "auto"
required: false
type: string
linux-x86-pocl-workers:
description: "Maximum PoCL CPU workers for 32-bit Linux Julia. Zero uses the existing configuration."
default: 0
required: false
type: number
self-hosted:
description: "Run the job needs on a self hosted machine"
default: false
Expand Down Expand Up @@ -139,6 +144,25 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: "Configure PoCL workers for 32-bit Linux"
if: >-
${{ inputs.linux-x86-pocl-workers != 0 && runner.os == 'Linux' &&
contains(fromJSON('["x86", "i686"]'), inputs.julia-arch || runner.arch) }}
shell: bash
env:
POCL_WORKERS: ${{ inputs.linux-x86-pocl-workers }}
run: |
if [[ ! $POCL_WORKERS =~ ^[1-9][0-9]{0,9}$ ]] || (( POCL_WORKERS > 2147483647 )); then
echo "::error::linux-x86-pocl-workers must be a positive 32-bit integer or zero to opt out."
exit 1
fi
for setting in POCL_CPU_MAX_CU_COUNT POCL_MAX_PTHREAD_COUNT POCL_MAX_COMPUTE_UNITS JULIA_KA_CPU_THREADS; do
if printenv "$setting" >/dev/null; then
exit 0
fi
done
printf 'POCL_CPU_MAX_CU_COUNT=%s\n' "$POCL_WORKERS" >> "$GITHUB_ENV"

- name: "Install 32-bit runtime libraries (i386)"
# A 32-bit (i686) Julia cannot exec on the 64-bit Linux runners without
# the i386 dynamic loader and C/C++ runtime. setup-julia invokes julia
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ tested via `project: lib/X` without a hand-written develop step.
| `group` | string | `""` | Test group; exposed to tests via an env var (see `group-env-name`). |
| `group-env-name` | string | `"GROUP"` | Name of the env var the group is set under (e.g. `ODEDIFFEQ_TEST_GROUP`). |
| `num-threads` | string | `"auto"` | `JULIA_NUM_THREADS`. `auto` matches the runner's vCPUs on hosted runners; on self-hosted it falls back to `2` (avoid oversubscribing a large shared box). An explicit integer is always honored. |
| `linux-x86-pocl-workers` | number | `0` | Maximum worker count for the PoCL CPU driver on 32-bit Linux Julia. A positive count sets `POCL_CPU_MAX_CU_COUNT` before Julia starts when the runner has no explicit PoCL worker limit or `JULIA_KA_CPU_THREADS` setting. Zero uses the existing configuration. |
| `self-hosted` | boolean | `false` | Run on a self-hosted runner. |
| `os` | string | `"ubuntu-latest"` | Runner OS (ignored when self-hosted). |
| `runner` | string | `""` | JSON-encoded `runs-on` (string or label array, e.g. `'["self-hosted","Linux","X64","gpu"]'`). When non-empty, overrides `self-hosted`/`os`. |
Expand Down Expand Up @@ -712,6 +713,7 @@ a near-zero-line `CI.yml`, and can split into groups later.
| Input | Type | Default | Description |
|---|---|---|---|
| `group-env-name` | string | `"GROUP"` | Env var the package's `runtests.jl` reads its group from (OrdinaryDiffEq uses `ODEDIFFEQ_TEST_GROUP`). |
| `linux-x86-pocl-workers` | number | `0` | PoCL CPU worker limit forwarded to `tests.yml` for 32-bit Linux Julia. |
| `check-bounds` | string | `"yes"` | `julia-runtest` `check_bounds` per group. |
| `allow-reresolve` | boolean | `true` | `julia-runtest` `allow_reresolve`. |
| `coverage` | boolean | `true` | Collect & upload coverage. |
Expand Down
37 changes: 37 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,43 @@ end
@test i386_at !== nothing && setup_at !== nothing && first(i386_at) < first(setup_at)
end

@testset "Linux x86 PoCL worker limit" begin
workflows = joinpath(@__DIR__, "..", ".github", "workflows")
tests = read(joinpath(workflows, "tests.yml"), String)
grouped = read(joinpath(workflows, "grouped-tests.yml"), String)
input = r"(?m)^ linux-x86-pocl-workers:\n(?: [^\n]*\n)*? default: 0\n"
@test occursin(input, tests)
@test occursin(input, grouped)
@test occursin("linux-x86-pocl-workers: \${{ inputs.linux-x86-pocl-workers }}", grouped)

step = match(r"(?ms)^ - name: \"Configure PoCL workers for 32-bit Linux\"\n(.*?)^ - ", tests)
@test step !== nothing
if step !== nothing
@test step.offset < first(findfirst("uses: julia-actions/setup-julia", tests))
@test occursin("inputs.linux-x86-pocl-workers != 0 && runner.os == 'Linux'", step.match)
@test occursin("""contains(fromJSON('["x86", "i686"]'), inputs.julia-arch || runner.arch)""", step.match)
shell = last(split(step.captures[1], " run: |\n"; limit = 2))
settings = ("POCL_CPU_MAX_CU_COUNT", "POCL_MAX_PTHREAD_COUNT", "POCL_MAX_COMPUTE_UNITS", "JULIA_KA_CPU_THREADS")
function configure(limit, overrides...)
return mktemp() do file, io
close(io)
env = Dict(k => v for (k, v) in ENV if k ∉ settings)
merge!(env, Dict("GITHUB_ENV" => file, "POCL_WORKERS" => limit), Dict(overrides...))
cmd = setenv(`bash -eu -c $shell`, env)
ok = success(pipeline(cmd; stdout = devnull, stderr = devnull))
return ok, read(file, String)
end
end
@test configure("2") == (true, "POCL_CPU_MAX_CU_COUNT=2\n")
for setting in settings
@test configure("2", setting => "5") == (true, "")
end
for invalid in ("-1", "1.5", "2147483648")
@test configure(invalid) == (false, "")
end
end
end

# develop_sources.jl: the [sources] develop helper used by tests.yml on Julia
# <1.11. The pure path-collection (collect_source_paths) is tested here without
# mutating any environment.
Expand Down
Loading