Skip to content

Commit 869760b

Browse files
committed
let as_cu supports CUModule
1 parent edb609d commit 869760b

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

cuda_core/cuda/core/_cpp/resource_handles.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,10 @@ inline CUlibrary as_cu(const LibraryHandle& h) noexcept {
754754
return h ? *h : nullptr;
755755
}
756756

757+
inline CUmodule as_cu(const CUmodule& h) noexcept {
758+
return h;
759+
}
760+
757761
inline CUkernel as_cu(const KernelHandle& h) noexcept {
758762
return h ? *h : nullptr;
759763
}
@@ -838,10 +842,8 @@ inline std::intptr_t as_intptr(const LibraryHandle& h) noexcept {
838842
return reinterpret_cast<std::intptr_t>(as_cu(h));
839843
}
840844

841-
// Regular pointer (CUmodule), not a shared_ptr: lifetime is owned by the
842-
// CUlibrary it was retrieved from.
843845
inline std::intptr_t as_intptr(const CUmodule& h) noexcept {
844-
return reinterpret_cast<std::intptr_t>(h);
846+
return reinterpret_cast<std::intptr_t>(as_cu(h));
845847
}
846848

847849
inline std::intptr_t as_intptr(const KernelHandle& h) noexcept {

cuda_core/cuda/core/_resource_handles.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ cdef extern from "_cpp/resource_handles.hpp" namespace "cuda_core":
8585
cydriver.CUmemoryPool as_cu(MemoryPoolHandle h) noexcept nogil
8686
cydriver.CUdeviceptr as_cu(DevicePtrHandle h) noexcept nogil
8787
cydriver.CUlibrary as_cu(LibraryHandle h) noexcept nogil
88+
cydriver.CUmodule as_cu(cydriver.CUmodule h) noexcept nogil
8889
cydriver.CUkernel as_cu(KernelHandle h) noexcept nogil
8990
cydriver.CUgraph as_cu(GraphHandle h) noexcept nogil
9091
cydriver.CUgraphExec as_cu(GraphExecHandle h) noexcept nogil

0 commit comments

Comments
 (0)