Developer Guide

Intel® oneAPI DPC++/C++ Compiler Handbook for FPGAs

ID 785441
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

FPGA Extensions

The following sections summarize FPGA extensions supported:

The device_global Extension

device_global Extension

FPGA Extension

Description

Example

sycl::ext::oneapi::experimental::device_global()

Introduces device-scoped memory allocations into SYCL that can be accessed within a kernel using C++ global variable syntax. These memory allocations have unique instances per SYCL device.

namespace exp = sycl::ext::oneapi::experimental;
using FPGAProperties = decltype(exp::properties(
    exp::device_image_scope, exp::host_access_none));
exp::device_global<int, FPGAProperties> val;

The fpga_datapath Extension

fpga_datapath Extension

FPGA Extension

Description

Example

sycl::ext::intel::experiments::fpga_datpath<T> The fpga_datapath extension is a class template templated on a type T, that represents an object of type T. It is a request to the compiler to implement that object in the datapath instead of an off-datapath memory.

The fpga_datapath template has reference wrapper-like semantics, and is implicitly convertible to the wrapped type.

Because C++ doesn't allow for overloading of the dot operator, a get() member of fpga_datapath allows the extractions of a reference to which the usual dot operator can be applied.

The fpga_datapath class template is functionally equivalent to the fpga_register memory attribute.

struct MyClass {
  bool x;
};

namespace intelexp = sycl::ext::intel::experimental;

sycl::queue q;
q.single_task([=] {
  intelexp::fpga_datapath<int[4]> fd1{1, 3, 5, 7};
  intelexp::fpga_datapath<MyClass> fd2;
  fm2.get().x = fm1[0];
});

The fpga_reg Extension

fpga_reg Extension

FPGA Extension

Description

Example

ext::intel::fpga_reg()

Helps the compiler infer at least one pipelining register in the datapath.

#include <sycl/ext/intel/fpga_extensions.hpp>
r[k] = ext::intel::fpga_reg(a[k]) + b[k];

The task_sequence Extension

The following table summarizes the task_sequence template parameters and function APIs:

task_sequence Template Parameters
Template Parameter Description
auto &f typename ReturnT, typename... ArgsT, ReturnT (&f)(ArgsT...) Callable f that defines the asynchronous task to be associated with the task_sequence.
uint32_t invocation_capacity The size of the hardware queue instantiated for async() function calls.
uint32_t response_capacity The size of the hardware queue instantiated to hold task function results.
task_sequence Function APIs
Function API Description
void async(ArgsT... Args) Asynchronously calls f with Args. Increments the number of outstanding tasks by 1.
ReturnT get() Synchronously retrieves the result of an asynchronous call.
~task_sequence() Destructor for task_sequence.