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

SPIR-V validation error: "Interface variable is used by entry point, but is not listed as an interface" #9958

Closed
karolherbst opened this issue Jun 17, 2023 · 11 comments
Assignees
Labels
bug Something isn't working confirmed

Comments

@karolherbst
Copy link
Contributor

karolherbst commented Jun 17, 2023

Multiple SyCL CTS tests are triggering the "Interface variable is used by entry point, but is not listed as an interface" spir-v validation error, e.g. test_atomic_fence

; SPIR-V
; Version: 1.4
; Generator: Khronos LLVM/SPIR-V Translator; 14
; Bound: 1113
; Schema: 0
...
               OpEntryPoint Kernel %23 "_ZTSZZN17atomic_fence_test16run_atomic_fenceISt17integral_constantIN4sycl3_V112memory_orderELS4_3EES1_INS3_12memory_scopeELS6_2EES1_INS_9test_typeELS8_1EEEclERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESI_SI_ENKUlRNS3_7handlerEE_clESK_EUlNS3_7nd_itemILi1EEEE_"
...
    %__spirv_BuiltInGlobalOffset = OpVariable %_ptr_CrossWorkgroup_v3ulong CrossWorkgroup
...
         %23 = OpFunction %void None %22
...
         %65 = OpLoad %v3ulong %__spirv_BuiltInGlobalOffset Aligned 32

From the SPIR-V specification on OpEntryPoint:

"Interface is a list of of global OpVariable instructions. These declare the set of global variables from a module that form the interface of this entry point. The set of Interface must be equal to or a superset of the global OpVariable Result referenced by the entry point’s static call tree, within the interface’s storage classes. Before version 1.4, the interface’s storage classes are limited to the Input and Output storage classes. Starting with version 1.4, the interface’s storage classes are all storage classes used in declaring all global variables referenced by the entry point’s call tree."

Side Note: the storage class of builtins also have to be in the Input storage class according to the OpenCL SPIR-V Env specification in 2.9: "An OpVariable in a SPIR-V module with the BuiltIn decoration represents a built-in variable. All built-in variables must be in the Input storage class."

Side Note2: I'm confused this even comes up, as this issue was fixed years ago in the SPIRV-LLVM-Translator:

@karolherbst karolherbst added the bug Something isn't working label Jun 17, 2023
@karolherbst
Copy link
Contributor Author

I actually filed a bug already a few months ago on the "Built In variable" storage class: #6703

@asudarsa
Copy link
Contributor

asudarsa commented Jul 21, 2023

This is the llvm-spirv command I run on the bc file attached. This llvm-spirv is built using Khronos main branch SPIRV-LLVM-Translator.

llvm-spirv -o atomic_fence.spv -spirv-max-version=1.4 -spirv-debug-info-version=ocl-100 -spirv-allow-extra-diexpressions -spirv-allow-unknown-intrinsics=llvm.genx. -spirv-ext=-all,+SPV_EXT_shader_atomic_float_add,+SPV_EXT_shader_atomic_float_min_max,+SPV_KHR_no_integer_wrap_decoration,+SPV_KHR_float_controls,+SPV_KHR_expect_assume,+SPV_KHR_linkonce_odr,+SPV_INTEL_subgroups,+SPV_INTEL_media_block_io,+SPV_INTEL_device_side_avc_motion_estimation,+SPV_INTEL_fpga_loop_controls,+SPV_INTEL_unstructured_loop_controls,+SPV_INTEL_fpga_reg,+SPV_INTEL_blocking_pipes,+SPV_INTEL_function_pointers,+SPV_INTEL_kernel_attributes,+SPV_INTEL_io_pipes,+SPV_INTEL_inline_assembly,+SPV_INTEL_arbitrary_precision_integers,+SPV_INTEL_float_controls2,+SPV_INTEL_vector_compute,+SPV_INTEL_fast_composite,+SPV_INTEL_joint_matrix,+SPV_INTEL_arbitrary_precision_fixed_point,+SPV_INTEL_arbitrary_precision_floating_point,+SPV_INTEL_variable_length_array,+SPV_INTEL_fp_fast_math_mode,+SPV_INTEL_long_constant_composite,+SPV_INTEL_arithmetic_fence,+SPV_INTEL_global_variable_decorations,+SPV_INTEL_fpga_buffer_location,+SPV_INTEL_fpga_argument_interfaces,+SPV_INTEL_fpga_invocation_pipelining_attributes,+SPV_INTEL_optnone,+SPV_INTEL_token_type,+SPV_INTEL_bfloat16_conversion,+SPV_INTEL_joint_matrix,+SPV_INTEL_hw_thread_queries,+SPV_INTEL_memory_access_aliasing,+SPV_KHR_uniform_group_instructions,+SPV_INTEL_masked_gather_scatter,+SPV_INTEL_tensor_float32_conversion atomic_fence.bc

I get the following OpEntryPoint in the generated spv code. Looks like all the interfaces are listed as we expect.

OpEntryPoint Kernel %1356 "_ZTSZZN17atomic_fence_test16run_atomic_fenceISt17integral_constantIN4sycl3_V112memory_orderELS4_3EES1_INS3_12memory_scopeELS6_2EES1_INS_9test_typeELS8_1EEEclERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESI_SI_ENKUlRNS3_7handlerEE_clESK_EUlNS3_7nd_itemILi1EEEE_" %__spirv_BuiltInGlobalOffset %__spirv_BuiltInGlobalInvocationId %__spirv_BuiltInLocalInvocationId %__spirv_BuiltInWorkgroupId %__spirv_BuiltInGlobalLinearId %__spirv_BuiltInWorkgroupSize

However, I see a new error now:

error: line 68: AliasDomainDeclINTEL must appear in a block
  %61 = OpAliasDomainDeclINTEL

Will open a separate issue, may be.

Thanks

@asudarsa
Copy link
Contributor

@karolherbst

Can you please check when convenient?
I did verify that the EntryPoint did not have interfaces listed with an older llvm-spirv.

Thanks

@asudarsa asudarsa self-assigned this Jul 21, 2023
@karolherbst
Copy link
Contributor Author

@karolherbst

Can you please check when convenient? I did verify that the EntryPoint did not have interfaces listed with an older llvm-spirv.

Thanks

this isn't a bug inside llvm-spirv, because I've fixed it there a long time ago. This is a bug inside Intel's SyCL implementation, which I have no idea why it happens, but it does.

@asudarsa
Copy link
Contributor

@karolherbst
Can you please check when convenient? I did verify that the EntryPoint did not have interfaces listed with an older llvm-spirv.
Thanks

this isn't a bug inside llvm-spirv, because I've fixed it there a long time ago. This is a bug inside Intel's SyCL implementation, which I have no idea why it happens, but it does.

Ah..of course..thanks for the redirect. Given that it's reported here, I should have tried llvm-spirv from intel/llvm branch. I will try that and see if I am able to reproduce the error.

Thanks

@asudarsa
Copy link
Contributor

This issue is mainly due to differences between intel/llvm's llvm-spirv and khronos. We are tracking the effort to minimize this difference here: #7592

In this particular case, we are missing the following commit in intel/llvm:
commit 352ea14d320da10fcf72c19b46c50020e657c89a
Author: KornevNikita [email protected]
Date: Tue Dec 21 16:07:34 2021 +0300
Fix the collection of entry point interfaces (#1334)
This is a patch to expand the collection of entry point interfaces.
In SPIR-V 1.4 and later OpEntryPoint must list all global variables in the
interface. Also fix quoted string output in SPIRV text format.
Co-authored-by: Alexey Sotkin [email protected]

Reintroducing this commit resolves this issue. We will investigate further and provide a PR to intel/llvm soon.

Thanks

@karolherbst
Copy link
Contributor Author

This issue is mainly due to differences between intel/llvm's llvm-spirv and khronos. We are tracking the effort to minimize this difference here: #7592

In this particular case, we are missing the following commit in intel/llvm: commit 352ea14d320da10fcf72c19b46c50020e657c89a Author: KornevNikita [email protected] Date: Tue Dec 21 16:07:34 2021 +0300 Fix the collection of entry point interfaces (#1334) This is a patch to expand the collection of entry point interfaces. In SPIR-V 1.4 and later OpEntryPoint must list all global variables in the interface. Also fix quoted string output in SPIRV text format. Co-authored-by: Alexey Sotkin [email protected]

Reintroducing this commit resolves this issue. We will investigate further and provide a PR to intel/llvm soon.

Thanks

Though is 352ea14d320da10fcf72c19b46c50020e657c89a enough as the storage class of builtins needs to be Input?

I don't think spirv-val validates this yet as this is mainly an OpenCL SPIR-V Env spec thing.

AlexeySachkov pushed a commit that referenced this issue Aug 2, 2023
…y point interfaces (PR #1334) (#10623)

This PR pulls in the following PR from upstream Khronos
SPIRV-LLVM-Translator repo:
KhronosGroup/SPIRV-LLVM-Translator#1334

`
This is a patch to expand the collection of entry point interfaces.
In SPIR-V 1.4 and later OpEntryPoint must list all global variables in
the
interface.
`
In addition, a couple of minor changes have been added to sync with
latest code.
This patch addresses #9958

Updated the following tests to sync with upstream as well:

llvm-spirv/test/extensions/INTEL/SPV_INTEL_inline_assembly/inline_asm_clobbers.cl

llvm-spirv/test/extensions/INTEL/SPV_INTEL_inline_assembly/inline_asm_constraints.cl

Thanks

---------

Signed-off-by: Arvind Sudarsanam <[email protected]>
@asudarsa
Copy link
Contributor

asudarsa commented Aug 2, 2023

Hi @karolherbst

Thanks again for reporting this. A fix has been merged for this. Can you please verify if this issue is resolved at your end?

Sincerely

@asudarsa
Copy link
Contributor

asudarsa commented Aug 2, 2023

I do see the error reported by spirv-val goes away with this patch.
For this issue and other similar SYCL-CTS/spirv-val fails, it will be helpful if we can know the reproduction steps that you used in order to reproduce the error on our end. I might have missed something in my local test.

Thanks again
Sincerely

@karolherbst
Copy link
Contributor Author

spirv-val doesn't report any error if builtins aren't in the Input storage class, but it is a OpenCL SPIR-V Env spec violation nonetheless.

@karolherbst
Copy link
Contributor Author

karolherbst commented Oct 12, 2023

Anyway, this can be closed as we already have a bug for the invalid storage class: #6703

mdtoguchi pushed a commit to mdtoguchi/llvm that referenced this issue Oct 18, 2023
…y point interfaces (PR intel#1334) (intel#10623)

This PR pulls in the following PR from upstream Khronos
SPIRV-LLVM-Translator repo:
KhronosGroup/SPIRV-LLVM-Translator#1334

`
This is a patch to expand the collection of entry point interfaces.
In SPIR-V 1.4 and later OpEntryPoint must list all global variables in
the
interface.
`
In addition, a couple of minor changes have been added to sync with
latest code.
This patch addresses intel#9958

Updated the following tests to sync with upstream as well:

llvm-spirv/test/extensions/INTEL/SPV_INTEL_inline_assembly/inline_asm_clobbers.cl

llvm-spirv/test/extensions/INTEL/SPV_INTEL_inline_assembly/inline_asm_constraints.cl

Thanks

---------

Signed-off-by: Arvind Sudarsanam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed
Projects
None yet
Development

No branches or pull requests

3 participants