Core C-API

Contents

Core C-API#

Common#

Common Enumerations#

tinytc_status_t#

enum tinytc_status_t#

Status codes.

Values:

enumerator tinytc_status_success = 0x0#

Success.

enumerator tinytc_status_bad_alloc = 0x1#

Failure to allocate storage.

enumerator tinytc_status_invalid_arguments = 0x2#

Function got invalid arguments.

enumerator tinytc_status_out_of_range = 0x3#

Element access out of bounds.

enumerator tinytc_status_runtime_error = 0x4#

Runtime error.

enumerator tinytc_status_internal_compiler_error = 0x5#

Internal compiler error.

enumerator tinytc_status_unsupported_subgroup_size = 0x6#

Device does not support subgroup size.

enumerator tinytc_status_unsupported_work_group_size = 0x7#

Device does not support work-group size.

enumerator tinytc_status_compilation_error = 0x8#

Compilation error.

enumerator tinytc_status_file_io_error = 0x9#

Error during File I/O.

enumerator tinytc_status_parse_error = 0xa#

Error during parsing.

enumerator tinytc_status_unavailable_extension = 0xb#

Unavailable runtime extension.

enumerator tinytc_status_unsupported_backend = 0xc#

Unsupported backend (SYCL runtime)

enumerator tinytc_status_invalid_kernel_arguments = 0xd#

Kernel got invalid arguments.

enumerator tinytc_status_unsupported_device = 0xe#

Unsupported device.

enumerator tinytc_status_ir_out_of_bounds = 0x100#

Out of bounds access.

enumerator tinytc_status_ir_invalid_shape = 0x101#

Invalid tensor shape.

enumerator tinytc_status_ir_incompatible_shapes = 0x102#

Tensor shape requirements not satisfied.

enumerator tinytc_status_ir_shape_stride_mismatch = 0x103#

Mismatch of shape and stride.

enumerator tinytc_status_ir_scalar_mismatch = 0x104#

Mismatch of scalar types.

enumerator tinytc_status_ir_invalid_number_of_indices = 0x105#
enumerator tinytc_status_ir_expected_scalar = 0x106#

Invalid number of indices.

Expected a value of scalar type

enumerator tinytc_status_ir_expected_memref = 0x107#

Expected a value of memref type.

enumerator tinytc_status_ir_expected_memref_or_scalar = 0x108#

Expected memref or scalar type.

enumerator tinytc_status_ir_expected_memref_or_group = 0x109#

Expected a value of memref or group type.

enumerator tinytc_status_ir_expected_vector_or_matrix = 0x10a#

Expected a vector or marix.

enumerator tinytc_status_ir_unexpected_yield = 0x10b#

Unexpected yield instruction.

enumerator tinytc_status_ir_yield_mismatch = 0x10c#

Wrong number of yielded values.

enumerator tinytc_status_ir_multiple_dynamic_modes = 0x10d#

At most one mode must be dynamic.

enumerator tinytc_status_ir_invalid_slice = 0x10e#

Invalid slice.

enumerator tinytc_status_ir_expand_shape_order_too_small = 0x10f#

Expand shape too small.

enumerator tinytc_status_ir_expand_shape_mismatch = 0x110#

Invalid expand shape.

enumerator tinytc_status_ir_collective_called_from_spmd = 0x111#

Collective instruction from SPMD.

enumerator tinytc_status_ir_fp_unsupported = 0x112#

Instruction does not support floating type.

enumerator tinytc_status_ze_result_not_ready = 0x10000#

ZE_RESULT_NOT_READY.

enumerator tinytc_status_ze_result_error_device_lost = 0x10001#

ZE_RESULT_ERROR_DEVICE_LOST.

enumerator tinytc_status_ze_result_error_out_of_host_memory = 0x10002#

ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY.

enumerator tinytc_status_ze_result_error_out_of_device_memory = 0x10003#

ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY.

enumerator tinytc_status_ze_result_error_module_build_failure = 0x10004#

ZE_RESULT_ERROR_MODULE_BUILD_FAILURE.

ZE_RESULT_ERROR_MODULE_LINK_FAILURE.

enumerator tinytc_status_ze_result_error_device_requires_reset = 0x10006#

ZE_RESULT_ERROR_DEVICE_REQUIRES_RESET.

enumerator tinytc_status_ze_result_error_device_in_low_power_state = 0x10007#

ZE_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE.

enumerator tinytc_status_ze_result_exp_error_device_is_not_vertex = 0x10008#

ZE_RESULT_EXP_ERROR_DEVICE_IS_NOT_VERTEX.

enumerator tinytc_status_ze_result_exp_error_vertex_is_not_device = 0x10009#

ZE_RESULT_EXP_ERROR_VERTEX_IS_NOT_DEVICE.

enumerator tinytc_status_ze_result_exp_error_remote_device = 0x1000A#

ZE_RESULT_EXP_ERROR_REMOTE_DEVICE.

enumerator tinytc_status_ze_result_exp_error_operands_incompatible = 0x1000B#

ZE_RESULT_EXP_ERROR_OPERANDS_INCOMPATIBLE.

enumerator tinytc_status_ze_result_exp_rtas_build_retry = 0x1000C#

ZE_RESULT_EXP_RTAS_BUILD_RETRY.

enumerator tinytc_status_ze_result_exp_rtas_build_deferred = 0x1000D#

ZE_RESULT_EXP_RTAS_BUILD_DEFERRED.

enumerator tinytc_status_ze_result_error_insufficient_permissions = 0x1000E#

ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS.

enumerator tinytc_status_ze_result_error_not_available = 0x1000F#

ZE_RESULT_ERROR_NOT_AVAILABLE.

enumerator tinytc_status_ze_result_error_dependency_unavailable = 0x10010#

ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE.

enumerator tinytc_status_ze_result_warning_dropped_data = 0x10011#

ZE_RESULT_WARNING_DROPPED_DATA.

enumerator tinytc_status_ze_result_error_uninitialized = 0x10012#

ZE_RESULT_ERROR_UNINITIALIZED.

enumerator tinytc_status_ze_result_error_unsupported_version = 0x10013#

ZE_RESULT_ERROR_UNSUPPORTED_VERSION.

enumerator tinytc_status_ze_result_error_unsupported_feature = 0x10014#

ZE_RESULT_ERROR_UNSUPPORTED_FEATURE.

enumerator tinytc_status_ze_result_error_invalid_argument = 0x10015#

ZE_RESULT_ERROR_INVALID_ARGUMENT.

enumerator tinytc_status_ze_result_error_invalid_null_handle = 0x10016#

ZE_RESULT_ERROR_INVALID_NULL_HANDLE.

enumerator tinytc_status_ze_result_error_handle_object_in_use = 0x10017#

ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE.

enumerator tinytc_status_ze_result_error_invalid_null_pointer = 0x10018#

ZE_RESULT_ERROR_INVALID_NULL_POINTER.

enumerator tinytc_status_ze_result_error_invalid_size = 0x10019#

ZE_RESULT_ERROR_INVALID_SIZE.

enumerator tinytc_status_ze_result_error_unsupported_size = 0x1001A#

ZE_RESULT_ERROR_UNSUPPORTED_SIZE.

enumerator tinytc_status_ze_result_error_unsupported_alignment = 0x1001B#

ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT.

enumerator tinytc_status_ze_result_error_invalid_synchronization_object = 0x1001C#

ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT.

enumerator tinytc_status_ze_result_error_invalid_enumeration = 0x1001D#

ZE_RESULT_ERROR_INVALID_ENUMERATION.

enumerator tinytc_status_ze_result_error_unsupported_enumeration = 0x1001E#

ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION.

enumerator tinytc_status_ze_result_error_unsupported_image_format = 0x1001F#

ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT.

enumerator tinytc_status_ze_result_error_invalid_native_binary = 0x10020#

ZE_RESULT_ERROR_INVALID_NATIVE_BINARY.

enumerator tinytc_status_ze_result_error_invalid_global_name = 0x10021#

ZE_RESULT_ERROR_INVALID_GLOBAL_NAME.

enumerator tinytc_status_ze_result_error_invalid_kernel_name = 0x10022#

ZE_RESULT_ERROR_INVALID_KERNEL_NAME.

enumerator tinytc_status_ze_result_error_invalid_function_name = 0x10023#

ZE_RESULT_ERROR_INVALID_FUNCTION_NAME.

enumerator tinytc_status_ze_result_error_invalid_group_size_dimension = 0x10024#

ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION.

enumerator tinytc_status_ze_result_error_invalid_global_width_dimension = 0x10025#

ZE_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION.

enumerator tinytc_status_ze_result_error_invalid_kernel_argument_index = 0x10026#

ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX.

enumerator tinytc_status_ze_result_error_invalid_kernel_argument_size = 0x10027#

ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE.

enumerator tinytc_status_ze_result_error_invalid_kernel_attribute_value = 0x10028#

ZE_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE.

enumerator tinytc_status_ze_result_error_invalid_module_unlinked = 0x10029#

ZE_RESULT_ERROR_INVALID_MODULE_UNLINKED.

enumerator tinytc_status_ze_result_error_invalid_command_list_type = 0x1002A#

ZE_RESULT_ERROR_INVALID_COMMAND_LIST_TYPE.

enumerator tinytc_status_ze_result_error_overlapping_regions = 0x1002B#

ZE_RESULT_ERROR_OVERLAPPING_REGIONS.

enumerator tinytc_status_ze_result_warning_action_required = 0x1002C#

ZE_RESULT_WARNING_ACTION_REQUIRED.

enumerator tinytc_status_ze_result_error_unknown = 0x1002D#

ZE_RESULT_ERROR_UNKNOWN.

enumerator tinytc_status_cl_build_program_failure = 0x20000#

CL_BUILD_PROGRAM_FAILURE.

enumerator tinytc_status_cl_compile_program_failure = 0x20001#

CL_COMPILE_PROGRAM_FAILURE.

enumerator tinytc_status_cl_compiler_not_available = 0x20002#

CL_COMPILER_NOT_AVAILABLE.

enumerator tinytc_status_cl_device_not_found = 0x20003#

CL_DEVICE_NOT_FOUND.

enumerator tinytc_status_cl_device_not_available = 0x20004#

CL_DEVICE_NOT_AVAILABLE.

enumerator tinytc_status_cl_device_partition_failed = 0x20005#

CL_DEVICE_PARTITION_FAILED.

enumerator tinytc_status_cl_exec_status_error_for_events_in_wait_list = 0x20006#

CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST.

enumerator tinytc_status_cl_image_format_mismatch = 0x20007#

CL_IMAGE_FORMAT_MISMATCH.

enumerator tinytc_status_cl_image_format_not_supported = 0x20008#

CL_IMAGE_FORMAT_NOT_SUPPORTED.

enumerator tinytc_status_cl_invalid_arg_index = 0x20009#

CL_INVALID_ARG_INDEX.

enumerator tinytc_status_cl_invalid_arg_size = 0x2000A#

CL_INVALID_ARG_SIZE.

enumerator tinytc_status_cl_invalid_arg_value = 0x2000B#

CL_INVALID_ARG_VALUE.

enumerator tinytc_status_cl_invalid_binary = 0x2000C#

CL_INVALID_BINARY.

enumerator tinytc_status_cl_invalid_buffer_size = 0x2000D#

CL_INVALID_BUFFER_SIZE.

enumerator tinytc_status_cl_invalid_build_options = 0x2000E#

CL_INVALID_BUILD_OPTIONS.

enumerator tinytc_status_cl_invalid_command_queue = 0x2000F#

CL_INVALID_COMMAND_QUEUE.

enumerator tinytc_status_cl_invalid_compiler_options = 0x20010#

CL_INVALID_COMPILER_OPTIONS.

enumerator tinytc_status_cl_invalid_context = 0x20011#

CL_INVALID_CONTEXT.

enumerator tinytc_status_cl_invalid_device = 0x20012#

CL_INVALID_DEVICE.

enumerator tinytc_status_cl_invalid_device_partition_count = 0x20013#

CL_INVALID_DEVICE_PARTITION_COUNT.

enumerator tinytc_status_cl_invalid_device_queue = 0x20014#

CL_INVALID_DEVICE_QUEUE.

enumerator tinytc_status_cl_invalid_device_type = 0x20015#

CL_INVALID_DEVICE_TYPE.

enumerator tinytc_status_cl_invalid_event = 0x20016#

CL_INVALID_EVENT.

enumerator tinytc_status_cl_invalid_event_wait_list = 0x20017#

CL_INVALID_EVENT_WAIT_LIST.

enumerator tinytc_status_cl_invalid_global_offset = 0x20018#

CL_INVALID_GLOBAL_OFFSET.

enumerator tinytc_status_cl_invalid_global_work_size = 0x20019#

CL_INVALID_GLOBAL_WORK_SIZE.

enumerator tinytc_status_cl_invalid_host_ptr = 0x2001A#

CL_INVALID_HOST_PTR.

enumerator tinytc_status_cl_invalid_image_descriptor = 0x2001B#

CL_INVALID_IMAGE_DESCRIPTOR.

enumerator tinytc_status_cl_invalid_image_format_descriptor = 0x2001C#

CL_INVALID_IMAGE_FORMAT_DESCRIPTOR.

enumerator tinytc_status_cl_invalid_image_size = 0x2001D#

CL_INVALID_IMAGE_SIZE.

enumerator tinytc_status_cl_invalid_kernel = 0x2001E#

CL_INVALID_KERNEL.

enumerator tinytc_status_cl_invalid_kernel_args = 0x2001F#

CL_INVALID_KERNEL_ARGS.

enumerator tinytc_status_cl_invalid_kernel_definition = 0x20020#

CL_INVALID_KERNEL_DEFINITION.

enumerator tinytc_status_cl_invalid_kernel_name = 0x20021#

CL_INVALID_KERNEL_NAME.

enumerator tinytc_status_cl_invalid_linker_options = 0x20022#

CL_INVALID_LINKER_OPTIONS.

enumerator tinytc_status_cl_invalid_mem_object = 0x20023#

CL_INVALID_MEM_OBJECT.

enumerator tinytc_status_cl_invalid_operation = 0x20024#

CL_INVALID_OPERATION.

enumerator tinytc_status_cl_invalid_pipe_size = 0x20025#

CL_INVALID_PIPE_SIZE.

enumerator tinytc_status_cl_invalid_platform = 0x20026#

CL_INVALID_PLATFORM.

enumerator tinytc_status_cl_invalid_program = 0x20027#

CL_INVALID_PROGRAM.

enumerator tinytc_status_cl_invalid_program_executable = 0x20028#

CL_INVALID_PROGRAM_EXECUTABLE.

enumerator tinytc_status_cl_invalid_property = 0x20029#

CL_INVALID_PROPERTY.

enumerator tinytc_status_cl_invalid_queue_properties = 0x2002A#

CL_INVALID_QUEUE_PROPERTIES.

enumerator tinytc_status_cl_invalid_sampler = 0x2002B#

CL_INVALID_SAMPLER.

enumerator tinytc_status_cl_invalid_spec_id = 0x2002C#

CL_INVALID_SPEC_ID.

enumerator tinytc_status_cl_invalid_value = 0x2002D#

CL_INVALID_VALUE.

enumerator tinytc_status_cl_invalid_work_dimension = 0x2002E#

CL_INVALID_WORK_DIMENSION.

enumerator tinytc_status_cl_invalid_work_group_size = 0x2002F#

CL_INVALID_WORK_GROUP_SIZE.

enumerator tinytc_status_cl_invalid_work_item_size = 0x20030#

CL_INVALID_WORK_ITEM_SIZE.

enumerator tinytc_status_cl_kernel_arg_info_not_available = 0x20031#

CL_KERNEL_ARG_INFO_NOT_AVAILABLE.

CL_LINK_PROGRAM_FAILURE.

enumerator tinytc_status_cl_linker_not_available = 0x20033#

CL_LINKER_NOT_AVAILABLE.

enumerator tinytc_status_cl_map_failure = 0x20034#

CL_MAP_FAILURE.

enumerator tinytc_status_cl_mem_copy_overlap = 0x20035#

CL_MEM_COPY_OVERLAP.

enumerator tinytc_status_cl_mem_object_allocation_failure = 0x20036#

CL_MEM_OBJECT_ALLOCATION_FAILURE.

enumerator tinytc_status_cl_misaligned_sub_buffer_offset = 0x20037#

CL_MISALIGNED_SUB_BUFFER_OFFSET.

enumerator tinytc_status_cl_out_of_host_memory = 0x20038#

CL_OUT_OF_HOST_MEMORY.

enumerator tinytc_status_cl_out_of_resources = 0x20039#

CL_OUT_OF_RESOURCES.

enumerator tinytc_status_cl_max_size_restriction_exceeded = 0x2003A#

CL_MAX_SIZE_RESTRICTION_EXCEEDED.

enumerator tinytc_status_cl_profiling_info_not_available = 0x2003B#

CL_PROFILING_INFO_NOT_AVAILABLE.

enumerator tinytc_status_unknown = 0x7fffffff#

Unknown error occured.

tinytc_support_level_t#

enum tinytc_support_level_t#

Support level of a device.

Values:

enumerator tinytc_support_level_none = 0x0#

Device is unsupported (e.g. subgroups feature missing in OpenCL-C)

enumerator tinytc_support_level_basic = 0x1#

Device provides necessary features but is not well tested.

enumerator tinytc_support_level_tuned = 0x2#

Device provides necessary features and is well tested.

Common Definitions#

TINYTC_VERSION_MAJOR#

TINYTC_VERSION_MAJOR = 0;#

Major version (X.x.x)

TINYTC_VERSION_MINOR#

TINYTC_VERSION_MINOR = 3;#

Minor version (x.X.x)

TINYTC_VERSION_PATCH#

TINYTC_VERSION_PATCH = 0;#

Patch version (x.x.X)

TINYTC_VERSION_HASH#

TINYTC_VERSION_HASH = "2c614c9";#

Git commit hash.

TINYTC_VERSION_NUMBER_OF_COMMITS_SINCE_RELEASE#

TINYTC_VERSION_NUMBER_OF_COMMITS_SINCE_RELEASE = 0;#

Number of commits since last tag.

TINYTC_VERSION_DESCRIPTION#

TINYTC_VERSION_DESCRIPTION = "v0.3.0-0-2c614c9";#

Version string (vx.x.x-x-x)

Common Functions#

tinytc_error_string#

char const *tinytc_error_string(tinytc_status_t status)#

Translate status code to textual description.

Parameters:
  • status – [in] status code

Returns:

String

tinytc_string_destroy#

void tinytc_string_destroy(char *str)#

Delete a (non-const) string returned from tinytc API.

Parameters:
  • str – [in] string

Common Typedefs#

tinytc_binary_t#

typedef struct tinytc_binary *tinytc_binary_t#

binary handle

tinytc_bool_t#

typedef uint8_t tinytc_bool_t#

Bool type {0,1}.

tinytc_core_info_t#

typedef struct tinytc_core_info *tinytc_core_info_t#

core_info handle

tinytc_recipe_t#

typedef struct tinytc_recipe *tinytc_recipe_t#

recipe handle

tinytc_recipe_handler_t#

typedef struct tinytc_recipe_handler *tinytc_recipe_handler_t#

recipe_handler handle

tinytc_source_t#

typedef struct tinytc_source *tinytc_source_t#

source handle

tinytc_source_context_t#

typedef struct tinytc_source_context *tinytc_source_context_t#

source_context handle

const_tinytc_binary_t#

typedef const struct tinytc_binary *const_tinytc_binary_t#

const binary handle

const_tinytc_core_info_t#

typedef const struct tinytc_core_info *const_tinytc_core_info_t#

const core_info handle

const_tinytc_recipe_t#

typedef const struct tinytc_recipe *const_tinytc_recipe_t#

const recipe handle

const_tinytc_recipe_handler_t#

typedef const struct tinytc_recipe_handler *const_tinytc_recipe_handler_t#

const recipe_handler handle

const_tinytc_source_t#

typedef const struct tinytc_source *const_tinytc_source_t#

const source handle

const_tinytc_source_context_t#

typedef const struct tinytc_source_context *const_tinytc_source_context_t#

const source_context handle

Binary#

Binary Functions#

tinytc_binary_create#

tinytc_status_t tinytc_binary_create(tinytc_binary_t *bin, tinytc_bundle_format_t format, size_t data_size, uint8_t const *data, tinytc_core_feature_flags_t core_features)#

Create binary.

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

  • format – [in] Bundle format (SPIR-V or Native)

  • data_size – [in] Size of data in bytes

  • data – [in][range(0, data_size)] Binary data; data is copied

  • 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_binary_get_core_features#

tinytc_status_t tinytc_binary_get_core_features(const_tinytc_binary_t bin, tinytc_core_feature_flags_t *core_features)#

Get requested core features.

Parameters:
  • bin – [in] binary object

  • core_features – [out] core features

Returns:

tinytc_status_success on success and error otherwise

tinytc_binary_get_raw#

tinytc_status_t tinytc_binary_get_raw(const_tinytc_binary_t bin, tinytc_bundle_format_t *format, size_t *data_size, uint8_t const **data)#

Get raw binary data.

Parameters:
  • bin – [in] binary object

  • format – [out] binary format

  • data_size – [out] size of data

  • data – [out] data array; returned pointer is invalidated if the binary object is deleted

Returns:

tinytc_status_success on success and error otherwise

tinytc_binary_release#

tinytc_status_t tinytc_binary_release(tinytc_binary_t bin)#

Release binary object.

Decreases reference count by 1, free memory if reference count is 0.

Parameters:
  • bin – [inout] binary object

Returns:

tinytc_status_success on success and error otherwise

tinytc_binary_retain#

tinytc_status_t tinytc_binary_retain(tinytc_binary_t bin)#

Increase reference count of binary object by 1.

Parameters:
  • bin – [inout] binary object

Returns:

tinytc_status_success on success and error otherwise

Compiler#

Compiler Enumerations#

tinytc_bundle_format_t#

enum tinytc_bundle_format_t#

Target binary format.

Values:

enumerator tinytc_bundle_format_spirv = 0#

SPIR-V.

enumerator tinytc_bundle_format_native = 1#

Native device binary.

Compiler Functions#

tinytc_prog_compile_to_opencl#

tinytc_status_t tinytc_prog_compile_to_opencl(tinytc_source_t *src, tinytc_prog_t prg, const_tinytc_core_info_t info, tinytc_source_context_t ctx)#

Compile tensor language to OpenCL-C.

Parameters:
  • src – [out] pointer to the source object created

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

  • info – [in] core info object

  • 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

Device Info#

Device Info Enumerations#

tinytc_core_feature_flag_t#

enum tinytc_core_feature_flag_t#

Core features that may be optionally enabled.

Values:

enumerator tinytc_core_feature_flag_large_register_file = 0x1#

Request a large register file. On PVC this doubles the number of registers per vector engine but halves the number of available hardware threads. When this feature is activated, the kernel is compiled with the “-ze-opt-large-register-file” option.

tinytc_intel_gpu_architecture_t#

enum tinytc_intel_gpu_architecture_t#

IP versions for Intel GPUs.

Note: IP versions are extracted from

Values:

enumerator tinytc_intel_gpu_architecture_tgl = 0x03000000#

Tiger Lake.

enumerator tinytc_intel_gpu_architecture_pvc = 0x030f0007#

Ponte Vecchio.

Device Info Functions#

tinytc_core_info_get_core_features#

tinytc_status_t tinytc_core_info_get_core_features(tinytc_core_info_t info, tinytc_core_feature_flags_t *flags)#

Get core features.

Parameters:
  • info – [in] core info object

  • flags – [out] pointer to core feature flags

Returns:

tinytc_status_success on success and error otherwise

tinytc_core_info_get_register_space#

tinytc_status_t tinytc_core_info_get_register_space(const_tinytc_core_info_t info, int32_t *space)#

Returns register space per subgroup in bytes.

Parameters:
  • info – [in] core info object

  • space – [out] pointer to register space

Returns:

tinytc_status_success on success and error otherwise

tinytc_core_info_get_subgroup_sizes#

tinytc_status_t tinytc_core_info_get_subgroup_sizes(const_tinytc_core_info_t info, uint32_t *sgs_size, int32_t const **sgs)#

Returns available subgroup sizes.

Parameters:
  • info – [in] core info object

  • sgs_size – [out] pointer to number of subgroup sizes

  • sgs – [out] pointer to subgroup size array; pointer is invalidated when core info is deleted

Returns:

tinytc_status_success on success and error otherwise

tinytc_core_info_set_core_features#

tinytc_status_t tinytc_core_info_set_core_features(tinytc_core_info_t info, tinytc_core_feature_flags_t flags)#

Set core features.

Parameters:
  • info – [in] core info object

  • flags – [in] set core features; must be 0 or a combination of tinytc_core_feature_flag_t

Returns:

tinytc_status_success on success and error otherwise

tinytc_core_info_generic_create#

tinytc_status_t tinytc_core_info_generic_create(tinytc_core_info_t *info, int32_t register_space, int32_t max_work_group_size, uint32_t sgs_size, int32_t const *sgs)#

Create core_info for a generic GPUs.

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

  • register_space – [in] Size of register file per subgroup in bytes

  • max_work_group_size – [in] Maximum size of local work group

  • sgs_size – [in] Length of sgs array

  • sgs – [in] Allowed subgroup sizes

Returns:

tinytc_status_success on success and error otherwise

tinytc_core_info_intel_create#

tinytc_status_t tinytc_core_info_intel_create(tinytc_core_info_t *info, uint32_t ip_version, int32_t num_eus_per_subslice, int32_t num_threads_per_eu, uint32_t sgs_size, int32_t const *sgs)#

Create core_info for Intel GPUs.

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

  • ip_version – [in] IP version of architecture

  • num_eus_per_subslice – [in] Number of Execution Units (Xe Vector Engines) per subslice (Xe Core)

  • num_threads_per_eu – [in] Number of threads per Execution Unit (Xe Vector Engine)

  • sgs_size – [in] Length of sgs array

  • sgs – [in] Allowed subgroup sizes

Returns:

tinytc_status_success on success and error otherwise

tinytc_core_info_intel_create_from_arch#

tinytc_status_t tinytc_core_info_intel_create_from_arch(tinytc_core_info_t *info, tinytc_intel_gpu_architecture_t arch)#

Look up core info for Intel GPU architecture.

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

  • arch – [in] IP version

Returns:

tinytc_status_success on success and error otherwise

tinytc_core_info_release#

tinytc_status_t tinytc_core_info_release(tinytc_core_info_t obj)#

Release core info object.

Decreases reference count by 1, free memory if reference count is 0.

Parameters:
  • obj – [inout] core info object

Returns:

tinytc_status_success on success and error otherwise

tinytc_core_info_retain#

tinytc_status_t tinytc_core_info_retain(tinytc_core_info_t obj)#

Increase reference count of core info object by 1.

Parameters:
  • obj – [inout] core info object

Returns:

tinytc_status_success on success and error otherwise

Device Info Typedefs#

tinytc_core_feature_flags_t#

typedef uint32_t tinytc_core_feature_flags_t#

Type for combination of core feature flags.

Parser#

Parser Functions#

tinytc_parse_file#

tinytc_status_t tinytc_parse_file(tinytc_prog_t *prg, char const *filename, tinytc_source_context_t ctx)#

Parser tensor language source file and create prog.

Parameters:
  • prg – [out] pointer to prog object created

  • filename – [in] path to source file

  • ctx – [inout][optional] source context object; stores error log; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_parse_stdin#

tinytc_status_t tinytc_parse_stdin(tinytc_prog_t *prg, tinytc_source_context_t ctx)#

Parser tensor language source from stdin and create prog.

Parameters:
  • prg – [out] pointer to prog object created

  • ctx – [inout][optional] source context object; stores error log; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_parse_string#

tinytc_status_t tinytc_parse_string(tinytc_prog_t *prg, size_t source_size, char const *source, tinytc_source_context_t ctx)#

Parser tensor language source from string and create prog.

Parameters:
  • prg – [out] pointer to prog object created

  • source_size – [in] length of source string

  • source – [in] source string

  • ctx – [inout][optional] source context object; stores error log; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

Recipe#

Recipe Enumerations#

tinytc_mem_type_t#

enum tinytc_mem_type_t#

Memory object type.

Values:

enumerator tinytc_mem_type_buffer = 0x0#

Buffer object (e.g. cl_mem)

enumerator tinytc_mem_type_usm_pointer = 0x1#

Unified shared memory pointer.

enumerator tinytc_mem_type_svm_pointer = 0x2#

Shared virtual memory pointer.

Recipe Functions#

tinytc_recipe_get_prog#

tinytc_status_t tinytc_recipe_get_prog(const_tinytc_recipe_t recipe, tinytc_prog_t *prg)#

Get prog object.

Parameters:
  • recipe – [in] recipe object

  • prg – [out] pointer to prog object; reference count is increased so the user needs to call tinytc_prog_release to clean up

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_get_source#

tinytc_status_t tinytc_recipe_get_source(const_tinytc_recipe_t recipe, tinytc_source_t *src)#

Get source object.

Parameters:
  • recipe – [in] recipe object

  • src – [out] pointer to source object; reference count is increased so the user needs to call tinytc_source_release to clean up

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_handler_get_recipe#

tinytc_status_t tinytc_recipe_handler_get_recipe(const_tinytc_recipe_handler_t handler, tinytc_recipe_t *recipe)#

Get recipe object.

Parameters:
  • handler – [in] recipe handler object

  • recipe – [out] pointer to recipe object; reference count is increased so the user needs to call tinytc_recipe_release to clean up

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_small_gemm_batched_create#

tinytc_status_t tinytc_recipe_small_gemm_batched_create(tinytc_recipe_t *recipe, const_tinytc_core_info_t info, tinytc_scalar_type_t ty, tinytc_transpose_t tA, tinytc_transpose_t tB, int64_t M, int64_t N, int64_t K, int64_t ldA, int64_t strideA, int64_t ldB, int64_t strideB, int64_t ldC, int64_t strideC, tinytc_source_context_t ctx)#

Returns a small batched GEMM recipe.

The program contains a kernel for \(\beta=0\) called “gemm_beta0” and a kernel for \(\beta\neq 0\) called “gemm”. All matrix shapes and strides are known at compile-time.

The signature of the generated kernels gemm and gemm_beta0 is (if A and B are not transposed)

func @{name}(%alpha: {ty.alpha},
             %A: memref<{ty.A}x{M}x{K}x?,strided<1,{ldA},{strideA}>>,
             %B: memref<{ty.B}x{K}x{N}x?,strided<1,{ldB},{strideB}>>,
             %beta: {ty.beta},
             %C: memref<{ty.C}x{M}x{N}x?,strided<1,{ldC},{strideC}>>)

meaning that its kernels need arguments in the following order:

alpha, A_ptr, howmany, B_ptr, howmany, beta, C_ptr, howmany
Parameters:
  • recipe – [out] pointer to the recipe object created

  • info – [in] core info object

  • ty – [in] Scalar types of alpha, A, B, beta, C

  • tA – [in] Transpose A

  • tB – [in] Transpose B

  • M – [in] Number of rows of A, C

  • N – [in] Number of columns of B, C

  • K – [in] Number columns of A, number of rows of B

  • ldA – [in] Leading dimension of A

  • strideA – [in] Number of elements between A-matrices

  • ldB – [in] Leading dimension of B

  • strideB – [in] Number of elements between B-matrices

  • ldC – [in] Leading dimension of C

  • strideC – [in] Number of elements between C-matrices

  • ctx – [inout][optional] source context object; saves error log; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_small_gemm_batched_set_args#

tinytc_status_t tinytc_recipe_small_gemm_batched_set_args(tinytc_recipe_handler_t handler, int64_t howmany, size_t alpha_size, const void *alpha_value, tinytc_mem_type_t A_type, const void *A_value, tinytc_mem_type_t B_type, const void *B_value, size_t beta_size, const void *beta_value, tinytc_mem_type_t C_type, const void *C_value)#

Set kernel arguments for small GEMM batched recipe.

Parameters:
  • handler – [inout] Recipe handler object

  • howmany – [in] Group size

  • alpha_size – [in] Size of alpha argument

  • alpha_value – [in] Pointer to data used for alpha; data is copied

  • A_type – [in] Type of memory object used for A-matrix

  • A_value – [in] Memory object used for A-matrix

  • B_type – [in] Type of memory object used for B-matrix

  • B_value – [in] Memory object used for B-matrix

  • beta_size – [in] Size of beta argument

  • beta_value – [in] Pointer to data used for beta; data is copied

  • C_type – [in] Type of memory object used for C-matrix

  • C_value – [in] Memory object used for C-matrix

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_tall_and_skinny_create#

tinytc_status_t tinytc_recipe_tall_and_skinny_create(tinytc_recipe_t *recipe, const_tinytc_core_info_t info, tinytc_scalar_type_t ty, int64_t N, int64_t K, int32_t M_block_size, tinytc_source_context_t ctx)#

Returns a tall and skinny recipe.

The program contains a kernel for beta = 0 called “gemm_beta0” and a kernel for beta != 0 called “gemm”. M (= number of rows of A, C) and strides are dynamic.

The signature of the generated kernels gemm and gemm_beta0 is

func @{name}(%alpha: {ty.alpha},
             %A: memref<{ty.A}x?x{K},strided<1,?>>,
             %B: memref<{ty.B}x{K}x{N},strided<1,?>>,
             %beta: {ty.beta},
             %C: memref<{ty.C}x?x{N},strided<1,?>>)

meaning that its kernels need arguments in the following order:

alpha, A_ptr, M, ldA, B_ptr, ldB, beta, C_ptr, M, ldC

where ldA, ldB, ldC is the size of stride[1] of A, B, C, respectively.

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

  • info – [in] core info object

  • ty – [in] Scalar type of alpha, A, B, beta, C

  • N – [in] Number of columns of B, C

  • K – [in] Number columns of A, number of rows of B

  • M_block_size – [in][optional] Size of M block that each work group gets; pass 0 to have the parameter auto-selected

  • ctx – [inout][optional] source context object; saves error log; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_tall_and_skinny_create_specialized#

tinytc_status_t tinytc_recipe_tall_and_skinny_create_specialized(tinytc_recipe_t *recipe, const_tinytc_core_info_t info, tinytc_scalar_type_t ty, int64_t M, int64_t N, int64_t K, int64_t ldA, int64_t ldB, int64_t ldC, int32_t M_block_size, tinytc_source_context_t ctx)#

Returns a tall and skinny recipe with additional specialization constants.

Similar to tinytc_recipe_tall_and_skinny_create but with the additional specialization constants M, ldA, ldB, and ldC. The specializtion constants may be either set to a fixed value or to TINYTC_DYNAMIC. Note that if a specialization constant is set to a fixed value then the parameter with the same name in tinytc_recipe_tall_and_skinny_set_args is ignored.

The generated kernels have the following signature:

func @{name}(%alpha: {ty.alpha},
             %A: memref<{ty.A}x{M}x{K},strided<1,{ldA}>>,
             %B: memref<{ty.B}x{K}x{N},strided<1,{ldB}>>,
             %beta: {ty.beta},
             %C: memref<{ty.C}x{M}x{N},strided<1,{ldC}>>)
Parameters:
  • recipe – [out] pointer to the recipe object created

  • info – [in] core info object

  • ty – [in] Scalar type of alpha, A, B, beta, C

  • M – [in] Number of rows of A, C; can be TINYTC_DYNAMIC

  • N – [in] Number of columns of B, C

  • K – [in] Number columns of A, number of rows of B

  • ldA – [in] Leading dimension of A; can be TINYTC_DYNAMIC

  • ldB – [in] Leading dimension of B; can be TINYTC_DYNAMIC

  • ldC – [in] Leading dimension of C; can be TINYTC_DYNAMIC

  • M_block_size – [in][optional] Size of M block that each work group gets; pass 0 to have the parameter auto-selected

  • ctx – [inout][optional] source context object; saves error log; can be nullptr

Returns:

tinytc_recipe_tall_and_skinny_set_args#

tinytc_status_t tinytc_recipe_tall_and_skinny_set_args(tinytc_recipe_handler_t handler, int64_t M, size_t alpha_size, const void *alpha_value, tinytc_mem_type_t A_type, const void *A_value, int64_t ldA, tinytc_mem_type_t B_type, const void *B_value, int64_t ldB, size_t beta_size, const void *beta_value, tinytc_mem_type_t C_type, const void *C_value, int64_t ldC)#

Set kernel arguments for tall and skinny GEMM recipe.

Parameters:
  • handler – [inout] Recipe handler object

  • M – [in] Size of M-mode

  • alpha_size – [in] Size of alpha argument

  • alpha_value – [in] Pointer to data used for alpha; data is copied

  • A_type – [in] Type of memory object used for A-matrix

  • A_value – [in] Memory object used for A-matrix

  • ldA – [in] Leading dimension of A

  • B_type – [in] Type of memory object used for B-matrix

  • B_value – [in] Memory object used for B-matrix

  • ldB – [in] Leading dimension of B

  • beta_size – [in] Size of beta argument

  • beta_value – [in] Pointer to data used for beta; data is copied

  • C_type – [in] Type of memory object used for C-matrix

  • C_value – [in] Memory object used for C-matrix

  • ldC – [in] Leading dimension of C

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_tall_and_skinny_suggest_block_size#

tinytc_status_t tinytc_recipe_tall_and_skinny_suggest_block_size(const_tinytc_core_info_t info, int32_t *M_block_size)#

Suggest an M block size for tall and skinny recipe.

Parameters:
  • info – [in] core info object

  • M_block_size – [out] pointer to block size

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_release#

tinytc_status_t tinytc_recipe_release(tinytc_recipe_t obj)#

Release recipe object.

Decreases reference count by 1, free memory if reference count is 0.

Parameters:
  • obj – [inout] recipe object

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_retain#

tinytc_status_t tinytc_recipe_retain(tinytc_recipe_t obj)#

Increase reference count of recipe object by 1.

Parameters:
  • obj – [inout] recipe object

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_handler_release#

tinytc_status_t tinytc_recipe_handler_release(tinytc_recipe_handler_t obj)#

Release recipe handler object.

Decreases reference count by 1, free memory if reference count is 0.

Parameters:
  • obj – [inout] recipe handler object

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_handler_retain#

tinytc_status_t tinytc_recipe_handler_retain(tinytc_recipe_handler_t obj)#

Increase reference count of recipe handler object by 1.

Parameters:
  • obj – [inout] recipe handler object

Returns:

tinytc_status_success on success and error otherwise

Source#

Source Functions#

tinytc_source_get_code#

tinytc_status_t tinytc_source_get_code(const_tinytc_source_t src, size_t *length, char const **code)#

Get source text.

Parameters:
  • src – [in] source object

  • length – [out] pointer to code length

  • code – [out] code contains a pointer to the source text; the pointer is only valid as long as the source object is alive

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_get_core_features#

tinytc_status_t tinytc_source_get_core_features(const_tinytc_source_t src, tinytc_core_feature_flags_t *core_features)#

Get core features.

Parameters:
  • src – [in] source object

  • core_features – [out] pointer to core features

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_get_location#

tinytc_status_t tinytc_source_get_location(const_tinytc_source_t src, tinytc_location_t *loc)#

Get source location.

Parameters:
  • src – [in] source object

  • loc – [out] pointer to location

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_get_extensions#

tinytc_status_t tinytc_source_get_extensions(const_tinytc_source_t src, uint32_t *extensions_size, char const *const **extensions)#

Get required OpenCL extensions.

Parameters:
  • src – [in] source object

  • extensions_size – [out] pointer to number of extensions

  • extensions – [out][range(0,extensions_size)] pointer to array of C-strings; array owned by source object

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_release#

tinytc_status_t tinytc_source_release(tinytc_source_t obj)#

Release source object.

Decreases reference count by 1, free memory if reference count is 0.

Parameters:
  • obj – [inout] source object

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_retain#

tinytc_status_t tinytc_source_retain(tinytc_source_t obj)#

Increase reference count of source object by 1.

Parameters:
  • obj – [inout] source object

Returns:

tinytc_status_success on success and error otherwise

Source Context#

Source Context Functions#

tinytc_source_context_create#

tinytc_status_t tinytc_source_context_create(tinytc_source_context_t *ctx)#

Create source context.

The source context stores the tensor language source and enhaces error messages with source code context.

Parameters:
  • ctx – [out] pointer to the source context object created

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_context_add_source#

tinytc_status_t tinytc_source_context_add_source(tinytc_source_context_t ctx, char const *name, char const *text, int32_t *source_id)#

Add source context.

Manually add a source file to the source context that can be referenced in a tinytc_location. Useful to enhance error messages when using the builder methods and classes.

Parameters:
  • ctx – [in] source context object

  • name – [in] source name

  • text – [in] source text

  • source_id – [out] pointer to source id

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_context_get_error_log#

tinytc_status_t tinytc_source_context_get_error_log(const_tinytc_source_context_t ctx, char const **log)#

Get error log.

The string’s memory is owned by source context. Note that the pointer may invalidated by any function call involving the source context object, so the string should be copied or printed right after a call to this function.

Parameters:
  • ctx – [in] source context object

  • log – [out] pointer to string

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_context_report_error#

tinytc_status_t tinytc_source_context_report_error(tinytc_source_context_t ctx, const tinytc_location_t *location, char const *what, tinytc_bool_t append)#

Report an error and augment the error with source context.

Parameters:
  • ctx – [in] source context object

  • location – [in] source location

  • what – [in] error description

  • append – [in] true: append to error log, false: clear error log

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_context_release#

tinytc_status_t tinytc_source_context_release(tinytc_source_context_t obj)#

Release source context object.

Decreases reference count by 1, free memory if reference count is 0.

Parameters:
  • obj – [inout] source context object

Returns:

tinytc_status_success on success and error otherwise

tinytc_source_context_retain#

tinytc_status_t tinytc_source_context_retain(tinytc_source_context_t obj)#

Increase reference count of source context object by 1.

Parameters:
  • obj – [inout] source context object

Returns:

tinytc_status_success on success and error otherwise