Skip to content

Commit

Permalink
Add support for cuStreamGetCtx
Browse files Browse the repository at this point in the history
  • Loading branch information
the-slow-one committed Jan 17, 2025
1 parent be925b2 commit f5dd74c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions clang/lib/DPCT/RulesLang/APINamesStream.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ ASSIGNABLE_FACTORY(HEADER_INSERT_FACTORY(
MEMBER_CALL(ARG(0), true, "wait"),
CALL(ARG(1), ARG(0), ARG("0"), ARG(2)))))))

ASSIGNABLE_FACTORY(FEATURE_REQUEST_FACTORY(
HelperFeatureEnum::device_ext,
ASSIGN_FACTORY_ENTRY("cuStreamGetCtx", DEREF(1),
CALL(MapNames::getDpctNamespace() + "get_device_id",
MEMBER_CALL(ARG(0), true, "get_device")))))

ASSIGNABLE_FACTORY(CONDITIONAL_FACTORY_ENTRY(
UseExtGraph,
CALL_FACTORY_ENTRY("cudaStreamBeginCapture",
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/DPCT/RulesLang/RulesLang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4178,7 +4178,7 @@ void StreamAPICallRule::registerMatcher(MatchFinder &MF) {
"cudaStreamIsCapturing", "cudaStreamQuery", "cudaStreamWaitEvent",
"cudaStreamAddCallback", "cuStreamCreate", "cuStreamSynchronize",
"cuStreamWaitEvent", "cuStreamDestroy_v2", "cuStreamAttachMemAsync",
"cuStreamAddCallback", "cuStreamQuery");
"cuStreamAddCallback", "cuStreamQuery", "cuStreamGetCtx");
};

MF.addMatcher(
Expand Down
6 changes: 6 additions & 0 deletions clang/test/dpct/driver-stream-and-event.cu
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,9 @@ unsigned getEventFlags(bool enabledSyncBlock) {

return flags;
}

// CHECK: void test_stream_and_context(dpct::queur_ptr stream, int& context);
void test_stream_and_context(CUstream stream, CUcontext& context) {
// CHECK: context = dpct::get_device_id(stream->get_device());
cuStreamGetCtx(stream, &context);
}

0 comments on commit f5dd74c

Please sign in to comment.