@@ -45,7 +45,6 @@ ur_result_t setupContext(ur_context_handle_t Context, uint32_t numDevices,
4545 UR_CALL (DI->allocShadowMemory (Context));
4646 }
4747 CI->DeviceList .emplace_back (hDevice);
48- CI->AllocInfosMap [hDevice];
4948 }
5049 return UR_RESULT_SUCCESS;
5150}
@@ -1306,23 +1305,25 @@ ur_result_t UR_APICALL urEnqueueUSMFill(
13061305 // /< must not refer to an element of the phEventWaitList array.
13071306) {
13081307 auto pfnUSMFill = getContext ()->urDdiTable .Enqueue .pfnUSMFill ;
1309-
13101308 getContext ()->logger .debug (" ==== urEnqueueUSMFill" );
13111309
1312- auto Mem = (uptr)pMem;
1310+ UR_CALL (pfnUSMFill (hQueue, pMem, patternSize, pPattern, size,
1311+ numEventsInWaitList, phEventWaitList, phEvent));
1312+
1313+ const auto Mem = (uptr)pMem;
13131314 auto MemInfoItOp = getMsanInterceptor ()->findAllocInfoByAddress (Mem);
13141315 if (MemInfoItOp) {
13151316 auto MemInfo = (*MemInfoItOp)->second ;
13161317
13171318 const auto &DeviceInfo =
13181319 getMsanInterceptor ()->getDeviceInfo (MemInfo->Device );
1319- UR_CALL (DeviceInfo->Shadow ->EnqueuePoisonShadow (
1320- hQueue, Mem, size, 0 , numEventsInWaitList, phEventWaitList,
1321- phEvent));
1320+ const auto MemShadow = DeviceInfo->Shadow ->MemToShadow (Mem);
1321+
1322+ UR_CALL (EnqueueUSMBlockingSet (hQueue, (void *)MemShadow, 0 , size, 1 ,
1323+ phEvent, phEvent));
13221324 }
13231325
1324- return pfnUSMFill (hQueue, pMem, patternSize, pPattern, size,
1325- numEventsInWaitList, phEventWaitList, phEvent);
1326+ return UR_RESULT_SUCCESS;
13261327}
13271328
13281329// /////////////////////////////////////////////////////////////////////////////
@@ -1349,7 +1350,10 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy(
13491350 auto pfnUSMMemcpy = getContext ()->urDdiTable .Enqueue .pfnUSMMemcpy ;
13501351 getContext ()->logger .debug (" ==== pfnUSMMemcpy" );
13511352
1352- auto Src = (uptr)pSrc, Dst = (uptr)pDst;
1353+ UR_CALL (pfnUSMMemcpy (hQueue, blocking, pDst, pSrc, size,
1354+ numEventsInWaitList, phEventWaitList, phEvent));
1355+
1356+ const auto Src = (uptr)pSrc, Dst = (uptr)pDst;
13531357 auto SrcInfoItOp = getMsanInterceptor ()->findAllocInfoByAddress (Src);
13541358 auto DstInfoItOp = getMsanInterceptor ()->findAllocInfoByAddress (Dst);
13551359
@@ -1359,21 +1363,23 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy(
13591363
13601364 const auto &DeviceInfo =
13611365 getMsanInterceptor ()->getDeviceInfo (SrcInfo->Device );
1362- UR_CALL (DeviceInfo->Shadow ->EnqueueCopyShadow (
1363- hQueue, blocking, Dst, Src, size, numEventsInWaitList,
1364- phEventWaitList, phEvent));
1366+ const auto SrcShadow = DeviceInfo->Shadow ->MemToShadow (Src);
1367+ const auto DstShadow = DeviceInfo->Shadow ->MemToShadow (Dst);
1368+
1369+ UR_CALL (pfnUSMMemcpy (hQueue, blocking, (void *)DstShadow,
1370+ (void *)SrcShadow, size, 1 , phEvent, phEvent));
13651371 } else if (DstInfoItOp) {
13661372 auto DstInfo = (*DstInfoItOp)->second ;
13671373
13681374 const auto &DeviceInfo =
13691375 getMsanInterceptor ()->getDeviceInfo (DstInfo->Device );
1370- UR_CALL (DeviceInfo->Shadow ->EnqueuePoisonShadow (
1371- hQueue, Dst, size, 0 , numEventsInWaitList, phEventWaitList,
1372- phEvent));
1376+ auto DstShadow = DeviceInfo->Shadow ->MemToShadow (Dst);
1377+
1378+ UR_CALL (EnqueueUSMBlockingSet (hQueue, (void *)DstShadow, 0 , size, 1 ,
1379+ phEvent, phEvent));
13731380 }
13741381
1375- return pfnUSMMemcpy (hQueue, blocking, pDst, pSrc, size, numEventsInWaitList,
1376- phEventWaitList, phEvent);
1382+ return UR_RESULT_SUCCESS;
13771383}
13781384
13791385// /////////////////////////////////////////////////////////////////////////////
@@ -1406,20 +1412,25 @@ ur_result_t UR_APICALL urEnqueueUSMFill2D(
14061412 auto pfnUSMFill2D = getContext ()->urDdiTable .Enqueue .pfnUSMFill2D ;
14071413 getContext ()->logger .debug (" ==== urEnqueueUSMFill2D" );
14081414
1409- auto Mem = (uptr)pMem;
1415+ UR_CALL (pfnUSMFill2D (hQueue, pMem, pitch, patternSize, pPattern, width,
1416+ height, numEventsInWaitList, phEventWaitList,
1417+ phEvent));
1418+
1419+ const auto Mem = (uptr)pMem;
14101420 auto MemInfoItOp = getMsanInterceptor ()->findAllocInfoByAddress (Mem);
14111421 if (MemInfoItOp) {
14121422 auto MemInfo = (*MemInfoItOp)->second ;
14131423
14141424 const auto &DeviceInfo =
14151425 getMsanInterceptor ()->getDeviceInfo (MemInfo->Device );
1416- UR_CALL (DeviceInfo->Shadow ->EnqueuePoisonShadow (
1417- hQueue, Mem, width * height, 0 , numEventsInWaitList,
1418- phEventWaitList, phEvent));
1426+ const auto MemShadow = DeviceInfo->Shadow ->MemToShadow (Mem);
1427+
1428+ const char Pattern = 0 ;
1429+ UR_CALL (pfnUSMFill2D (hQueue, (void *)MemShadow, pitch, 1 , &Pattern,
1430+ width, height, 1 , phEvent, phEvent));
14191431 }
14201432
1421- return pfnUSMFill2D (hQueue, pMem, pitch, patternSize, pPattern, width,
1422- height, numEventsInWaitList, phEventWaitList, phEvent);
1433+ return UR_RESULT_SUCCESS;
14231434}
14241435
14251436// /////////////////////////////////////////////////////////////////////////////
@@ -1448,8 +1459,43 @@ ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
14481459 // /< kernel execution instance. If phEventWaitList and phEvent are not
14491460 // /< NULL, phEvent must not refer to an element of the phEventWaitList array.
14501461) {
1451- ur_result_t result = UR_RESULT_SUCCESS;
1452- return result;
1462+ auto pfnUSMMemcpy2D = getContext ()->urDdiTable .Enqueue .pfnUSMMemcpy2D ;
1463+ getContext ()->logger .debug (" ==== pfnUSMMemcpy2D" );
1464+
1465+ UR_CALL (pfnUSMMemcpy2D (hQueue, blocking, pDst, dstPitch, pSrc, srcPitch,
1466+ width, height, numEventsInWaitList, phEventWaitList,
1467+ phEvent));
1468+
1469+ auto Src = (uptr)pSrc, Dst = (uptr)pDst;
1470+ auto SrcInfoItOp = getMsanInterceptor ()->findAllocInfoByAddress (Src);
1471+ auto DstInfoItOp = getMsanInterceptor ()->findAllocInfoByAddress (Dst);
1472+
1473+ if (SrcInfoItOp && DstInfoItOp) {
1474+ auto SrcInfo = (*SrcInfoItOp)->second ;
1475+ auto DstInfo = (*DstInfoItOp)->second ;
1476+
1477+ const auto &DeviceInfo =
1478+ getMsanInterceptor ()->getDeviceInfo (SrcInfo->Device );
1479+ auto SrcShadow = DeviceInfo->Shadow ->MemToShadow (Src);
1480+ auto DstShadow = DeviceInfo->Shadow ->MemToShadow (Dst);
1481+
1482+ UR_CALL (pfnUSMMemcpy2D (hQueue, blocking, (void *)DstShadow, dstPitch,
1483+ (void *)SrcShadow, srcPitch, width, height,
1484+ numEventsInWaitList, phEventWaitList, phEvent));
1485+ } else if (DstInfoItOp) {
1486+ auto DstInfo = (*DstInfoItOp)->second ;
1487+
1488+ const auto &DeviceInfo =
1489+ getMsanInterceptor ()->getDeviceInfo (DstInfo->Device );
1490+ auto DstShadow = DeviceInfo->Shadow ->MemToShadow (Dst);
1491+
1492+ const char Pattern = 0 ;
1493+ UR_CALL (getContext ()->urDdiTable .Enqueue .pfnUSMFill2D (
1494+ hQueue, (void *)DstShadow, dstPitch, 1 , &Pattern, width, height, 1 ,
1495+ phEvent, phEvent));
1496+ }
1497+
1498+ return UR_RESULT_SUCCESS;
14531499}
14541500
14551501// /////////////////////////////////////////////////////////////////////////////
0 commit comments