Skip to content

Commit 89d114e

Browse files
committed
Modify buffer location property if in simulation environment in acl_usm.cpp
1 parent f4bc596 commit 89d114e

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

src/acl_hal_mmd.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,19 +2767,10 @@ void *acl_hal_mmd_host_alloc(const std::vector<cl_device_id> devices,
27672767
handles[i] = device_info[physical_device_id].handle;
27682768
}
27692769

2770-
int use_offline_only;
2771-
acl_get_offline_device_user_setting(&use_offline_only);
2772-
2773-
if (use_offline_only == ACL_CONTEXT_MPSIM) {
2774-
result = dispatch->aocl_mmd_host_alloc(
2775-
handles, devices.size(), size, alignment,
2776-
(aocl_mmd_mem_properties_t *)properties, error);
2777-
acl_delete_arr(handles);
2778-
} else {
2779-
result = dispatch->aocl_mmd_host_alloc(handles, devices.size(), size,
2780-
alignment, nullptr, error);
2781-
acl_delete_arr(handles);
2782-
}
2770+
result = dispatch->aocl_mmd_host_alloc(
2771+
handles, devices.size(), size, alignment,
2772+
(aocl_mmd_mem_properties_t *)properties, error);
2773+
acl_delete_arr(handles);
27832774

27842775
if (error) {
27852776
switch (*error) {

src/acl_usm.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,18 @@ CL_API_ENTRY void *CL_API_CALL clHostMemAllocINTEL(
163163
UNLOCK_BAIL_INFO(CL_OUT_OF_HOST_MEMORY, context, "Out of host memory");
164164
}
165165

166+
int use_offline_only;
167+
acl_get_offline_device_user_setting(&use_offline_only);
168+
mem_properties_t *properties_ptr;
169+
if (use_offline_only == ACL_CONTEXT_MPSIM) {
170+
properties_ptr = mmd_properties.data();
171+
} else {
172+
properties_ptr = nullptr;
173+
}
174+
166175
int error = 0;
167176
void *mem = acl_get_hal()->host_alloc(devices, size, alignment,
168-
mmd_properties.data(), &error);
177+
properties_ptr, &error);
169178
if (error) {
170179
acl_free(usm_alloc);
171180
switch (error) {
@@ -449,9 +458,18 @@ clSharedMemAllocINTEL(cl_context context, cl_device_id device,
449458
UNLOCK_BAIL_INFO(CL_OUT_OF_HOST_MEMORY, context, "Out of host memory");
450459
}
451460

461+
int use_offline_only;
462+
acl_get_offline_device_user_setting(&use_offline_only);
463+
mem_properties_t *properties_ptr;
464+
if (use_offline_only == ACL_CONTEXT_MPSIM) {
465+
properties_ptr = mmd_properties.data();
466+
} else {
467+
properties_ptr = nullptr;
468+
}
469+
452470
int error;
453471
void *mem = acl_get_hal()->shared_alloc(device, size, alignment,
454-
mmd_properties.data(), &error);
472+
properties_ptr, &error);
455473
if (mem == NULL) {
456474
acl_free(usm_alloc);
457475
switch (error) {

0 commit comments

Comments
 (0)