@@ -125,6 +125,8 @@ static ur_result_t synchronousZeCopy(ur_context_handle_t hContext,
125125ur_result_t
126126ur_discrete_mem_handle_t ::migrateBufferTo(ur_device_handle_t hDevice, void *src,
127127 size_t size) {
128+ TRACK_SCOPE_LATENCY (" ur_discrete_mem_handle_t::migrateBufferTo" );
129+
128130 auto Id = hDevice->Id .value ();
129131
130132 if (!deviceAllocations[Id]) {
@@ -163,9 +165,11 @@ ur_discrete_mem_handle_t::~ur_discrete_mem_handle_t() {
163165 }
164166}
165167
166- void *ur_discrete_mem_handle_t ::getDevicePtrUnlocked (
168+ void *ur_discrete_mem_handle_t ::getDevicePtr (
167169 ur_device_handle_t hDevice, access_mode_t access, size_t offset,
168170 size_t size, std::function<void (void *src, void *dst, size_t )> migrate) {
171+ TRACK_SCOPE_LATENCY (" ur_discrete_mem_handle_t::getDevicePtr" );
172+
169173 std::ignore = access;
170174 std::ignore = size;
171175 std::ignore = migrate;
@@ -198,17 +202,10 @@ void *ur_discrete_mem_handle_t::getDevicePtrUnlocked(
198202 offset;
199203}
200204
201- void *ur_discrete_mem_handle_t ::getDevicePtr(
202- ur_device_handle_t hDevice, access_mode_t access, size_t offset,
203- size_t size, std::function<void (void *src, void *dst, size_t )> migrate) {
204- std::lock_guard lock (this ->Mutex );
205- return getDevicePtrUnlocked (hDevice, access, offset, size, migrate);
206- }
207-
208205void *ur_discrete_mem_handle_t ::mapHostPtr(
209206 access_mode_t access, size_t offset, size_t size,
210207 std::function<void (void *src, void *dst, size_t )> migrate) {
211- std::lock_guard lock ( this -> Mutex );
208+ TRACK_SCOPE_LATENCY ( " ur_discrete_mem_handle_t::mapHostPtr " );
212209
213210 // TODO: use async alloc?
214211
@@ -231,7 +228,7 @@ void *ur_discrete_mem_handle_t::mapHostPtr(
231228void ur_discrete_mem_handle_t::unmapHostPtr (
232229 void *pMappedPtr,
233230 std::function<void (void *src, void *dst, size_t )> migrate) {
234- std::lock_guard lock ( this -> Mutex );
231+ TRACK_SCOPE_LATENCY ( " ur_discrete_mem_handle_t::unmapHostPtr " );
235232
236233 for (auto &hostAllocation : hostAllocations) {
237234 if (hostAllocation.ptr == pMappedPtr) {
@@ -241,9 +238,9 @@ void ur_discrete_mem_handle_t::unmapHostPtr(
241238 deviceAllocations[activeAllocationDevice->Id .value ()]) +
242239 hostAllocation.offset ;
243240 } else if (hostAllocation.access != access_mode_t ::write_invalidate) {
244- devicePtr = ur_cast<char *>(getDevicePtrUnlocked (
245- hContext->getDevices ()[0 ], access_mode_t ::read_only,
246- hostAllocation.offset , hostAllocation.size , migrate));
241+ devicePtr = ur_cast<char *>(
242+ getDevicePtr ( hContext->getDevices ()[0 ], access_mode_t ::read_only,
243+ hostAllocation.offset , hostAllocation.size , migrate));
247244 }
248245
249246 if (devicePtr) {
@@ -328,7 +325,8 @@ ur_result_t urMemBufferCreateWithNativeHandle(
328325ur_result_t urMemGetInfo (ur_mem_handle_t hMemory, ur_mem_info_t propName,
329326 size_t propSize, void *pPropValue,
330327 size_t *pPropSizeRet) {
331- std::shared_lock<ur_shared_mutex> Lock (hMemory->Mutex );
328+ // No locking needed here, we only read const members
329+
332330 UrReturnHelper returnValue (propSize, pPropValue, pPropSizeRet);
333331
334332 switch (propName) {
0 commit comments