-
Notifications
You must be signed in to change notification settings - Fork 248
Fix SPV_INTEL_runtime_aligned implementation part 1 #1796
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
It was implemented via new decoration, which is not correct. Instead it should be Function Parameter Attribute decoration. In this commit starts fixing this in step-by-step manner. Signed-off-by: Sidorov, Dmitry <[email protected]>
|
@broxigarchen may I ask you to take a look? |
|
@broxigarchen @tiwaria1 @asudarsa @vmaksimo @jgstarIntel @maksimsab please take a look |
vmaksimo
left a comment
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.
Only from the code I understood that somehow we want to save the non-conformant implementation for now. Please update the description about what this step do. Also the link to the spec could be useful.
Am I right that test/transcoding/SPV_INTEL_runtime_aligned/RuntimeAligned.ll is not changed for now because we preserve the old implementation?
| mapValue(BA, &(*I)); | ||
| setName(&(*I), BA); | ||
| BA->foreachAttr([&](SPIRVFuncParamAttrKind Kind) { | ||
| // Skip this function parameter attribute as it will translated among |
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.
Just to clarify, why wasn't it skipped before?
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.
Because it wasn't a function parameter attribute (since it was implemented incorrectly)
|
Viktoria this is the spec doc: https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_runtime_aligned.asciidoc Yes it should be function parameter attribute as per the spec |
|
Hey Dmitry, what did this look like in IR after reverse-translation before this change? What will the IR be after this change? (I am guessing kernel parameter attribute?) |
@tiwaria1 It remains to be the same - a function metadata looking like: |
Added in the description. Yeap, the test is unchanged intentionally |
Thanks, I asked to understand if FPGA backend would need to be updated after this fix to handle IR changes. Looks like it will not be needed. |
| BF->foreachArgument([&](SPIRVFunctionParameter *Arg) { | ||
| if (Arg->getType()->isTypePointer() && | ||
| if (Arg->hasAttr(FunctionParameterAttributeRuntimeAlignedINTEL) || | ||
| Arg->hasDecorate(internal::DecorationRuntimeAlignedINTEL)) { |
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.
we finally will remove this line
"Arg->hasDecorate(internal::DecorationRuntimeAlignedINTEL)"
right?
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.
Right, I believe that is the intention - but only after consumers are ready to work with the correct implementation.
|
Sorry I guess your previous email get buried in my mail box and I just saw it now. PR looks good to me. I guess the SPIRV consumer might need to merge the patch later after it's finalized. Just curious why we need to do this step by step? |
| Arg->hasDecorate(internal::DecorationRuntimeAlignedINTEL)) { | ||
| DecorationFound = true; | ||
| RuntimeAlignedFound = true; | ||
| ValueVec.push_back(ForeachFnArg(Arg)); |
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.
ForeachFnArg seems unnecessary here. We can just create a ConstantInt with 1 and push it here.
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.
It actually does exactly what you're mentioned, see https://github.com/KhronosGroup/SPIRV-LLVM-Translator/pull/1796/files#diff-7990d99acb2f8325d245dfecdab758eae5aebae2b54c04fd8e906212eb80ae10R4472-R4473
| case FunctionParameterAttributeNoCapture: | ||
| case FunctionParameterAttributeNoWrite: | ||
| case FunctionParameterAttributeNoReadWrite: | ||
| case FunctionParameterAttributeRuntimeAlignedINTEL: |
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.
I suppose this change will be useful when SPIRVWriter.cpp is updated.
lib/SPIRV/SPIRVReader.cpp
Outdated
| RuntimeAlignedFound = true; | ||
| ValueVec.push_back(ForeachFnArg(Arg)); | ||
| } else { | ||
| llvm::Metadata *DefaultNode = ConstantAsMetadata::get( |
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.
One nit: Instead of creating DefaultNode for each Argument, we can create a single static global DefaultNode and push it when required.
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.
Guess no need to have it as a global, moved it out of lambda to have it initialized only once in the function.
asudarsa
left a comment
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.
Few nits. Are not PR blocking.
Without consumers update such SPIR-V changes will result in a missing feature. And once it's updated - it takes time until new driver is being propagated in different CIs (and SPIR-V generator change might reach CI at this point). Also I don't have much control over every SPIR-V consumer, hence prefer to go with conservative approach anyway. |
|
Closing and reopening to run tests. |
|
Hi @MrSidims, Is this change ready to be merged? Also, IIUC, the forward translation is the next and final step in this effort? Thanks |
| @@ -0,0 +1,68 @@ | |||
| ; RUN: llvm-spirv -spirv-text -r %s -o %t.bc | |||
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.
Not a blocker for this PR. Going forward, it will be great if we can introduce such .spt tests by generating them using the spirv-dis tool which generates a more readable file.
Thanks
asudarsa
left a comment
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.
Translator change Looks good. Thanks
It was implemented via new decoration, which is not correct. Instead it should be Function Parameter Attribute decoration.
In this commit starts fixing this in step-by-step manner.
This step only adds reverse translation to be reused later by SPIR-V consumers.
Link to spec: https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_runtime_aligned.asciidoc
Signed-off-by: Sidorov, Dmitry [email protected]