[erlang-questions] Clarify: HiPE auto-spawning?
Mikael Pettersson
mikpe@REDACTED
Fri Nov 16 13:53:22 CET 2007
On Fri, 16 Nov 2007 22:01:14 +1000, Philip Robinson wrote:
> Does HiPE automatically spread (spawn) a program across multiple cores?
>
> For example, if I have a function:
>
> test(A, B) ->
> {A + B, A * B}.
>
> Will HiPE convert it into something like the following?
>
> test(A, B) ->
> PidThis = self(),
> Pid1 = spawn(fun() -> PidThis ! {self(), A + B} end),
> Pid2 = spawn(fun() -> PidThis ! {self(), A * B} end),
> Tmp1 = receive {Pid1, Result1} -> Result1 end,
> Tmp2 = receive {Pid2, Result2} -> Result2 end,
> {Tmp1, Tmp2}.
HiPE will not perform this transformation.
The transformation you suggest changes the semantics
of the code (Erlang code can have side-effects),
and may reduce its performance. So if you want it,
you need to express it yourself.
/Mikael
More information about the erlang-questions
mailing list