Skip to content

Commit d6861c5

Browse files
committed
add more testing and return default global mem instead of 0
1 parent 397a189 commit d6861c5

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/acl_usm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ clDeviceMemAllocINTEL(cl_context context, cl_device_id device,
240240
// Iterate over properties.
241241
// The end of the properties list is specified with a zero.
242242
cl_mem_alloc_flags_intel alloc_flags = 0;
243-
cl_uint mem_id = 0;
243+
cl_uint mem_id = acl_get_default_memory(device->def);
244244
while (properties != NULL && *properties != 0) {
245245
switch (*properties) {
246246
case CL_MEM_ALLOC_FLAGS_INTEL: {
@@ -616,7 +616,7 @@ CL_API_ENTRY cl_int CL_API_CALL clGetMemAllocInfoINTEL(
616616
if (usm_alloc) {
617617
RESULT_UINT(usm_alloc->mem->mem_id);
618618
} else {
619-
RESULT_UINT(CL_MEM_TYPE_UNKNOWN_INTEL);
619+
RESULT_UINT(0);
620620
}
621621
} break;
622622

test/acl_usm_test.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,22 @@ MT_TEST(acl_usm, buffer_location_usm) {
417417

418418
// Check alloc information
419419
cl_uint read_mem_id = 4;
420-
size_t ret_size;
420+
size_t ret_size = 9;
421421
status = clGetMemAllocInfoINTEL(m_context, test_ptr,
422422
CL_MEM_ALLOC_BUFFER_LOCATION_INTEL,
423423
sizeof(cl_uint), &read_mem_id, &ret_size);
424424

425425
CHECK_EQUAL(CL_SUCCESS, status);
426426
CHECK_EQUAL(0, read_mem_id);
427+
CHECK_EQUAL(sizeof(cl_uint), ret_size);
428+
// Check when given pointer is invalid
429+
status = clGetMemAllocInfoINTEL(m_context, NULL,
430+
CL_MEM_ALLOC_BUFFER_LOCATION_INTEL,
431+
sizeof(cl_uint), &read_mem_id, &ret_size);
432+
433+
CHECK_EQUAL(CL_SUCCESS, status);
434+
CHECK_EQUAL(0, read_mem_id);
435+
CHECK_EQUAL(sizeof(cl_uint), ret_size);
427436

428437
status = clMemFreeINTEL(m_context, test_ptr);
429438
CHECK_EQUAL(status, CL_SUCCESS);

0 commit comments

Comments
 (0)