DPC++ Runtime
Runtime libraries for oneAPI DPC++
|
|
Go to the documentation of this file.
30 : MAsyncHandler(AsyncHandler), MDevices(1, Device), MContext(nullptr),
31 MPlatform(), MPropList(PropList), MHostContext(Device.is_host()),
32 MSupportBufferLocationByDevices(NotChecked) {
39 : MAsyncHandler(AsyncHandler), MDevices(Devices), MContext(nullptr),
40 MPlatform(), MPropList(PropList), MHostContext(false),
41 MSupportBufferLocationByDevices(NotChecked) {
43 std::vector<RT::PiDevice> DeviceIds;
44 for (
const auto &D : MDevices) {
50 const bool UseCUDAPrimaryContext = MPropList.
has_property<
58 Props, DeviceIds.size(), DeviceIds.data(),
nullptr,
nullptr, &MContext);
61 DeviceIds.data(),
nullptr,
70 : MAsyncHandler(AsyncHandler), MDevices(), MContext(
PiContext), MPlatform(),
71 MHostContext(false), MSupportBufferLocationByDevices(NotChecked) {
73 std::vector<RT::PiDevice> DeviceIds;
74 size_t DevicesNum = 0;
79 DeviceIds.resize(DevicesNum);
83 &DeviceIds[0],
nullptr);
85 if (!DeviceIds.empty()) {
86 std::shared_ptr<detail::platform_impl> Platform =
89 MDevices.emplace_back(createSyclObjFromImpl<device>(
90 Platform->getOrMakeDeviceImpl(Dev, Platform)));
108 throw invalid_object_error(
109 "This instance of context doesn't support OpenCL interoperability.",
114 return pi::cast<cl_context>(MContext);
120 for (
auto LibProg : MCachedLibPrograms) {
121 assert(LibProg.second &&
"Null program must not be kept in the cache");
131 return MAsyncHandler;
135 cl_uint context_impl::get_info<info::context::reference_count>()
const {
139 this->getHandleRef(), this->
getPlugin());
141 template <>
platform context_impl::get_info<info::context::platform>()
const {
144 return createSyclObjFromImpl<platform>(MPlatform);
147 std::vector<cl::sycl::device>
148 context_impl::get_info<info::context::devices>()
const {
152 std::vector<cl::sycl::memory_order>
153 context_impl::get_info<info::context::atomic_memory_order_capabilities>()
163 pi::cast<pi_context_info>(
165 sizeof(Result), &Result,
nullptr);
169 std::vector<cl::sycl::memory_scope>
170 context_impl::get_info<info::context::atomic_memory_scope_capabilities>()
181 pi::cast<pi_context_info>(
183 sizeof(Result), &Result,
nullptr);
191 return MKernelProgramCache;
195 std::shared_ptr<detail::device_impl> Device)
const {
196 for (
auto D : MDevices)
212 if (MSupportBufferLocationByDevices !=
NotChecked)
213 return MSupportBufferLocationByDevices ==
Supported ? true :
false;
215 MSupportBufferLocationByDevices =
Supported;
216 for (
auto &Device : MDevices) {
217 if (!Device.has_extension(
"cl_intel_mem_alloc_buffer_location")) {
222 return MSupportBufferLocationByDevices ==
Supported ? true :
false;
@ atomic_memory_order_capabilities
static const plugin & getPlugin(backend Backend)
intptr_t pi_context_properties
bool has_property() const
pi_result piContextGetInfo(pi_context context, pi_context_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
static RetType get(RT::PiContext ctx, const plugin &Plugin)
Objects of the property_list class are containers for the SYCL properties.
@ PI_CONTEXT_INFO_NUM_DEVICES
@ PI_CONTEXT_INFO_DEVICES
backend getBackend(void) const
bool hasDevice(std::shared_ptr< detail::device_impl > Device) const
Returns true if and only if context contains the given device.
pi_result piContextRelease(pi_context context)
pi_result piProgramRelease(pi_program program)
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
void call(ArgsT... Args) const
Calls the API, traces the call, checks the result.
We provide new interfaces for matrix muliply in this patch:
std::vector< memory_order > readMemoryOrderBitfield(pi_memory_order_capabilities bits)
context_impl(const device &Device, async_handler AsyncHandler, const property_list &PropList)
Constructs a context_impl using a single SYCL devices.
pi_bitfield pi_memory_scope_capabilities
const async_handler & get_async_handler() const
Gets asynchronous exception handler.
The plugin class provides a unified interface to the underlying low-level runtimes for the device-agn...
uintptr_t pi_native_handle
pi_result piContextRetain(pi_context context)
cl_context get() const
Gets OpenCL interoperability context handle.
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
pi_native_handle getNative() const
Gets the native handle of the SYCL context.
pi_result piContextCreate(const pi_context_properties *properties, pi_uint32 num_devices, const pi_device *devices, void(*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data), void *user_data, pi_context *ret_context)
bool is_host() const
Checks if this context is a host context.
bool isBufferLocationSupported() const
const plugin & getPlugin() const
pi_result piextContextGetNativeHandle(pi_context context, pi_native_handle *nativeHandle)
Gets the native handle of a PI context object.
@ atomic_memory_scope_capabilities
std::vector< memory_scope > readMemoryScopeBitfield(pi_memory_scope_capabilities bits)
pi_bitfield pi_memory_order_capabilities
std::function< void(cl::sycl::exception_list)> async_handler
RT::PiContext & getHandleRef()
Gets the underlying context object (if any) without reference count modification.
#define __SYCL_PI_CONTEXT_PROPERTIES_CUDA_PRIMARY
PI context mapping to a CUDA context object.
PI device mapping to a CUdevice.
#define __SYCL_INLINE_NAMESPACE(X)
KernelProgramCache & getKernelProgramCache() const
void setContextPtr(const ContextPtr &AContext)