Giter Club home page Giter Club logo

Comments (5)

dneto0 avatar dneto0 commented on May 22, 2024

The root cause is the translation of

  %conv = sext i8 %1 to i32

The i8 is mapped to a SPIR-V 32-bit unsigned int. But the conversion of the SExt doesn't take that into account.

Original OpenCL C:

kernel void bar(global int* A, global char4* B) {
  *A = B->y;
}

last LLVM:

  %0 = load <4 x i8>, <4 x i8> addrspace(1)* %B, align 4
  %1 = extractelement <4 x i8> %0, i32 1
  %conv = sext i8 %1 to i32
  store i32 %conv, i32 addrspace(1)* %A, align 4

becomes SPIR-V:

         %28 = OpLoad %uint %27
         %29 = OpShiftRightLogical %uint %28 %uint_8
         %30 = OpBitwiseAnd %uint %29 %uint_255
         %31 = OpSConvert %uint %29   ; Not right because source type is too wide in SPIR-V
               OpStore %26 %31

from clspv.

dneto0 avatar dneto0 commented on May 22, 2024

There's a corresponding problem with unsigned char.

from clspv.

dneto0 avatar dneto0 commented on May 22, 2024

Also sitofp i8 to float

kernel void bar(global float* A, global char4* B) {
  *A = (float)(B->y);
}

Final LLVM:

  %1 = extractelement <4 x i8> %0, i32 1
  %conv = sitofp i8 %1 to float
  store float %conv, float addrspace(1)* %A, align 4

becomes SPIR-V:

         %29 = OpLoad %uint %28
         %30 = OpShiftRightLogical %uint %29 %uint_8
         %31 = OpBitwiseAnd %uint %30 %uint_255
         %32 = OpConvertSToF %float %30

from clspv.

dneto0 avatar dneto0 commented on May 22, 2024

I can't reproduce a problem with unsigned char.

from clspv.

alan-baker avatar alan-baker commented on May 22, 2024

Default behaviour (when char support is enabled) is ok, but disabling char support is still problematic.

from clspv.

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.