Skip to content

Commit 28fa5bd

Browse files
author
Deepak Raj H R
authored
[SYCLomatic] Add migration support for cuStreamGetCtx (#2624)
1 parent 9dfc681 commit 28fa5bd

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

clang/lib/DPCT/RulesLang/APINamesStream.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ ASSIGNABLE_FACTORY(HEADER_INSERT_FACTORY(
3131
MEMBER_CALL(ARG(0), true, "wait"),
3232
CALL(ARG(1), ARG(0), ARG("0"), ARG(2)))))))
3333

34+
ASSIGNABLE_FACTORY(FEATURE_REQUEST_FACTORY(
35+
HelperFeatureEnum::device_ext,
36+
ASSIGN_FACTORY_ENTRY("cuStreamGetCtx", DEREF(1),
37+
CALL(MapNames::getDpctNamespace() + "get_device_id",
38+
MEMBER_CALL(ARG(0), true, "get_device")))))
39+
3440
ASSIGNABLE_FACTORY(CONDITIONAL_FACTORY_ENTRY(
3541
UseExtGraph,
3642
CALL_FACTORY_ENTRY("cudaStreamBeginCapture",

clang/lib/DPCT/RulesLang/RulesLang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4178,7 +4178,7 @@ void StreamAPICallRule::registerMatcher(MatchFinder &MF) {
41784178
"cudaStreamIsCapturing", "cudaStreamQuery", "cudaStreamWaitEvent",
41794179
"cudaStreamAddCallback", "cuStreamCreate", "cuStreamSynchronize",
41804180
"cuStreamWaitEvent", "cuStreamDestroy_v2", "cuStreamAttachMemAsync",
4181-
"cuStreamAddCallback", "cuStreamQuery");
4181+
"cuStreamAddCallback", "cuStreamQuery", "cuStreamGetCtx");
41824182
};
41834183

41844184
MF.addMatcher(

clang/lib/DPCT/SrcAPI/APINames.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ ENTRY(cuStreamEndCapture, cuStreamEndCapture, false, NO_FLAG, P4, "comment")
17831783
ENTRY(cuStreamGetAttribute, cuStreamGetAttribute, false, NO_FLAG, P7, "comment")
17841784
ENTRY(cuStreamGetCaptureInfo, cuStreamGetCaptureInfo_v2, false, NO_FLAG, P7, "comment")
17851785
ENTRY(cuStreamGetCaptureInfo_v3, cuStreamGetCaptureInfo_v3, false, NO_FLAG, P7, "comment")
1786-
ENTRY(cuStreamGetCtx, cuStreamGetCtx, false, NO_FLAG, P4, "comment")
1786+
ENTRY(cuStreamGetCtx, cuStreamGetCtx, true, NO_FLAG, P4, "Successful")
17871787
ENTRY(cuStreamGetCtx_v2, cuStreamGetCtx_v2, false, NO_FLAG, P4, "comment")
17881788
ENTRY(cuStreamGetFlags, cuStreamGetFlags, false, NO_FLAG, P4, "comment")
17891789
ENTRY(cuStreamGetId, cuStreamGetId, false, NO_FLAG, P4, "comment")

clang/test/dpct/driver-stream-and-event.cu

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,9 @@ unsigned getEventFlags(bool enabledSyncBlock) {
183183

184184
return flags;
185185
}
186+
187+
// CHECK: void test_stream_and_context(dpct::queue_ptr stream, int &context) {
188+
void test_stream_and_context(CUstream stream, CUcontext& context) {
189+
// CHECK: context = dpct::get_device_id(stream->get_device());
190+
cuStreamGetCtx(stream, &context);
191+
}

0 commit comments

Comments
 (0)