I am generating the orbit of a partition of a set of size $n$ under the action of the symmetric group $S_n$. PermutationReplace won't allow itself to be parallelized. Why is this ? Is it because the Operating System is already multi-threading it ? Is there a way to parallelize it efficiently ? I tried the below, but my ugly attempt at parallelization led to slower code, not faster. My timing results were 0.26 seconds serially, and 3.83 seconds in parallel. I have 4 cores available.
n = 8;
partition = {{1, 3, 5}, {2}, {4, 7}, {6, 8}};
Parallelize[PermutationReplace[partition, SymmetricGroup[n]]];
starttime = TimeUsed[];
serial = PermutationReplace[partition, SymmetricGroup[n]];
endtime = TimeUsed[];
Print["Serial computation took ", endtime - starttime, " seconds."];
starttime = TimeUsed[];
parallel =
ParallelTable[
PermutationReplace[partition, permutation], {permutation,
SymmetricGroup[n]}, Method -> "CoarsestGrained"];
endtime = TimeUsed[];
Print["Parallel computation took ", endtime - starttime,
" seconds."];
serial == parallel
PermutationReplace
, so I do not think that multi-treading occurs automatically in this case. If I launch the kernels before runningParallelize
, the runtime with and without it about the same.ParallelTable
fails as written in the code but appears to work for,ParallelTable[PermutationReplace[partition, permutation], {permutation, SymmetricGroup[n] // GroupElements}, Method -> "CoarsestGrained"];
but is very slow. $\endgroup$ – bbgodfrey Sep 4 '18 at 1:40