Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sycl/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ set(SYCL_COMMON_SOURCES
"builtins/native_math_functions.cpp"
"builtins/relational_functions.cpp"
"detail/accessor_impl.cpp"
"detail/adapter_impl.cpp"
"detail/allowlist.cpp"
"detail/bindless_images.cpp"
"detail/buffer_impl.cpp"
Expand Down
44 changes: 44 additions & 0 deletions sycl/source/detail/adapter_impl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file contains the definitions for the members of the adapter_impl
/// class.
///
//===----------------------------------------------------------------------===//

#include "adapter_impl.hpp"

namespace sycl {
inline namespace _V1 {
namespace detail {

void adapter_impl::ur_failed_throw_exception(sycl::errc errc,
ur_result_t ur_result) const {
assert(ur_result != UR_RESULT_SUCCESS);
std::string message =
__SYCL_UR_ERROR_REPORT(MBackend) + codeToString(ur_result);

if (ur_result == UR_RESULT_ERROR_ADAPTER_SPECIFIC) {
assert(!adapterReleased);
const char *last_error_message = nullptr;
int32_t adapter_error = 0;
ur_result = call_nocheck<UrApiKind::urAdapterGetLastError>(
MAdapter, &last_error_message, &adapter_error);
if (last_error_message)
message += "\n" + std::string(last_error_message) + "(adapter error )" +
std::to_string(adapter_error) + "\n";
}

throw set_ur_error(sycl::exception(sycl::make_error_code(errc), message),
ur_result);
}

} // namespace detail
} // namespace _V1
} // namespace sycl
27 changes: 4 additions & 23 deletions sycl/source/detail/adapter_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,8 @@ class adapter_impl {
/// \throw SYCL 2020 exception(errc) if ur_result is not UR_RESULT_SUCCESS
template <sycl::errc errc = sycl::errc::runtime>
void checkUrResult(ur_result_t ur_result) const {
if (ur_result == UR_RESULT_ERROR_ADAPTER_SPECIFIC) {
assert(!adapterReleased);
const char *message = nullptr;
int32_t adapter_error = 0;
ur_result = call_nocheck<UrApiKind::urAdapterGetLastError>(
MAdapter, &message, &adapter_error);
throw sycl::detail::set_ur_error(
sycl::exception(
sycl::make_error_code(errc),
__SYCL_UR_ERROR_REPORT(MBackend) +
sycl::detail::codeToString(ur_result) +
(message ? "\n" + std::string(message) + "(adapter error )" +
std::to_string(adapter_error) + "\n"
: std::string{})),
ur_result);
}
if (ur_result != UR_RESULT_SUCCESS) {
throw sycl::detail::set_ur_error(
sycl::exception(sycl::make_error_code(errc),
__SYCL_UR_ERROR_REPORT(MBackend) +
sycl::detail::codeToString(ur_result)),
ur_result);
}
if (__builtin_expect(ur_result != UR_RESULT_SUCCESS, false))
ur_failed_throw_exception(errc, ur_result);
}

std::vector<ur_platform_handle_t> &getUrPlatforms() {
Expand Down Expand Up @@ -225,6 +204,8 @@ class adapter_impl {
bool adapterReleased = false;

private:
void ur_failed_throw_exception(sycl::errc errc, ur_result_t ur_result) const;

ur_adapter_handle_t MAdapter;
backend MBackend;
// Mutex to guard UrPlatforms and LastDeviceIds.
Expand Down
6 changes: 0 additions & 6 deletions sycl/source/detail/event_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ static uint64_t inline getTimestamp(device_impl *Device) {
}
}

ur_event_handle_t event_impl::getHandle() const { return MEvent.load(); }

void event_impl::setHandle(const ur_event_handle_t &UREvent) {
MEvent.store(UREvent);
}

context_impl &event_impl::getContextImpl() {
initContextIfNeeded();
assert(MContext && "Trying to get context from a host event!");
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/event_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ class event_impl {
void setComplete();

/// Returns raw interoperability event handle.
ur_event_handle_t getHandle() const;
ur_event_handle_t getHandle() const { return MEvent.load(); }

/// Set event handle for this event object.
void setHandle(const ur_event_handle_t &UREvent);
void setHandle(const ur_event_handle_t &UREvent) { MEvent.store(UREvent); }

/// Returns context that is associated with this event.
context_impl &getContextImpl();
Expand Down
6 changes: 0 additions & 6 deletions unified-runtime/source/loader/ur_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,9 @@
#include <stdlib.h>

namespace ur_lib {
///////////////////////////////////////////////////////////////////////////////
context_t *getContext() { return context_t::get_direct(); }

///////////////////////////////////////////////////////////////////////////////
context_t::context_t() { parseEnvEnabledLayers(); }

///////////////////////////////////////////////////////////////////////////////
context_t::~context_t() {}

void context_t::parseEnvEnabledLayers() {
auto maybeEnableEnvVarVec = getenv_to_vec("UR_ENABLE_LAYERS");
if (!maybeEnableEnvVarVec.has_value()) {
Expand Down
3 changes: 1 addition & 2 deletions unified-runtime/source/loader/ur_lib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class __urdlllocal context_t : public AtomicSingleton<context_t> {
#endif

context_t();
~context_t();

std::once_flag initOnce;

Expand Down Expand Up @@ -117,7 +116,7 @@ class __urdlllocal context_t : public AtomicSingleton<context_t> {
void tearDownLayers() const;
};

context_t *getContext();
inline context_t *getContext() { return context_t::get_direct(); }

ur_result_t urLoaderConfigCreate(ur_loader_config_handle_t *phLoaderConfig);
ur_result_t urLoaderConfigRetain(ur_loader_config_handle_t hLoaderConfig);
Expand Down
Loading