Giter Site home page Giter Site logo

Comments (4)

dkolsen-pgi avatar dkolsen-pgi commented on June 19, 2024 3

Note you'd still need an operation to extend these vectors before passing them to a shuffle as input.

That's not necessary. The result vector can have a different size than the two input vectors.

from clangir.

bcardosolopes avatar bcardosolopes commented on June 19, 2024

Current CIRGen may emit %vi4res = cir.vec.create(..., %vi2a, %vi2b) for the source OpenCL code vi4 vi4res = (vi4)(vi2a, vi2b), and end up with "inserting elements typed vi2 into a vector typed vi4 in LLVM IR".

I don't remember offhand. Does this seems like something done by design (i.e. we already have testcases for this) or is it something we forgot to verify?

Looking at VecCreateOp::verify my impression is that this isn't supported, didn't you get verification errors?

The corresponding implementation from OG CodeGen is here. It uses shuffle operations to extend two vectors and merge the effective elements into the final result.

We can make it CIRGen or Lowering (keep the cir.vec.create(%vi2a, %vi2b) in CIR, rather than emitting shuffles immediately). I prefer CIRGen still.

Whatever we decide to do on CIRGen, we need to make sure that the corresponding LLVM lowering should match what OG codegen does (in this case it shall be series of shuffles). However, if we could do better in CIRGen to map the semantics in a more clear way, we should do it - if we emit shuffles in CIRGen we make it potentially harder to retrieve original information, because we need to look into the shuffle and recognize it's just joining two smaller vectores.

I'd prefer avoiding shuffles this early for this, but if it's something we are already doing, then it wouldn't be inconsistent (and we can later improve by adding other ops). I'd also be fine with improving cir.vec.create to support the "building from smaller vectors" scenary. Another option would be to introduce operations for extending number of lanes and use that result to build the vectors, but not sure how well that feds into cir.vec.create later.

@dkolsen-pgi, suggestions on what do you think might play better here?

from clangir.

dkolsen-pgi avatar dkolsen-pgi commented on June 19, 2024

GNU vectors do not support concatenating two vectors with the syntax:

vi4 res = (vi4)(a, b);

So I haven't implemented that in CIR.

I think this is best implemented with cir.vec.shuffle rather than cir.vec.create. Concatenating two vectors is one of the things that shufflevector is designed to do.

from clangir.

bcardosolopes avatar bcardosolopes commented on June 19, 2024

Works for me, though a concat op would be cool too, but perhaps we could wait until we actually have a pass that'd prefer saving some compile time by not having to look at the mask to reconstruct the concat.

Note you'd still need an operation to extend these vectors before passing them to a shuffle as input. We could probably use some form of cast for that.

from clangir.

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.