Code Monkey home page Code Monkey logo

Comments (6)

karolherbst avatar karolherbst commented on August 16, 2024

SPIRV 1.4 added OpPtrEqual and OpPtrNotEqual in order to let us compare pointers, but maybe it would be too harsh to require 1.4?

Otherwise in order to fix that we would have to cast pointers to unsigned integers and compare these.

from spirv-llvm-translator.

kpet avatar kpet commented on August 16, 2024

+1, I've hit a similar problem. Here's a module to reproduce:

source_filename = "repro.cl"
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-unknown"

define spir_kernel void @test(i8 addrspace(1)* %aptr, i8 addrspace(1)* %bptr) local_unnamed_addr #0 !kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3 !kernel_arg_base_type !3 !kernel_arg_type_qual !4 {
entry:
  %cmp213 = icmp ugt i8 addrspace(1)* %aptr, %bptr
  ret void
}

attributes #0 = { "use-soft-float"="false" }
attributes #1 = { nounwind readnone speculatable }

!llvm.ident = !{!0}

!0 = !{!"clang version 9.0.0 "}
!1 = !{i32 1, i32 1}
!2 = !{!"none", !"none"}
!3 = !{!"uchar*", !"uchar*"}
!4 = !{!"", !""}

The SPIR-V produced is

; SPIR-V
; Version: 1.0
; Generator: Khronos LLVM/SPIR-V Translator; 14
; Bound: 13
; Schema: 0
               OpCapability Addresses
               OpCapability Kernel
               OpCapability Int8
          %1 = OpExtInstImport "OpenCL.std"
               OpMemoryModel Physical64 OpenCL
               OpEntryPoint Kernel %6 "test"
         %12 = OpString "kernel_arg_type.test.uchar*,uchar*,"
               OpSource Unknown 0
               OpName %aptr "aptr"
               OpName %bptr "bptr"
               OpName %entry "entry"
               OpName %cmp213 "cmp213"
      %uchar = OpTypeInt 8 0
       %void = OpTypeVoid
%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar
          %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_uchar
       %bool = OpTypeBool
          %6 = OpFunction %void None %5
       %aptr = OpFunctionParameter %_ptr_CrossWorkgroup_uchar
       %bptr = OpFunctionParameter %_ptr_CrossWorkgroup_uchar
      %entry = OpLabel
     %cmp213 = OpUGreaterThan %bool %aptr %bptr
               OpReturn
               OpFunctionEnd

which fails validation

error: line 22: Expected operands to be scalar or vector int: UGreaterThan
  %cmp213 = OpUGreaterThan %bool %aptr %bptr

from spirv-llvm-translator.

kpet avatar kpet commented on August 16, 2024

@karolherbst We do need a solution pre-1.4. It seems that converting to integers is the only way. FWIW, the LLVM language reference manual states

If the operands are pointer typed, the pointer values are compared as if they were integers.

from spirv-llvm-translator.

karolherbst avatar karolherbst commented on August 16, 2024

yeah, I think converting to integers pre 1.4 is valid, I would just support both ways. And I think there is already the assumption that the consumer always has to be able to support the most recent spirv version...

might be worth to kind of being able to tell what's the highest version the consumer supports and then disabling certain features or something.

from spirv-llvm-translator.

AlexeySachkov avatar AlexeySachkov commented on August 16, 2024

And I think there is already the assumption that the consumer always has to be able to support the most recent spirv version...

Really? For example, intel/compute-runtime supports only SPIR-V 1.2

might be worth to kind of being able to tell what's the highest version the consumer supports and then disabling certain features or something.

I think we definitely need this, see #110 for appropriate discussion.

from spirv-llvm-translator.

karolherbst avatar karolherbst commented on August 16, 2024

And I think there is already the assumption that the consumer always has to be able to support the most recent spirv version...

Really? For example, intel/compute-runtime supports only SPIR-V 1.2

oh, could be that I am wrong. I think some future spir-v feature was enabled without the extension... would have to search for it again.

from spirv-llvm-translator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.