Skip to content

[SYCL] Enable template parameter support for ii and max_concurrency attributes #811

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 6 commits into from
Nov 21, 2019

Conversation

vmaksimo
Copy link
Contributor

No description provided.

Signed-off-by: Viktoria Maksimova <[email protected]>
Signed-off-by: Viktoria Maksimova <[email protected]>
@bader bader changed the title [SYCL]Enable template parameter support for ii and max_concurrency attributes [SYCL] Enable template parameter support for ii and max_concurrency attributes Nov 12, 2019
Signed-off-by: Viktoria Maksimova <[email protected]>
MrSidims
MrSidims previously approved these changes Nov 18, 2019
Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

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

LGTM
I'd like to see the PR be approved by Erich prior merging.

@@ -229,6 +229,36 @@ void ivdep_dependent() {
};
}

template <int A, int B, int C>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you test a non-dependent attribute in a dependent context? I have a feeling that the transforms running on a non-dependent version will cause the int value to be lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, int value is lost in this case. Do you have any suggestions why it happens or how to handle this? As I see, it requires more than one-line fix, but unfortunately I have no idea where the error can be hidden.

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 the best way about this is to just remove the IntervalValue field from the attribute. I don't think it is necessary anyway. It'll simplify a bunch of code, and result in only the Expr needing to be handled everywhere. It means you need to do a touch more work in CGLoopInfo (call isIntegerConstantExpr() on the expr to get the integer value out), but it simplifies the rest of the patch a bunch.

Signed-off-by: Viktoria Maksimova <[email protected]>
unsigned ValueInt = 0;
if (auto *E = IntelFPGAII->getIntervalExpr()) {
llvm::APSInt ArgVal(32);
if (E->isIntegerConstantExpr(ArgVal, Ctx)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be an 'if', it should absolutely be true (since you made sure of it before). This should assert. Typically we do something like:

bool Valid = E->IsIntegerConstantExpr(ArgVal, Ctx);
assert(Valid && "Not a ConstantExpr?");(void)Valid;

if (ValueInt > 0)
setSYCLIInterval(ValueInt);
unsigned ValueInt = 0;
if (auto *E = IntelFPGAII->getIntervalExpr()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What codegen are we doing if there ISN'T an expression?

Also, const auto should be possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it no codegen if there is no expression?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess not? But this should likely be checked in SEMA and asserted here. Also, can you write a SEMA test for 'no parameters passed'? That seems like it should be an error case as well.

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 with that, no need to double-check.
About test - I see that the test has already have cases for no parameters in boo() function

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks for pointing that out.

}

if (IntelFPGAMaxConcurrency) {
setSYCLMaxConcurrencyEnable();
setSYCLMaxConcurrencyNThreads(IntelFPGAMaxConcurrency->getNThreads());
unsigned ValueInt = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comments as above.

llvm::APSInt ArgVal(32);
if (E->isIntegerConstantExpr(ArgVal, Ctx)) {
ValueInt = ArgVal.getSExtValue();
if (ValueInt > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

You check this condition in SEMA right? No need to do it again.

const SYCLIntelFPGAIIAttr *TemplateInstantiator::TransformSYCLIntelFPGAIIAttr(
const SYCLIntelFPGAIIAttr *II) {
Expr *TransformedExpr =
II->getIntervalExpr()
Copy link
Contributor

Choose a reason for hiding this comment

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

The ternary isn't necessary, TransformExpr returns nullptr if it receives 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.

Ternary is for expression checking. getIntervalExpr() can be nullptr, so .get() will cause segfault in this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe that is correct. getDerived.TransformExpr(nullptr) would return an ExprResult containing a nullptr. The 'get' function should just return that same pointer: https://clang.llvm.org/doxygen/Ownership_8h_source.html#l00170

Thus, if you do getDerived().TransformExpr(II->getIntervalExpr()).get() you will get either the transformed expr, or nullptr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see. Thank you for correction

Signed-off-by: Viktoria Maksimova <[email protected]>
@bader bader merged commit 6a283ae into intel:sycl Nov 21, 2019
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