Set-Up: While I had tested a few toy examples that ParallelSum produces the result faster than the Sum, here I encounter one example in my code that the ParallelSum produces either wrong/incorrect result or a warning message. My code below has some new function definitions. (In reality, my complete code has more complicated functions and mappings, but I try to boil down to something simpler to save your energy for your review.)
A_ ⊕ B_ :=
Mod[{A[[1]] + B[[1]] + A[[2]] B[[3]], A[[2]] + B[[2]],
A[[3]] + B[[3]]}, 2];
Conv[m_] := IntegerDigits[Mod[m, 8], 2, 3];
SumD[n_, o_] := (fF[Conv[n]⊕Conv[o]])
Do[fF[IntegerDigits[j, 2, 3]] = j, {j, 0, 7}]
Mapp[0] = {0, 0};
Mapp[1] = {0, 1};
Mapp[2] = {1, 0};
Mapp[3] = {1, 1};
While the Sum
Sum[Mapp[SumD[a, b]][[2]], {a, 0, 1}, {b, 0, 1}]
works and it produces the correct result 2,
the ParallelSum
ParallelSum[Mapp[SumD[a, b]][[2]], {a, 0, 1}, {b, 0, 1}]
does not produce the correct result. It actually produces wrong result if I make a list of a large number of summations.
Question: I am guessing the following --- Some of the functions defined by me in the earlier part of my code, they are ONLY defined in the Kernel 1, but not defined in other Kernels? Am I correct? How do we modify it to make the ParallelSum work well? [especially I need the ParallelSum, for a list of a large number of summations not shown in my shortened code above.]
Thanks in advance!