@everywhere  const k=200000000

On Sun, Jun 1, 2014 at 8:26 PM, Andreas Noack Jensen <
[email protected]> wrote:

> I don't know why you get that error. It is not there on my machine.
>
> However, for some reason defining k as const does not work for parallel
> loops. It only makes a difference for serial loops so my explanation was
> wrong. Is this expected?
>
> julia> const k1=10000000;k2 = k1;
>
> julia> @time for i = 1:10000000
>        int(randbool())
>        end
> elapsed time: 0.041954142 seconds (0 bytes allocated)
>
> julia> @time for i = 1:k1
>        int(randbool())
>        end
> elapsed time: 0.042543885 seconds (0 bytes allocated)
>
> julia> @time for i = 1:k2
>        int(randbool())
>        end
> elapsed time: 2.923224821 seconds (639983688 bytes allocated)
>
> julia> @time tmp = @parallel (+) for i = 1:10000000
>        int(randbool())
>        end
> elapsed time: 0.05594257 seconds (155072 bytes allocated)
>
> julia> @time tmp = @parallel (+) for i = 1:k1
>        int(randbool())
>        end
> elapsed time: 3.067074328 seconds (640486512 bytes allocated)
>
> julia> @time tmp = @parallel (+) for i = 1:k2
>        int(randbool())
>        end
> elapsed time: 3.021796716 seconds (640090424 bytes allocated)
>
>
> 2014-06-01 16:28 GMT+02:00 paul analyst <[email protected]>:
>
> After restart julia :
>>
>>
>> D:\install\Julia\Julia 0.3.0-prerelease-win64-ver3\Julia 0.3.0-prerelease
>> ver 3>bin\julia.exe -p 8
>>                _
>>    _       _ _(_)_     |  A fresh approach to technical computing
>>   (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
>>    _ _   _| |_  __ _   |  Type "help()" to list help topics
>>   | | | | | | |/ _` |  |
>>   | | |_| | | | (_| |  |  Version 0.3.0-prerelease+2599 (2014-04-11 23:52
>> UTC)
>>  _/ |\__'_|_|_|\__'_|  |  Commit bf7096c (50 days old master)
>> |__/                   |  x86_64-w64-mingw32
>>
>> julia> const k=200000000
>>
>> 200000000
>>
>> julia> tic();
>>
>> julia> nheads = @parallel (+) for i=1:k
>>        int(randbool())
>>        end
>> exception on exception on 3: 4: ERROR: ERROR: exception on exception on
>> 2: exception on 7: ERROR: 5:
>>  ERROR: ERROR: exception on k not defined6: exception on ERROR:
>>  in anonymous at no file:1379
>> 8k:  not definedERROR:
>>  in anonymous at no file:1379
>> k not definedk not defined
>>  in anonymous at no file:1379
>>
>>  in anonymous at no file:1379
>> k not definedk not definedk not defined
>>  in anonymous at no file:1379
>>
>>  in anonymous at no file:1379
>>
>>  in anonymous at no file:1379exception on
>> 9: ERROR: k not defined
>>  in anonymous at no file:1379
>> ERROR: no method +(UndefVarError, UndefVarError)
>>  in mr_pairwise at reduce.jl:534
>>
>> julia> toc()
>> elapsed time: 2.493525081 seconds
>> 2.493525081
>>
>> julia>
>>
>> W dniu niedziela, 1 czerwca 2014 16:27:14 UTC+2 użytkownik paul analyst
>> napisał:
>>
>>>
>>>
>>>
>>>
>>> *julia> const k=200000000;ERROR: cannot declare k constant; it already
>>> has a value :/Paul*
>>> W dniu niedziela, 1 czerwca 2014 16:13:27 UTC+2 użytkownik Andreas Noack
>>> Jensen napisał:
>>>>
>>>> This is the usual problem with global variables in Julia. If you define
>>>> k by
>>>>
>>>> const k=200000000
>>>>
>>>> the timing results should be similar.
>>>>
>>>>
>>>> 2014-06-01 16:09 GMT+02:00 paul analyst <[email protected]>:
>>>>
>>>>>
>>>>> D:\install\Julia\Julia 0.3.0-prerelease-win64-ver3\Julia
>>>>> 0.3.0-prerelease ver 3>bin\julia.exe -p 8
>>>>>                _
>>>>>    _       _ _(_)_     |  A fresh approach to technical computing
>>>>>   (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
>>>>>    _ _   _| |_  __ _   |  Type "help()" to list help topics
>>>>>   | | | | | | |/ _` |  |
>>>>>   | | |_| | | | (_| |  |  Version 0.3.0-prerelease+2599 (2014-04-11
>>>>> 23:52 UTC)
>>>>>  _/ |\__'_|_|_|\__'_|  |  Commit bf7096c (50 days old master)
>>>>> |__/                   |  x86_64-w64-mingw32
>>>>>
>>>>> julia> procs()
>>>>> 9-element Array{Int64,1}:
>>>>>  1
>>>>>  2
>>>>>  3
>>>>>  4
>>>>>  5
>>>>>  6
>>>>>  7
>>>>>  8
>>>>>  9
>>>>>
>>>>> julia> tic();
>>>>>
>>>>> julia> nheads = @parallel (+) for i=1:200000000
>>>>>        int(randbool())
>>>>>        end
>>>>> 100006468
>>>>>
>>>>> julia> toc()
>>>>> elapsed time: 2.77418807 seconds
>>>>> 2.77418807
>>>>>
>>>>> julia>exit()
>>>>>
>>>>>
>>>>> D:\install\Julia\Julia 0.3.0-prerelease-win64-ver3\Julia
>>>>> 0.3.0-prerelease ver 3>bin\julia.exe -p 8
>>>>>                _
>>>>>    _       _ _(_)_     |  A fresh approach to technical computing
>>>>>   (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
>>>>>    _ _   _| |_  __ _   |  Type "help()" to list help topics
>>>>>   | | | | | | |/ _` |  |
>>>>>   | | |_| | | | (_| |  |  Version 0.3.0-prerelease+2599 (2014-04-11
>>>>> 23:52 UTC)
>>>>>  _/ |\__'_|_|_|\__'_|  |  Commit bf7096c (50 days old master)
>>>>> |__/                   |  x86_64-w64-mingw32
>>>>>
>>>>> julia> k=200000000
>>>>> 200000000
>>>>>
>>>>> julia> tic();
>>>>>
>>>>> julia> nheads = @parallel (+) for i=1:k
>>>>>        int(randbool())
>>>>>        end
>>>>> 99989022
>>>>>
>>>>> julia> toc()
>>>>> elapsed time: 18.631674663 seconds
>>>>> 18.631674663
>>>>>
>>>>> julia>
>>>>>
>>>>> What hapend ?
>>>>>
>>>>> Paul
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Med venlig hilsen
>>>>
>>>> Andreas Noack Jensen
>>>>
>>>
>
>
> --
> Med venlig hilsen
>
> Andreas Noack Jensen
>

Reply via email to