@@ -48,7 +48,7 @@ from cuda.core._resource_handles cimport (
4848 create_graph_handle_ref,
4949 create_graph_node_handle,
5050 graph_node_get_graph,
51- invalidate_graph_node_handle ,
51+ invalidate_graph_node ,
5252)
5353from cuda.core._utils.cuda_utils cimport HANDLE_RETURN, _parse_fill_value
5454
@@ -63,11 +63,11 @@ from cuda.core import Device
6363from cuda.core._graph._graph_def._adjacency_set_proxy import AdjacencySetProxy
6464from cuda.core._utils.cuda_utils import driver, handle_return
6565
66- _node_cache = weakref.WeakValueDictionary()
66+ _node_registry = weakref.WeakValueDictionary()
6767
6868
69- cdef inline GraphNode _cached (GraphNode n):
70- _node_cache [< uintptr_t> n._h_node.get()] = n
69+ cdef inline GraphNode _registered (GraphNode n):
70+ _node_registry [< uintptr_t> n._h_node.get()] = n
7171 return n
7272
7373
@@ -153,8 +153,8 @@ cdef class GraphNode:
153153 return
154154 with nogil:
155155 HANDLE_RETURN(cydriver.cuGraphDestroyNode(node))
156- _node_cache .pop(< uintptr_t> self ._h_node.get(), None )
157- invalidate_graph_node_handle (self ._h_node)
156+ _node_registry .pop(< uintptr_t> self ._h_node.get(), None )
157+ invalidate_graph_node (self ._h_node)
158158
159159 @property
160160 def pred (self ):
@@ -532,8 +532,7 @@ cdef inline ConditionalNode _make_conditional_node(
532532 n._cond_type = cond_type
533533 n._branches = branches
534534
535- return _cached(n)
536-
535+ return _registered(n)
537536
538537cdef inline GraphNode GN_create(GraphHandle h_graph, cydriver.CUgraphNode node):
539538 cdef GraphNodeHandle h_node = create_graph_node_handle(node, h_graph)
@@ -544,12 +543,12 @@ cdef inline GraphNode GN_create(GraphHandle h_graph, cydriver.CUgraphNode node):
544543 (< GraphNode> n)._h_node = h_node
545544 return n
546545
547- # Return a cached object or create and cache a new one.
548- cached = _node_cache .get(< uintptr_t> h_node.get())
549- if cached is not None :
550- return < GraphNode> cached
546+ # Return a registered object or create and register a new one.
547+ registered = _node_registry .get(< uintptr_t> h_node.get())
548+ if registered is not None :
549+ return < GraphNode> registered
551550 else :
552- return _cached (GN_create_impl(h_node))
551+ return _registered (GN_create_impl(h_node))
553552
554553
555554cdef inline GraphNode GN_create_impl(GraphNodeHandle h_node):
@@ -617,7 +616,7 @@ cdef inline KernelNode GN_launch(GraphNode self, LaunchConfig conf, Kernel ker,
617616 _attach_user_object(as_cu(h_graph), < void * > new KernelHandle(ker._h_kernel),
618617 < cydriver.CUhostFn> _destroy_kernel_handle_copy)
619618
620- return _cached (KernelNode._create_with_params(
619+ return _registered (KernelNode._create_with_params(
621620 create_graph_node_handle(new_node, h_graph),
622621 conf.grid, conf.block, conf.shmem_size,
623622 ker._h_kernel))
@@ -646,7 +645,7 @@ cdef inline EmptyNode GN_join(GraphNode self, tuple nodes):
646645 HANDLE_RETURN(cydriver.cuGraphAddEmptyNode(
647646 & new_node, as_cu(h_graph), deps_ptr, num_deps))
648647
649- return _cached (EmptyNode._create_impl(create_graph_node_handle(new_node, h_graph)))
648+ return _registered (EmptyNode._create_impl(create_graph_node_handle(new_node, h_graph)))
650649
651650
652651cdef inline AllocNode GN_alloc(GraphNode self , size_t size, object options):
@@ -722,7 +721,7 @@ cdef inline AllocNode GN_alloc(GraphNode self, size_t size, object options):
722721 HANDLE_RETURN(cydriver.cuGraphAddMemAllocNode(
723722 & new_node, as_cu(h_graph), deps, num_deps, & alloc_params))
724723
725- return _cached (AllocNode._create_with_params(
724+ return _registered (AllocNode._create_with_params(
726725 create_graph_node_handle(new_node, h_graph), alloc_params.dptr, size,
727726 device_id, memory_type, tuple (peer_ids)))
728727
@@ -742,7 +741,7 @@ cdef inline FreeNode GN_free(GraphNode self, cydriver.CUdeviceptr c_dptr):
742741 HANDLE_RETURN(cydriver.cuGraphAddMemFreeNode(
743742 & new_node, as_cu(h_graph), deps, num_deps, c_dptr))
744743
745- return _cached (FreeNode._create_with_params(create_graph_node_handle(new_node, h_graph), c_dptr))
744+ return _registered (FreeNode._create_with_params(create_graph_node_handle(new_node, h_graph), c_dptr))
746745
747746
748747cdef inline MemsetNode GN_memset(
@@ -777,7 +776,7 @@ cdef inline MemsetNode GN_memset(
777776 & new_node, as_cu(h_graph), deps, num_deps,
778777 & memset_params, ctx))
779778
780- return _cached (MemsetNode._create_with_params(
779+ return _registered (MemsetNode._create_with_params(
781780 create_graph_node_handle(new_node, h_graph), c_dst,
782781 val, elem_size, width, height, pitch))
783782
@@ -838,7 +837,7 @@ cdef inline MemcpyNode GN_memcpy(
838837 HANDLE_RETURN(cydriver.cuGraphAddMemcpyNode(
839838 & new_node, as_cu(h_graph), deps, num_deps, & params, ctx))
840839
841- return _cached (MemcpyNode._create_with_params(
840+ return _registered (MemcpyNode._create_with_params(
842841 create_graph_node_handle(new_node, h_graph), c_dst, c_src, size,
843842 c_dst_type, c_src_type))
844843
@@ -865,7 +864,7 @@ cdef inline ChildGraphNode GN_embed(GraphNode self, GraphDef child_def):
865864
866865 cdef GraphHandle h_embedded = create_graph_handle_ref(embedded_graph, h_graph)
867866
868- return _cached (ChildGraphNode._create_with_params(
867+ return _registered (ChildGraphNode._create_with_params(
869868 create_graph_node_handle(new_node, h_graph), h_embedded))
870869
871870
@@ -887,7 +886,7 @@ cdef inline EventRecordNode GN_record_event(GraphNode self, Event ev):
887886 _attach_user_object(as_cu(h_graph), < void * > new EventHandle(ev._h_event),
888887 < cydriver.CUhostFn> _destroy_event_handle_copy)
889888
890- return _cached (EventRecordNode._create_with_params(
889+ return _registered (EventRecordNode._create_with_params(
891890 create_graph_node_handle(new_node, h_graph), ev._h_event))
892891
893892
@@ -909,7 +908,7 @@ cdef inline EventWaitNode GN_wait_event(GraphNode self, Event ev):
909908 _attach_user_object(as_cu(h_graph), < void * > new EventHandle(ev._h_event),
910909 < cydriver.CUhostFn> _destroy_event_handle_copy)
911910
912- return _cached (EventWaitNode._create_with_params(
911+ return _registered (EventWaitNode._create_with_params(
913912 create_graph_node_handle(new_node, h_graph), ev._h_event))
914913
915914
@@ -936,6 +935,6 @@ cdef inline HostCallbackNode GN_callback(GraphNode self, object fn, object user_
936935 & new_node, as_cu(h_graph), deps, num_deps, & node_params))
937936
938937 cdef object callable_obj = fn if not isinstance (fn, ct._CFuncPtr) else None
939- return _cached (HostCallbackNode._create_with_params(
938+ return _registered (HostCallbackNode._create_with_params(
940939 create_graph_node_handle(new_node, h_graph), callable_obj,
941940 node_params.fn, node_params.userData))
0 commit comments