C-API#

Device Info#

Device Info Functions#

tinytc_cl_core_info_create#

tinytc_status_t tinytc_cl_core_info_create(tinytc_core_info_t *info, cl_device_id device)#

Query core info from OpenCL 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_cl_get_support_level#

tinytc_status_t tinytc_cl_get_support_level(cl_device_id device, tinytc_support_level_t *level)#

Get support level of OpenCL 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_cl_get_global_size#

void tinytc_cl_get_global_size(const size_t *num_groups, const size_t *local_size, size_t *global_size)#

Convert group size to opencl global range.

Parameters:
  • num_groups – [in][range(0,3)] pointer to number of groups of size >= 3

  • local_size – [in][range(0,3)] pointer to local size array of size >= 3

  • global_size – [out][range(0,3)] pointer to global size array of size >= 3

tinytc_cl_get_group_size#

tinytc_status_t tinytc_cl_get_group_size(cl_kernel kernel, size_t *local_size)#

Get work group size for kernel.

Parameters:
  • kernel – [in] kernel handle

  • local_size – [out][range(0,3)] pointer to local size array of size >= 3 entries

Returns:

tinytc_status_success on success and error otherwise

tinytc_cl_kernel_bundle_create_with_program#

tinytc_status_t tinytc_cl_kernel_bundle_create_with_program(cl_program *bundle, cl_context context, cl_device_id device, tinytc_prog_t prg, tinytc_core_feature_flags_t core_features)#

Compile tensor program.

Parameters:
  • bundle – [out] pointer to the kernel bundle (cl_program) 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

Returns:

tinytc_status_success on success and error otherwise

tinytc_cl_kernel_bundle_create_with_binary#

tinytc_status_t tinytc_cl_kernel_bundle_create_with_binary(cl_program *bundle, cl_context context, cl_device_id device, const_tinytc_binary_t bin)#

Create an OpenCL program from a tinytc binary.

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

  • context – [in] context handle

  • device – [in] device handle

  • bin – [in] binary object

Returns:

tinytc_status_success on success and error otherwise

Recipe#

Recipe Functions#

tinytc_cl_recipe_handler_create#

tinytc_status_t tinytc_cl_recipe_handler_create(tinytc_recipe_handler_t *handler, cl_context context, cl_device_id device, tinytc_recipe_t recipe)#

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

Returns:

tinytc_status_success on success and error otherwise

tinytc_cl_recipe_handler_submit#

tinytc_status_t tinytc_cl_recipe_handler_submit(tinytc_recipe_handler_t handler, cl_command_queue queue, cl_uint num_wait_events, const cl_event *wait_events, cl_event *event)#

Submit recipe to device.

Parameters:
  • handler – [in] recipe handler object

  • queue – [in] command queue handle

  • 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

  • event – [out][optional] pointer to event object created; can be nullptr

Returns:

tinytc_status_success on success and error otherwise