#include <detail/program_impl.hpp>
Public Member Functions | |
program_impl ()=delete | |
program_impl (ContextImplPtr Context, const property_list &PropList) | |
Constructs an instance of program. More... | |
program_impl (ContextImplPtr Context, std::vector< device > DeviceList, const property_list &PropList) | |
Constructs an instance of SYCL program for the provided DeviceList. More... | |
program_impl (std::vector< std::shared_ptr< program_impl >> ProgramList, std::string LinkOptions, const property_list &PropList) | |
Constructs an instance of SYCL program by linking together each SYCL program instance in ProgramList. More... | |
program_impl (ContextImplPtr Context, pi_native_handle InteropProgram) | |
Constructs a program instance from an interop raw BE program handle. More... | |
program_impl (ContextImplPtr Context, sycl::detail::pi::PiKernel Kernel) | |
Constructs a program instance from plugin interface interoperability kernel. More... | |
~program_impl () | |
template<typename propertyT > | |
bool | has_property () const |
Checks if this program_impl has a property of type propertyT. More... | |
template<typename propertyT > | |
propertyT | get_property () const |
Gets the specified property of this program_impl. More... | |
cl_program | get () const |
Returns a valid cl_program instance. More... | |
sycl::detail::pi::PiProgram & | getHandleRef () |
const sycl::detail::pi::PiProgram & | getHandleRef () const |
bool | is_host () const |
void | compile_with_kernel_name (std::string KernelName, std::string CompileOptions) |
Compiles the SYCL kernel function into the encapsulated raw program. More... | |
void | build_with_kernel_name (std::string KernelName, std::string BuildOptions) |
Builds the SYCL kernel function into encapsulated raw program. More... | |
void | link (std::string LinkOptions="") |
Links encapsulated raw program. More... | |
bool | has_kernel (std::string KernelName, bool IsCreatedFromSource) const |
Checks if kernel is available for this program. More... | |
kernel | get_kernel (std::string KernelName, std::shared_ptr< program_impl > PtrToSelf, bool IsCreatedFromSource) const |
Returns a SYCL kernel for the SYCL kernel function defined by kernel name. More... | |
std::vector< std::vector< char > > | get_binaries () const |
Returns built program binaries. More... | |
context | get_context () const |
const PluginPtr & | getPlugin () const |
ContextImplPtr | getContextImplPtr () const |
std::vector< device > | get_devices () const |
std::string | get_compile_options () const |
Returns compile options that were provided when the encapsulated program was explicitly compiled. More... | |
std::string | get_link_options () const |
Returns compile options that were provided to the most recent invocation of link member function. More... | |
std::string | get_build_options () const |
Returns the compile, link, or build options, from whichever of those operations was performed most recently on the encapsulated cl_program. More... | |
program_state | get_state () const |
void | flush_spec_constants (const RTDeviceBinaryImage &Img, sycl::detail::pi::PiProgram NativePrg=nullptr) const |
Takes current values of specialization constants and "injects" them into the underlying native program program via specialization constant managemment PI APIs. More... | |
void | stableSerializeSpecConstRegistry (SerializedObj &Dst) const |
bool | hasSetSpecConstants () const |
Tells whether a specialization constant has been set for this program. More... | |
bool | is_cacheable () const |
pi_native_handle | getNative () const |
Returns the native plugin handle. More... | |
bool | isInterop () const |
Definition at line 36 of file program_impl.hpp.
|
delete |
|
explicit |
Constructs an instance of program.
The program will be created in the program_state::none state and associated with the provided context and the devices that are associated with the context.
Context | is a pointer to SYCL context impl. |
PropList | is an instance of property_list. |
Definition at line 29 of file program_impl.cpp.
sycl::_V1::detail::program_impl::program_impl | ( | ContextImplPtr | Context, |
std::vector< device > | DeviceList, | ||
const property_list & | PropList | ||
) |
Constructs an instance of SYCL program for the provided DeviceList.
The program will be created in the program_state::none state and associated with the provided context and the devices in the provided DeviceList.
Context | is a pointer to SYCL context impl. |
DeviceList | is a list of SYCL devices. |
PropList | is an instance of property_list. |
Definition at line 34 of file program_impl.cpp.
sycl::_V1::detail::program_impl::program_impl | ( | std::vector< std::shared_ptr< program_impl >> | ProgramList, |
std::string | LinkOptions, | ||
const property_list & | PropList | ||
) |
Constructs an instance of SYCL program by linking together each SYCL program instance in ProgramList.
Each program in ProgramList must be in the program_state::compiled state and must be associated with the same SYCL context. Otherwise an invalid_object_error SYCL exception will be thrown. A feature_not_supported exception will be thrown if any device that the program is to be linked for returns false for the device information query info::device::is_linker_available. Kernels caching for linked programs won't be allowed due to only compiled state of each and every program in the list and thus unknown state of caching resolution.
ProgramList | is a list of program_impl instances. |
LinkOptions | is a string containing valid OpenCL link options. |
PropList | is an instance of property_list. |
Definition at line 46 of file program_impl.cpp.
References sycl::_V1::detail::compiled, getPlugin(), is_host(), sycl::_V1::detail::linked, and piProgramLink().
sycl::_V1::detail::program_impl::program_impl | ( | ContextImplPtr | Context, |
pi_native_handle | InteropProgram | ||
) |
Constructs a program instance from an interop raw BE program handle.
TODO: BE generalization will change that to something better.
The state of the constructed program can be either program_state::compiled or program_state::linked, depending on the state of the InteropProgram. Otherwise an invalid_object_error SYCL exception is thrown.
The instance of the program will be retained on construction.
Context | is a pointer to SYCL context impl. |
InteropProgram | is an instance of plugin interface interoperability program. |
Definition at line 119 of file program_impl.cpp.
sycl::_V1::detail::program_impl::program_impl | ( | ContextImplPtr | Context, |
sycl::detail::pi::PiKernel | Kernel | ||
) |
Constructs a program instance from plugin interface interoperability kernel.
Context | is a pointer to SYCL context impl. |
Kernel | is a raw PI kernel handle. |
Definition at line 201 of file program_impl.cpp.
sycl::_V1::detail::program_impl::~program_impl | ( | ) |
Definition at line 209 of file program_impl.cpp.
References getPlugin(), is_host(), and piProgramRelease().
void sycl::_V1::detail::program_impl::build_with_kernel_name | ( | std::string | KernelName, |
std::string | BuildOptions | ||
) |
Builds the SYCL kernel function into encapsulated raw program.
The SYCL kernel function is defined by the kernel name. This member function sets the state of this SYCL program to program_state::linked. If the program was not in the program_state::none state, an invalid_object_error SYCL exception is thrown. If the compilation fails, a compile_program_error SYCL exception is thrown. If any device that the program is being built for returns false for the device information queries info::device::is_compiler_available or info::device::is_linker_available, a feature_not_supported SYCL exception is thrown.
KernelName | is a string containing SYCL kernel name. |
BuildOptions | is a string containing OpenCL compile options. |
M | is an OS handle to user code module. |
void sycl::_V1::detail::program_impl::compile_with_kernel_name | ( | std::string | KernelName, |
std::string | CompileOptions | ||
) |
Compiles the SYCL kernel function into the encapsulated raw program.
The kernel function is defined by its name. This member function sets the state of this SYCL program to program_state::compiled. If this program was not in the program_state::none state, an invalid_object_error exception is thrown. If the compilation fails, a compile_program_error SYCL exception is thrown. If any device that the program is being compiled for returns false for the device information query info::device::is_compiler_available, a feature_not_supported exception is thrown.
KernelName | is a string containing SYCL kernel name. |
CompileOptions | is a string of valid OpenCL compile options. |
Module | is an OS handle to user code module. |
Definition at line 228 of file program_impl.cpp.
References sycl::_V1::detail::compiled, is_host(), and sycl::_V1::detail::none.
void sycl::_V1::detail::program_impl::flush_spec_constants | ( | const RTDeviceBinaryImage & | Img, |
sycl::detail::pi::PiProgram | NativePrg = nullptr |
||
) | const |
Takes current values of specialization constants and "injects" them into the underlying native program program via specialization constant managemment PI APIs.
The native program passed as non-null argument overrides the MProgram native program field.
Img | device binary image corresponding to this program, used to resolve spec constant name to SPIR-V integer ID |
NativePrg | if not null, used as the flush target, otherwise MProgram is used |
Definition at line 446 of file program_impl.cpp.
References sycl::_V1::detail::DeviceBinaryProperty::asByteArray(), sycl::_V1::detail::ByteArray::consume(), sycl::_V1::detail::ByteArray::dropBytes(), sycl::_V1::detail::ByteArray::empty(), get_context(), getHandleRef(), sycl::_V1::detail::RTDeviceBinaryImage::getSpecConstants(), sycl::_V1::detail::getSyclObjImpl(), sycl::_V1::detail::spec_constant_impl::getValuePtr(), sycl::_V1::detail::spec_constant_impl::isSet(), and piextProgramSetSpecializationConstant().
Referenced by sycl::_V1::detail::ProgramManager::flushSpecConstants().
cl_program sycl::_V1::detail::program_impl::get | ( | ) | const |
Returns a valid cl_program instance.
The instance of cl_program will be retained before returning. If the program is created for a SYCL host device, an invalid_object_error exception is thrown.
Definition at line 217 of file program_impl.cpp.
References getPlugin(), is_host(), sycl::_V1::detail::none, and piProgramRetain().
Referenced by sycl::_V1::detail::ProgramManager::flushSpecConstants().
std::vector< std::vector< char > > sycl::_V1::detail::program_impl::get_binaries | ( | ) | const |
Returns built program binaries.
If this program is not in the program_state::compiled or program_state::linked states, an invalid_object_error SYCL exception is thrown.
Definition at line 315 of file program_impl.cpp.
References getPlugin(), is_host(), sycl::_V1::detail::none, PI_PROGRAM_INFO_BINARIES, PI_PROGRAM_INFO_BINARY_SIZES, and piProgramGetInfo().
|
inline |
Returns the compile, link, or build options, from whichever of those operations was performed most recently on the encapsulated cl_program.
If no compile, link, or build operations have been performed on this program, or if the program includes the host device in its device list, then an empty string is returned.
Definition at line 270 of file program_impl.hpp.
|
inline |
Returns compile options that were provided when the encapsulated program was explicitly compiled.
If the program was built instead of explicitly compiled, if the program has not yet been compiled, or if the program has been compiled for only the host device, then an empty string is return, unless the underlying cl_program was explicitly compiled, in which case the compile options used in the explicit compile are returned.
Definition at line 244 of file program_impl.hpp.
|
inline |
Definition at line 217 of file program_impl.hpp.
References is_host().
Referenced by flush_spec_constants().
|
inline |
Definition at line 232 of file program_impl.hpp.
kernel sycl::_V1::detail::program_impl::get_kernel | ( | std::string | KernelName, |
std::shared_ptr< program_impl > | PtrToSelf, | ||
bool | IsCreatedFromSource | ||
) | const |
Returns a SYCL kernel for the SYCL kernel function defined by kernel name.
If program is in the program_state::none state or if the SYCL kernel function is not available, an invalid_object_error exception is thrown.
Definition at line 298 of file program_impl.cpp.
References is_host(), and sycl::_V1::detail::none.
|
inline |
Returns compile options that were provided to the most recent invocation of link member function.
If the program has not been explicitly linked using the aforementioned function, constructed with an explicitly linking constructor, or if the program has been linked for only the host device, then an empty string is returned. If the program was constructed from cl_program, then an empty string is returned unless the cl_program was explicitly linked, in which case the link options used in that explicit link are returned. If the program object was constructed using a constructor form that links a vector of programs, then the link options passed to this constructor are returned.
Definition at line 260 of file program_impl.hpp.
|
inline |
Gets the specified property of this program_impl.
Throws invalid_object_error if this program_impl does not have a property of type propertyT.
Definition at line 117 of file program_impl.hpp.
References sycl::_V1::property_list::get_property().
|
inline |
Definition at line 273 of file program_impl.hpp.
|
inline |
Definition at line 229 of file program_impl.hpp.
Referenced by getNative().
|
inline |
Definition at line 132 of file program_impl.hpp.
Referenced by flush_spec_constants(), and sycl::_V1::detail::ProgramManager::flushSpecConstants().
|
inline |
Definition at line 135 of file program_impl.hpp.
pi_native_handle sycl::_V1::detail::program_impl::getNative | ( | ) | const |
Returns the native plugin handle.
Definition at line 485 of file program_impl.cpp.
References getContextImplPtr(), getPlugin(), sycl::_V1::opencl, piextProgramGetNativeHandle(), and piProgramRetain().
|
inline |
Definition at line 224 of file program_impl.hpp.
References is_host().
Referenced by get(), get_binaries(), getNative(), has_kernel(), link(), program_impl(), and ~program_impl().
bool sycl::_V1::detail::program_impl::has_kernel | ( | std::string | KernelName, |
bool | IsCreatedFromSource | ||
) | const |
Checks if kernel is available for this program.
The SYCL kernel is defined by kernel name. If the program state is program_state::none an invalid_object_error SYCL exception is thrown.
Definition at line 270 of file program_impl.cpp.
References getPlugin(), is_host(), sycl::_V1::detail::none, and piextGetDeviceFunctionPointer().
|
inline |
Checks if this program_impl has a property of type propertyT.
Definition at line 107 of file program_impl.hpp.
References sycl::_V1::property_list::has_property().
|
inline |
Tells whether a specialization constant has been set for this program.
Definition at line 292 of file program_impl.hpp.
Referenced by sycl::_V1::detail::ProgramManager::flushSpecConstants().
|
inline |
Definition at line 295 of file program_impl.hpp.
|
inline |
Definition at line 138 of file program_impl.hpp.
Referenced by compile_with_kernel_name(), get(), get_binaries(), get_context(), get_kernel(), getPlugin(), has_kernel(), link(), program_impl(), and ~program_impl().
|
inline |
Definition at line 300 of file program_impl.hpp.
void sycl::_V1::detail::program_impl::link | ( | std::string | LinkOptions = "" | ) |
Links encapsulated raw program.
This member function sets the state of this SYCL program to program_state::linked. If the program was not in the program_state::compiled state, an invalid_object_error SYCL exception is thrown. If linking fails, a compile_program_error is thrown. If any device that the program is to be linked for returns false for the device information query info::device::is_linker_available, a feature_not_supported exception is thrown.
LinkOptions | is a string containing OpenCL link options. |
Definition at line 241 of file program_impl.cpp.
References sycl::_V1::detail::compiled, sycl::_V1::detail::SYCLConfig< Config >::get(), getPlugin(), is_host(), sycl::_V1::detail::linked, piProgramLink(), and piProgramRelease().
|
inline |
Definition at line 287 of file program_impl.hpp.
References sycl::_V1::detail::stableSerializeSpecConstRegistry().