2
2
// SPDX-License-Identifier: BSD-3-Clause
3
3
4
4
// System headers.
5
- #include < algorithm>
6
5
#include < assert.h>
7
6
#include < string.h>
8
7
@@ -279,23 +278,37 @@ CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfoIntelFPGA(
279
278
// Cut by 2 again, see comment for CL_DEVICE_GLOBAL_MEM_SIZE
280
279
size /= 2 ;
281
280
#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)
283
283
cl_ulong size = 0 ;
284
284
for (unsigned gmem_idx = 0 ;
285
285
gmem_idx < device->def .autodiscovery_def .num_global_mem_systems ;
286
286
gmem_idx++) {
287
287
if (device->def .autodiscovery_def .global_mem_defs [gmem_idx].type ==
288
288
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
+ }
291
305
}
292
306
}
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
299
312
#endif
300
313
RESULT_ULONG (size);
301
314
} break ;
@@ -322,15 +335,12 @@ CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfoIntelFPGA(
322
335
size = size / 8 ;
323
336
}
324
337
#else
325
- cl_ulong global_mem_size = 0 ;
326
338
cl_ulong size = 0 ;
327
339
for (unsigned gmem_idx = 0 ;
328
340
gmem_idx < device->def .autodiscovery_def .num_global_mem_systems ;
329
341
gmem_idx++) {
330
342
if (device->def .autodiscovery_def .global_mem_defs [gmem_idx].type ==
331
343
ACL_GLOBAL_MEM_DEVICE_PRIVATE) {
332
- global_mem_size += ACL_RANGE_SIZE (
333
- device->def .autodiscovery_def .global_mem_defs [gmem_idx].range );
334
344
cl_ulong curr_size = 0 ;
335
345
// TODO: investigate if ACL_MEM_ALIGN of 0x400 is still required to
336
346
// perform device allocations to memory with 0 starting address
@@ -349,10 +359,9 @@ CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfoIntelFPGA(
349
359
}
350
360
}
351
361
}
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
356
365
#endif
357
366
RESULT_ULONG (size);
358
367
} break ;
0 commit comments