Skip to content

Commit b50288c

Browse files
committed
Pass buffer location property only if the environment is simulation
1 parent 89d114e commit b50288c

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

src/acl_usm.cpp

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ CL_API_ENTRY void *CL_API_CALL clHostMemAllocINTEL(
150150
{
151151
auto mmd_properties_it = mmd_properties.begin();
152152
if (mem_id) {
153-
*mmd_properties_it++ = AOCL_MMD_MEM_PROPERTIES_BUFFER_LOCATION;
153+
int use_offline_only;
154+
acl_get_offline_device_user_setting(&use_offline_only);
155+
if (use_offline_only == ACL_CONTEXT_MPSIM) {
156+
*mmd_properties_it++ = AOCL_MMD_MEM_PROPERTIES_BUFFER_LOCATION;
157+
}
154158
*mmd_properties_it++ = *mem_id;
155159
}
156160
*mmd_properties_it++ = 0;
@@ -163,18 +167,9 @@ CL_API_ENTRY void *CL_API_CALL clHostMemAllocINTEL(
163167
UNLOCK_BAIL_INFO(CL_OUT_OF_HOST_MEMORY, context, "Out of host memory");
164168
}
165169

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-
175170
int error = 0;
176171
void *mem = acl_get_hal()->host_alloc(devices, size, alignment,
177-
properties_ptr, &error);
172+
mmd_properties.data(), &error);
178173
if (error) {
179174
acl_free(usm_alloc);
180175
switch (error) {
@@ -445,7 +440,11 @@ clSharedMemAllocINTEL(cl_context context, cl_device_id device,
445440
{
446441
auto mmd_properties_it = mmd_properties.begin();
447442
if (mem_id) {
448-
*mmd_properties_it++ = AOCL_MMD_MEM_PROPERTIES_BUFFER_LOCATION;
443+
int use_offline_only;
444+
acl_get_offline_device_user_setting(&use_offline_only);
445+
if (use_offline_only == ACL_CONTEXT_MPSIM) {
446+
*mmd_properties_it++ = AOCL_MMD_MEM_PROPERTIES_BUFFER_LOCATION;
447+
}
449448
*mmd_properties_it++ = *mem_id;
450449
}
451450
*mmd_properties_it++ = 0;
@@ -458,18 +457,9 @@ clSharedMemAllocINTEL(cl_context context, cl_device_id device,
458457
UNLOCK_BAIL_INFO(CL_OUT_OF_HOST_MEMORY, context, "Out of host memory");
459458
}
460459

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-
470460
int error;
471461
void *mem = acl_get_hal()->shared_alloc(device, size, alignment,
472-
properties_ptr, &error);
462+
mmd_properties.data(), &error);
473463
if (mem == NULL) {
474464
acl_free(usm_alloc);
475465
switch (error) {

0 commit comments

Comments
 (0)