How to write parallel compositions of processes in Elixir?

How can parallel composition of process be encoded in Elixir ?

I am not sure I understand your question. What do you mean by “encode” and “parallel composition”? A bit more context would be useful here.

Kindly look into this particular thread : Trying to find a correspondence between constructs in a given Mailbox Calculus and Elixir

Can you please explain what you are asking about, instead of posting a link to a link to link to a pdf that I have to read completely?

The parallel composition is made of of a process P concurrently being processed to another process G. However the process are defined explicitly in the link provided in the previous thread.

p = spawn(fn … end)
g = spawn(fn … end)
send(g, p)

Depending on your exact communication needs, you might want to wrap p in a tupple to “tag” it before sending.

Would is happening when sending send (g,p) please ? Sorry but I am new to Elixir.

spawn will return the PID of the spawned process, send/2 sends the term it gets as second argument to the process identified by the first argument.

send/2 does not understand via-tuples though, only PIDs and atoms.

Thanks a lot.

One suggestion: you might get better help by continuing the original thread instead of opening multiple ones. That way, people would immediately have the context of the previous discussion at hand.

Some people (me for sure) might not be 100% aware of your specific definition of the terms you are using. It might be because some of them are used with different meanings in different contexts like academia and industry (e.g. “process” as an abstract unit of computation, vs. OS process, vs. Erlang process or “encoding” as serialization vs. encoding in formal types).

Thank you all for your help and sorry again for mixing up thing.

Though I have to be honest, I still don’t get what “process P gets processed by G” actually means.

Processes are isolated to each other in the BEAM and communicate via sending messages.

I have not read the paper you linked transitively, as I don’t have the time right now. Perhaps I might be able to do during the weekend, but that’s not a promise.

Thanks a lot. I meant something like this P | G. Process P being parallelised with Process G.

Just spawn them separately then. That makes them running concurrently.

There is no true parallelism in the BEAM.

What do you mean by this? Surely two processes will run in parallel, on different schedulers, if you have more than one CPU core on your system.

By “true parallelism” I mean what I have learned as “parallel computing” at university.

Same operations on different data at the same time. As on GPU or modern CPU using SIMD.

1 Like

One more reason to make sure we all understand the specific definition of the terms we use in the thread :wink:

Terms like “process”, “encoding”, “parallelism” all have different meanings in different context:

  • OS process, vs Erlang process, vs. abstract unit of computation
  • Parallelism as execution on multiple CPUs vs. SIMD
  • Encoding as serialization vs. type encoding vs. writing in code
2 Likes

There is no true parallelism within a given BEAM scheduler yes. If you are on a multi-core processor running multiple schedulers (the default) then true parallelism does occur.

4 Likes