Skip to content

Commit c9cca6e

Browse files
sherry-yuanzibaiwan
authored andcommitted
Comment field definition of HAL MMD struct for better readability
-------------------------------------------------------------------- Previously when we navigate the code, we usually see calls like `acl_get_hal()->shared_alloc`, however when we search for `shared_alloc` we do not see where it is defined immediately. This has caused many confusion when navigating the code. By adding the struct field corresponding to each definition, it help us to directly find what function corresponds to it without matching the index of the struct. Why not designated initialization? windows require c++ version above 20 to do this.
1 parent 5de74b7 commit c9cca6e

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

src/acl_hal_mmd.cpp

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -302,47 +302,49 @@ acl_kernel_update_callback acl_kernel_update_fn = NULL;
302302
acl_profile_callback acl_profile_fn = NULL;
303303
acl_device_update_callback acl_device_update_fn = NULL;
304304

305-
static acl_hal_t acl_hal_mmd = {acl_hal_mmd_init_device,
306-
NULL, // Populated based on MMD property
307-
acl_hal_mmd_get_timestamp,
308-
acl_hal_mmd_copy_hostmem_to_hostmem,
309-
acl_hal_mmd_copy_hostmem_to_globalmem,
310-
acl_hal_mmd_copy_globalmem_to_hostmem,
311-
acl_hal_mmd_copy_globalmem_to_globalmem,
312-
acl_hal_mmd_register_callbacks,
313-
acl_hal_mmd_launch_kernel,
314-
acl_hal_mmd_unstall_kernel,
315-
acl_hal_mmd_program_device,
316-
acl_hal_mmd_query_temperature,
317-
acl_hal_mmd_get_device_official_name,
318-
acl_hal_mmd_get_device_vendor_name,
319-
acl_hal_mmd_legacy_shared_alloc,
320-
acl_hal_mmd_legacy_shared_free,
321-
acl_hal_mmd_get_profile_data,
322-
acl_hal_mmd_reset_profile_counters,
323-
acl_hal_mmd_disable_profile_counters,
324-
acl_hal_mmd_enable_profile_counters,
325-
acl_hal_mmd_set_profile_shared_control,
326-
acl_hal_mmd_set_profile_start_count,
327-
acl_hal_mmd_set_profile_stop_count,
328-
acl_hal_mmd_has_svm_support,
329-
acl_hal_mmd_has_physical_mem,
330-
acl_hal_get_board_extension_function_address,
331-
acl_hal_mmd_pll_reconfigure,
332-
acl_hal_mmd_reset_kernels,
333-
acl_hal_mmd_hostchannel_create,
334-
acl_hal_mmd_hostchannel_destroy,
335-
acl_hal_mmd_hostchannel_pull,
336-
acl_hal_mmd_hostchannel_push,
337-
acl_hal_mmd_hostchannel_get_buffer,
338-
acl_hal_mmd_hostchannel_ack_buffer,
339-
acl_hal_mmd_get_device_status,
340-
acl_hal_mmd_get_debug_verbosity,
341-
acl_hal_mmd_try_devices,
342-
acl_hal_mmd_close_devices,
343-
acl_hal_mmd_host_alloc,
344-
acl_hal_mmd_free,
345-
acl_hal_mmd_shared_alloc};
305+
static acl_hal_t acl_hal_mmd = {
306+
acl_hal_mmd_init_device, // init_device
307+
NULL, // yield: Populated based on MMD property
308+
acl_hal_mmd_get_timestamp, // get_timestamp
309+
acl_hal_mmd_copy_hostmem_to_hostmem, // copy_hostmem_to_hostmem
310+
acl_hal_mmd_copy_hostmem_to_globalmem, // copy_hostmem_to_globalmem
311+
acl_hal_mmd_copy_globalmem_to_hostmem, // copy_globalmem_to_hostmem
312+
acl_hal_mmd_copy_globalmem_to_globalmem, // copy_globalmem_to_globalmem
313+
acl_hal_mmd_register_callbacks, // register_callbacks
314+
acl_hal_mmd_launch_kernel, // launch_kernel
315+
acl_hal_mmd_unstall_kernel, // unstall_kernel
316+
acl_hal_mmd_program_device, // program_device
317+
acl_hal_mmd_query_temperature, // query_temperature
318+
acl_hal_mmd_get_device_official_name, // get_device_official_name
319+
acl_hal_mmd_get_device_vendor_name, // get_device_vendor_name
320+
acl_hal_mmd_legacy_shared_alloc, // legacy_shared_alloc
321+
acl_hal_mmd_legacy_shared_free, // legacy_shared_free
322+
acl_hal_mmd_get_profile_data, // get_profile_data
323+
acl_hal_mmd_reset_profile_counters, // reset_profile_counters
324+
acl_hal_mmd_disable_profile_counters, // disable_profile_counters
325+
acl_hal_mmd_enable_profile_counters, // enable_profile_counters
326+
acl_hal_mmd_set_profile_shared_control, // set_profile_shared_control
327+
acl_hal_mmd_set_profile_start_count, // set_profile_start_cycle
328+
acl_hal_mmd_set_profile_stop_count, // set_profile_stop_cycle
329+
acl_hal_mmd_has_svm_support, // has_svm_memory_support
330+
acl_hal_mmd_has_physical_mem, // has_physical_mem
331+
acl_hal_get_board_extension_function_address, // get_board_extension_function_address
332+
acl_hal_mmd_pll_reconfigure, // pll_reconfigure
333+
acl_hal_mmd_reset_kernels, // reset_kernels
334+
acl_hal_mmd_hostchannel_create, // hostchannel_create
335+
acl_hal_mmd_hostchannel_destroy, // hostchannel_destroy
336+
acl_hal_mmd_hostchannel_pull, // hostchannel_pull
337+
acl_hal_mmd_hostchannel_push, // hostchannel_push
338+
acl_hal_mmd_hostchannel_get_buffer, // hostchannel_get_buffer
339+
acl_hal_mmd_hostchannel_ack_buffer, // hostchannel_ack_buffer
340+
acl_hal_mmd_get_device_status, // get_device_status
341+
acl_hal_mmd_get_debug_verbosity, // get_debug_verbosity
342+
acl_hal_mmd_try_devices, // try_devices
343+
acl_hal_mmd_close_devices, // close_devices
344+
acl_hal_mmd_host_alloc, // host_alloc
345+
acl_hal_mmd_free, // free
346+
acl_hal_mmd_shared_alloc // shared_alloc
347+
};
346348

347349
// This will contain the device physical id to tell us which device across all
348350
// loaded BSPs (even with the same handle numbers) is calling the interrupt

0 commit comments

Comments
 (0)