Skip to content

Commit 08c6e94

Browse files
committed
Initialize max number of global memory definition for simulator
Simulator does not have any global memory interface information until the actuall aocx is loaded. (Note this is only a problem for simulator not hardware run, in hardware run, we can communicate with BSP to query memory interface information) Prior to loading aocx it uses predefined autodiscovery [1] to initialize its global memory interface, which has only 1 global memory In the sycl runtime flow today, the USM device allocation call happens before aocx is loaded. The aocx is loaded when clCreateProgram is called, which typically happen on first kernel launch in sycl runtime. The USM device allocation on mutli global memory system will fail because there are in total 1 global memory as defined in [1] but the user is requesting more than 1 device global memory. User could go around this issue by launching a sacrificial kernel that uses shared allocation as kernel argument. This will setup the correct global memory interface in runtime. This change eliminate the need to run a sacrificial kernel. However there are a few downside: 1. The address range/size may not be exactly the same as the one that is in aocx, but this is not too large of a problem because runtime first fit allocation algorithm will fill the lowest address range first. Unless user requested more than what is availble. 2. it potentially occupied more space than required 3. will not error out when user requested a non-existing device global memory because we are using ACL_MAX_GLOBAL_MEM for num_global_mem_systems [1] https://github.com/intel/fpga-runtime-for-opencl/blob/950f21dd079dfd55a473ba4122a4a9dca450e36f/include/acl_shipped_board_cfgs.h#L7
1 parent 83a27ea commit 08c6e94

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/acl_kernel_if.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,13 @@ int acl_kernel_if_init(acl_kernel_if *kern, acl_bsp_io bsp_io,
715715
auto parse_result = acl_load_device_def_from_str(
716716
std::string(acl_shipped_board_cfgs[1]),
717717
sysdef->device[0].autodiscovery_def, err_msg);
718+
// Fill in definition for all device global memory
719+
sysdef->device[0].autodiscovery_def.num_global_mem_systems =
720+
ACL_MAX_GLOBAL_MEM;
721+
for (int i = 0; i < ACL_MAX_GLOBAL_MEM; i++) {
722+
sysdef->device[0].autodiscovery_def.global_mem_defs[i] =
723+
sysdef->device[0].autodiscovery_def.global_mem_defs[0];
724+
}
718725
if (parse_result)
719726
sysdef->num_devices = 1;
720727
// Override the device name to the simulator.

0 commit comments

Comments
 (0)