[erlang-questions] Vector instructions

jm <>
Tue Apr 8 01:38:26 CEST 2008

James Hague wrote:
> On Sun, Apr 6, 2008 at 4:16 PM, Zvi <> wrote:
>>  With generic tuples it's impossible to implement efficient SIMD operations.
> I would hesitate to say "impossible" :)  Efficiency would clearly be
> better than what we have now, though not the pinnacle of performance
> (and is anything in Erlang the pinnacle of performance?).

How about,
%% <3.1415, 1.0>
V1 = <<16#40, 16#49, 16#0E, 16#56, 16#3F, 16#80, 16#00, 16#00>>,
%% <1.0, 1.6180>
V2 = <<16#3F, 16#80, 16#00, 16#00, 16#3F, 16#CF, 16#1A, 16#9F>>,
vec:add(single, V1, V2).

obviously V1 and V2 would normally be created with helper functions. The 
advantage of using binaries would be that you would have to add a new 
type to Erlang and could more easily do DSP functionality on an input 
stream, eg GSM codecs using for VOIP, before having to optimise with C 
or another lower language. The first parameter to vec:add/3 would be one 
of the atoms: single, double, octet, short, long, or longlong.

What about matricies? list of binaries?


> I can certainly see the quirks in my proposal, and I don't ever expect
> to see it in Erlang.  But I don't know if adding yet another basic
> data type to Erlang is the way to go.
>>  Also there is many undefined/confusing behaiviors, when elements of tuple
>>  are not numeric.
> Not any more than you have with "1 + ok".
> _______________________________________________
> erlang-questions mailing list
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list