Skip to content

Commit 09d6ddd

Browse files
committed
cuda_core forward compatibility changes.
1 parent 24fde17 commit 09d6ddd

4 files changed

Lines changed: 26 additions & 24 deletions

File tree

cuda_core/cuda/core/experimental/_graph.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def create_conditional_handle(self, default_value=None) -> driver.CUgraphConditi
476476
default_value = 0
477477
flags = 0
478478

479-
status, _, graph, _, _ = handle_return(driver.cuStreamGetCaptureInfo(self._mnff.stream.handle))
479+
status, _, graph, *_, _ = handle_return(driver.cuStreamGetCaptureInfo(self._mnff.stream.handle))
480480
if status != driver.CUstreamCaptureStatus.CU_STREAM_CAPTURE_STATUS_ACTIVE:
481481
raise RuntimeError("Cannot create a conditional handle when graph is not being built")
482482

@@ -486,20 +486,22 @@ def create_conditional_handle(self, default_value=None) -> driver.CUgraphConditi
486486

487487
def _cond_with_params(self, node_params) -> GraphBuilder:
488488
# Get current capture info to ensure we're in a valid state
489-
status, _, graph, dependencies, num_dependencies = handle_return(
489+
status, _, graph, *deps_info, num_dependencies = handle_return(
490490
driver.cuStreamGetCaptureInfo(self._mnff.stream.handle)
491491
)
492492
if status != driver.CUstreamCaptureStatus.CU_STREAM_CAPTURE_STATUS_ACTIVE:
493493
raise RuntimeError("Cannot add conditional node when not actively capturing")
494494

495495
# Add the conditional node to the graph
496-
node = handle_return(driver.cuGraphAddNode(graph, dependencies, num_dependencies, node_params))
496+
deps_info_update = [
497+
[handle_return(driver.cuGraphAddNode(graph, *deps_info, num_dependencies, node_params))]
498+
] + [None] * (len(deps_info) - 1)
497499

498500
# Update the stream's capture dependencies
499501
handle_return(
500502
driver.cuStreamUpdateCaptureDependencies(
501503
self._mnff.stream.handle,
502-
[node], # dependencies
504+
*deps_info_update, # dependencies, edgeData
503505
1, # numDependencies
504506
driver.CUstreamUpdateCaptureDependencies_flags.CU_STREAM_SET_CAPTURE_DEPENDENCIES,
505507
)
@@ -677,17 +679,23 @@ def add_child(self, child_graph: GraphBuilder):
677679
raise ValueError("Parent graph is not being built.")
678680

679681
stream_handle = self._mnff.stream.handle
680-
_, _, graph_out, dependencies_out, num_dependencies_out = handle_return(
682+
_, _, graph_out, *deps_info_out, num_dependencies_out = handle_return(
681683
driver.cuStreamGetCaptureInfo(stream_handle)
682684
)
683685

684-
child_node = handle_return(
685-
driver.cuGraphAddChildGraphNode(graph_out, dependencies_out, num_dependencies_out, child_graph._mnff.graph)
686-
)
686+
deps_info_update = [
687+
[
688+
handle_return(
689+
driver.cuGraphAddChildGraphNode(
690+
graph_out, deps_info_out[0], num_dependencies_out, child_graph._mnff.graph
691+
)
692+
)
693+
]
694+
] + [None] * (len(deps_info_out) - 1)
687695
handle_return(
688696
driver.cuStreamUpdateCaptureDependencies(
689697
stream_handle,
690-
[child_node],
698+
*deps_info_update, # dependencies, edgeData
691699
1,
692700
driver.CUstreamUpdateCaptureDependencies_flags.CU_STREAM_SET_CAPTURE_DEPENDENCIES,
693701
)

cuda_core/tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import os
4+
import helpers
55

66
try:
77
from cuda.bindings import driver
@@ -65,5 +65,4 @@ def pop_all_contexts():
6565
return pop_all_contexts
6666

6767

68-
# TODO: make the fixture more sophisticated using path finder
69-
skipif_need_cuda_headers = pytest.mark.skipif(os.environ.get("CUDA_PATH") is None, reason="need CUDA header")
68+
skipif_need_cuda_headers = pytest.mark.skipif(helpers.CUDA_INCLUDE_PATH is None, reason="need CUDA header")

cuda_core/tests/test_event.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
import os
5-
import pathlib
65
import time
76

7+
import helpers
88
import numpy as np
99
import pytest
1010
from conftest import skipif_need_cuda_headers
@@ -144,7 +144,7 @@ def test_error_timing_incomplete():
144144
program_options = ProgramOptions(
145145
std="c++17",
146146
arch=f"sm_{arch}",
147-
include_path=str(pathlib.Path(os.environ["CUDA_PATH"]) / pathlib.Path("include")),
147+
include_path=helpers.CCCL_INCLUDE_PATHS,
148148
)
149149
prog = Program(code, code_type="c++", options=program_options)
150150
mod = prog.compile(target_type="cubin")

cuda_core/tests/test_launcher.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
import ctypes
5-
import os
6-
import pathlib
75

6+
import helpers
87
import numpy as np
98
import pytest
109
from conftest import skipif_need_cuda_headers
@@ -94,7 +93,7 @@ def test_launch_invalid_values(init_cuda):
9493
(ctypes.c_float, "float", 3.14),
9594
(ctypes.c_double, "double", 2.718),
9695
)
97-
if os.environ.get("CUDA_PATH"):
96+
if helpers.CCCL_INCLUDE_PATHS is not None:
9897
PARAMS += (
9998
(np.float16, "half", 0.78),
10099
(np.complex64, "cuda::std::complex<float>", 1 + 2j),
@@ -128,18 +127,15 @@ def test_launch_scalar_argument(python_type, cpp_type, init_value):
128127

129128
# Compile and force instantiation for this type
130129
arch = "".join(f"{i}" for i in dev.compute_capability)
131-
if os.environ.get("CUDA_PATH"):
132-
include_path = str(pathlib.Path(os.environ["CUDA_PATH"]) / pathlib.Path("include"))
130+
if helpers.CCCL_INCLUDE_PATHS is not None:
133131
code = (
134132
r"""
135133
#include <cuda_fp16.h>
136134
#include <cuda/std/complex>
137135
"""
138136
+ code
139137
)
140-
else:
141-
include_path = None
142-
pro_opts = ProgramOptions(std="c++11", arch=f"sm_{arch}", include_path=include_path)
138+
pro_opts = ProgramOptions(std="c++17", arch=f"sm_{arch}", include_path=helpers.CCCL_INCLUDE_PATHS)
143139
prog = Program(code, code_type="c++", options=pro_opts)
144140
ker_name = f"write_scalar<{cpp_type}>"
145141
mod = prog.compile("cubin", name_expressions=(ker_name,))
@@ -173,8 +169,7 @@ def test_cooperative_launch():
173169

174170
# Compile and force instantiation for this type
175171
arch = "".join(f"{i}" for i in dev.compute_capability)
176-
include_path = str(pathlib.Path(os.environ["CUDA_PATH"]) / pathlib.Path("include"))
177-
pro_opts = ProgramOptions(std="c++17", arch=f"sm_{arch}", include_path=include_path)
172+
pro_opts = ProgramOptions(std="c++17", arch=f"sm_{arch}", include_path=helpers.CCCL_INCLUDE_PATHS)
178173
prog = Program(code, code_type="c++", options=pro_opts)
179174
ker = prog.compile("cubin").get_kernel("test_grid_sync")
180175

0 commit comments

Comments
 (0)