DPC++ Runtime
Runtime libraries for oneAPI DPC++
posix_pi.cpp
Go to the documentation of this file.
1 //==---------------- posix_pi.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 
10 #include <sycl/detail/pi.hpp>
11 
12 #include <dlfcn.h>
13 #include <string>
14 
16 namespace sycl {
17 namespace detail {
18 namespace pi {
19 
20 void *loadOsLibrary(const std::string &PluginPath) {
21  // TODO: Check if the option RTLD_NOW is correct. Explore using
22  // RTLD_DEEPBIND option when there are multiple plugins.
23  void *so = dlopen(PluginPath.c_str(), RTLD_NOW);
24  if (!so && trace(TraceLevel::PI_TRACE_ALL)) {
25  char *Error = dlerror();
26  std::cerr << "SYCL_PI_TRACE[-1]: dlopen(" << PluginPath << ") failed with <"
27  << (Error ? Error : "unknown error") << ">" << std::endl;
28  }
29  return so;
30 }
31 
32 int unloadOsLibrary(void *Library) { return dlclose(Library); }
33 
34 void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName) {
35  return dlsym(Library, FunctionName.c_str());
36 }
37 
38 } // namespace pi
39 } // namespace detail
40 } // namespace sycl
41 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::detail::pi::PI_TRACE_ALL
@ PI_TRACE_ALL
Definition: pi.hpp:58
cl::sycl::detail::pi::getOsLibraryFuncAddress
void * getOsLibraryFuncAddress(void *Library, const std::string &FunctionName)
Definition: posix_pi.cpp:34
sycl
Definition: invoke_simd.hpp:68
pi.hpp
cl::sycl::detail::pi::unloadOsLibrary
int unloadOsLibrary(void *Library)
Definition: posix_pi.cpp:32
defines.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)
cl::sycl::detail::pi::loadOsLibrary
void * loadOsLibrary(const std::string &Library)
Definition: posix_pi.cpp:20
cl::sycl::detail::pi::trace
bool trace(TraceLevel level)
Definition: pi.cpp:366
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:11