Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vectorization in functional programming

Tags:

haskell

Im currently doing a machinelerning course where we implement every algorithm using vectorization. The concept of vectorization seems to be most applicable to imperative programming to make the code more compact and to use the highly optimized numerical libraries for the language. However when looking in ml books for functional programming the algorithms are implemented declarative not using vectorization. You win the readability for programmers that are not experts in linear algebra but can this implementation in haskell get close to a vectorization implementation in an imperative language?

My question is how does the concept of vectorization apply in functional languages?

like image 778
user3139545 Avatar asked Sep 29 '22 11:09

user3139545


2 Answers

Deriving from work in http://research.microsoft.com/en-us/um/people/simonpj/papers/ndp/haskell-beats-C.pdf there is a SIMD branch of GHC at https://ghc.haskell.org/trac/ghc/wiki/SIMD and ongoing work at bringing those instructions in as primitive suitable for use by libraries such as vector.

The research described in (https://dorchard.wordpress.com/2013/10/14/automatic-simd-vectorization-for-haskell-and-icfp-2013/) describes another approach that uses vectorization directly in code generation. That sort of approach has not yet landed in any usable form.

like image 193
sclv Avatar answered Oct 07 '22 16:10

sclv


This is a kind of theoretical question, but in general, vectorization is used for speeding up the procedures in terms of optimization. The algorithms may be implemented declarative but in the actual implementations they usually are vectorized as well as the functions they use.

like image 34
azal Avatar answered Oct 07 '22 16:10

azal