Skip to content

[SYCL] Enable basic support for 2020 specialization constants in sycl-post-link #3353

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
Mar 24, 2021

Conversation

vmaksimo
Copy link
Contributor

@vmaksimo vmaksimo commented Mar 12, 2021

SYCL 2020 specialization constants implementation will use new intrinsic in
DPC++ headers to provide required markup for the compiler.

By doing this change, SpecConstantsPass starts to support new interface for
specialization constants. It doesn't implement handling of new arguments, which
would be done in further PRs (for now new arguments are just ignored).

Spec is under review here, but it doesn't affect the patch promotion: #3331

…-post-link

SYCL 2020 specialization constants implementation will use new intrinsic in
DPC++ headers to provide required markup for the compiler.

By doing this change, SpecConstantsPass starts to support new interface for
specialization constants. It doesn't implement handling of new arguments, which
would be done in further PRs (for now new arguments are just ignored).
@vmaksimo vmaksimo force-pushed the basic_spec_const_2020 branch from ca3eebc to f7ebe9f Compare March 12, 2021 10:59
@romanovvlad
Copy link
Contributor

@bader @kbobrovs Could you please review?

@@ -21,4 +21,14 @@ SYCL_EXTERNAL T __sycl_getSpecConstantValue(const char *ID);
template <typename T>
SYCL_EXTERNAL T __sycl_getCompositeSpecConstantValue(const char *ID);

template <typename T>
SYCL_EXTERNAL T __sycl_getScalar2020SpecConstantValue(const char *SymbolicID,
Copy link
Contributor

Choose a reason for hiding this comment

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

please add description and doc comments for each new intrinsic

@@ -23,7 +23,17 @@
; CHECK: %[[#POD:]] = call %struct._ZTS3POD.POD @"_Z29__spirv_SpecConstantCompositeAstruct._ZTS1A.Aclass._ZTSN2cl4sycl3vecIiLi2EEE.cl::sycl::vec"([2 x %struct._ZTS1A.A] %[[#NA]], %"class._ZTSN2cl4sycl3vecIiLi2EEE.cl::sycl::vec" %[[#B]]), !SYCL_SPEC_CONST_SYM_ID ![[#MD:]]
; CHECK: store %struct._ZTS3POD.POD %[[#POD]]
;
; Test checks related to 2020 API for composite specialization constants.
Copy link
Contributor

Choose a reason for hiding this comment

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

this does not seem to have any 2020 specifics, am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These checks are just related to function with new intrinsic API calls, but you're right that IR doesn't look different.
I'll remove this mark as a bit confusing one.

store float %add.i, float addrspace(4)* %ptridx.ascast.i.i, align 4, !tbaa !11
call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %3) #3
ret void
}
Copy link
Contributor

Choose a reason for hiding this comment

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

there no single CHECK in this function - what is the purpose of adding it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function was added to test new __sycl_get*2020SpecializationConstant intrinsic (which are introduced in spec constants 2020 design).
The corresponding checks for this piece of IR are located at the beginning of the file (as it was done for this test initially).

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to move the checks next to the source IR portion which are supposed to produce the checked result. Otherwise it is really hard to follow the logic of the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, done

@vmaksimo vmaksimo requested a review from kbobrovs March 18, 2021 09:34
@@ -69,6 +57,11 @@ entry:
ret void
}

; CHECK: %[[#N0:]] = call i32 @_Z20__spirv_SpecConstantii(i32 [[#ID + 6]], i32
Copy link
Contributor

Choose a reason for hiding this comment

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

My idea was to actually move the checks right below the __sycl_get* intrinsics which lead to the checked IR.

Comment on lines 24 to 25
// The intrinsics below are used to enable support of specialization constants
// 2020. This feature required post-link to handle more parameters.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! One more nit

Suggested change
// The intrinsics below are used to enable support of specialization constants
// 2020. This feature required post-link to handle more parameters.
// The intrinsics below are used to implement support SYCL2020 specialization constants.
// SYCL2020 version requires more parameters compared to the initial version.

Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

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

LGTM modulo comments from Konst (the one about doc comment for each new intrinsic is still haven't addressed)

@vmaksimo
Copy link
Contributor Author

LGTM modulo comments from Konst (the one about doc comment for each new intrinsic is still haven't addressed)

I don't think that we need to duplicate the description for composite intrinsic as the comment would be a copy-paste. It relates to both of the new intrinsics (the same way that a previous couple of intrinsics was documented above).

@bader
Copy link
Contributor

bader commented Mar 23, 2021

@kbobrovs, please, take a look if your concerns are resolved.

@AlexeySachkov
Copy link
Contributor

LGTM modulo comments from Konst (the one about doc comment for each new intrinsic is still haven't addressed)

I don't think that we need to duplicate the description for composite intrinsic as the comment would be a copy-paste. It relates to both of the new intrinsics (the same way that a previous couple of intrinsics was documented above).

Ok, works for me

@kbobrovs
Copy link
Contributor

LGTM modulo comments from Konst (the one about doc comment for each new intrinsic is still haven't addressed)

I don't think that we need to duplicate the description for composite intrinsic as the comment would be a copy-paste. It relates to both of the new intrinsics (the same way that a previous couple of intrinsics was documented above).

Ok, works for me

For met too. Added comment seems enough.

@kbobrovs
Copy link
Contributor

@kbobrovs, please, take a look if your concerns are resolved.

@bader, yes, approved.

@bader bader merged commit 7bf4a6d into intel:sycl Mar 24, 2021
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.

5 participants