Skip to content

Commit a92bfbe

Browse files
author
Deepak Raj H R
authored
[SYCLomatic] Add migration support for CUstreamCallback type (#2614)
1 parent 35d7d33 commit a92bfbe

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

clang/lib/DPCT/RuleInfra/MapNames.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ void MapNames::setExplicitNamespaceMap(
343343
HelperFeatureEnum::device_ext)},
344344
{"CUstream_st",
345345
std::make_shared<TypeNameRule>(getClNamespace() + "queue")},
346+
{"CUstreamCallback",
347+
std::make_shared<TypeNameRule>(getDpctNamespace() + "queue_callback",
348+
HelperFeatureEnum::device_ext)},
346349
{"char1", std::make_shared<TypeNameRule>("int8_t")},
347350
{"char2", std::make_shared<TypeNameRule>(getClNamespace() + "char2")},
348351
{"char3", std::make_shared<TypeNameRule>(getClNamespace() + "char3")},

clang/lib/DPCT/RulesLang/RulesLang.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ void TypeInDeclRule::registerMatcher(MatchFinder &MF) {
345345
"cublasLtEpilogue_t", "cublasLtMatmulPreference_t",
346346
"cublasLtMatmulHeuristicResult_t", "CUjit_target",
347347
"cublasLtMatrixTransformDesc_t", "cudaGraphicsMapFlags",
348-
"cudaGraphicsRegisterFlags", "cudaExternalMemoryHandleType"))))))
348+
"cudaGraphicsRegisterFlags", "cudaExternalMemoryHandleType",
349+
"CUstreamCallback"))))))
349350
.bind("cudaTypeDef"),
350351
this);
351352

clang/runtime/dpct-rt/include/dpct/device.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <array>
1414
#include <climits>
1515
#include <cstring>
16+
#include <functional>
1617
#include <iostream>
1718
#include <map>
1819
#include <mutex>
@@ -84,6 +85,8 @@ typedef sycl::queue *queue_ptr;
8485

8586
typedef char *device_ptr;
8687

88+
using queue_callback = std::function<void (queue_ptr, int, void*)>;
89+
8790
/// Destroy \p event pointed memory.
8891
///
8992
/// \param event Pointer to the sycl::event address.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ void test_stream() {
130130
// CHECK: int result = DPCT_CHECK_ERROR(std::async([&]() { hStream->wait(); callback<char>(hStream, 0, data); }));
131131
CUresult result = cuStreamAddCallback(hStream, callback<char>, data, flag);
132132

133+
// CHECK dpct::queue_callback cbptr = callback<char>;
134+
CUstreamCallback cbptr = callback<char>;
135+
// CHECK: std::async([&]() { hStream->wait(); cbptr(hStream, 0, data); });
136+
cuStreamAddCallback(hStream, cbptr, data, flag);
137+
133138
//CHECK: /*
134139
//CHECK-NEXT: DPCT1026:{{[0-9]+}}: The call to cuStreamAttachMemAsync was removed because SYCL currently does not support associating USM with a specific queue.
135140
//CHECK-NEXT: */

0 commit comments

Comments
 (0)