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

SIMD support in the vector library #251

Closed
Magalame opened this issue Jul 9, 2019 · 16 comments
Closed

SIMD support in the vector library #251

Magalame opened this issue Jul 9, 2019 · 16 comments

Comments

@Magalame
Copy link

Magalame commented Jul 9, 2019

Hi!

I was wondering if there were any plan to add support for SIMD instructions to vector now that GHC supports them even without llvm?

Thanks to @Drezil and @klapaucius I'm aware of this paper and this work, but the branch is 6 years old and so probably doesn't reflect the current direction of vector.

If there's any need for help, I'd be more than happy to contribute!

@Magalame
Copy link
Author

Magalame commented Jul 9, 2019

Came from lehins/massiv#80

@chessai
Copy link
Member

chessai commented Sep 24, 2019

as far as i am aware, that patch you link to doesn't actually work as intended. @bgamari and @AndreasPK would be able to say why, if so.

@andrewthad
Copy link
Contributor

Here's the commit that reverted NCG SIMD support: https://gitlab.haskell.org/ghc/ghc/commit/db948daea6c01c073f8d09a79fa5adda279fbf0c

@Magalame
Copy link
Author

Thanks @andrewthad for the link! Do we know when it'll be added back?

@chessai
Copy link
Member

chessai commented Sep 24, 2019

@Magalame i know the two individuals that plan on implementing it/supervising its implementation are Ben Gamari and Andreas Klebinger.

@bgamari
Copy link
Contributor

bgamari commented Sep 24, 2019

@AndreasPK has indeed expressed interest in picking it up. In short, the commit as written has an overly-simplistic view of register allocation and breaks in some cases.

@cartazio
Copy link
Contributor

cartazio commented Sep 25, 2019 via email

@Magalame
Copy link
Author

Magalame commented Oct 7, 2019

@bgamari @AndreasPK thanks a lot for the work you're putting into this. Do you have a general idea of when it would be available?

@Magalame
Copy link
Author

Magalame commented Oct 7, 2019

Thanks @cartazio for the details, I thought the MultisC type would have ensured a relatively seamless integration?

@cartazio
Copy link
Contributor

cartazio commented Oct 9, 2019

it worked as a technology demonstrator, but simd as it currently exists in the forseeable future is incredible monomorphic, only really for vectors on Float/Double/Int32/Int64/Word32/Word64, so it would only pay off for a pretty spare/small fraction of user code.

It is possible that a future version of vector could allow simd integration to the fusion framework, but given engineering priorities for the future of vector as they currently exist, unless we can jointly improve the current O2 compilation performance AND fusion quality first, its not going to happen ever. Adding another rewrite rule layer to the current setup seems like piling architecture debt.

that aside, not enough compiler support in the GHC layer actually exists to robustly support simd across all supported targets. And since vector is so widely used, that might be a blocker to including it in core vector as a library until conditional compilation / distinct code paths per microarchtecture is sanely supported at the GHC layer.

if you want to experiment rebasing the multiC change set onto vector master or friends, so we can look at it in an up to date way, i'm all ears. We just genuinely dont have the time/resources/bandwidth though. And i'm skeptical that its the right architecture going forward

@cartazio cartazio closed this as completed Oct 9, 2019
@Magalame
Copy link
Author

I see, thanks so much for taking the time to answer!

@cartazio
Copy link
Contributor

cartazio commented Oct 12, 2019 via email

@GeorgeCo
Copy link

I assume that if you compile with llvm you will get SIMD instructions when applicable. Is that false?

@cartazio
Copy link
Contributor

cartazio commented Jun 23, 2023 via email

@Drezil
Copy link

Drezil commented Jun 24, 2023

Depends on the operations you do.
vector is basically an implementation of the "recycle your arrays"-paper. It has streaming-capabilities AND block/buffer ones. What gets done is ruled by compiler optimisations and if the generated llvm looks code looks optimizable for libllvm than those things get turned into simd operations. But it is hit and miss - as far as I remember.
It has been years when I last looked into it .. so it may have changed in the meantime.

@cartazio
Copy link
Contributor

cartazio commented Jun 24, 2023 via email

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

No branches or pull requests

7 participants