Plans#

A plan encapsulate the online compilation of an FFT and the setup of internal buffers. The cost of creating a plan is high, therefore plans should be reused. If you need to create plans multiple times consider caching.

Creating and executing plans#

SYCL factory functions#

auto bbfft::make_plan(configuration const &cfg, ::sycl::queue queue, jit_cache *cache = nullptr) -> sycl_plan#

Create a plan for the configuration.

Parameters:
  • cfg – configuration

  • queue – queue handle

  • cache – optional kernel cache

Returns:

plan

auto bbfft::make_plan(configuration const &cfg, ::sycl::queue queue, ::sycl::context context, ::sycl::device device, jit_cache *cache = nullptr) -> sycl_plan#

Create a plan for the configuration.

Parameters:
  • cfg – configuration

  • queue – queue handle

  • context – context handle

  • device – device handle

  • cache – optional kernel cache

Returns:

plan

OpenCL factory functions#

auto bbfft::make_plan(configuration const &cfg, cl_command_queue queue, jit_cache *cache = nullptr) -> opencl_plan#

Create a plan for the configuration.

Parameters:
  • cfg – configuration

  • queue – queue handle

  • cache – optional kernel cache

Returns:

plan

auto bbfft::make_plan(configuration const &cfg, cl_command_queue queue, cl_context context, cl_device_id device, jit_cache *cache = nullptr) -> opencl_plan#

Create a plan for the configuration.

Parameters:
  • cfg – configuration

  • queue – queue handle

  • context – context handle

  • device – device handle

  • cache – optional kernel cache

Returns:

plan

Level Zero factory function#

auto bbfft::make_plan(configuration const &cfg, ze_command_list_handle_t queue, ze_context_handle_t context, ze_device_handle_t device, jit_cache *cache = nullptr) -> level_zero_plan#

Create a plan for the configuration.

Parameters:
  • cfg – configuration

  • queue – queue handle

  • context – context handle

  • device – device handle

  • cache – optional kernel cache

Returns:

plan

Plan class#

template<typename EventT>
class plan : public bbfft::base_plan<detail::plan_impl<EventT>>#

The plan class contains the kernels to run a specific FFT configuration.

FFT kernels are specialized for the required problem size. Plans store the best kernels for the requested problem size or problem configuration.

Plan objects are not created directly but via make_plan.

Template Parameters:

EventT – event type of the compute runtime

Public Types

using event_t = EventT#

Event type returned by execute functions.

Public Functions

inline auto execute(mem const &in, mem const &out) -> event_t#

Execute plan (out-of-place)

Parameters:
  • in – Pointer to input tensor

  • out – Pointer to output tensor

Returns:

Completion event

inline auto execute(mem const &in, mem const &out, event_t dep_event) -> event_t#

Execute plan (out-of-place)

Parameters:
  • in – Pointer to input tensor

  • out – Pointer to output tensor

  • dep_event – Event to wait on before launching

Returns:

Completion event

inline auto execute(mem const &in, mem const &out, std::vector<event_t> const &dep_events) -> event_t#

Execute plan (out-of-place)

Parameters:
  • in – Pointer to input tensor

  • out – Pointer to output tensor

  • dep_events – Events to wait on before launching

Returns:

Completion event

inline auto execute(mem const &inout) -> event_t#

Execute plan (in-place)

Parameters:

inout – Pointer to input and output tensor

Returns:

Completion event

inline auto execute(mem const &inout, event_t dep_event) -> event_t#

Execute plan (in-place)

Parameters:
  • inout – Pointer to input and output tensor

  • dep_event – Event to wait on before launching

Returns:

Completion event

inline auto execute(mem const &inout, std::vector<event_t> const &dep_events) -> event_t#

Execute plan (in-place)

Parameters:
  • inout – Pointer to input and output tensor

  • dep_events – Events to wait on before launching

Returns:

Completion event

Mem struct#

struct mem#

Stores memory object and memory type.

Public Functions

template<typename T>
inline mem(T const value, mem_type type = auto_mem_type_v<T>)#

ctor

Template Parameters:

T – type

Parameters:
  • value – Memory object

  • type – Memory object type

Public Members

const void *value#

Memory object (either pointer or cl_mem)

mem_type type#

Memory object type.

enum class bbfft::mem_type#

Memory type.

Values:

enumerator buffer#

Buffer object (e.g. cl_mem)

enumerator usm_pointer#

Unified shared memory pointer.

enumerator svm_pointer#

Shared virtual memory pointer.

template<typename T, typename Enable = void>
struct auto_mem_type#

Automatically determine memory type.

Template Parameters:
  • T – type

  • Enable – Used for enable_if

template<typename T>
constexpr auto bbfft::auto_mem_type_v = auto_mem_type<T>::value#

Helper template for auto_mem_type.

Template Parameters:

T – type

Configuration errors#

Bad configuration#

class bad_configuration : public std::exception#

Exception type for faulty or unsupported configurations.

Public Functions

bad_configuration(std::string what)#

Constructor.

Parameters:

what – Explanatory string

bad_configuration(char const *what)#

Constructor.

Parameters:

what – Explanatory string

char const *what() const noexcept override#

Explanation of exception.

Returns:

Explanatory string

Level Zero#

ZE_CHECK(X)#

Checks Level Zero call for error and throws exception if call was not successful.

Parameters:
  • X – Level Zero call or ze_result_t status code

class error : public std::exception#

Level Zero error.

Public Functions

error(std::string what, ze_result_t status)#

Constructor.

Parameters:
  • what – Explanatory string

  • status – Status code returned by Level Zero

error(char const *what, ze_result_t status)#

Constructor.

Parameters:
  • what – Explanatory string

  • status – Status code returned by Level Zero

char const *what() const noexcept override#

Explanation.

Returns:

Explanatory string

ze_result_t error_code() const noexcept#

Level Zero status code.

Returns:

Status code

OpenCL#

CL_CHECK(X)#

Checks OpenCL call for error and throws exception if call was not successful.

Parameters:
  • X – OpenCL call or cl_int status code

class error : public std::exception#

OpenCL error.

Public Functions

error(std::string what, cl_int status)#

Constructor.

Parameters:
  • what – Explanatory string

  • status – Status code returned by OpenCL

error(char const *what, cl_int status)#

Constructor.

Parameters:
  • what – Explanatory string

  • status – Status code returned by OpenCL

char const *what() const noexcept override#

Explanation.

Returns:

Explanatory string

cl_int status_code() const noexcept#

OpenCL status code.

Returns:

Status code