C-API#

Common#

Common Functions#

tinytc_ze_convert_status#

tinytc_status_t tinytc_ze_convert_status(ze_result_t result)#

Device Info#

Device Info Functions#

tinytc_ze_core_info_create#

tinytc_status_t tinytc_ze_core_info_create(tinytc_core_info_t *info, ze_device_handle_t device)#

Query core info from level zero runtime.

Parameters:
  • info – [out] pointer to the core_info object created

  • device – [in] device handle

Returns:

tinytc_status_success on success and error otherwise

tinytc_ze_get_support_level#

tinytc_status_t tinytc_ze_get_support_level(ze_device_handle_t device, tinytc_support_level_t *level)#

Get support level of Level Zero device.

Parameters:
  • device – [in] Device handle

  • level – [out] Pointer to support level

Returns:

tinytc_status_success on success and error otherwise

Kernel#

Kernel Functions#

tinytc_ze_get_group_count#

ze_group_count_t tinytc_ze_get_group_count(int64_t howmany)#

Convert group size to level zero group count.

Parameters:
  • howmany – group size

Returns:

group count

tinytc_ze_get_group_size#

tinytc_status_t tinytc_ze_get_group_size(ze_kernel_handle_t kernel, uint32_t *x, uint32_t *y, uint32_t *z)#

Get work group size for kernel.

Parameters:
  • kernel – [in] kernel handle

  • x – [out] pointer to group size in x dimension

  • y – [out] pointer to group size in y dimension

  • z – [out] pointer to group size in z dimension

Returns:

tinytc_status_success on success and error otherwise

tinytc_ze_kernel_create#

tinytc_status_t tinytc_ze_kernel_create(ze_kernel_handle_t *krnl, ze_module_handle_t mod, char const *name)#

Create a kernel and set group size.

Parameters:
  • krnl – [out] pointer to the kernel object created

  • mod – [in] module handle

  • name – [in] kernel name

Returns:

tinytc_status_success on success and error otherwise

tinytc_ze_kernel_bundle_create_with_binary#

tinytc_status_t tinytc_ze_kernel_bundle_create_with_binary(ze_module_handle_t *bundle, ze_context_handle_t context, ze_device_handle_t device, const_tinytc_binary_t bin, tinytc_source_context_t source_ctx)#

Create an OpenCL program from a tinytc binary.

Parameters:
  • bundle – [out] pointer to the kernel bundle (ze_module_handle_t) object created

  • context – [in] context handle

  • device – [in] device handle

  • bin – [in] binary object

  • source_ctx – [inout][optional] source context object to save extended error messages that are enhanced with source code context; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_ze_kernel_bundle_create_with_program#

tinytc_status_t tinytc_ze_kernel_bundle_create_with_program(ze_module_handle_t *bundle, ze_context_handle_t context, ze_device_handle_t device, tinytc_prog_t prg, tinytc_core_feature_flags_t core_features, tinytc_source_context_t source_ctx)#

Compile tensor program.

Parameters:
  • bundle – [out] pointer to the kernel bundle (ze_module_handle_t) object created

  • context – [in] context handle

  • device – [in] device handle

  • prg – [inout] tensor program; modified as compiler passes are run

  • core_features – [in][optional] requested core features; must be 0 (default) or a combination of tinytc_core_feature_flag_t

  • source_ctx – [inout][optional] source context object to save extended error messages that are enhanced with source code context; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_ze_kernel_bundle_create_with_source#

tinytc_status_t tinytc_ze_kernel_bundle_create_with_source(ze_module_handle_t *bundle, ze_context_handle_t context, ze_device_handle_t device, const_tinytc_source_t src, tinytc_source_context_t source_ctx)#

Compile OpenCL-C source to device binary.

Parameters:
  • bundle – [out] pointer to the kernel bundle (ze_module_handle_t) object created

  • context – [in] context handle

  • device – [in] device handle

  • src – [in] source text and extensions

  • source_ctx – [inout][optional] source context object to save extended error messages that are enhanced with source code context; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_ze_source_compile_to_binary#

tinytc_status_t tinytc_ze_source_compile_to_binary(tinytc_binary_t *bin, const_tinytc_source_t src, uint32_t ip_version, tinytc_bundle_format_t format, tinytc_source_context_t source_ctx)#

Compile OpenCL-C source to device binary.

Parameters:
  • bin – [out] pointer to the binary object created

  • src – [in] source text

  • ip_version – [in] IP version (pass tinytc_intel_gpu_architecture_t here)

  • format – [in] binary format (SPIR-V or native)

  • source_ctx – [inout][optional] source context object to save extended error messages that are enhanced with source code context; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

Recipe#

Recipe Functions#

tinytc_ze_recipe_handler_create#

tinytc_status_t tinytc_ze_recipe_handler_create(tinytc_recipe_handler_t *handler, ze_context_handle_t context, ze_device_handle_t device, tinytc_recipe_t recipe, tinytc_source_context_t source_ctx)#

Create kernel object for recipe.

Parameters:
  • handler – [out] pointer to recipe handler object

  • context – [in] context handle

  • device – [in] device handle

  • recipe – [in] recipe object

  • source_ctx – [inout][optional] source context object to save extended error messages that are enhanced with source code context; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_ze_recipe_handler_submit#

tinytc_status_t tinytc_ze_recipe_handler_submit(tinytc_recipe_handler_t handler, ze_command_list_handle_t list, ze_event_handle_t signal_event, uint32_t num_wait_events, ze_event_handle_t *wait_events)#

Submit recipe to device.

Parameters:
  • handler – [in] recipe handler object

  • list – [in] command list handle

  • signal_event – [inout][optional] event to be signalled on completion; can be nullptr

  • num_wait_events – [in][optional] number of events the kernel depends on

  • wait_events – [in][optional][range(0,num_wait_events)] array of events to wait on; can be nullptr if num_wait_events is 0

Returns:

tinytc_status_success on success and error otherwise