DPC++ Runtime
Runtime libraries for oneAPI DPC++
esimd_emulator_device_interface.cpp
Go to the documentation of this file.
1 //==--------------- esimd_emulator_device_interface.cpp --------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
17 
18 #include <sycl/detail/common.hpp>
20 
22 namespace sycl {
23 namespace detail {
24 
25 __SYCL_EXPORT ESIMDDeviceInterface *getESIMDDeviceInterface() {
26  // TODO (performance) cache the interface pointer, can make a difference
27  // when calling fine-grained libCM APIs through it (like memory access in a
28  // tight loop)
29  void *PIOpaqueData = nullptr;
30 
31  try {
32  PIOpaqueData =
33  getPluginOpaqueData<sycl::backend::ext_intel_esimd_emulator>(nullptr);
34  } catch (...) {
35  std::cerr << "ESIMD EMU plugin error or not loaded - try setting "
36  "SYCL_DEVICE_FILTER=esimd_emulator:gpu environment variable"
37  << std::endl;
38  throw sycl::feature_not_supported();
39  }
40 
41  ESIMDEmuPluginOpaqueData *OpaqueData =
42  reinterpret_cast<ESIMDEmuPluginOpaqueData *>(PIOpaqueData);
43 
44  // First check if opaque data version is compatible.
45  if (OpaqueData->version != ESIMD_EMULATOR_PLUGIN_OPAQUE_DATA_VERSION) {
46  // NOTE: the version check should always be '!=' as layouts of different
47  // versions of PluginOpaqueData is not backward compatible, unlike
48  // layout of the ESIMDDeviceInterface.
49 
50  std::cerr << __FUNCTION__ << std::endl
51  << "Opaque data returned by ESIMD Emu plugin is incompatible with"
52  << "the one used in current implementation." << std::endl
53  << "Returned version : " << OpaqueData->version << std::endl
54  << "Required version : "
55  << ESIMD_EMULATOR_PLUGIN_OPAQUE_DATA_VERSION << std::endl;
56  throw feature_not_supported();
57  }
58  // Opaque data version is OK, can cast the 'data' field.
59  ESIMDDeviceInterface *Interface =
60  reinterpret_cast<ESIMDDeviceInterface *>(OpaqueData->data);
61 
62  // Now check that device interface version is compatible.
63  if (Interface->version < ESIMD_DEVICE_INTERFACE_VERSION) {
64  std::cerr << __FUNCTION__ << std::endl
65  << "The device interface version provided from plug-in "
66  << "library is behind required device interface version"
67  << std::endl
68  << "Found version : " << Interface->version << std::endl
69  << "Required version :" << ESIMD_DEVICE_INTERFACE_VERSION
70  << std::endl;
71  throw feature_not_supported();
72  }
73  return Interface;
74 }
75 } // namespace detail
76 } // namespace sycl
77 } // __SYCL_INLINE_NAMESPACE(cl)
esimd_emulator_device_interface.hpp
cl::sycl::detail::getESIMDDeviceInterface
ESIMDDeviceInterface * getESIMDDeviceInterface()
Definition: esimd_emulator_device_interface.cpp:25
cl::sycl::errc::feature_not_supported
@ feature_not_supported
sycl
Definition: invoke_simd.hpp:68
common.hpp
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
std::cerr
__SYCL_EXTERN_STREAM_ATTRS ostream cerr
Linked to standard error (unbuffered)
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:11