Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15142 > unrolled thread

how to write ParallelSubmit in a Do loop? trying to use up all CPU

Started byalex <0899607@gmail.com>
First post2013-07-08 03:17 +0000
Last post2013-07-08 03:17 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  how to write ParallelSubmit in a Do loop? trying to use up all CPU alex <0899607@gmail.com> - 2013-07-08 03:17 +0000

#15142 — how to write ParallelSubmit in a Do loop? trying to use up all CPU

Fromalex <0899607@gmail.com>
Date2013-07-08 03:17 +0000
Subjecthow to write ParallelSubmit in a Do loop? trying to use up all CPU
Message-ID<krdavm$epe$1@smc.vnet.net>
when it comes a heavily calculation, it takes time, but not fully cpu usage
i found a scrip using ParallelSubmit, which is quite powerful and really shorten the time in calculating

http://mathematica.stackexchange.com/questions/10969/parallelization-problem-in-linearsolve-and-minimize


t = AbsoluteTime[];
job1 = ParallelSubmit[Table[Prime[k], {k, 1, 2500000}]];
job2 = ParallelSubmit[Table[Prime[k], {k, 2500001, 5000000}]];
job3 = ParallelSubmit[Table[Prime[k], {k, 5000001, 7500000}]];
job4 = ParallelSubmit[Table[Prime[k], {k, 7500001, 10000000}]];
job5 = ParallelSubmit[Table[Prime[k], {k, 10000001, 12500000}]];
job6 = ParallelSubmit[Table[Prime[k], {k, 12500001, 15000000}]];
job7 = ParallelSubmit[Table[Prime[k], {k, 15000001, 17500000}]];
job8 = ParallelSubmit[Table[Prime[k], {k, 17500001, 20000000}]];
{a1, a2, a3, a4, a5, a6, a7, a8} =
 WaitAll[{job1, job2, job3, job4, job5, job6, job7, job8}];
time2 = AbsoluteTime[] - t

t = AbsoluteTime[];





then i try to rewrite the script by using Do loop, so i can just setup the initial and final value then it can be separated into 8 parts automatically , but i failed.


t = AbsoluteTime[];
initial = 1
final = 20000000
step = (final - initial + 1)/8
Clear["job"]
Clear["i"]

Do[job[i]=ParallelSubmit[Table[Prime[k], {k, step*i + 1, step*(i + 1)}]]
 , {i, 0, 7}]

Clear["a"]
Table[a[jj], {jj, 1, 8}] = WaitAll[Table[job[j], {j, 0, 7}]]

time2 = AbsoluteTime[] - t 



it keeps showing Null, it seems that it cant replace the variable in Do loop exactly, it is still a variable. 

how do i rewrite the scrip? to make it be separated into 8 parts automatically? 
thank you for your help ^^

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web