Skip to content

Expose an API to query the CUDA compute stream to launch a custom kernel#9141

Merged
hariharans29 merged 10 commits intomasterfrom
hari/cuda_stream_api
Nov 9, 2021
Merged

Expose an API to query the CUDA compute stream to launch a custom kernel#9141
hariharans29 merged 10 commits intomasterfrom
hari/cuda_stream_api

Conversation

@hariharans29
Copy link
Copy Markdown
Member

Description:

Description as title.

  • Particularly useful for the scenario where-in custom ops compiled into shared libraries need to achieve implicit synchronization with ORT's CUDA kernels

    • Also useful for the "regular" custom ops scenario where custom ops are not compiled into a shared library and directly registered used the APIs. But that had a work-around of creating a session with a user-created stream and just using that stream to launch custom kernels. This work-around is much harder to achieve when custom ops are compiled into shared libraries (See Update CUDA custom op unit tests to account for recent ORT change #6971)
  • Currently, we only have one compute stream per-session. So, this could be a session level API. But it is kept as an API at the OrtKernelContext level to keep the design flexible enough for the case where-in (in future) sessions could have multiple streams (one per host thread). When the sessions starts maintaining one stream per host thread, the API will start returning the stream corresponding to that thread.

Motivation and Context
#7068 (comment)

Comment thread include/onnxruntime/core/session/onnxruntime_cxx_api.h Outdated
Comment thread include/onnxruntime/core/session/onnxruntime_c_api.h
@minrui-hust
Copy link
Copy Markdown

amazing feature, I am just looking for it!

@wangyems
Copy link
Copy Markdown
Contributor

wangyems commented Oct 8, 2021

Working as expected on my end. Thanks Hari!

@wangyems wangyems self-requested a review October 8, 2021 18:10
wangyems
wangyems previously approved these changes Oct 8, 2021
Comment thread include/onnxruntime/core/session/onnxruntime_c_api.h Outdated
@hariharans29 hariharans29 merged commit 65590b0 into master Nov 9, 2021
@hariharans29 hariharans29 deleted the hari/cuda_stream_api branch November 9, 2021 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants