Skip to content

[SYCL] remove alignedAllocHost's Kind param #14862

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

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

ldrumm
Copy link
Contributor

@ldrumm ldrumm commented Jul 31, 2024

alignedAllocHost was introduced as part of what was described as a bugfix in 01869a0 wherin alignedAlloc was simply renamed to alignedAllocHost, but the Kind parameter (host|device|shared) was left unchanged, and the bugfix actually appears to be in the calling code. I'm not quite sure what happened there, but in any case we shouldn't have a Kind parameter if we only ever intend to work on the host (indeed the existing code treats Kind == host as an invariant, returning an error otherwise).

It looks like a couple of other people tried to work around this when adding other features (e.g. in 7df3923) but didn't fix this due to perceived ABI breaks. However, this function hasn't been exposed as part of the abi due to a declaration / definition mismatch between the header and implementation, so it was never callable in the first place.

Thus, this is a putatively NFC cleanup, but it's a change to the SYCL runtime ABI so not "genuine-NFC".

`alignedAllocHost` was introduced as part of what was described as a
bugfix in 01869a0 wherin `alignedAlloc` was simply renamed to
`alignedAllocHost`, but the `Kind` parameter (host|device|shared) was
left unchanged, and the bugfix actually appears to be in the calling
code. I'm not quite sure what happened there, but in any case we
shouldn't have a `Kind` parameter if we only ever intend to work on the
host (indeed the existing code treats Kind == host as an invariant,
returning an error otherwise).

It looks like a couple of other people tried to work around this when
adding other features (e.g. in 7df3923) but didn't fix this due to
ABI breaks.

Thus, this is a putatively NFC cleanup, but it's a change to the SYCL
runtime ABI so not "genuine-NFC".
@ldrumm ldrumm requested a review from a team as a code owner July 31, 2024 14:11
@ldrumm ldrumm requested a review from maarquitos14 July 31, 2024 14:11
@ldrumm ldrumm temporarily deployed to WindowsCILock July 31, 2024 14:12 — with GitHub Actions Inactive
@ldrumm ldrumm temporarily deployed to WindowsCILock July 31, 2024 14:44 — with GitHub Actions Inactive
@maarquitos14
Copy link
Contributor

I'm confused. If this is breaking ABI, why is there no change to sycl/test/abi/*?

@ldrumm
Copy link
Contributor Author

ldrumm commented Jul 31, 2024

I'm confused. If this is breaking ABI, why is there no change to sycl/test/abi/*?

Doh! because I forgot.

Will add

@ldrumm ldrumm changed the title [SYCL] remove alignedAllocHost's Kind param [SYCL][ABI-Break] remove alignedAllocHost's Kind param Jul 31, 2024
@AlexeySachkov AlexeySachkov added the abi-break change that's breaking abi and waiting for the next window to be able to merge label Jul 31, 2024
@maarquitos14
Copy link
Contributor

BTW, we're not in ABI-breaking window, so this will have to wait until the next one.

@ldrumm
Copy link
Contributor Author

ldrumm commented Aug 6, 2024

I'm confused. If this is breaking ABI, why is there no change to sycl/test/abi/*?

Doh! because I forgot.

Will add

Just tried to do this and noticed that this symbol was never in the dump in the first place. After some head scratching, It looks like the declaration in the header never had a matching definition so no symbol was emitted.

This is because of function overloading. The declaration in the header was

__SYCL_EXPORT void *alignedAllocHost(size_t Alignment, size_t Bytes,
                                     const context &Ctxt, sycl::usm::alloc Kind,
                                     const code_location &CL);

The definition in usm_impl.cpp was

void *alignedAllocHost(size_t Alignment, size_t Size, const context &Ctxt,
                       alloc Kind, const property_list &PropList,
                       const detail::code_location &CodeLoc) {

Notice that the signatures don't match.

Since the definition in the cpp file didn't get the __SYCL_EXPORT attributes applied, the symbol never got made public in the DSO.

Thus, this is not actually ABI-breaking since it was never public in the first place and no changes to the dump file need be made (on GNU toolchains, at least; need to check win32)

@ldrumm
Copy link
Contributor Author

ldrumm commented Aug 6, 2024

If my analysis above is correct, would it make sense to just not expose this in the headers at all and move it into an anonymous namespace inside usm_impl.cpp?

@maarquitos14
Copy link
Contributor

I'm confused. If this is breaking ABI, why is there no change to sycl/test/abi/*?

Doh! because I forgot.
Will add

Just tried to do this and noticed that this symbol was never in the dump in the first place. After some head scratching, It looks like the declaration in the header never had a matching definition so no symbol was emitted.

This is because of function overloading. The declaration in the header was

__SYCL_EXPORT void *alignedAllocHost(size_t Alignment, size_t Bytes,
                                     const context &Ctxt, sycl::usm::alloc Kind,
                                     const code_location &CL);

The definition in usm_impl.cpp was

void *alignedAllocHost(size_t Alignment, size_t Size, const context &Ctxt,
                       alloc Kind, const property_list &PropList,
                       const detail::code_location &CodeLoc) {

Notice that the signatures don't match.

Since the definition in the cpp file didn't get the __SYCL_EXPORT attributes applied, the symbol never got made public in the DSO.

Thus, this is not actually ABI-breaking since it was never public in the first place and no changes to the dump file need be made (on GNU toolchains, at least; need to check win32)

That explains why CI passed. If it was indeed an ABI break, and no changes in the related tests, CI should have failed.

@maarquitos14
Copy link
Contributor

If my analysis above is correct, would it make sense to just not expose this in the headers at all and move it into an anonymous namespace inside usm_impl.cpp?

@AlexeySachkov what's your opinion on this? IMO, if this was never exposed, it sounds good to me.

@AlexeySachkov
Copy link
Contributor

If my analysis above is correct, would it make sense to just not expose this in the headers at all and move it into an anonymous namespace inside usm_impl.cpp?

@AlexeySachkov what's your opinion on this? IMO, if this was never exposed, it sounds good to me.

If it was never exposed and used from public headers (only declared there), then for sure it should be moved down to the library. Absolutely no objections to that

Thus, we can make this implementation private with impunity
@ldrumm
Copy link
Contributor Author

ldrumm commented Aug 22, 2024

It's now in an anonymous namespace, and I've verified win32 as well. Thus I will remove the ABI-BREAK tag, and I think this is ready to merge (pending CI)

@ldrumm ldrumm changed the title [SYCL][ABI-Break] remove alignedAllocHost's Kind param [SYCL] remove alignedAllocHost's Kind param Aug 22, 2024
@maarquitos14 maarquitos14 removed the abi-break change that's breaking abi and waiting for the next window to be able to merge label Aug 22, 2024
Copy link
Contributor

@maarquitos14 maarquitos14 left a comment

Choose a reason for hiding this comment

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

LGTM.

@martygrant martygrant merged commit bbc0cf5 into intel:sycl Aug 26, 2024
12 of 13 checks passed
@ldrumm ldrumm deleted the alignedAllocHost branch August 26, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants