Skip to content

Implement RegisterMapInterfaceINTEL execution mode #1774

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 13 commits into from
Mar 8, 2023

Conversation

tiwaria1
Copy link
Contributor

@tiwaria1 tiwaria1 commented Dec 8, 2022

This PR adds the new execution mode RegisterMapInterfaceINTEL, see the Khronos
SPIRV spec here: KhronosGroup/SPIRV-Registry#176
This execution mode allows specifying a 'register' based interface for FPGA kernels.

The RegisterMapInterfaceINTEL execution mode is added with a 0/1 literal based on
the kernel metadata. When the metadata is:

!ip_interface !N
!N = !{!"csr"}

The translator emits RegisterMapInterfaceINTEL 0, and when the metadata is:

!ip_interface !N
!N = !{!"csr", !"accept_downstream_stall"}

The translator emits RegisterMapInterfaceINTEL 1

NOTE

@CLAassistant
Copy link

CLAassistant commented Dec 8, 2022

CLA assistant check
All committers have signed the CLA.

@tiwaria1
Copy link
Contributor Author

tiwaria1 commented Dec 8, 2022

@MrSidims Could you please help me review this as well? The tricky part here is that:

  1. This exec mode is under capability FPGAKernelAttributesv2INTEL which implicitly defines the existing capability FPGAKernelAttributesINTEL. Not sure how exactly to reflect that in the code yet.
  2. The spec states only one of StreamingInterfaceINTEL and RegisterMapInterfaceINTEL are valid at a time - should this be checked here in the translator or at some other level of the tool?

@MrSidims
Copy link
Contributor

MrSidims commented Dec 9, 2022

The spec states only one of StreamingInterfaceINTEL and RegisterMapInterfaceINTEL are valid at a time - should this be checked here in the translator or at some other level of the tool?

We usually add checks on the translation level, see Unroll vs DontUnroll masks as an example. I don't remember, if it's a case for FPGA extensions, since we were relying on clang to check correctness of attributes back then (probably we still have some checks here as well), but it seems to be a bad idea now not to add checks, since we no longer adding attributes to clang (with appropriate diagnostics). So I'd suggest to add checks here.

@MrSidims
Copy link
Contributor

MrSidims commented Dec 9, 2022

@tiwaria1 please don't forget to add a test :)

@tiwaria1
Copy link
Contributor Author

tiwaria1 commented Jan 26, 2023

@tiwaria1 please don't forget to add a test :)

Added one. I did not run it locally though. Is there any automatic git CI testing that will run it for me on this PR?

@MrSidims
Copy link
Contributor

@tiwaria1 please don't forget to add a test :)
Added one. I did not run it locally though. Is there any automatic git CI testing that will run it for me on this PR?

Yet here is, but I expect it to be broken right now due to LLVM upgrade to 17.0.0 . So I would suggest running tests locally (it won't faster the merge, since we would need to wait for the fixed CI, but still help with finding problems if any). To run test you should add -DLLVM_SPIRV_INCLUDE_TESTS=ON to cmake and run make test -j...

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.

To incorporate changes from SPIR-V headers please update spirv-headers-tag.conf

@tiwaria1
Copy link
Contributor Author

To incorporate changes from SPIR-V headers please update spirv-headers-tag.conf

I can only do that once the SPIRV-Headers PR is merged right?

@MrSidims
Copy link
Contributor

To incorporate changes from SPIR-V headers please update spirv-headers-tag.conf

I can only do that once the SPIRV-Headers PR is merged right?

Ah, sorry, I've seen notification, that the PR got closed and assumed, that is was merged.

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, just waiting for the headers be merged
Thanks!

@tiwaria1
Copy link
Contributor Author

tiwaria1 commented Mar 1, 2023

Hey @MrSidims the headers change has been merged. Has the CI been fixed yet?

@MrSidims
Copy link
Contributor

MrSidims commented Mar 3, 2023

@tiwaria1 please take a look at the test failure

@tiwaria1
Copy link
Contributor Author

tiwaria1 commented Mar 6, 2023

Having trouble building the translator locally, I did the following (llvm in-tree build steps):

git clone https://github.com/llvm/llvm-project.git
cd llvm-project/llvm/projects/
git clone https://github.com/tiwaria1/SPIRV-LLVM-Translator.git
cd SPIRV-LLVM-Translator/
# checkout my branch
mkdir build
cd build/
cmake ../llvm -DLLVM_ENABLE_PROJECTS="clang" -DCMAKE_BUILD_TYPE=Debug
make llvm-spirv -j`nproc`

and got the error:

/p/psg/swip/w/tiwaria1/ipauth/tiwaria1_specs/llvm-project/llvm/projects/SPIRV-LLVM-Translator/lib/SPIRV/SPIRVLowerConstExpr.cpp:48:10: fatal error: llvm/ADT/Triple.h: No such file or directory
 #include "llvm/ADT/Triple.h"
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
projects/SPIRV-LLVM-Translator/lib/SPIRV/CMakeFiles/LLVMSPIRVLib.dir/build.make:257: recipe for target 'projects/SPIRV-LLVM-Translator/lib/SPIRV/CMakeFiles/LLVMSPIRVLib.dir/SPIRVLowerConstExpr.cpp.o' failed

@tiwaria1
Copy link
Contributor Author

tiwaria1 commented Mar 6, 2023

Not sure what's up with clang-format check, it says:

Run cat diff-to-inspect.txt | /usr/share/clang/clang-format-17/clang-format-diff.py -p1 > clang-format.patch
Traceback (most recent call last):
  File "/usr/share/clang/clang-format-17/clang-format-diff.py", line 177, in <module>
    main()
  File "/usr/share/clang/clang-format-17/clang-format-diff.py", line [13](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/actions/runs/4345812544/jobs/7591095087#step:6:14)5, in main
    process_subprocess_result(proc, args)
  File "/usr/share/clang/clang-format-[17](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/actions/runs/4345812544/jobs/7591095087#step:6:18)/clang-format-diff.py", line 42, in process_subprocess_result
    with open(filename) as f:
NameError: name 'filename' is not defined
Error: Process completed with exit code 1.

@MrSidims
Copy link
Contributor

MrSidims commented Mar 6, 2023

Not sure what's up with clang-format check, it says:

I'll take a look at clang-format check, you may ignore it
Please take a look at the failed test:
Failed Tests (1):
LLVM_SPIRV :: extensions/INTEL/SPV_INTEL_kernel_attributes/register_map_interface_attribute.ll

/home/runner/work/SPIRV-LLVM-Translator/SPIRV-LLVM-Translator/SPIRV-LLVM-Translator/test/extensions/INTEL/SPV_INTEL_kernel_attributes/register_map_interface_attribute.ll:11:16: error: CHECK-SPIRV: expected string not found in input
; CHECK-SPIRV: Capability FPGAKernelAttributesv2INTEL
               ^
<stdin>:5:39: note: scanning from here
2 Capability FPGAKernelAttributesINTEL 
                                      ^
<stdin>:7:9: note: possible intended match here
8 Extension "SPV_INTEL_kernel_attributes" 

@tiwaria1
Copy link
Contributor Author

tiwaria1 commented Mar 7, 2023

I'll take a look at clang-format check, you may ignore it Please take a look at the failed test: Failed Tests (1): LLVM_SPIRV :: extensions/INTEL/SPV_INTEL_kernel_attributes/register_map_interface_attribute.ll

It was the missing entry in SPIRVNameMapEnum.h that was causing this. Fixed.

@tiwaria1
Copy link
Contributor Author

tiwaria1 commented Mar 8, 2023

What do I do about the clang-format error? Looks like it is some sort of script issue?

@MrSidims MrSidims merged commit a9f4f25 into KhronosGroup:main Mar 8, 2023
AlexeySachkov pushed a commit to intel/llvm that referenced this pull request Jul 25, 2023
…properties, fix RegisterMap sycl-post-link (#10406)

Add defaults for template parameters for streaming_interface and
register_map_interface in fpga_kernel_properties.hpp since current usage
gets too verbose, and defaults are allowed and implementation defined.

Register map interface also does not match SPIRV expected interface
[spec](https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_kernel_attributes.asciidoc)
and
[implementation](KhronosGroup/SPIRV-LLVM-Translator#1774),
so update sycl-post-link.
mdtoguchi pushed a commit to mdtoguchi/llvm that referenced this pull request Oct 18, 2023
…properties, fix RegisterMap sycl-post-link (intel#10406)

Add defaults for template parameters for streaming_interface and
register_map_interface in fpga_kernel_properties.hpp since current usage
gets too verbose, and defaults are allowed and implementation defined.

Register map interface also does not match SPIRV expected interface
[spec](https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_kernel_attributes.asciidoc)
and
[implementation](KhronosGroup/SPIRV-LLVM-Translator#1774),
so update sycl-post-link.
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.

3 participants