Skip to content

Conversation

@KseniyaTikhomirova
Copy link
Contributor

This is part of the SYCL support upstreaming effort. The relevant RFCs can be found here:

https://discourse.llvm.org/t/rfc-add-full-support-for-the-sycl-programming-model/74080 https://discourse.llvm.org/t/rfc-sycl-runtime-upstreaming/74479

Plan for next PR:

E2E lit configs & test for get_platforms & get_devices impl
context & USM free functions impl

// SYCL 2020 A.3. Device information descriptors.
namespace info {

enum class partition_property : std::uint32_t {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing to intel/llvm I changed the type of partition enums from intptr to uint.
It was aligned with openCL type:
typedef intptr_t cl_device_partition_property;

but I doubt we should keep it the same way.

using PlatformWithDevStorageType =
std::unordered_map<ol_platform_handle_t, std::vector<ol_device_handle_t>>;
using Platform2DevContainer =
std::vector<std::pair<ol_platform_handle_t, ol_device_handle_t>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that it is not correct to use map here since rehash may cause change of device order. I have redone this and corresponding code.

@KseniyaTikhomirova
Copy link
Contributor Author

KseniyaTikhomirova commented Jan 20, 2026

@tahonermann, @dvrogozh, @sergey-semenov, @bader, @againull, @YuriPlyakhin, @Fznamznon

FYI, published for review.

@Fznamznon Fznamznon added the SYCL https://registry.khronos.org/SYCL label Jan 20, 2026
@Fznamznon Fznamznon requested review from Fznamznon, YuriPlyakhin, againull, bader and tahonermann and removed request for tahonermann January 20, 2026 17:36
return isCPU();
case (aspect::gpu):
return isGPU();
case (aspect::accelerator):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between gpu and accelerator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accelerator == fpga, It is present in spec so I have to cover it, but we have no plan to get it enabled in liboffload and so in libsycl

return;

// MDevices reallocation is prevented to keep correct ranges in MDeviceRange
MDevices.reserve(PlatformsAndDev.size());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Does MDevices supposed to be empty or it might contain something? If the latter shouldn't that be something like MDevices.reserve(MDevices.size() + PlatformsAndDev.size())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must be empty. This operation is done once in the first get_platforms call. After that the data is reused and never changes.

Signed-off-by: Tikhomirova, Kseniya <[email protected]>
@KseniyaTikhomirova
Copy link
Contributor Author

@dvrogozh & @bader thank you for your review. I have replied to or fixed all your comments.

pinging @dm-vodopyanov who agreed to participate in review for upstreaming.

Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general.
Just a few minor nits in comments.

Signed-off-by: Tikhomirova, Kseniya <[email protected]>
Copy link

@dvrogozh dvrogozh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 99 to 102
std::string Result;
Result.resize(ExpectedSize - 1);
callAndThrow(olGetDeviceInfo, MOffloadDevice, olInfo, ExpectedSize,
Result.data());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is UB. olGetDeviceInfo can write ExpectedSize bytes into Result.data() but writable size in Result.data() is only ExpectedSize - 1 after resize.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it shouldn't since liboffload (same as UR) counts null terminator in the size while std::string doesn't.
Although I do agree that it's confusing. I had to check why I did it this way before answering this question. So it is not obvious and must be commented or updated to the safe version with resize(ExpectedSize). I will do the second.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@againull againull Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my bad, checked it, and indeed liboffload counts null terminator, and we are allowed to write null terminator at Result.data() + Result.size() (only writing anything besides null terminator is undefined behavior).

So, if we assume that liboffload guarantees that it counts null terminator (they should document it though) then we should return the original version with resize(ExpectedSize - 1).
Or if we want to stay on safer side, we should leave current version but trim after call:

if (!Result.empty() && Result.back() == '\0')
   Result.pop_back();

Current version is not very good because, for example for "Intel" count() will return 6 and operator== doesn't work as expected by user.

Copy link
Contributor Author

@KseniyaTikhomirova KseniyaTikhomirova Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I haven't thought about operator.
thanks, I returned it back and added comment ae54270
regarding safer side - I think it will be pretty confusing and will mean expecting of flaky behavior of liboffload (that shouldn't happen, if it changes - that is API breaking change) if we add this.

Signed-off-by: Tikhomirova, Kseniya <[email protected]>
@KseniyaTikhomirova
Copy link
Contributor Author

pinging @dklochkov-emb who will review instead @dm-vodopyanov

Signed-off-by: Tikhomirova, Kseniya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SYCL https://registry.khronos.org/SYCL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants