-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][FPGA] Update __builtin_intel_fpga_mem #5002
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
Conversation
According to intel#4980 this built-in should take four more constant integer parameters with following default values: ``` const int32_t AnchorID = -1 const int32_t TargetAnchor = 0 const int32_t Type = 0 const int32_t Cycle = 0 ``` The old variant is still allowed for backward compatibility. In case some parameters are not provided - default value will be emitted in annotation string.
@shuoniu-intel , please take a look to make sure we have the same understanding of how this is supposed to work. Please also let me know if strings emitted in LLVM IR i.e. |
LGTM! |
Ping @elizabethandrews , @premanandrao , @smanna12 on review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me. I just have minor nits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
5916950
/summary:run |
@shuoniu-intel , Is it safe to merge this one? Does FPGA compiler support new form of the annotations? Or maybe we should wait for the spec? |
I think the spec must be approved and merged before the implementation. |
auto AddOptionalArgValue = [&E, &Ctx, &Out](int DefaultValue, | ||
unsigned NumOfArg, | ||
StringRef StringToAdd) { | ||
Optional<llvm::APSInt> IntVal = | ||
(E->getNumArgs() > NumOfArg) | ||
? E->getArg(NumOfArg)->getIntegerConstantExpr(Ctx) | ||
: APSInt::get(DefaultValue); | ||
assert(IntVal.hasValue() && "Constant arg isn't actually constant?"); | ||
Out << "{" << StringToAdd << ":" << toString(*IntVal, 10) << "}"; | ||
}; | ||
|
||
AddOptionalArgValue(-1, 3, "anchor-id"); | ||
AddOptionalArgValue(0, 4, "target-anchor"); | ||
AddOptionalArgValue(0, 5, "type"); | ||
AddOptionalArgValue(0, 6, "cycle"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May we use AddOptionalArgValue for first two parameters as well (maybe to rename lambda to AddArgValue)?
auto AddOptionalArgValue = [&E, &Ctx, &Out](int DefaultValue, | |
unsigned NumOfArg, | |
StringRef StringToAdd) { | |
Optional<llvm::APSInt> IntVal = | |
(E->getNumArgs() > NumOfArg) | |
? E->getArg(NumOfArg)->getIntegerConstantExpr(Ctx) | |
: APSInt::get(DefaultValue); | |
assert(IntVal.hasValue() && "Constant arg isn't actually constant?"); | |
Out << "{" << StringToAdd << ":" << toString(*IntVal, 10) << "}"; | |
}; | |
AddOptionalArgValue(-1, 3, "anchor-id"); | |
AddOptionalArgValue(0, 4, "target-anchor"); | |
AddOptionalArgValue(0, 5, "type"); | |
AddOptionalArgValue(0, 6, "cycle"); | |
auto AddArgValue = [&E, &Ctx, &Out](unsigned NumOfArg, | |
StringRef StringToAdd, | |
int DefaultValue = MIN_INT) { | |
Optional<llvm::APSInt> IntVal = | |
(E->getNumArgs() > NumOfArg) | |
? E->getArg(NumOfArg)->getIntegerConstantExpr(Ctx) | |
: APSInt::get(DefaultValue); | |
assert(IntVal.hasValue() && "Constant arg isn't actually constant?"); | |
Out << "{" << StringToAdd << ":" << toString(*IntVal, 10) << "}"; | |
}; | |
AddArgValue(1, "params"); | |
AddArgValue(2, "cache-size"); | |
AddArgValue(3, "anchor-id", -1); | |
AddArgValue(4, "target-anchor", 0); | |
AddArgValue(5, "type", 0); | |
AddArgValue(6, "cycle", 0); |
It should be safe since your implementation is backwards-compatible. |
Please note that even though the new builtin is backward compatible for users in C++ code, this patch adds permanent generation of four new default values in the annotation string in LLVM IR, so after this patch the output is always a bit different. I was wondering if FPGA compiler will be ok with that. |
Let this PR wait for the spec then. Meanwhile I'll verify if the FPGA compiler is okay with the new annotation string. Btw this will be the new look of the annotation string output from clang and SPIR-V right? |
I expect, that it will map LLVM IR construct on
I don't think we have OK test coverage for FPGA h/w here :( In general, if the compiler doesn't know what to do with annotation information - the annotation intrinsics should be ignored (if seen otherwise - it's a bug in the device's backend IMO). |
Yeah, It will look like the old variant but with default values
|
This is a continuation of @Fznamznon's PR #5002. Most of the changes here are from there. According to #4980 this built-in should take four more constant integer parameters with following default values: const int32_t AnchorID = -1 const int32_t TargetAnchor = 0 const int32_t Type = 0 const int32_t Cycle = 0 The old variant is still allowed for backward compatibility. In case some parameters are not provided - default value will be emitted in annotation string. In addition to the state of PR #5002, this PR makes minor changes. It incorporates @mlychkov's code review comments there and modifies the CodeGenSYCL test to accept both opaque and non-opaque pointers.
According to #4980 this built-in
should take four more constant integer parameters with following default
values:
The old variant is still allowed for backward compatibility. In case
some parameters are not provided - default value will be emitted in
annotation string.