interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / nvrm / cpu_barrier.h

40 lines · 1378 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2#ifndef NVRM_CPU_BARRIER_H
3#define NVRM_CPU_BARRIER_H
4
5/* CPU publication order for memory the device reads or the host reads back.
6 *
7 * AArch64, including the GB10 host, executes `dsb sy`. That system barrier
8 * is the production ordering primitive. A portable host build executes a
9 * sequentially consistent fence, which is a real instruction, so the same
10 * sources compile on x86-64. Opening the Blackwell device stays AArch64-only.
11 *
12 * ADR 0043 missing feature: seeded Omega has no host CPU publication barrier
13 * that is `dsb sy` on AArch64 and a real fence on every other host. This
14 * header is that barrier in C. The non-AArch64 fence is migration-pending C.
15 * Extension proposal: https://github.com/aien-dev/omega-mv/issues/939
16 * evidence/HOST-X86-20261030/proposal-cpu-barrier.md
17 */
18static inline void nvrm_cpu_barrier(void)
19{
20#if defined(__aarch64__)
21 __asm__ volatile("dsb sy" ::: "memory");
22#else
23 __atomic_thread_fence(__ATOMIC_SEQ_CST);
24#endif
25}
26
27/* Spin hint between polls. AArch64 keeps `yield`. Other hosts keep the
28 * compiler barrier already used by src/omega_gpu_wait.c. This is not the
29 * publication barrier above.
30 */
31static inline void nvrm_cpu_relax(void)
32{
33#if defined(__aarch64__)
34 __asm__ volatile("yield");
35#else
36 __asm__ volatile("" ::: "memory");
37#endif
38}
39
40#endif