Skip to content

[SYCL][Test] Add IR checks into atomic tests #2834

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
Dec 2, 2020

Conversation

AGindinson
Copy link
Contributor

Check that correct __spirv_Atomic* external calls are emitted
by the compiler FE, and thus ensure that the headers provide a
proper implementation for each function.

Signed-off-by: Artem Gindinson [email protected]

Check that correct `__spirv_Atomic*` external calls are emitted
by the compiler FE, and thus ensure that the headers provide a
proper implementation for each function.

Signed-off-by: Artem Gindinson <[email protected]>
@AGindinson AGindinson requested a review from a team as a code owner November 30, 2020 12:59
@AGindinson AGindinson requested a review from s-kanaev November 30, 2020 12:59
@AGindinson
Copy link
Contributor Author

This is mainly being done in scope of future atomic float extensions' support. A draft example of this is #2765.

Artem Gindinson added 2 commits December 2, 2020 13:27
@AGindinson
Copy link
Contributor Author

AGindinson commented Dec 2, 2020

@s-kanaev @intel/llvm-reviewers-runtime Ping

Copy link
Contributor

@s-kanaev s-kanaev left a comment

Choose a reason for hiding this comment

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

Looks good. Only got several comments out of curiosity.

@@ -181,12 +195,31 @@ int main() {
}

constexpr int N = 32;
// CHECK-LLVM: declare dso_local spir_func i32
// CHECK-LLVM-SAME: @_Z{{[0-9]+}}__spirv_AtomicIAdd
// CHECK-LLVM-SAME: (i32 addrspace(1)*, i32, i32, i32)
add_test<int>(q, N);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious what if the function isn't inlined? Is its inlining forced somehow?

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 believe that inlining can't take place as such. These __spirv_Atomic* functions are generated due to being included from here, however no definition is provided. These external calls get lowered at later stages (e.g. mapped onto corresponding SPIR-V operands during translation from LLVM IR - see #2765 as a fresh example).

compare_exchange_test<unsigned long long>(q, N);
// The remaining functions use the already-declared ones on the IR level
Copy link
Contributor

Choose a reason for hiding this comment

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

Do they? It was integers and now we have floats and doubles...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for this is that float/pointer-typed functions are emulated instead of being mapped onto particular SPIR-V operands. I do not know the details of why integer compare_exchange external calls are made inside this emulation, but #2765 exemplifies what happens if the emulation is changed by an external call to a unique float-typed function.

@romanovvlad romanovvlad merged commit 5c4df90 into intel:sycl Dec 2, 2020
@AGindinson AGindinson deleted the private/agindins/atomic-tests branch December 2, 2020 12:31
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.

3 participants