how to write ParallelSubmit in a Do loop? trying to use up all CPU
- To: mathgroup at smc.vnet.net
- Subject: [mg131443] how to write ParallelSubmit in a Do loop? trying to use up all CPU
- From: alex <0899607 at gmail.com>
- Date: Sun, 7 Jul 2013 23:20:47 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@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 ^^
- Follow-Ups:
- Re: how to write ParallelSubmit in a Do loop? trying to use up all CPU
- From: Sseziwa Mukasa <mukasa@gmail.com>
- Re: how to write ParallelSubmit in a Do loop? trying to use up all CPU