Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion sycl/cmake/modules/FetchUnifiedRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if(SYCL_UR_USE_FETCH_CONTENT)
CACHE PATH "Path to external '${name}' adapter source dir" FORCE)
endfunction()

set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
set(UNIFIED_RUNTIME_REPO "https://github.com/aarongreig/unified-runtime.git")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/UnifiedRuntimeTag.cmake)

set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
Expand Down
8 changes: 1 addition & 7 deletions sycl/cmake/modules/UnifiedRuntimeTag.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# commit 09ae26af4e4e4301177db704b3b109ecd388c846
# Merge: d2f69680 dd920712
# Author: Callum Fare <[email protected]>
# Date: Thu Nov 7 11:43:19 2024 +0000
# Merge pull request #2233 from martygrant/martin/memory-cts-spec-gap-2
# Improvements to align CTS and Spec for Memory
set(UNIFIED_RUNTIME_TAG 09ae26af4e4e4301177db704b3b109ecd388c846)
set(UNIFIED_RUNTIME_TAG aaron/addAssertDeviceInfoQuery)
11 changes: 5 additions & 6 deletions sycl/source/detail/device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle,
}
MPlatform = Platform;

MIsAssertFailSupported =
has_extension(UR_DEVICE_INFO_EXTENSION_DEVICELIB_ASSERT);
Adapter->call<UrApiKind::urDeviceGetInfo>(
MDevice, UR_DEVICE_INFO_USE_NATIVE_ASSERT, sizeof(ur_bool_t),
&MUseNativeAssert, nullptr);
}

device_impl::~device_impl() {
Expand Down Expand Up @@ -472,7 +473,7 @@ bool device_impl::has(aspect Aspect) const {
case aspect::ext_oneapi_srgb:
return get_info<info::device::ext_oneapi_srgb>();
case aspect::ext_oneapi_native_assert:
return isAssertFailSupported();
return useNativeAssert();
case aspect::ext_oneapi_cuda_async_barrier: {
int async_barrier_supported;
bool call_successful =
Expand Down Expand Up @@ -782,9 +783,7 @@ bool device_impl::has(aspect Aspect) const {
return false; // This device aspect has not been implemented yet.
}

bool device_impl::isAssertFailSupported() const {
return MIsAssertFailSupported;
}
bool device_impl::useNativeAssert() const { return MUseNativeAssert; }

std::string device_impl::getDeviceName() const {
std::call_once(MDeviceNameFlag,
Expand Down
9 changes: 7 additions & 2 deletions sycl/source/detail/device_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ class device_impl {
/// \return true if the SYCL device has the given feature.
bool has(aspect Aspect) const;

bool isAssertFailSupported() const;
/// Indicates the SYCL device prefers to use its native assert
/// implementation.
///
/// If this is false we will use the fallback assert implementation,
/// as detailed in doc/design/Assert.md
bool useNativeAssert() const;

bool isRootDevice() const { return MRootDevice == nullptr; }

Expand Down Expand Up @@ -302,7 +307,7 @@ class device_impl {
ur_device_type_t MType;
ur_device_handle_t MRootDevice = nullptr;
PlatformImplPtr MPlatform;
bool MIsAssertFailSupported = false;
bool MUseNativeAssert = false;
mutable std::string MDeviceName;
mutable std::once_flag MDeviceNameFlag;
mutable ext::oneapi::experimental::architecture MDeviceArch{};
Expand Down
1 change: 1 addition & 0 deletions sycl/unittests/assert/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_sycl_unittest(AssertTests OBJECT
assert.cpp
support_native.cpp
)

51 changes: 51 additions & 0 deletions sycl/unittests/assert/support_native.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//==---------- support_native.cpp --- Check support is correctly reported --==//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "ur_mock_helpers.hpp"

#include <sycl/sycl.hpp>

#include <helpers/UrMock.hpp>

#include <gtest/gtest.h>

template <bool Support>
static ur_result_t redefinedDeviceGetInfoAfter(void *pParams) {
auto &Params = *reinterpret_cast<ur_device_get_info_params_t *>(pParams);
if (*Params.ppropName == UR_DEVICE_INFO_USE_NATIVE_ASSERT) {
if (*Params.ppPropValue)
*reinterpret_cast<ur_bool_t *>(*Params.ppPropValue) = Support;
if (*Params.ppPropSizeRet)
**Params.ppPropSizeRet = sizeof(ur_bool_t);
}
return UR_RESULT_SUCCESS;
}

TEST(SupportNativeAssert, True) {
mock::getCallbacks().set_after_callback("urDeviceGetInfo",
&redefinedDeviceGetInfoAfter<true>);

sycl::unittest::UrMock<> Mock;
sycl::platform Plt = sycl::platform();

const sycl::device Dev = Plt.get_devices()[0];

ASSERT_TRUE(Dev.has(sycl::aspect::ext_oneapi_native_assert));
}

TEST(SupportNativeAssert, False) {
mock::getCallbacks().set_after_callback("urDeviceGetInfo",
&redefinedDeviceGetInfoAfter<false>);

sycl::unittest::UrMock<> Mock;
sycl::platform Plt = sycl::platform();

const sycl::device Dev = Plt.get_devices()[0];

ASSERT_FALSE(Dev.has(sycl::aspect::ext_oneapi_native_assert));
}
Loading