Skip to content

Commit 06a1a7e

Browse files
committed
[SYCLomatic] Add query-api-mapping for 1 runtime API cudaEventRecordWithFlags
Signed-off-by: chenwei.sun <chenwei.sun@intel.com>
1 parent ff03b4a commit 06a1a7e

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void test(cudaEvent_t event, cudaStream_t stream) {
2+
// Start
3+
cudaEventRecordWithFlags(event /*cudaEvent_t*/, stream /*cudaStream_t*/,
4+
cudaEventRecordDefault /*unsigned int*/);
5+
// End
6+
}

clang/lib/DPCT/RulesLang/RulesLang.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3276,6 +3276,19 @@ void EventAPICallRule::handleEventRecordWithProfilingDisabled(
32763276
static std::set<std::pair<const Decl *, std::string>> DeclDupFilter;
32773277
auto &SM = DpctGlobalInfo::getSourceManager();
32783278

3279+
int NumArgs = CE->getNumArgs();
3280+
if (NumArgs == 3) { // Special process for cudaEventRecordWithFlags().
3281+
auto APIName = CE->getDirectCallee()->getNameInfo().getName().getAsString();
3282+
const Expr *SecArg = CE->getArg(2);
3283+
ExprAnalysis Arg2EA(SecArg);
3284+
auto Arg2Name = Arg2EA.getReplacedString();
3285+
if (Arg2Name != "cudaEventRecordDefault") {
3286+
report(CE->getBeginLoc(), Diagnostics::NOT_SUPPORTED_PARAMETER, false,
3287+
APIName, "parameter " + Arg2Name + " is unsupported");
3288+
return;
3289+
}
3290+
}
3291+
32793292
const ValueDecl *MD = nullptr;
32803293
if ((MD = getDecl(CE->getArg(0))) == nullptr)
32813294
return;

clang/test/dpct/query_api_mapping/Runtime/test.cu

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,11 @@
519519
// CUDARUNTIMEGETVERSION-NEXT: cudaRuntimeGetVersion(pi /*int **/);
520520
// CUDARUNTIMEGETVERSION-NEXT: Is migrated to:
521521
// CUDARUNTIMEGETVERSION-NEXT: *pi = dpct::get_major_version(dpct::get_current_device());
522+
523+
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaEventRecordWithFlags | FileCheck %s -check-prefix=cudaEventRecordWithFlags
524+
// cudaEventRecordWithFlags: CUDA API:
525+
// cudaEventRecordWithFlags-NEXT: cudaEventRecordWithFlags(event /*cudaEvent_t*/, stream /*cudaStream_t*/,
526+
// cudaEventRecordWithFlags-NEXT: cudaEventRecordDefault /*unsigned int*/);
527+
// cudaEventRecordWithFlags-NEXT: Is migrated to:
528+
// cudaEventRecordWithFlags-NEXT: *event = dpct::get_in_order_queue().ext_oneapi_submit_barrier();
529+

clang/test/dpct/query_api_mapping/test_all.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@
14461446
// CHECK-NEXT: cudaEventElapsedTime
14471447
// CHECK-NEXT: cudaEventQuery
14481448
// CHECK-NEXT: cudaEventRecord
1449+
// CHECK-NEXT: cudaEventRecordWithFlags
14491450
// CHECK-NEXT: cudaEventSynchronize
14501451
// CHECK-NEXT: cudaExternalMemoryGetMappedBuffer
14511452
// CHECK-NEXT: cudaExternalMemoryGetMappedMipmappedArray

0 commit comments

Comments
 (0)