Skip to content

Commit 39d99cf

Browse files
committed
small optimization
1 parent 07647a1 commit 39d99cf

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

source/loader/layers/sanitizer/msan/msan_ddi.cpp

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,9 +1307,9 @@ ur_result_t UR_APICALL urEnqueueUSMFill(
13071307
auto pfnUSMFill = getContext()->urDdiTable.Enqueue.pfnUSMFill;
13081308
getContext()->logger.debug("==== urEnqueueUSMFill");
13091309

1310-
ur_event_handle_t hEvent = nullptr;
1310+
ur_event_handle_t hEvents[2] = {};
13111311
UR_CALL(pfnUSMFill(hQueue, pMem, patternSize, pPattern, size,
1312-
numEventsInWaitList, phEventWaitList, &hEvent));
1312+
numEventsInWaitList, phEventWaitList, &hEvents[0]));
13131313

13141314
const auto Mem = (uptr)pMem;
13151315
auto MemInfoItOp = getMsanInterceptor()->findAllocInfoByAddress(Mem);
@@ -1320,13 +1320,13 @@ ur_result_t UR_APICALL urEnqueueUSMFill(
13201320
getMsanInterceptor()->getDeviceInfo(MemInfo->Device);
13211321
const auto MemShadow = DeviceInfo->Shadow->MemToShadow(Mem);
13221322

1323-
const ur_event_handle_t hEventWait = hEvent;
1324-
UR_CALL(EnqueueUSMBlockingSet(hQueue, (void *)MemShadow, 0, size, 1,
1325-
&hEventWait, &hEvent));
1323+
UR_CALL(EnqueueUSMBlockingSet(hQueue, (void *)MemShadow, 0, size, 0,
1324+
nullptr, &hEvents[1]));
13261325
}
13271326

13281327
if (phEvent) {
1329-
*phEvent = hEvent;
1328+
UR_CALL(getContext()->urDdiTable.Enqueue.pfnEventsWait(
1329+
hQueue, 2, hEvents, phEvent));
13301330
}
13311331

13321332
return UR_RESULT_SUCCESS;
@@ -1356,9 +1356,9 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy(
13561356
auto pfnUSMMemcpy = getContext()->urDdiTable.Enqueue.pfnUSMMemcpy;
13571357
getContext()->logger.debug("==== pfnUSMMemcpy");
13581358

1359-
ur_event_handle_t hEvent = nullptr;
1359+
ur_event_handle_t hEvents[2] = {};
13601360
UR_CALL(pfnUSMMemcpy(hQueue, blocking, pDst, pSrc, size,
1361-
numEventsInWaitList, phEventWaitList, &hEvent));
1361+
numEventsInWaitList, phEventWaitList, &hEvents[0]));
13621362

13631363
const auto Src = (uptr)pSrc, Dst = (uptr)pDst;
13641364
auto SrcInfoItOp = getMsanInterceptor()->findAllocInfoByAddress(Src);
@@ -1373,23 +1373,22 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy(
13731373
const auto SrcShadow = DeviceInfo->Shadow->MemToShadow(Src);
13741374
const auto DstShadow = DeviceInfo->Shadow->MemToShadow(Dst);
13751375

1376-
const ur_event_handle_t hEventWait = hEvent;
13771376
UR_CALL(pfnUSMMemcpy(hQueue, blocking, (void *)DstShadow,
1378-
(void *)SrcShadow, size, 1, &hEventWait, &hEvent));
1377+
(void *)SrcShadow, size, 0, nullptr, &hEvents[1]));
13791378
} else if (DstInfoItOp) {
13801379
auto DstInfo = (*DstInfoItOp)->second;
13811380

13821381
const auto &DeviceInfo =
13831382
getMsanInterceptor()->getDeviceInfo(DstInfo->Device);
13841383
auto DstShadow = DeviceInfo->Shadow->MemToShadow(Dst);
13851384

1386-
const ur_event_handle_t hEventWait = hEvent;
1387-
UR_CALL(EnqueueUSMBlockingSet(hQueue, (void *)DstShadow, 0, size, 1,
1388-
&hEventWait, &hEvent));
1385+
UR_CALL(EnqueueUSMBlockingSet(hQueue, (void *)DstShadow, 0, size, 0,
1386+
nullptr, &hEvents[1]));
13891387
}
13901388

13911389
if (phEvent) {
1392-
*phEvent = hEvent;
1390+
UR_CALL(getContext()->urDdiTable.Enqueue.pfnEventsWait(
1391+
hQueue, 2, hEvents, phEvent));
13931392
}
13941393

13951394
return UR_RESULT_SUCCESS;
@@ -1425,10 +1424,10 @@ ur_result_t UR_APICALL urEnqueueUSMFill2D(
14251424
auto pfnUSMFill2D = getContext()->urDdiTable.Enqueue.pfnUSMFill2D;
14261425
getContext()->logger.debug("==== urEnqueueUSMFill2D");
14271426

1428-
ur_event_handle_t hEvent = nullptr;
1427+
ur_event_handle_t hEvents[2] = {};
14291428
UR_CALL(pfnUSMFill2D(hQueue, pMem, pitch, patternSize, pPattern, width,
14301429
height, numEventsInWaitList, phEventWaitList,
1431-
&hEvent));
1430+
&hEvents[0]));
14321431

14331432
const auto Mem = (uptr)pMem;
14341433
auto MemInfoItOp = getMsanInterceptor()->findAllocInfoByAddress(Mem);
@@ -1440,13 +1439,13 @@ ur_result_t UR_APICALL urEnqueueUSMFill2D(
14401439
const auto MemShadow = DeviceInfo->Shadow->MemToShadow(Mem);
14411440

14421441
const char Pattern = 0;
1443-
const ur_event_handle_t hEventWait = hEvent;
14441442
UR_CALL(pfnUSMFill2D(hQueue, (void *)MemShadow, pitch, 1, &Pattern,
1445-
width, height, 1, &hEventWait, &hEvent));
1443+
width, height, 0, nullptr, &hEvents[1]));
14461444
}
14471445

14481446
if (phEvent) {
1449-
*phEvent = hEvent;
1447+
UR_CALL(getContext()->urDdiTable.Enqueue.pfnEventsWait(
1448+
hQueue, 2, hEvents, phEvent));
14501449
}
14511450

14521451
return UR_RESULT_SUCCESS;
@@ -1481,10 +1480,10 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
14811480
auto pfnUSMMemcpy2D = getContext()->urDdiTable.Enqueue.pfnUSMMemcpy2D;
14821481
getContext()->logger.debug("==== pfnUSMMemcpy2D");
14831482

1484-
ur_event_handle_t hEvent = nullptr;
1483+
ur_event_handle_t hEvents[2] = {};
14851484
UR_CALL(pfnUSMMemcpy2D(hQueue, blocking, pDst, dstPitch, pSrc, srcPitch,
14861485
width, height, numEventsInWaitList, phEventWaitList,
1487-
&hEvent));
1486+
&hEvents[0]));
14881487

14891488
const auto Src = (uptr)pSrc, Dst = (uptr)pDst;
14901489
auto SrcInfoItOp = getMsanInterceptor()->findAllocInfoByAddress(Src);
@@ -1499,10 +1498,9 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
14991498
const auto SrcShadow = DeviceInfo->Shadow->MemToShadow(Src);
15001499
const auto DstShadow = DeviceInfo->Shadow->MemToShadow(Dst);
15011500

1502-
const ur_event_handle_t hEventWait = hEvent;
15031501
UR_CALL(pfnUSMMemcpy2D(hQueue, blocking, (void *)DstShadow, dstPitch,
1504-
(void *)SrcShadow, srcPitch, width, height, 1,
1505-
&hEventWait, &hEvent));
1502+
(void *)SrcShadow, srcPitch, width, height, 0,
1503+
nullptr, &hEvents[1]));
15061504
} else if (DstInfoItOp) {
15071505
auto DstInfo = (*DstInfoItOp)->second;
15081506

@@ -1511,14 +1509,14 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
15111509
const auto DstShadow = DeviceInfo->Shadow->MemToShadow(Dst);
15121510

15131511
const char Pattern = 0;
1514-
const ur_event_handle_t hEventWait = hEvent;
15151512
UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMFill2D(
1516-
hQueue, (void *)DstShadow, dstPitch, 1, &Pattern, width, height, 1,
1517-
&hEventWait, &hEvent));
1513+
hQueue, (void *)DstShadow, dstPitch, 1, &Pattern, width, height, 0,
1514+
nullptr, &hEvents[1]));
15181515
}
15191516

15201517
if (phEvent) {
1521-
*phEvent = hEvent;
1518+
UR_CALL(getContext()->urDdiTable.Enqueue.pfnEventsWait(
1519+
hQueue, 2, hEvents, phEvent));
15221520
}
15231521

15241522
return UR_RESULT_SUCCESS;

0 commit comments

Comments
 (0)