Skip to content

Commit facc176

Browse files
committed
Make runtime return true device capabilities
1 parent 3dd9998 commit facc176

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

src/acl_device.cpp

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
// System headers.
5-
#include <algorithm>
65
#include <assert.h>
76
#include <string.h>
87

@@ -279,23 +278,37 @@ CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfoIntelFPGA(
279278
// Cut by 2 again, see comment for CL_DEVICE_GLOBAL_MEM_SIZE
280279
size /= 2;
281280
#else
282-
// Constant memory is global memory.
281+
// Return the maximum size of a single allocation to the constant memory
282+
// (i.e., global memory)
283283
cl_ulong size = 0;
284284
for (unsigned gmem_idx = 0;
285285
gmem_idx < device->def.autodiscovery_def.num_global_mem_systems;
286286
gmem_idx++) {
287287
if (device->def.autodiscovery_def.global_mem_defs[gmem_idx].type ==
288288
ACL_GLOBAL_MEM_DEVICE_PRIVATE) {
289-
size += ACL_RANGE_SIZE(
290-
device->def.autodiscovery_def.global_mem_defs[gmem_idx].range);
289+
cl_ulong curr_size = 0;
290+
// TODO: investigate if ACL_MEM_ALIGN of 0x400 is still required to
291+
// perform device allocations to memory with 0 starting address
292+
if (device->def.autodiscovery_def.global_mem_defs[gmem_idx]
293+
.allocation_type &
294+
ACL_GLOBAL_MEM_DEVICE_ALLOCATION) {
295+
curr_size = ACL_RANGE_SIZE(
296+
device->def.autodiscovery_def.global_mem_defs[gmem_idx]
297+
.get_usable_range());
298+
} else {
299+
curr_size = ACL_RANGE_SIZE(
300+
device->def.autodiscovery_def.global_mem_defs[gmem_idx].range);
301+
}
302+
if (curr_size > size) {
303+
size = curr_size;
304+
}
291305
}
292306
}
293-
// Note that OpenCL 1.2 specifies the minimum value for devices not of
294-
// type CL_DEVICE_TYPE_CUSTOM to be 64KB, however, the OpenCL conformance
295-
// test api:test_min_max_constant_buffer_size expects to allocate two
296-
// buffers of the size returned here, so following the spec may result
297-
// in conformance test failures.
298-
size = std::max(size, (cl_ulong)64 * 1024);
307+
// Note: devices not of type CL_DEVICE_TYPE_CUSTOM and conformant
308+
// to OpenCL 1.2 spec will return size at least of 64KB here
309+
// TODO: the OpenCL conformance test api:test_min_max_constant_buffer_size
310+
// expects to allocate two buffers of the size returned, need to
311+
// confirm conformance here
299312
#endif
300313
RESULT_ULONG(size);
301314
} break;
@@ -322,15 +335,12 @@ CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfoIntelFPGA(
322335
size = size / 8;
323336
}
324337
#else
325-
cl_ulong global_mem_size = 0;
326338
cl_ulong size = 0;
327339
for (unsigned gmem_idx = 0;
328340
gmem_idx < device->def.autodiscovery_def.num_global_mem_systems;
329341
gmem_idx++) {
330342
if (device->def.autodiscovery_def.global_mem_defs[gmem_idx].type ==
331343
ACL_GLOBAL_MEM_DEVICE_PRIVATE) {
332-
global_mem_size += ACL_RANGE_SIZE(
333-
device->def.autodiscovery_def.global_mem_defs[gmem_idx].range);
334344
cl_ulong curr_size = 0;
335345
// TODO: investigate if ACL_MEM_ALIGN of 0x400 is still required to
336346
// perform device allocations to memory with 0 starting address
@@ -349,10 +359,9 @@ CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfoIntelFPGA(
349359
}
350360
}
351361
}
352-
// OpenCL 1.2: min value = max(CL_DEVICE_GLOBAL_MEM_SIZE/4, 1*1024*1024)
353-
// for devices that are not of type CL_DEVICE_TYPE_CUSTOM
354-
size = std::max(size,
355-
std::max(global_mem_size / 4, (cl_ulong)1 * 1024 * 1024));
362+
// Note: devices not of type CL_DEVICE_TYPE_CUSTOM and
363+
// conformant to OpenCL 1.2 spec will return size at least of
364+
// max(CL_DEVICE_GLOBAL_MEM_SIZE/4, 1*1024*1024) here
356365
#endif
357366
RESULT_ULONG(size);
358367
} break;

0 commit comments

Comments
 (0)