"How do you write pseudo-code for parallel programming? Especially, how do you differentiate local and shared variables? How do you represent operations like scatter, gather, reduce, broadcast, and point-to-point communications? Is there some standards about that?"

Please, note the original question was asked here but it still does NOT have a good acceptable answer.

Re-elaborating other questions, summarizing and keeping the things easy: is there a way of saying in pseudocode "DO ALL THESE THINGS IN PARALLEL"?

I am using the package algorithm2e with TeXStudio. How to typeset the parallel code using them?

  • Then I suggest that you elaborate you question, for example explain why the other answers on TeX.SE is not satisfying.
    – Sveinung
    Aug 7, 2019 at 16:23
  • that is a great suggestion, I will
    – Leos313
    Aug 7, 2019 at 16:24
  • the question was updated. I would like to remark that in the original question it was stated that the question is a kind of duplicate of others because there is still a big hole in this field in that direction
    – Leos313
    Aug 7, 2019 at 16:32
  • yes it is. To be more precise, how to write it using algorithm2e, the package I am using. To be honest, a general answer on how to structure a pseudocode (not only in LaTeX, that I am using right now) can be sufficient
    – Leos313
    Aug 7, 2019 at 18:37
  • Let us continue this discussion in chat.
    – Leos313
    Aug 8, 2019 at 8:15

1 Answer 1


After some web research, I have realized that a kind of "standard" still does not exits. So here is my personal solution using algorithm2e:

    \SetKwBlock{DoParallel}{do in parallel}{end}
    \KwIn{Some inputs}
    \KwOut{The ouput}
        Compute a \;
        Compute b \;
        Compute c \;
    \Return{the solution}\;
    \caption{Parallel Algo}

The result is:

enter image description here

It is based on defining a new command using the expression \SetKwBlock. The manual of the package can be found here. Also, I have just added almost the same solution to a similar question on StackOverflow. The answer and the question can be found here.

Using the strategy of defining your keywords in order to describe your algorithm with the details you prefer, it should be always possible. Take into consideration that:

  1. more details → more you will be close to your programming languages.
  2. fewer details → more it can be seen as a pseudo-code.

Concluding: it is always a matter of trade-offs: you decide where is the limit (taking into account the target people you refer to).

The same strategy has been used in journal papers (for instance, see Algorithm 3 and 4 of this IEEE journal paper).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.