Skip to content

Commit bd69003

Browse files
committed
Merge remote-tracking branch 'origin/main' into ajost/vmm-fabric
2 parents 04f6145 + 2aef8de commit bd69003

38 files changed

Lines changed: 2145 additions & 1401 deletions

‎.clang-format‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# A clang-format style derived from Python's PEP 7 (4-space indent, Stroustrup braces,
6+
# return type on its own line), except that the column limit is 120 rather than 79.
7+
# Based on https://gist.github.com/pganssle/0e3a5f828b4d07d79447f6ced8e7e4db
8+
BasedOnStyle: Google
9+
BreakAfterReturnType: AllDefinitions
10+
AllowShortIfStatementsOnASingleLine: Never
11+
BreakBeforeBraces: Stroustrup
12+
ColumnLimit: 120
13+
DerivePointerAlignment: false
14+
IndentWidth: 4
15+
Language: Cpp
16+
PointerAlignment: Right
17+
ReflowComments: Always
18+
SpaceBeforeParens: ControlStatements
19+
SpacesInParens: Never
20+
TabWidth: 4
21+
UseTab: Never
22+
23+
# Keep include order as written; reordering can break order-sensitive builds.
24+
SortIncludes: {Enabled: false}
25+
26+
# Ruff-like wrapping: break after "(", indent arguments, put ")" on its own line.
27+
# This does not contradict PEP7, but extends it to the consistent style where
28+
# calls either fit on a single line or they are broken across multiple lines with
29+
# one argument per line (indented).
30+
AlignAfterOpenBracket: true
31+
BreakAfterOpenBracketBracedList: true
32+
BreakAfterOpenBracketFunction: true
33+
BreakAfterOpenBracketIf: true
34+
BreakBeforeCloseBracketBracedList: true
35+
BreakBeforeCloseBracketFunction: true
36+
BreakBeforeCloseBracketIf: true
37+
PackArguments: {BinPack: OnePerLine}
38+
PackParameters: {BinPack: OnePerLine}
39+
AllowAllArgumentsOnNextLine: false

‎.pre-commit-config.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ repos:
3232
- id: ruff-format
3333
exclude: .*\.pyi$
3434

35+
- repo: https://github.com/pre-commit/mirrors-clang-format
36+
rev: 98ad4ddb9c057de2f5b9e93e44e6db959807d68c # frozen: v23.1.3
37+
hooks:
38+
- id: clang-format
39+
types_or: [c, c++, cuda]
40+
exclude: ^cuda_core/(cuda/core/_include/(dlpack|aoti_shim)\.h|third_party/)
41+
3542
- repo: local
3643
hooks:
3744
- id: check-precommit-installed

‎CONTRIBUTING.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ between commits, leaving stale headers or out-of-date stubs in the history.
238238
If the hook isn't installed, `pre-commit run` will print a visible warning
239239
reminding you to run `pre-commit install`.
240240

241+
C, C++ and CUDA sources are formatted with `clang-format` using the
242+
[`.clang-format`](.clang-format) at the repository root, which follows PEP 7
243+
except for a 120-column limit. The
244+
pre-commit hook installs its own pinned `clang-format` (from PyPI) into the
245+
hook environment, so no system-wide installation is required. Vendored code
246+
(for example `dlpack.h` and `cuda_core/third_party/`) is excluded in
247+
`.pre-commit-config.yaml`. To format in your editor, install the same version
248+
with `pip install clang-format==23.1.3`.
249+
241250
## CodeRabbit
242251

243252
This section explains how to use CodeRabbit for CUDA Python pull request review.

‎benchmarks/cuda_bindings/benchmarks/cpp/bench_ctx_device.cpp‎

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
#include <cstdlib>
1010
#include <iostream>
1111

12-
13-
static void check_cu(CUresult status, const char* message) {
12+
static void
13+
check_cu(CUresult status, const char *message)
14+
{
1415
if (status != CUDA_SUCCESS) {
15-
const char* error_name = nullptr;
16+
const char *error_name = nullptr;
1617
cuGetErrorName(status, &error_name);
1718
std::cerr << message << ": " << (error_name ? error_name : "unknown") << '\n';
1819
std::exit(1);
1920
}
2021
}
2122

22-
23-
int main(int argc, char** argv) {
23+
int
24+
main(int argc, char **argv)
25+
{
2426
bench::Options options = bench::parse_args(argc, argv);
2527

2628
// Setup: init CUDA and create a context
@@ -45,25 +47,19 @@ int main(int argc, char** argv) {
4547

4648
// --- ctx_set_current ---
4749
{
48-
suite.run("ctx_device.ctx_set_current", [&]() {
49-
check_cu(cuCtxSetCurrent(ctx), "cuCtxSetCurrent failed");
50-
});
50+
suite.run("ctx_device.ctx_set_current", [&]() { check_cu(cuCtxSetCurrent(ctx), "cuCtxSetCurrent failed"); });
5151
}
5252

5353
// --- ctx_get_device ---
5454
{
5555
CUdevice dev;
56-
suite.run("ctx_device.ctx_get_device", [&]() {
57-
check_cu(cuCtxGetDevice(&dev), "cuCtxGetDevice failed");
58-
});
56+
suite.run("ctx_device.ctx_get_device", [&]() { check_cu(cuCtxGetDevice(&dev), "cuCtxGetDevice failed"); });
5957
}
6058

6159
// --- device_get ---
6260
{
6361
CUdevice dev;
64-
suite.run("ctx_device.device_get", [&]() {
65-
check_cu(cuDeviceGet(&dev, 0), "cuDeviceGet failed");
66-
});
62+
suite.run("ctx_device.device_get", [&]() { check_cu(cuDeviceGet(&dev, 0), "cuDeviceGet failed"); });
6763
}
6864

6965
// --- device_get_attribute ---
@@ -80,21 +76,15 @@ int main(int argc, char** argv) {
8076
// --- device_primary_ctx_retain ---
8177
// Outer retain so the benchmarked retain/release pair just bumps the refcount.
8278
CUcontext primary_outer = nullptr;
83-
check_cu(
84-
cuDevicePrimaryCtxRetain(&primary_outer, device),
85-
"cuDevicePrimaryCtxRetain (setup) failed"
86-
);
79+
check_cu(cuDevicePrimaryCtxRetain(&primary_outer, device), "cuDevicePrimaryCtxRetain (setup) failed");
8780
{
8881
CUcontext primary = nullptr;
8982
suite.run("ctx_device.device_primary_ctx_retain", [&]() {
9083
check_cu(cuDevicePrimaryCtxRetain(&primary, device), "cuDevicePrimaryCtxRetain failed");
9184
check_cu(cuDevicePrimaryCtxRelease(device), "cuDevicePrimaryCtxRelease failed");
9285
});
9386
}
94-
check_cu(
95-
cuDevicePrimaryCtxRelease(device),
96-
"cuDevicePrimaryCtxRelease (teardown) failed"
97-
);
87+
check_cu(cuDevicePrimaryCtxRelease(device), "cuDevicePrimaryCtxRelease (teardown) failed");
9888

9989
// Cleanup
10090
check_cu(cuCtxDestroy(ctx), "cuCtxDestroy failed");

‎benchmarks/cuda_bindings/benchmarks/cpp/bench_event.cpp‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
#include <cstdlib>
1010
#include <iostream>
1111

12-
13-
static void check_cu(CUresult status, const char* message) {
12+
static void
13+
check_cu(CUresult status, const char *message)
14+
{
1415
if (status != CUDA_SUCCESS) {
15-
const char* error_name = nullptr;
16+
const char *error_name = nullptr;
1617
cuGetErrorName(status, &error_name);
1718
std::cerr << message << ": " << (error_name ? error_name : "unknown") << '\n';
1819
std::exit(1);
1920
}
2021
}
2122

22-
23-
int main(int argc, char** argv) {
23+
int
24+
main(int argc, char **argv)
25+
{
2426
bench::Options options = bench::parse_args(argc, argv);
2527

2628
// Setup
@@ -47,9 +49,7 @@ int main(int argc, char** argv) {
4749
bench::BenchmarkSuite suite(options);
4850
// Drain the persistent stream after calibration so event_record (which
4951
// enqueues onto the stream) and event_synchronize start from a known state.
50-
suite.set_post_calibrate([&]() {
51-
check_cu(cuStreamSynchronize(stream), "post-calibrate sync failed");
52-
});
52+
suite.set_post_calibrate([&]() { check_cu(cuStreamSynchronize(stream), "post-calibrate sync failed"); });
5353

5454
// --- event_create_destroy ---
5555
{
@@ -62,9 +62,7 @@ int main(int argc, char** argv) {
6262

6363
// --- event_record ---
6464
{
65-
suite.run("event.event_record", [&]() {
66-
check_cu(cuEventRecord(event, stream), "cuEventRecord failed");
67-
});
65+
suite.run("event.event_record", [&]() { check_cu(cuEventRecord(event, stream), "cuEventRecord failed"); });
6866
}
6967

7068
// Re-sync so event is in a known completed state after the record benchmark

0 commit comments

Comments
 (0)