[erlang-questions] Vector instructions

Robert Virding <>
Mon Apr 7 00:00:39 CEST 2008


I agree with Zvi here. Such a change would cause much confusion to users who
do not want this feature. It would be better to add a new datatype for this
and a set of functions operating on this type. BUT I would put the new BIFs
in a separate module and not just dump them into erlang.

I don't agree with you on your other "mistakes":

1. With records we were constrained to make them as fast as pure tuple
operations. We maybe could have made a new datatype for it though.
2. And I think that lists are a wonderful datatype for processing strings.

Robert

On 06/04/2008, Zvi <> wrote:
>
>
> James,
>
> With generic tuples it's impossible to implement efficient SIMD
> operations.
> Also there is many undefined/confusing behaiviors, when elements of tuple
> are not numeric.
>
> This is the same kind of mistakes, like 2 bad design decisions made in
> Erlang:
> 1. "Ohh, record looks just like a tuple!",  so let's throw in some
> syntactic
> sugar for this, instead of real immutable structs/dictionaries.
> 2. "Ohh, string looks just like a list of integers!", so let's throw in
> some
> syntactic sugar for this, instead of implementing real Unicode-aware
> immutable string datatype.
>
> In my opinion Erlang might be a good match, not only for High Availability
> (HA) applications, but also High Performance Computing (HPC) applications,
> and it might wipe out MPI as de-facto standard, by additing highly
> optimized
> Matlab-like "matrix of double"/"multidimensional array of double"
> datatype.
> Array Programming is also such a good fit for FP, since you may naturaly
> extend map and fold/reduce for this datatype.
> Also, vector math, even if not implemented efficiently, makes you much
> more
> productive and allows you to prototype with one-liners from shell.
> Combining
> this with Erlang's built-in concurrency and distrition primitives it makes
> it Super-High-level language. Unlike other Array programming languages, I
> propose that Erlang matrix datatype will be immutable.
>
> So, in my view Erlang should be  H^3 (read as H-cube) language:
>
> Highly Available
> HPC
> High-level
>
> For the start maybe it's possible to take some code from PyNum
> (unfortunately Octave has GNU license).
>
> http://en.wikipedia.org/wiki/Category:Array_programming_languages
> http://en.wikipedia.org/wiki/Numpy
> http://en.wikipedia.org/wiki/GNU_Octave
>
>
> BTW, I somewhat disappointed with vector math implemented in Matlab and
> kdb+/Q. It's not much faster than serial Erlang code (and much much slower
> than parallel Erlang code). You can see it in my little PI calculation
> benchmark:
>
> Matlab:
>
> >> tic; N=1000000; Step = 1/N; PI =
> Step*sum(4./(1+(((1:N)-0.5)*Step).^2));
> >> toc
> Elapsed time is 0.125428 seconds.
>
> Q:
>
> q)N:1000000
> q)Step:1%N
> q)PI: {[]; Step*((4f % (1f + ((Step*((1+ til N)-0.5)) xexp 2))) +/)}
> q)PI()
> 3.141593
> q)\t do[1000;PI()]
> 264359
> q)
>
> i.e. 264 ms
>
> on my dual CPU workstation I getting ~ 200 ms.
>
>
> Erlang:
>
> Serial tail-recursuive Erlang version takes ~ 170 ms - 300 ms (on
> different
> machines).
> Parallel Erlang version on 16 cores takes 15 ms
>
> Zvi
>
>
>
> James Hague wrote:
> >
> >>  Has anyone given any thought to adding vector instructions or
> otherwise
> >>  adding support for vectors to Erlang?
> >
> > I've proposed adding APL-style vector operations on tuples:
> >
> > {1,2,3} + 1 ==> {2,3,4}
> > {1,2,3) * 2 ==> {2,4,6}
> > 2 * {1,2,3} ==> {2,4,6}
> > {1,2,3} + {3,2,1} ==> {4,4,4}
> >
> > The operations apply to the top level only; they're not recursive.
> > This would make vector math style code a lot simpler to write in
> > Erlang.  One of the points raised in response to this was that we
> > shouldn't be overloading tuple operations like this, but have a
> > special "vector of float" type.  I'm not sure I agree with that.
> > _______________________________________________
> > erlang-questions mailing list
> > 
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> >
>
>
> --
> View this message in context:
> http://www.nabble.com/Vector-instructions-tp16468138p16529946.html
> Sent from the Erlang Questions mailing list archive at Nabble.com.
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080407/b65e14ef/attachment.html>


More information about the erlang-questions mailing list