Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def Aspectext_oneapi_exportable_device_mem : Aspect<"ext_oneapi_exportable_devic
def Aspectext_oneapi_clock_sub_group : Aspect<"ext_oneapi_clock_sub_group">;
def Aspectext_oneapi_clock_work_group : Aspect<"ext_oneapi_clock_work_group">;
def Aspectext_oneapi_clock_device : Aspect<"ext_oneapi_clock_device">;
def Aspectext_oneapi_is_integrated_gpu : Aspect<"ext_oneapi_is_integrated_gpu">;

// Deprecated aspects
def AspectInt64_base_atomics : Aspect<"int64_base_atomics">;
Expand Down Expand Up @@ -174,7 +175,8 @@ def : TargetInfo<"__TestAspectList",
Aspectext_oneapi_exportable_device_mem,
Aspectext_oneapi_clock_sub_group,
Aspectext_oneapi_clock_work_group,
Aspectext_oneapi_clock_device],
Aspectext_oneapi_clock_device,
Aspectext_oneapi_is_integrated_gpu],
[]>;
// This definition serves the only purpose of testing whether the deprecated aspect list defined in here and in SYCL RT
// match.
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions sycl/include/sycl/info/aspects.def
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ __SYCL_ASPECT(ext_oneapi_exportable_device_mem, 90)
__SYCL_ASPECT(ext_oneapi_clock_sub_group, 91)
__SYCL_ASPECT(ext_oneapi_clock_work_group, 92)
__SYCL_ASPECT(ext_oneapi_clock_device, 93)
__SYCL_ASPECT(ext_oneapi_is_integrated_gpu, 94)
5 changes: 5 additions & 0 deletions sycl/source/detail/device_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,11 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
return get_info_impl_nocheck<UR_DEVICE_INFO_CLOCK_DEVICE_SUPPORT_EXP>()
.value_or(0);
}
CASE(ext_oneapi_is_integrated_gpu) {
return is_gpu() &&
get_info_impl_nocheck<UR_DEVICE_INFO_IS_INTEGRATED_GPU>().value_or(
0);
}
else {
return false; // This device aspect has not been implemented yet.
}
Expand Down
1 change: 1 addition & 0 deletions sycl/source/detail/ur_device_info_ret_types.inc
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,5 @@ MAP(UR_DEVICE_INFO_MEMORY_EXPORT_EXPORTABLE_DEVICE_MEM_EXP, ur_bool_t)
MAP(UR_DEVICE_INFO_CLOCK_SUB_GROUP_SUPPORT_EXP, ur_bool_t)
MAP(UR_DEVICE_INFO_CLOCK_WORK_GROUP_SUPPORT_EXP, ur_bool_t)
MAP(UR_DEVICE_INFO_CLOCK_DEVICE_SUPPORT_EXP, ur_bool_t)
MAP(UR_DEVICE_INFO_IS_INTEGRATED_GPU, ur_bool_t)
// clang-format on
1 change: 1 addition & 0 deletions sycl/source/feature_test.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ inline namespace _V1 {
#define SYCL_KHR_QUEUE_EMPTY_QUERY 1
#define SYCL_EXT_ONEAPI_MEMORY_EXPORT 1
#define SYCL_EXT_ONEAPI_CLOCK 1
#define SYCL_EXT_ONEAPI_DEVICE_IS_INTEGRATED_GPU 1
// In progress yet
#define SYCL_EXT_ONEAPI_ATOMIC16 0
#define SYCL_KHR_DEFAULT_CONTEXT 1
Expand Down
28 changes: 28 additions & 0 deletions sycl/test-e2e/DeviceIsIntegratedGPU/device_is_cpu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//==--- device_is_cpu.cpp - sycl_ext_oneapi_device_is_integrated_gpu test --==//
//
// 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
//
//===----------------------------------------------------------------------===//
// REQUIRES: cpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

// Test checks that aspect::ext_oneapi_is_integrated_gpu is false if device is
// not GPU (e.g., CPU).

#include <sycl/detail/core.hpp>

using namespace sycl;

int main() {
queue Queue;
auto dev = Queue.get_device();

if (!dev.has(aspect::ext_oneapi_is_integrated_gpu))
return 0;

assert(false && "aspect::ext_oneapi_is_integrated_gpu must be false");
return 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//==- device_is_integrated_gpu.cpp - sycl_ext_oneapi_device_is_integrated_gpu
// test -==//
//
// 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
//
//===----------------------------------------------------------------------===//
// REQUIRES: gpu-intel-gen12
// UNSUPPORTED: cuda, hip
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

// Test checks that aspect::ext_oneapi_is_integrated_gpu is true if GPU device
// is integrated.

#include <sycl/detail/core.hpp>

using namespace sycl;

int main() {
queue Queue;
auto dev = Queue.get_device();

if (dev.has(aspect::ext_oneapi_is_integrated_gpu))
return 0;

assert(false && "aspect::ext_oneapi_is_integrated_gpu must be true");
return 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//==- device_is_not_integrated_gpu.cpp -
// sycl_ext_oneapi_device_is_integrated_gpu test -==//
//
// 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
//
//===----------------------------------------------------------------------===//
// REQUIRES: arch-intel_gpu_pvc || arch-intel_gpu_bmg_g21
// UNSUPPORTED: cuda, hip
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

// Test checks that aspect::ext_oneapi_is_integrated_gpu is false if GPU device
// is discrete.

#include <sycl/detail/core.hpp>

using namespace sycl;

int main() {
queue Queue;
auto dev = Queue.get_device();

if (!dev.has(aspect::ext_oneapi_is_integrated_gpu))
return 0;

assert(false && "aspect::ext_oneapi_is_integrated_gpu must be false");
return 1;
}
1 change: 1 addition & 0 deletions sycl/unittests/Extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
add_sycl_unittest(ExtensionsTests OBJECT
CurrentDevice.cpp
DefaultContext.cpp
DeviceIsIntegratedGPU.cpp
FPGADeviceSelectors.cpp
DeviceArchitecture.cpp
USMMemcpy2D.cpp
Expand Down
69 changes: 69 additions & 0 deletions sycl/unittests/Extensions/DeviceIsIntegratedGPU.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//==--- DeviceIsIntegratedGPU.cpp - oneapi_device_is_integrated_gpu test ---==//
//
// 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 "sycl/platform.hpp"
#include <detail/device_impl.hpp>
#include <sycl/sycl.hpp>

#include <helpers/UrMock.hpp>

#include <gtest/gtest.h>

namespace {
template <bool IsIntegratedGPU, ur_device_type_t URDeviceType>
static ur_result_t redefinedDeviceGetInfoAfter(void *pParams) {
auto params = *static_cast<ur_device_get_info_params_t *>(pParams);
if (*params.ppropName == UR_DEVICE_INFO_IS_INTEGRATED_GPU) {
auto *Result = reinterpret_cast<ur_bool_t *>(*params.ppPropValue);
*Result = IsIntegratedGPU;
}

if (*params.ppropName == UR_DEVICE_INFO_TYPE) {
auto *Result = reinterpret_cast<ur_device_type_t *>(*params.ppPropValue);
*Result = URDeviceType;
}

return UR_RESULT_SUCCESS;
}
} // namespace

TEST(DeviceIsIntegratedGPU, DeviceIsNotIntegratedGPUOnGPUDevice) {
mock::getCallbacks().set_after_callback(
"urDeviceGetInfo", &redefinedDeviceGetInfoAfter</*IsIntegratedGPU=*/false,
UR_DEVICE_TYPE_GPU>);
sycl::device Device = sycl::platform().get_devices()[0];
ASSERT_FALSE(Device.has(sycl::aspect::ext_oneapi_is_integrated_gpu));
}

TEST(DeviceIsIntegratedGPU, DeviceIsIntegratedGPUOnGPUDevice) {
mock::getCallbacks().set_after_callback(
"urDeviceGetInfo", &redefinedDeviceGetInfoAfter</*IsIntegratedGPU=*/true,
UR_DEVICE_TYPE_GPU>);
sycl::device Device = sycl::platform().get_devices()[0];
ASSERT_TRUE(Device.has(sycl::aspect::ext_oneapi_is_integrated_gpu));
}

TEST(DeviceIsIntegratedGPU, DeviceIsNotIntegratedGPUOnCPUDevice) {
mock::getCallbacks().set_after_callback(
"urDeviceGetInfo", &redefinedDeviceGetInfoAfter</*IsIntegratedGPU=*/false,
UR_DEVICE_TYPE_CPU>);
sycl::device Device = sycl::platform().get_devices()[0];
ASSERT_FALSE(Device.has(sycl::aspect::ext_oneapi_is_integrated_gpu));
}

TEST(DeviceIsIntegratedGPU, DeviceIsIntegratedGPUOnCPUDevice) {
// Not much sense here but if for some reason UR_DEVICE_INFO_IS_INTEGRATED_GPU
// is true on CPU device, we check that
// sycl::aspect::ext_oneapi_is_integrated_gpu must be false as stated in the
// extension spec.
mock::getCallbacks().set_after_callback(
"urDeviceGetInfo", &redefinedDeviceGetInfoAfter</*IsIntegratedGPU=*/true,
UR_DEVICE_TYPE_CPU>);
sycl::device Device = sycl::platform().get_devices()[0];
ASSERT_FALSE(Device.has(sycl::aspect::ext_oneapi_is_integrated_gpu));
}
1 change: 1 addition & 0 deletions sycl/unittests/helpers/UrMock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ inline ur_result_t mock_urDeviceGetInfo(void *pParams) {
case UR_DEVICE_INFO_AVAILABLE:
case UR_DEVICE_INFO_LINKER_AVAILABLE:
case UR_DEVICE_INFO_COMPILER_AVAILABLE:
case UR_DEVICE_INFO_IS_INTEGRATED_GPU:
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
if (*params->ppPropValue)
*static_cast<ur_bool_t *>(*params->ppPropValue) = true;
Expand Down
2 changes: 2 additions & 0 deletions unified-runtime/include/ur_api.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions unified-runtime/include/ur_print.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions unified-runtime/scripts/core/EXP-DEVICE-IS-INTEGRATED-GPU.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<%
OneApi=tags['$OneApi']
x=tags['$x']
X=x.upper()
%>

.. _experimental-device-is-integrated-gpu:

================================================================================
Device is integrated GPU
================================================================================

.. warning::

Experimental features:

* May be replaced, updated, or removed at any time.
* Do not require maintaining API/ABI stability of their own additions over
time.
* Do not require conformance testing of their own additions.


Motivation
--------------------------------------------------------------------------------
This experimental extension enables the sycl_ext_oneapi_device_is_integrated_gpu
feature:
http://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_device_is_integrated_gpu.asciidoc
It introduces descriptor to query if device is integrated GPU.

API
--------------------------------------------------------------------------------

Enums
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* ${x}_device_info_t
* ${X}_DEVICE_INFO_IS_INTEGRATED_GPU

Changelog
--------------------------------------------------------------------------------

+-----------+------------------------+
| Revision | Changes |
+===========+========================+
| 1.0 | Initial Draft |
+-----------+------------------------+


Support
--------------------------------------------------------------------------------

Adapters which support this experimental feature *must* return ${X}_RESULT_SUCCESS
from the ${x}DeviceGetInfo call with this new ${X}_DEVICE_INFO_IS_INTEGRATED_GPU
device descriptor.

Contributors
--------------------------------------------------------------------------------

* Vodopyanov, Dmitry `[email protected] <[email protected]>`_
25 changes: 25 additions & 0 deletions unified-runtime/scripts/core/exp-device-is-integrated-gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (C) 2025 Intel Corporation
#
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
# Exceptions.
# See LICENSE.TXT
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# See YaML.md for syntax definition
#
--- #--------------------------------------------------------------------------
type: header
desc: "Intel $OneApi Unified Runtime Experimental APIs for quering if device is integrated GPU"
ordinal: "99"
--- #--------------------------------------------------------------------------
type: enum
extend: true
typed_etors: true
desc: "Extension enums for $x_device_info_t to support quering if device is integrated GPU."
name: $x_device_info_t
etors:
- name: IS_INTEGRATED_GPU
value: "0x2070"
desc: "[$x_bool_t] returns true if the device is integrated GPU."
2 changes: 2 additions & 0 deletions unified-runtime/source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,8 @@ ur_result_t urDeviceGetInfo(
case UR_DEVICE_INFO_CLOCK_DEVICE_SUPPORT_EXP:
// Currently GPUs only support sub-group clock.
return ReturnValue(false);
case UR_DEVICE_INFO_IS_INTEGRATED_GPU:
return ReturnValue(static_cast<ur_bool_t>(Device->isIntegrated() != 0));
default:
UR_LOG(ERR, "Unsupported ParamName in urGetDeviceInfo");
UR_LOG(ERR, "ParamNameParamName={}(0x{})", ParamName,
Expand Down
12 changes: 12 additions & 0 deletions unified-runtime/source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,18 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
}
return ReturnValue(Supported);
}
case UR_DEVICE_INFO_IS_INTEGRATED_GPU: {
cl_bool CLValue;

// TODO: use stable API instead of deprecated CL_DEVICE_HOST_UNIFIED_MEMORY.
// Currently CL_DEVICE_HOST_UNIFIED_MEMORY is deprecated by OpenCL 2.0, but
// still was not removed even from Intel implementations of OpenCL 3.0.
CL_RETURN_ON_FAILURE(clGetDeviceInfo(hDevice->CLDevice,
CL_DEVICE_HOST_UNIFIED_MEMORY,
sizeof(cl_bool), &CLValue, nullptr));

return ReturnValue(static_cast<ur_bool_t>(CLValue));
}
// TODO: We can't query to check if these are supported, they will need to be
// manually updated if support is ever implemented.
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
Expand Down
2 changes: 2 additions & 0 deletions unified-runtime/tools/urinfo/urinfo.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading