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


Groups > comp.soft-sys.math.mathematica > #15152

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

From Sseziwa Mukasa <mukasa@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: how to write ParallelSubmit in a Do loop? trying to use up all CPU
Date 2013-07-09 06:44 +0000
Message-ID <krgbgc$nv6$1@smc.vnet.net> (permalink)
References <20130708032047.1772769BF@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


First of all, Do always returns Null, but the assignment still happened, evaluate job[0] to check.

However for your computation to work you need to distribute the definition of step and enclose the local value of i in ParallelSubmit:

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

DistributeDefinitions[step]
Do[job[i]=ParallelSubmit[{i},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

Regards,
Sseziwa

On Jul 7, 2013, at 11:20 PM, alex <0899607@gmail.com> wrote:

> 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 ^^
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: how to write ParallelSubmit in a Do loop? trying to use up all CPU Sseziwa Mukasa <mukasa@gmail.com> - 2013-07-09 06:44 +0000

csiph-web