Are listability and being parallelized the same? In other words, Does parallelizing a listable function which has already a list as of its argument make the computation faster?

In the documentation it is written that a listable function threads over the elements of a list which seems is equal to parallelization if all those threading are calculated simultaneously. If it is not the case. what is the point of making a function listable while we can achieve that by parallelizing a function over a list.

  • 3
    $\begingroup$ No, they are generally not the same. Only a fraction of the Listable functions in the kernel can utilize all available threads. Besides, there are two different levels of Listability, the one which is low-level (used in kernel functions), and which allows to push all work into the kernel and avoid top-level threading, and the top-level, which is more a convenience to avoid explicit use of Map, than a speed booster. Check out this answer of mine, where I tried ... $\endgroup$ Dec 22 '14 at 15:39
  • 3
    $\begingroup$ ... to clarify this difference. As to parallel, the kernel-level parallelism is a coarse-grained one, so it's automatic use can't be justified in general, as often the kernel communication overhead will be more expensive than what you gain from using more than one kernel. So, to summarize, there are two types of Listability and two levels of parallelism, and your suggestion would IMO only make sense for fine-level parallelism applied automatically to all kernel functions (low-level Listability). This may happen some day, but to my knowledge, currently this is not the case. $\endgroup$ Dec 22 '14 at 15:43
  • $\begingroup$ @Leonid You really should re-post those comments as an answer. $\endgroup$
    – Mr.Wizard
    Dec 22 '14 at 16:19
  • $\begingroup$ @Mr.Wizard Will do, when I get a bit more time. $\endgroup$ Dec 22 '14 at 16:47
  • 3
    $\begingroup$ N.B. there is one further type of parallelism available to the user: OpenMP inside a LibraryFunction as per here. This produces something much more similar to the low-level parallelism and (especially if one uses OpenMP 3) can be extremely versatile. But, you must write the underlying code in C, Fortran, &c., rather than Mathematica. $\endgroup$ Dec 22 '14 at 17:14

No, Listable has nothing to do with parallelization, as done by the Parallel Computing Tools.

There is one exception: Compiled functions that have both RuntimeAttribtues -> {Listable} and Parallelization -> True set can run in parallel when threaded over a list. This is specific to compiled functions and is described in the Compile documentation page. This type of parallelization is completely separate from the type done by Parallelize (Parallel Computing Tools).


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.