@@ -3226,9 +3226,7 @@ void EventAPICallRule::handleEventRecordWithProfilingEnabled(
3226
3226
const CallExpr *CE, const MatchFinder::MatchResult &Result,
3227
3227
bool IsAssigned) {
3228
3228
int NumArgs = CE->getNumArgs ();
3229
- const Expr *StreamArg = CE->getArg (NumArgs - 1 );
3230
3229
if (NumArgs == 3 ) { // Special process for cudaEventRecordWithFlags().
3231
- StreamArg = CE->getArg (1 );
3232
3230
auto APIName = CE->getDirectCallee ()->getNameInfo ().getName ().getAsString ();
3233
3231
const Expr *SecArg = CE->getArg (2 );
3234
3232
ExprAnalysis Arg2EA (SecArg);
@@ -3241,195 +3239,32 @@ void EventAPICallRule::handleEventRecordWithProfilingEnabled(
3241
3239
emplaceTransformation (removeArg (CE, 2 , *Result.SourceManager ));
3242
3240
}
3243
3241
3244
- auto EventArg = CE->getArg (0 );
3245
- ExprAnalysis StreamEA (StreamArg);
3246
- ExprAnalysis Arg0EA (EventArg);
3247
- auto StreamName = StreamEA.getReplacedString ();
3248
- auto ArgName = Arg0EA.getReplacedString ();
3249
- bool IsDefaultStream = isDefaultStream (StreamArg);
3250
3242
auto IndentLoc = CE->getBeginLoc ();
3251
3243
auto &SM = DpctGlobalInfo::getSourceManager ();
3252
3244
3253
- if (needExtraParens (EventArg)) {
3254
- ArgName = " (" + ArgName + " )" ;
3255
- }
3256
-
3257
- if (needExtraParensInMemberExpr (StreamArg)) {
3258
- StreamName = " (" + StreamName + " )" ;
3259
- }
3260
-
3261
3245
if (IndentLoc.isMacroID ())
3262
3246
IndentLoc = SM.getExpansionLoc (IndentLoc);
3263
3247
3264
- if (IsAssigned) {
3265
-
3266
- std::string StmtStr;
3267
- if (IsDefaultStream) {
3268
- if (isPlaceholderIdxDuplicated (CE))
3269
- return ;
3270
- int Index = DpctGlobalInfo::getHelperFuncReplInfoIndexThenInc ();
3271
- buildTempVariableMap (Index, CE, HelperFuncType::HFT_DefaultQueue);
3272
- std::string Str;
3273
- if (!DpctGlobalInfo::useEnqueueBarrier ()) {
3274
- // ext_oneapi_submit_barrier is specified in the value of option
3275
- // --no-dpcpp-extensions.
3276
- if (DpctGlobalInfo::getUsmLevel () == UsmLevel::UL_None) {
3277
-
3278
- Str = MapNames::getDpctNamespace () +
3279
- " get_current_device().queues_wait_and_throw();" ;
3280
- Str += getNL ();
3281
- Str += getIndent (IndentLoc, SM).str ();
3282
- std::string SubStr = " {{NEEDREPLACEQ" + std::to_string (Index) +
3283
- " }}.single_task([=](){});" ;
3284
- SubStr = " *" + ArgName + " = " + SubStr;
3285
- Str += SubStr;
3286
-
3287
- Str += getNL ();
3288
- Str += getIndent (IndentLoc, SM).str ();
3289
- Str += MapNames::getDpctNamespace () +
3290
- " get_current_device().queues_wait_and_throw();" ;
3291
- Str += getNL ();
3292
- Str += getIndent (IndentLoc, SM).str ();
3293
- Str += " return 0;" ;
3294
-
3295
- Str = " [&](){" + Str + " }()" ;
3296
- emplaceTransformation (new ReplaceStmt (CE, std::move (Str)));
3297
- return ;
3298
- }
3299
- Str = " {{NEEDREPLACEQ" + std::to_string (Index) +
3300
- " }}.single_task([=](){})" ;
3301
-
3302
- } else {
3303
- if (DpctGlobalInfo::useSYCLCompat ()) {
3304
- report (CE->getBeginLoc (), Diagnostics::UNSUPPORT_SYCLCOMPAT, false ,
3305
- " cudaEventRecord" );
3306
- return ;
3307
- }
3308
- std::string ReplaceStr;
3309
- ReplaceStr = MapNames::getDpctNamespace () + " sync_barrier" ;
3310
- emplaceTransformation (new ReplaceCalleeName (CE, std::move (ReplaceStr)));
3311
- emplaceTransformation (new InsertBeforeStmt (CE, MapNames::getCheckErrorMacroName () + " (" ));
3312
- emplaceTransformation (new InsertAfterStmt (CE, " )" ));
3313
- report (CE->getBeginLoc (), Diagnostics::NOERROR_RETURN_ZERO, false );
3314
- return ;
3315
- }
3316
- StmtStr = " *" + ArgName + " = " + Str;
3317
- } else {
3318
- std::string Str;
3319
- if (!DpctGlobalInfo::useEnqueueBarrier ()) {
3320
- // ext_oneapi_submit_barrier is specified in the value of option
3321
- // --no-dpcpp-extensions.
3322
-
3323
- if (DpctGlobalInfo::getUsmLevel () == UsmLevel::UL_None) {
3324
-
3325
- Str = MapNames::getDpctNamespace () +
3326
- " get_current_device().queues_wait_and_throw();" ;
3327
- Str += getNL ();
3328
- Str += getIndent (IndentLoc, SM).str ();
3329
- Str += StreamName + " ->" + " single_task([=](){});" ;
3330
- Str += getNL ();
3331
- Str += getIndent (IndentLoc, SM).str ();
3332
- Str += MapNames::getDpctNamespace () +
3333
- " get_current_device().queues_wait_and_throw(); return 0;" ;
3334
-
3335
- Str = " [&](){" + Str + " }()" ;
3336
- emplaceTransformation (new ReplaceStmt (CE, std::move (Str)));
3337
- return ;
3338
- }
3339
- Str = StreamName + " ->" + " single_task([=](){})" ;
3340
-
3341
- } else {
3342
- Str = StreamName + " ->" + " ext_oneapi_submit_barrier()" ;
3343
- }
3344
- StmtStr = " *" + ArgName + " = " + Str;
3345
- }
3346
- StmtStr = MapNames::getCheckErrorMacroName () + " (" + StmtStr + " )" ;
3248
+ if (isPlaceholderIdxDuplicated (CE))
3249
+ return ;
3250
+ int Index = DpctGlobalInfo::getHelperFuncReplInfoIndexThenInc ();
3251
+ buildTempVariableMap (Index, CE, HelperFuncType::HFT_DefaultQueue);
3347
3252
3348
- emplaceTransformation (new ReplaceStmt (CE, std::move (StmtStr)));
3253
+ if (DpctGlobalInfo::useSYCLCompat ()) {
3254
+ report (CE->getBeginLoc (), Diagnostics::UNSUPPORT_SYCLCOMPAT, false ,
3255
+ " cudaEventRecord" );
3256
+ return ;
3257
+ }
3258
+ std::string ReplaceStr;
3259
+ ReplaceStr = MapNames::getDpctNamespace () + " sync_barrier" ;
3260
+ emplaceTransformation (new ReplaceCalleeName (CE, std::move (ReplaceStr)));
3349
3261
3262
+ if (IsAssigned) {
3263
+ emplaceTransformation (
3264
+ new InsertBeforeStmt (CE, MapNames::getCheckErrorMacroName () + " (" ));
3265
+ emplaceTransformation (new InsertAfterStmt (CE, " )" ));
3350
3266
report (CE->getBeginLoc (), Diagnostics::NOERROR_RETURN_ZERO, false );
3351
-
3352
- } else {
3353
- std::string ReplStr;
3354
- if (IsDefaultStream) {
3355
- if (isPlaceholderIdxDuplicated (CE))
3356
- return ;
3357
- int Index = DpctGlobalInfo::getHelperFuncReplInfoIndexThenInc ();
3358
- buildTempVariableMap (Index, CE, HelperFuncType::HFT_DefaultQueue);
3359
- std::string Str;
3360
- if (!DpctGlobalInfo::useEnqueueBarrier ()) {
3361
- // ext_oneapi_submit_barrier is specified in the value of option
3362
- // --no-dpcpp-extensions.
3363
-
3364
- if (DpctGlobalInfo::getUsmLevel () == UsmLevel::UL_None) {
3365
-
3366
- Str = MapNames::getDpctNamespace () +
3367
- " get_current_device().queues_wait_and_throw();" ;
3368
- Str += getNL ();
3369
- Str += getIndent (IndentLoc, SM).str ();
3370
- Str += " *" + ArgName + " = {{NEEDREPLACEQ" + std::to_string (Index) +
3371
- " }}.single_task([=](){});" ;
3372
- Str += getNL ();
3373
- Str += getIndent (IndentLoc, SM).str ();
3374
- Str += MapNames::getDpctNamespace () +
3375
- " get_current_device().queues_wait_and_throw()" ;
3376
-
3377
- } else {
3378
- Str = " *" + ArgName + " = {{NEEDREPLACEQ" + std::to_string (Index) +
3379
- " }}.single_task([=](){})" ;
3380
- }
3381
-
3382
- } else {
3383
- if (DpctGlobalInfo::useSYCLCompat ()) {
3384
- report (CE->getBeginLoc (), Diagnostics::UNSUPPORT_SYCLCOMPAT, false ,
3385
- " cudaEventRecord" );
3386
- return ;
3387
- }
3388
- std::string ReplaceStr;
3389
- ReplaceStr = MapNames::getDpctNamespace () + " sync_barrier" ;
3390
- emplaceTransformation (new ReplaceCalleeName (CE, std::move (ReplaceStr)));
3391
- return ;
3392
- }
3393
- ReplStr += Str;
3394
- } else {
3395
-
3396
- std::string Str;
3397
- if (!DpctGlobalInfo::useEnqueueBarrier ()) {
3398
- // ext_oneapi_submit_barrier is specified in the value of option
3399
- // --no-dpcpp-extensions.
3400
-
3401
- if (DpctGlobalInfo::getUsmLevel () == UsmLevel::UL_None) {
3402
-
3403
- Str = MapNames::getDpctNamespace () +
3404
- " get_current_device().queues_wait_and_throw();" ;
3405
- Str += getNL ();
3406
- Str += getIndent (IndentLoc, SM).str ();
3407
-
3408
- Str += " *" + ArgName + " = " + StreamName + " ->single_task([=](){});" ;
3409
- Str += getNL ();
3410
- Str += getIndent (IndentLoc, SM).str ();
3411
- Str += MapNames::getDpctNamespace () +
3412
- " get_current_device().queues_wait_and_throw()" ;
3413
-
3414
- } else {
3415
- Str = " *" + ArgName + " = " + StreamName + " ->single_task([=](){})" ;
3416
- }
3417
-
3418
- } else {
3419
- if (DpctGlobalInfo::useSYCLCompat ()) {
3420
- report (CE->getBeginLoc (), Diagnostics::UNSUPPORT_SYCLCOMPAT, false ,
3421
- " cudaEventRecord" );
3422
- return ;
3423
- }
3424
- std::string ReplaceStr;
3425
- ReplaceStr = MapNames::getDpctNamespace () + " sync_barrier" ;
3426
- emplaceTransformation (new ReplaceCalleeName (CE, std::move (ReplaceStr)));
3427
- return ;
3428
- }
3429
- ReplStr += Str;
3430
- }
3431
-
3432
- emplaceTransformation (new ReplaceStmt (CE, std::move (ReplStr)));
3267
+ return ;
3433
3268
}
3434
3269
}
3435
3270
0 commit comments