SUGGESTION: Run the OpenCL tests under Oclgrind in CI to catch data races and invalid memory accesses in kernels

Abierto
#3,430 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@SteveBronder ya está trabajando en esto.

Desde el 5/10/2026.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cpp
Área
ci-cd, testing

Línea de trabajo

Start by reading how runTests.py prefixes MPI tests, then inspect the CI setup for where a CPU-only OpenCL test stage belongs. Build test/unit/math/opencl with STAN_OPENCL=true and run its test binaries through Oclgrind with race logging. Done means the stage fails on non-empty logs and can later be made required once the reported races are fixed.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

code cleanup continuous integration dependencies gpu

Description

Motivation. CI runs the OpenCL tests on one GPU. A kernel bug that this device happens to tolerate stays invisible. Example: https://github.com/stan-dev/math/issues/3429, where the cholesky_decompose kernel returns a wrong factor on an AMD GPU because its barriers fence local memory only.

Oclgrind is an OpenCL device simulator. It needs no GPU and checks what real devices do not:

  • data races between work items, including a barrier with the wrong fence flag (--data-races),
  • reads and writes outside a buffer (always on),
  • use of uninitialized values (--uninitialized).

It runs our test binaries unchanged:

oclgrind --data-races --log races.log ./test/unit/math/opencl/cholesky_decompose_test

On develop this reports read-write races in cholesky_decompose, already for the 3×3 case, and nothing once the barriers are fixed. A first local pass also reports races in tridiagonalization_householder.

Suggested steps.

  1. Add oclgrind to the CI image.
  2. Add a CPU-only stage that builds test/unit/math/opencl with STAN_OPENCL=true and runs each test binary through oclgrind --data-races --log <file>. runTests.py already prefixes MPI tests with mpirun; the same mechanism can prefix oclgrind.
  3. Fail the stage when a log is not empty.
  4. Start it as non-blocking and make it required once the existing reports are fixed.
Lenguaje dominante
C++
Estrellas
845
Forks
225
Merge medio
3 d 9 h
PR fusionados (30 d)
12

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de stan-dev/math

Todos los issues de stan-dev/math

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.