DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
DPC++ User API
Collaboration diagram for DPC++ User API:

Modules

 Device selectors
 Device selectors enable DPC++ runtime to choose the best devices based on heuristics specified by the user, or by one of the built-in selectors.
 
 Accessors
 Specify aquisition and release of buffer and image data structures.
 

Classes

class  cl::sycl::buffer< T, dimensions, AllocatorT, __Enabled >
 Defines a shared array that can be used by kernels in queues. More...
 
class  cl::sycl::context
 The context class represents a SYCL context on which kernel functions may be executed. More...
 
class  cl::sycl::device
 The SYCL device class encapsulates a single SYCL device on which kernels may be executed. More...
 
class  cl::sycl::device_event
 Encapsulates a single SYCL device event which is available only within SYCL kernel functions and can be used to wait for asynchronous operations within a kernel function to complete. More...
 
class  cl::sycl::event
 An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barriers. More...
 
class  cl::sycl::exception
 
class  cl::sycl::exception_list
 A list of asynchronous exceptions. More...
 
class  cl::sycl::group< Dimensions >
 Encapsulates all functionality required to represent a particular work-group within a parallel execution. More...
 
class  cl::sycl::h_item< dimensions >
 Identifies an instance of a group::parallel_for_work_item function object executing at each point in a local range passed to a parallel_for_work_item call or to the corresponding parallel_for_work_group call. More...
 
class  cl::sycl::handler
 Command group handler class. More...
 
class  cl::sycl::id< dimensions >
 A unique identifier of an item in an index space. More...
 
class  cl::sycl::image< Dimensions, AllocatorT >
 Defines a shared image data. More...
 
class  cl::sycl::item< dimensions, with_offset >
 Identifies an instance of the function object executing at each point in a range. More...
 
class  cl::sycl::kernel
 Provides an abstraction of a SYCL kernel. More...
 
class  cl::sycl::kernel_id
 Objects of the class identify kernel is some kernel_bundle related APIs. More...
 
class  cl::sycl::kernel_bundle< State >
 The kernel_bundle class represents collection of device images in a particular state. More...
 
class  cl::sycl::kernel_handler
 Reading the value of a specialization constant. More...
 
class  cl::sycl::marray< Type, NumElements >
 Provides a cross-patform math array class template that works on SYCL devices as well as in host C++ code. More...
 
class  cl::sycl::multi_ptr< ElementType, Space >
 Provides constructors for address space qualified and non address space qualified pointers to allow interoperability between plain C++ and OpenCL C. More...
 
class  cl::sycl::nd_item< dimensions >
 Identifies an instance of the function object executing at each point in an nd_range. More...
 
class  cl::sycl::nd_range< dimensions >
 Defines the iteration domain of both the work-groups and the overall dispatch. More...
 
class  cl::sycl::platform
 Encapsulates a SYCL platform on which kernels may be executed. More...
 
class  cl::sycl::property_list
 Objects of the property_list class are containers for the SYCL properties. More...
 
class  cl::sycl::queue
 Encapsulates a single SYCL queue which schedules kernels on a SYCL device. More...
 
class  cl::sycl::range< dimensions >
 Defines the iteration domain of either a single work-group in a parallel dispatch, or the overall dimensions of the dispatch. More...
 
class  cl::sycl::sampler
 Encapsulates a configuration for sampling an image accessor. More...
 
class  cl::sycl::specialization_id< T >
 Declaring a specialization constant. More...
 
class  cl::sycl::stream
 A buffered output stream that allows outputting the values of built-in, vector and SYCL types to the console. More...
 
class  cl::sycl::vec< Type, NumElements >
 Provides a cross-patform vector class template that works efficiently on SYCL devices as well as in host C++ code. More...
 
class  cl::sycl::ext::oneapi::accessor_property_list< PropsT >
 Objects of the accessor_property_list class are containers for the SYCL properties. More...
 

Detailed Description

Todo:
a more specific intro

A sample DPC++ application:

#include <CL/sycl.hpp>
using namespace cl::sycl;
int main() {
// Create a buffer of 4 ints to be used inside the kernel code.
buffer<int, 1> Buffer(4);
// Create a simple asynchronous exception handler.
auto AsyncHandler = [](exception_list ExceptionList) {
for (auto &Exception : ExceptionList) {
std::rethrow_exception(Exception);
}
};
// Create a SYCL queue.
queue Queue(AsyncHandler);
// Size of index space for kernel.
range<1> NumOfWorkItems{Buffer.size()};
// Submit command group(work) to queue.
Queue.submit([&](handler &cgh) {
// Get write only access to the buffer on a device.
auto Accessor = Buffer.get_access<access::mode::write>(cgh);
// Execute kernel.
cgh.parallel_for<class FillBuffer>(NumOfWorkItems, [=](id<1> WIid) {
// Fill buffer with indices.
Accessor[WIid] = static_cast<int>(WIid.get(0));
});
});
// Get read only access to the buffer on the host.
// This introduces an implicit barrier which blocks execution until the
// command group above completes.
const auto HostAccessor = Buffer.get_access<access::mode::read>();
// Check the results.
bool MismatchFound = false;
for (size_t I = 0; I < Buffer.size(); ++I) {
if (HostAccessor[I] != I) {
std::cout << "The result is incorrect for element: " << I
<< " , expected: " << I << " , got: " << HostAccessor[I]
<< std::endl;
MismatchFound = true;
}
}
if (!MismatchFound) {
std::cout << "The results are correct!" << std::endl;
}
return MismatchFound;
}
cl::sycl::access::mode::read
@ read
cl::sycl::id< 1 >
cl::sycl
Definition: access.hpp:14
cl::sycl::queue
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:103
cl::sycl::buffer
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:46
cl::sycl::range< 1 >
cl::sycl::range::size
size_t size() const
Definition: range.hpp:50
cl::sycl::handler::parallel_for
void parallel_for(range< 1 > NumWorkItems, KernelType KernelFunc)
Definition: handler.hpp:1325
sycl.hpp
cl::sycl::handler
Command group handler class.
Definition: handler.hpp:361
cl::sycl::access::mode::write
@ write
cl::sycl::exception_list
A list of asynchronous exceptions.
Definition: exception_list.hpp:30