code-saturne / code-saturne/code_saturne

SIGSEGV in cs_sles_solve_ccc_fv when CS_CUDA_ALLOC_DEVICE_UVM is not set (v9.1.0)

Aperta
#164 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C++
Stelle
307
Fork
102
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Description

`cs_sles_solve_ccc_fv` allocates its extended solver buffers using `CS_ALLOC_DEVICE` (device-only memory). Those buffers are subsequently passed to the CPU-side convergence check, which dereferences them on the host and causes a SIGSEGV.

Setting `CS_CUDA_ALLOC_DEVICE_UVM=1` before launching the solver works around the crash: it remaps `cs_alloc_mode_device` to `CS_ALLOC_HOST_DEVICE_SHARED` at initialisation time (see `cs_base_cuda.cu:777`), making the buffers accessible from both host and device.

## Steps to reproduce

1. Build code_saturne v9.1.0 with CUDA support.
2. Run any case that exercises the CUDA sparse linear solver (`cs_sles_solve_ccc_fv`) without setting `CS_CUDA_ALLOC_DEVICE_UVM`.
3. Observe SIGSEGV during the convergence check after the first solver call.

## Workaround

```bash
export CS_CUDA_ALLOC_DEVICE_UVM=1
```

Set this before invoking the solver. It prevents the crash by ensuring solver buffers are in unified/shared memory.

## Expected behaviour

`cs_sles_solve_ccc_fv` should either allocate convergence-check buffers in host-accessible memory directly, or the convergence check should use a device-to-host copy rather than a direct host dereference.

## Environment

- code_saturne version: 9.1.0
- CUDA version: 13.1
- GPU architecture: sm_75
- OS: Ubuntu (x86_64)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da cs_sles_solve_ccc_fv e ispeziona come i suoi buffer estesi del solver arrivano al controllo della convergenza lato CPU. Confronta il comportamento di allocazione con cs_base_cuda.cu:777 e riproduci una build CUDA senza CS_CUDA_ALLOC_DEVICE_UVM. Il lavoro è completato quando il solver non va più in segmentation fault senza il workaround, mentre il workaround esistente di Unified Memory rimane valido.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp
Ambito
hpc
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.