Skip to main content
added 311 characters in body
Source Link
molekyla777
  • 2.9k
  • 1
  • 15
  • 28

If your computation in each cycle takes little time there is no reason for paralleling this cycle. Prove:

ParallelTable[i, {i, 1, 1000000}]; // AbsoluteTiming (*8 cores*)
(*{0.449026, Null}*)
Table[i, {i, 1, 1000000}]; // AbsoluteTiming
(*{0.011001, Null}*)

This is that becouse tranfering data to parallel kernels take more time than computation on it.

Post your real code please

EDIT

Replace construction like

For[i = 1, i <= n, i++, 
some code
]

with constructions like

ParallelDo[
some code
,{i,1,n},DistributedContexts->All]

DistributedContexts->All is not recomended becouse it is distribe all contexts to all parallel kernels.

If your computation in each cycle takes little time there is no reason for paralleling this cycle. Prove:

ParallelTable[i, {i, 1, 1000000}]; // AbsoluteTiming (*8 cores*)
(*{0.449026, Null}*)
Table[i, {i, 1, 1000000}]; // AbsoluteTiming
(*{0.011001, Null}*)

This is that becouse tranfering data to parallel kernels take more time than computation on it.

Post your real code please

If your computation in each cycle takes little time there is no reason for paralleling this cycle. Prove:

ParallelTable[i, {i, 1, 1000000}]; // AbsoluteTiming (*8 cores*)
(*{0.449026, Null}*)
Table[i, {i, 1, 1000000}]; // AbsoluteTiming
(*{0.011001, Null}*)

This is that becouse tranfering data to parallel kernels take more time than computation on it.

Post your real code please

EDIT

Replace construction like

For[i = 1, i <= n, i++, 
some code
]

with constructions like

ParallelDo[
some code
,{i,1,n},DistributedContexts->All]

DistributedContexts->All is not recomended becouse it is distribe all contexts to all parallel kernels.

Source Link
molekyla777
  • 2.9k
  • 1
  • 15
  • 28

If your computation in each cycle takes little time there is no reason for paralleling this cycle. Prove:

ParallelTable[i, {i, 1, 1000000}]; // AbsoluteTiming (*8 cores*)
(*{0.449026, Null}*)
Table[i, {i, 1, 1000000}]; // AbsoluteTiming
(*{0.011001, Null}*)

This is that becouse tranfering data to parallel kernels take more time than computation on it.

Post your real code please