C++-API#

Common#

Common Functions#

CL_CHECK_STATUS#

inline void tinytc::CL_CHECK_STATUS(cl_int stat)#

Throw exception for unsuccessful call to C-API and convert result code to tinytc status.

Device Info#

Device Info Functions#

get_support_level(cl_device_id)#

inline auto tinytc::get_support_level(cl_device_id device) -> support_level#

Get support level of OpenCL device.

Parameters:

device – Device handle

Returns:

Support level

make_core_info(cl_device_id)#

inline auto tinytc::make_core_info(cl_device_id device) -> core_info#

Query core info from OpenCL runtime.

Parameters:

device – device handle

Returns:

core info

Kernel#

Kernel Functions#

get_global_size(std::int64_t,std::array<std::size_t, 3u> const &)#

inline auto tinytc::get_global_size(std::int64_t howmany, std::array<std::size_t, 3u> const &local_size) -> std::array<std::size_t, 3u>#

Convert group size to opencl global range.

Parameters:
  • howmany – Group size

  • local_size – Work-group size

Returns:

Global size

get_group_size(cl_kernel)#

inline auto tinytc::get_group_size(cl_kernel kernel) -> std::array<std::size_t, 3u>#

Get work group size.

Parameters:

kernel – Kernel

Returns:

Work-group size

make_kernel(cl_program,char const*)#

inline auto tinytc::make_kernel(cl_program mod, char const *name) -> shared_handle<cl_kernel>#

Make a cl_kernel from a cl_program.

Parameters:
  • mod – Program

  • name – Kernel name

Returns:

cl_kernel (shared handle)

make_kernel_bundle(cl_context,cl_device_id,binary const&,source_context)#

inline auto tinytc::make_kernel_bundle(cl_context context, cl_device_id device, binary const &bin, source_context source_ctx = {}) -> shared_handle<cl_program>#

Make an OpenCL program from a tinytc binary.

Parameters:
  • context – Context

  • device – Device

  • bin – Binary

  • source_ctx – Source context for improved error reporting

Returns:

cl_program (shared handle)

make_kernel_bundle(cl_context,cl_device_id,prog,tinytc_core_feature_flags_t,source_context)#

inline auto tinytc::make_kernel_bundle(cl_context context, cl_device_id device, prog prg, tinytc_core_feature_flags_t core_features = 0, source_context source_ctx = {}) -> shared_handle<cl_program>#

Make an OpenCL program from a tinytc program.

Parameters:
  • context – Context

  • device – Device

  • prg – Program

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

  • source_ctx – Source context for improved error reporting

Returns:

cl_program (shared handle)

make_kernel_bundle(cl_context,cl_device_id,source const&,source_context)#

inline auto tinytc::make_kernel_bundle(cl_context context, cl_device_id device, source const &src, source_context source_ctx = {}) -> shared_handle<cl_program>#

Make an OpenCL program from a tinytc source.

Parameters:
  • context – Context

  • device – Device

  • src – Source

  • source_ctx – Source context for improved error reporting

Returns:

cl_program (shared handle)

Recipe#

Recipe Functions#

make_recipe_handler(cl_context,cl_device_id,recipe const&,source_context)#

inline auto tinytc::make_recipe_handler(cl_context context, cl_device_id device, recipe const &rec, source_context source_ctx = {}) -> opencl_recipe_handler#

Make recipe handler.

Parameters:
  • context – Context

  • device – Device

  • rec – Recipe

  • source_ctx – Source context for improved error reporting

Returns:

OpenCL recipe handler

Recipe Classes#

opencl_recipe_handler#

class opencl_recipe_handler : public tinytc::recipe_handler#

Recipe handler for the OpenCL runtime.

Public Functions

inline auto submit(cl_command_queue queue, uint32_t num_wait_events = 0, cl_event *wait_events = nullptr) -> shared_handle<cl_event>#

Submit recipe to queue.

Parameters:
  • queue – Command queue

  • num_wait_events – Number of events to wait

  • wait_events – Array of num_wait_events events to wait on

Returns:

Event (cl_event wrapped in shared_handle -> cleans up automatically)

inline void submit_no_event(cl_command_queue queue, uint32_t num_wait_events = 0, cl_event *wait_events = nullptr)#

Submit recipe to queue; does not return event.

Parameters:
  • queue – Command queue

  • num_wait_events – Number of events to wait

  • wait_events – Array of num_wait_events events to wait on

Recipe Structures#

auto_mem_type<cl_mem>#

template<>
struct auto_mem_type<cl_mem>#

Specialize auto_mem_type for cl_mem.

Public Static Attributes

static constexpr mem_type value = mem_type::buffer#

cl_mem maps to buffer type