Skip to content
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

Headers support for two Intel extensions #356

Merged
merged 5 commits into from
Aug 16, 2023

Conversation

vmaksimo
Copy link
Contributor

@vmaksimo vmaksimo marked this pull request as ready for review June 30, 2023 14:00
Copy link

@artemrad artemrad 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. My only concern is that it doesn't remove any of the legacy implementations for these decorations. I can't seem to find any reference to them either, so I am a bit confused.

@vmaksimo
Copy link
Contributor Author

@artemrad legacy implementation was done in SPIRV-LLVM Translator only according to https://github.com/intel/llvm/blob/sycl/sycl/doc/design/spirv-extensions/SPV_INTEL_global_variable_decorations.asciidoc spec.
Once we merge these new headers, we'll be able to switch to the official extension and remove old decorations in llvm-spirv.

@vmaksimo
Copy link
Contributor Author

vmaksimo commented Jul 6, 2023

@MrSidims @bashbaug please take a look. Thanks!

@@ -11880,6 +11880,32 @@
}
]
},
{
"category" : "ValueEnum",
"kind" : "HostAccessQualifier",
Copy link
Contributor

Choose a reason for hiding this comment

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

These new enums for HostAccessQualifier and the enums for InitializationModeQualifier aren't getting added to the headers because the generation scripts don't know about them. Are we OK with that?

Actually, I'm a little surprised the header generation script ran correctly because it has checks for unhandled "operand kinds":

        if (type == OperandNone) {
            std::cerr << "Unhandled operand kind found: " << operandKind << std::endl;
            exit(1);
        }

Did the generation script run correctly or were other changes needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I took a look at this in a bit more detail because all of the automated checks are passing. It turns out that this error is certainly occurring, though it isn't causing the CI jobs to fail for some reason. We should fix this.

See: https://github.com/KhronosGroup/SPIRV-Headers/actions/runs/5423707347/jobs/9931446730?pr=356#step:7:15

Run cd tools/buildHeaders
dos2unix: converting file DebugInfo.h to Unix format...
dos2unix: converting file OpenCLDebugInfo100.h to Unix format...
dos2unix: converting file AMD_gcn_shader.h to Unix format...
dos2unix: converting file AMD_shader_ballot.h to Unix format...
dos2unix: converting file AMD_shader_explicit_vertex_parameter.h to Unix format...
dos2unix: converting file AMD_shader_trinary_minmax.h to Unix format...
dos2unix: converting file NonSemanticDebugPrintf.h to Unix format...
dos2unix: converting file NonSemanticClspvReflection.h to Unix format...
dos2unix: converting file NonSemanticDebugBreak.h to Unix format...
Unhandled operand kind found: InitializationModeQualifier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bashbaug thanks for review and investigation! What do you think, should I add these enums to the generation script or to add them somewhere in different place?

Copy link
Contributor

Choose a reason for hiding this comment

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

should I add these enums to the generation script

Yes please. This shouldn't be too bad. You can have a look at the recent cooperative matrix PR #355 as an example since it also added a few new types (see the changes in tools/buildHeaders).

Once this is done I would also recommend checking that a basic test case disassembles and assembles properly since updates may be needed to SPIRV-Tools also.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @bashbaug! I've updated the headers generation. However I'm not sure how to test SPIR-V tools, because we don't have implementation for these headers in llvm-spirv yet. The CI checks are passing, could it be enough? Thanks!

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 please check that SPIRV-Tools builds with these changes? That would probably be the minimum to check, since the interaction between SPIRV-Headers and SPIRV-Tools is not checked via CI.

I'd recommend doing a light touch-test to see if a SPIR-V module using the new decorations assembles, disassembles, and validates properly also, though if this is broken it'll only affect the users of these extensions but not everyone using SPIR-V. You could do this manually, say by adding the decoration to a small existing SPIR-V ASM file, if the tooling to generate SPIR-V modules using these extensions is not implemented yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

I tried building SPIRV-Tools with these header changes just to see if it'd work and I hit build errors. In case it's helpful:

In file included from /home/bashbaug/git/spirv-tools/source/operand.cpp:36:
/home/bashbaug/git/spirv-tools/build/operand.kinds-unified1.inc:871:99: error: ‘SPV_OPERAND_TYPE_INITIALIZATION_MODE_QUALIFIER’ was not declared in this scope; did you mean ‘SPV_OPERAND_TYPE_OPTIONAL_ACCESS_QUALIFIER’?
  871 |   {"InitModeINTEL", 6147, 1, pygen_variable_caps_GlobalVariableFPGADecorationsINTEL, 0, nullptr, {SPV_OPERAND_TYPE_INITIALIZATION_MODE_QUALIFIER}, 0xffffffffu, 0xffffffffu},
      |                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                                   SPV_OPERAND_TYPE_OPTIONAL_ACCESS_QUALIFIER
/home/bashbaug/git/spirv-tools/build/operand.kinds-unified1.inc:873:96: error: ‘SPV_OPERAND_TYPE_HOST_ACCESS_QUALIFIER’ was not declared in this scope; did you mean ‘SPV_OPERAND_TYPE_ACCESS_QUALIFIER’?
  873 |   {"HostAccessINTEL", 6168, 1, pygen_variable_caps_GlobalVariableHostAccessINTEL, 0, nullptr, {SPV_OPERAND_TYPE_HOST_ACCESS_QUALIFIER, SPV_OPERAND_TYPE_LITERAL_STRING}, 0xffffffffu, 0xffffffffu},
      |                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                                SPV_OPERAND_TYPE_ACCESS_QUALIFIER

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Ben! I've also reproduced it locally, and just forgot to upload my fixes to the Tools - you can see the PR in the reference now :)
Now tools are buildable, local ctests pass, and the "basic" spirv with added capability and extension are going without problems through spirv-val, spirv-as and spirv-dis.

@bashbaug
Copy link
Contributor

@alan-baker can you please confirm it's OK to merge this? Thanks!

Copy link
Contributor

@alan-baker alan-baker left a comment

Choose a reason for hiding this comment

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

Seems ok

Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

Merging as discussed in the August 16th teleconference.

@bashbaug bashbaug merged commit b8b9eb8 into KhronosGroup:main Aug 16, 2023
10 checks passed
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.

None yet

4 participants