MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / build_graph

Function build_graph

python/2_CoreConcepts/cudaGraphs/cudaGraphs.py:109–146  ·  view source on GitHub ↗

Capture the 3-stage pipeline into a CUDA graph and return it.

(stream, kernels, config, buffers, size)

Source from the content-addressed store, hash-verified

107
108
109def build_graph(stream, kernels, config, buffers, size):
110 """Capture the 3-stage pipeline into a CUDA graph and return it."""
111 add_k, mul_k, sub_k = kernels
112 a, b, c, r1, r2, r3 = buffers
113
114 graph_builder = stream.create_graph_builder()
115 graph_builder.begin_building()
116 launch(
117 graph_builder,
118 config,
119 add_k,
120 a.data.ptr,
121 b.data.ptr,
122 r1.data.ptr,
123 np.uint64(size),
124 )
125 launch(
126 graph_builder,
127 config,
128 mul_k,
129 r1.data.ptr,
130 c.data.ptr,
131 r2.data.ptr,
132 np.uint64(size),
133 )
134 launch(
135 graph_builder,
136 config,
137 sub_k,
138 r2.data.ptr,
139 a.data.ptr,
140 r3.data.ptr,
141 np.uint64(size),
142 )
143 graph_builder.end_building()
144 graph = graph_builder.complete()
145 graph.upload(stream)
146 return graph_builder, graph
147
148
149def run_pipeline_graph(stream, graph, n_iters):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected