OpenCL: launches sized from CL_DEVICE_MAX_WORK_GROUP_SIZE can exceed the per-kernel limit
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 30/100
Rechercherichtung
The unaddressed launch sites are in src/opencl/cl_reduce.hpp (reduce phase_1 and phase_2) and src/opencl/cl_prefix_sum.hpp (prefix_sum_prescan_unroll and prefix_sum_propagate), all sized from get_max_wgs(). Start by checking how CLProgram exposes kernels and where #247's fix for reduce_by_key and sort_by_key sits. Done means a per-kernel work-group size is queried with clGetKernelWorkGroupInfo, cached, and used at these sites, with a failed query falling back to the default size.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
SPLA sizes single-group (and some multi-group) work-group launches from
CL_DEVICE_MAX_WORK_GROUP_SIZE instead of the per-kernel
CL_KERNEL_WORK_GROUP_SIZE. On drivers where the per-kernel limit is lower
than the device maximum (e.g. Imagination PowerVR BXE-2-32: device max 512,
but reduce_by_key_small per-kernel limit 480), the oversized launch is
refused with CL_OUT_OF_RESOURCES.
This is the generic form of the bug reported in #246 (silent SSSP early-stop
with FLT_MAX distances on belgium_osm). #247 fixes the two reported call
sites, but the same pattern exists elsewhere and is not addressed.
Mechanism
CL_DEVICE_MAX_WORK_GROUP_SIZE is only an upper bound. The actual maximum
work-group size a specific kernel can run at is CL_KERNEL_WORK_GROUP_SIZE,
which is resource-driven (registers, local memory, private memory) and varies
per kernel and per device/driver. Launching a work group larger than the
per-kernel limit fails with CL_OUT_OF_RESOURCES.
Confirmed on PowerVR BXE-2-32 (see #246):
| Kernel | Per-kernel limit | Local mem | Private mem |
|---|---|---|---|
| trivial fill | 512 | 16 B | 32 B |
reduce_by_key_small (min) |
480 | 2080 B | 80 B |
reduce_by_key_small (fmin) |
512 | 2080 B | 60 B |
A 512-thread launch succeeds for the trivial/fmin kernels but fails for the
min variant — proving the limit is genuinely per-kernel, so it must be
queried rather than assumed from the device max.
Affected launch sites
Sites that derive the work-group size from get_max_wgs() (device max):
| File | Kernel(s) | Local size | Status |
|---|---|---|---|
src/opencl/cl_reduce_by_key.hpp |
reduce_by_key_small |
align(size, wave) up to max WGS |
fixed by #247 |
src/opencl/cl_sort_by_key.hpp |
bitonic_sort_local, bitonic_sort_global |
up to max WGS | fixed by #247 |
src/opencl/cl_reduce.hpp |
reduce (phase_1 multi-group, phase_2 single-group) |
min(1024, max_wgs) → up to 512 |
not addressed |
src/opencl/cl_prefix_sum.hpp |
prefix_sum_prescan_unroll, prefix_sum_propagate |
min(max_wgs, 256) → up to 256 |
not addressed |
Lower-risk sites use get_default_wgs() (capped at 64) or get_wave_size()
(≤ 64) and are unlikely to exceed a per-kernel limit, but are the same class:
cl_map.hpp, cl_v_eadd.hpp, cl_v_eadd_fdb.hpp.
Proposed fix (systemic)
Introduce a single helper that returns a safe work-group size for a given
kernel — querying CL_KERNEL_WORK_GROUP_SIZE once and caching the result
(per program + kernel, e.g. on CLProgram) — and use it at every launch site
instead of get_max_wgs(). Never launch a work group larger than the
per-kernel limit.
Additional hardening:
- Check the
clGetKernelWorkGroupInforeturn code; on failure fall back to a
known-safe small size (e.g. the default WGS) rather than0. - Surface dispatch failures: in #246 the
CL_OUT_OF_RESOURCESwas not
reported — distances simply came back asFLT_MAX.
References
- #246 — original bug report (PowerVR, SSSP early-stop)
- #247 — partial fix (
reduce_by_key+sort_by_key)
- Vorherrschende Sprache
- C++
- Sterne
- 37
- Forks
- 21
- Ø Merge
- 11 Std. 3 Min.
- Gemergte PRs (30 T.)
- 13
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus SparseLinearAlgebra/spla
-
task
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
SparseLinearAlgebra/spla#316 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
task
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
SparseLinearAlgebra/spla#249 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
task
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
SparseLinearAlgebra/spla#315 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
task
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 70/100
SparseLinearAlgebra/spla#314 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Optimize compute_spgemm_part chunk flushes, atomics, radix sort, SLM, restrict, and subgroup shuffleOffentask
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
SparseLinearAlgebra/spla#313 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in SparseLinearAlgebra/spla
Ähnliche Issues
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itselfEvtl. vergeben @fedonman hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
gofractally/psibase#2379 ·
Maintainer antworten meist innerhalb von 3 Tagen