@@ -1248,36 +1248,34 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferMap(
1248
1248
const bool IsPinned =
1249
1249
BufferImpl.MemAllocMode == BufferMem::AllocMode::AllocHostPtr;
1250
1250
1251
- ur_result_t Result = UR_RESULT_SUCCESS;
1252
- if (!IsPinned &&
1253
- (mapFlags & (UR_MAP_FLAG_READ | UR_MAP_FLAG_WRITE)) {
1254
- // Pinned host memory is already on host so it doesn't need to be read.
1255
- Result = urEnqueueMemBufferRead (hQueue, hBuffer, blockingMap, offset, size,
1256
- MapPtr, numEventsInWaitList,
1257
- phEventWaitList, phEvent);
1258
- } else {
1259
- ScopedContext Active (hQueue->getDevice ());
1251
+ try {
1252
+ if (!IsPinned && (mapFlags & (UR_MAP_FLAG_READ | UR_MAP_FLAG_WRITE))) {
1253
+ // Pinned host memory is already on host so it doesn't need to be read.
1254
+ UR_CHECK_ERROR (urEnqueueMemBufferRead (
1255
+ hQueue, hBuffer, blockingMap, offset, size, MapPtr,
1256
+ numEventsInWaitList, phEventWaitList, phEvent));
1257
+ } else {
1258
+ ScopedContext Active (hQueue->getDevice ());
1260
1259
1261
- if (IsPinned) {
1262
- Result = urEnqueueEventsWait (hQueue, numEventsInWaitList, phEventWaitList ,
1263
- nullptr );
1264
- }
1260
+ if (IsPinned) {
1261
+ UR_CHECK_ERROR ( urEnqueueEventsWait (hQueue, numEventsInWaitList,
1262
+ phEventWaitList, nullptr ) );
1263
+ }
1265
1264
1266
- if (phEvent) {
1267
- try {
1265
+ if (phEvent) {
1268
1266
*phEvent = ur_event_handle_t_::makeNative (
1269
1267
UR_COMMAND_MEM_BUFFER_MAP, hQueue, hQueue->getNextTransferStream ());
1270
1268
UR_CHECK_ERROR ((*phEvent)->start ());
1271
1269
UR_CHECK_ERROR ((*phEvent)->record ());
1272
- } catch (ur_result_t Error) {
1273
- Result = Error;
1274
1270
}
1275
1271
}
1272
+ } catch (ur_result_t Error) {
1273
+ return Error;
1276
1274
}
1277
1275
1278
1276
*ppRetMap = MapPtr;
1279
1277
1280
- return Result ;
1278
+ return UR_RESULT_SUCCESS ;
1281
1279
}
1282
1280
1283
1281
// / Implements the unmap from the host, using a BufferWrite operation.
@@ -1297,36 +1295,35 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemUnmap(
1297
1295
const bool IsPinned =
1298
1296
BufferImpl.MemAllocMode == BufferMem::AllocMode::AllocHostPtr;
1299
1297
1300
- ur_result_t Result = UR_RESULT_SUCCESS;
1301
- if (!IsPinned &&
1302
- (Map->getMapFlags () &
1303
- (UR_MAP_FLAG_WRITE | UR_MAP_FLAG_WRITE_INVALIDATE_REGION))) {
1304
- // Pinned host memory is only on host so it doesn't need to be written to.
1305
- Result = urEnqueueMemBufferWrite (
1306
- hQueue, hMem, true , Map->getMapOffset (), Map->getMapSize (), pMappedPtr ,
1307
- numEventsInWaitList, phEventWaitList, phEvent);
1308
- } else {
1309
- ScopedContext Active (hQueue->getDevice ());
1298
+ try {
1299
+ if (!IsPinned &&
1300
+ (Map->getMapFlags () &
1301
+ (UR_MAP_FLAG_WRITE | UR_MAP_FLAG_WRITE_INVALIDATE_REGION))) {
1302
+ // Pinned host memory is only on host so it doesn't need to be written to.
1303
+ UR_CHECK_ERROR ( urEnqueueMemBufferWrite (
1304
+ hQueue, hMem, true , Map->getMapOffset (), Map->getMapSize (),
1305
+ pMappedPtr, numEventsInWaitList, phEventWaitList, phEvent) );
1306
+ } else {
1307
+ ScopedContext Active (hQueue->getDevice ());
1310
1308
1311
- if (IsPinned) {
1312
- Result = urEnqueueEventsWait (hQueue, numEventsInWaitList, phEventWaitList ,
1313
- nullptr );
1314
- }
1309
+ if (IsPinned) {
1310
+ UR_CHECK_ERROR ( urEnqueueEventsWait (hQueue, numEventsInWaitList,
1311
+ phEventWaitList, nullptr ) );
1312
+ }
1315
1313
1316
- if (phEvent) {
1317
- try {
1314
+ if (phEvent) {
1318
1315
*phEvent = ur_event_handle_t_::makeNative (
1319
1316
UR_COMMAND_MEM_UNMAP, hQueue, hQueue->getNextTransferStream ());
1320
1317
UR_CHECK_ERROR ((*phEvent)->start ());
1321
1318
UR_CHECK_ERROR ((*phEvent)->record ());
1322
- } catch (ur_result_t Error) {
1323
- Result = Error;
1324
1319
}
1325
1320
}
1321
+ } catch (ur_result_t Error) {
1322
+ return Error;
1326
1323
}
1327
1324
1328
1325
BufferImpl.unmap (pMappedPtr);
1329
- return Result ;
1326
+ return UR_RESULT_SUCCESS ;
1330
1327
}
1331
1328
1332
1329
UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFill (
0 commit comments