[compiler-rt] [llvm] [compiler-rt] Add KCSAN inspired GPU ConcurrencySanitizer runtime (PR #207714)
Marco Elver via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 30 01:03:13 PDT 2026
================
@@ -0,0 +1,59 @@
+//===-- sanitizer/gpu_sanitizer.h -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Shared ABI contract for GPU sanitizer reports shipped to the host over RPC.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SANITIZER_GPU_SANITIZER_H
+#define SANITIZER_GPU_SANITIZER_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SANITIZER_GPU_OPCODE(n) (('s' << 24) | (n))
+
+#define TSAN_GPU_REPORT_OPCODE SANITIZER_GPU_OPCODE(1)
+
+/// Access classification flags, mirroring the Linux kernel's KCSAN model.
+enum {
+ TSAN_GPU_ACCESS_WRITE = 1 << 0, ///< Non-atomic write.
+ TSAN_GPU_ACCESS_COMPOUND = 1 << 1, ///< Read-modify-write.
+ TSAN_GPU_ACCESS_ATOMIC = 1 << 2, ///< Atomic access.
+};
+
+/// Race report kinds.
+enum {
+ TSAN_GPU_DATA_RACE = 0, ///< Conflicting access.
+ TSAN_GPU_UNKNOWN_ORIGIN = 1, ///< Watched value changed with no finder.
+ TSAN_GPU_INTRA_WAVE = 2, ///< Conflict between lanes of the same wave.
+};
+
+/// The data associated with a single detected race.
+typedef struct __tsan_gpu_race {
----------------
melver wrote:
See my comment in the other PR: maybe you could come up with a smaller pass inserted after or before the TSan pass.
https://github.com/llvm/llvm-project/pull/207714
More information about the llvm-commits
mailing list