API Design

This section documents the general features of oneIPL API design. In particular, it covers the use of namespaces and data types from C++, from DPC++ and new ones introduced for oneIPL APIs.

oneIPL Namespaces

All oneIPL objects and routines must be contained within the oneapi::ipl C++ namespace. Non-public APIs and headers must be contained within the detail namespace and corresponding folder.

Standard C++ Data Type

oneIPL uses C++ STL data types for scalars where applicable:

  • Integer scalars shall be C++ fixed-size integer types (std::intN_t, std::uintN_t).

  • Standard floating point types shall be float, double.

DPC++ datatype usage

oneIPL uses the following DPC++ data types:

  • SYCL standard floating point type sycl::half for fp16.

  • Unified Shared Memory (USM) for pointer-based memory access.

  • sycl::queue - SYCL queue for scheduling kernels on a SYCL device.

  • sycl::buffer - SYCL buffer for buffer-based memory access.

  • sycl::event - SYCL event for output event synchronization in oneIPL routines with USM pointers. See Synchronization for more details.

  • std::vector<sycl::event> - Vector of SYCL events for input events synchronization in oneIPL routines with USM pointers. See Synchronization for more details.

oneIPL Defined Data Types

oneIPL uses the scoped enum type for image formats.

Each enumeration value shall come with plural noun.

enum class oneapi::ipl::formats

Image formats supported by oneIPL.

Values:

enumerator rgb

Red Green Blue (RGB) image.

enumerator bgr

Blue Green Red (BGR) image.

enumerator rgba

Red Green Blue Alpha (RGBA) image.

enumerator bgra

Blue Green Red Alpha (BGRA) image.

enumerator nv12

NV12 image YYYYYYYY UVUV per pixel, 2 planes.

enumerator i420

I420 image YYYYYYYY UU VV per pixel, 3 planes.

enumerator plane

Plane memory (grayscale image, single channel)

enumerator rgbp

3-planes memory (RGBP)

Image Formats Support and Definitions

oneIPL supports a variety of image formats. Format is a memory layout. The data mapped to this layout also has a type, which defines a color component of a pixel. Currently, the majority of the functions support multi-channel interleaved formats, and some functions has support for sampled formats (nv12, i420) and plane format (rgbp). Potential combinations are provided in the table below, but the supported subset is in the function specification pages.

DataT/Formats

plane

rgb/bgr

rgba/bgra

rgbp

NV12

i420

std::uint8_t

v

v

v

v

v

v

std::int8_t

v

v

v

v

x

x

std::uint16_t

v

v

v

v

x

x

std::int16_t

v

v

v

v

x

x

std::uint32_t

v

v

v

v

x

x

std::int32_t

v

v

v

v

x

x

float

v

v

v

v

x

x

double

v

v

v

v

x

x

APIs support for particular format and type must be defined during compilation via template parameters. oneIPL uses custom image type, which is a fundamental class for the data representation:

namespace oneapi {
namespace ipl {

  /// Wrapper class for different image implementations (using image memory or USM).
  template <formats Format, typename DataT, typename AllocatorT = select_image_allocator_t<Format, DataT>>
  class image final : public detail::image_impl_t<Format, DataT, AllocatorT>;
}
}

Internal computations must also be controlled during compilation via the ComputeT parameter. The default value for ComputeT is float. Potential combinations are provided in the table below, but the supported subset is in the function specification pages. Computations in integers may be used in some cases. This behavior must be specified explicitly in a function specification.

Supported values for ComputeT:

float

double

half

v

v

x

  • API must take a ComputeT as template parameter.

  • Compile-time checks must restrict APIs as much as possible using SFINAE constructs.

  • API targeting to device must take a device queue_t, source data, destination data.

  • API may optionally take spec with additional algorithmic parameters and dependencies to other async calls (generic list of sycl::event objects).

  • Default values for spec and dependencies must be in API declaration to make them optional.

Generic oneIPL API has the following syntax:

namespace oneapi {
namespace ipl {
  template <typename ComputeT = float,
            formats SrcFormat,
            typename SrcDataT,
            typename SrcAllocatorT,
            typename DstDataT,
            typename DstAllocatorT>
  sycl::event convert(sycl::queue&                            queue,
              image<SrcFormat, SrcDataT, SrcAllocatorT>&      src,
              image<formats::plane, DstDataT, DstAllocatorT>& dst,
              const convert_spec<DstDataT>&                   spec         = {},
              const std::vector<sycl::event>&                 dependencies = {});
}
}