I have the following code:
Answer = Table[Undefined, {1048576}];
SetSharedVariable[Answer];
ParallelDo[(
eq = getEx[i];
(* Some calculation here with eq *)
Answer[[i]] = Solve[eq][[1]];
), {i, 1048576}];
Export["my_list.csv", Answer]
What getEx[i]
does is to return me with an expression that I need to solve.
I need to get all 1M differents equations and save it´s answers, they are all independet of each other, so I could use parallel programming to speed thing a lot.
My problem is that with a SharedVariable, each kernel always goes to the main one for evaluation, so this code is almost slower then using a simple Do[]
instead of ParallelDo[]
I would like to know how could I make this run better? Since I am just writing into a SharedVariable but never reading from that during the parallel programing.
Thanks to all!