-
Notifications
You must be signed in to change notification settings - Fork 808
[SYCL] Implement sycl_ext_oneapi_device_is_integrated_gpu
#20289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dm-vodopyanov
wants to merge
4
commits into
intel:sycl
Choose a base branch
from
dm-vodopyanov:impl_device_is_integrated_gpu
base: sycl
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+289
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
29 changes: 29 additions & 0 deletions
29
sycl/test-e2e/DeviceIsIntegratedGPU/device_is_integrated_gpu.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//==- 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 | ||
// 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; | ||
} |
29 changes: 29 additions & 0 deletions
29
sycl/test-e2e/DeviceIsIntegratedGPU/device_is_not_integrated_gpu.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//==- 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 | ||
// 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; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//==--- 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) { | ||
sycl::unittest::UrMock<> Mock; | ||
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) { | ||
sycl::unittest::UrMock<> Mock; | ||
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) { | ||
sycl::unittest::UrMock<> Mock; | ||
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) { | ||
sycl::unittest::UrMock<> Mock; | ||
// 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)); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
unified-runtime/scripts/core/EXP-DEVICE-IS-INTEGRATED-GPU.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
unified-runtime/scripts/core/exp-device-is-integrated-gpu.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also update the Status section as described in the template:
https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/template.asciidoc#status