On Fri, 2015-09-25 at 12:54 +, John Colvin via Digitalmars-d-learn
wrote:
>
[…]
> I vastly prefer the UFCS version, but unfortunately reduce has
> its arguments the wrong way around for that if you use the
> version that takes a seed...
In which case the reduce parameter list is wrong,
Here's a correct version:
import std.parallelism, std.range, std.stdio, core.atomic;
void main()
{
shared ulong i = 0;
foreach (f; parallel(iota(1, 100+1)))
{
i.atomicOp!"+="(f);
}
i.writeln;
}
Thanks! Works fine. So "shared" and "atomic" is a must?
On Saturday, 26 September 2015 at 12:18:16 UTC, Zoidberg wrote:
I've run into an issue, which I guess could be resolved easily,
if I knew how...
[CODE]
ulong i = 0;
foreach (f; parallel(iota(1, 100+1)))
{
i += f;
}
thread_joinAll();
i.writeln;
[/CODE]
It's
Sorry I don't know the answers but these questions are
interesting so BUMP ;)
On Friday, 25 September 2015 at 15:19:27 UTC, bitwise wrote:
1) Are the following two snippets exactly equivalent(not just
in observable behaviour)?
a)
Mutex mut;
mut.lock();
scope(exit) mut.unlock();
b)
Mutex
Suppose we have, two modules:
module testOne;
import std.traits;
template getMember(alias T, string member) {
alias getMember = Identity!(__traits(getMember, T, member));
}
module app;
import testOne;
import std.traits;
class TestOne {
private {
int property;
}
On Saturday, 26 September 2015 at 09:17:10 UTC, Mike McKee wrote:
I was doing toHexString(myByteArray) instead of simply doing
myByteArray.toHexString(). (That was on an md5 example, by the
way.) Intellisense would have helped me realize this.
Both these forms are the same. It's called UFCS
On 26/09/15 9:17 PM, Mike McKee wrote:
I've tried Sublime Text 3 editor on the Mac, but even it doesn't seem to
have the D2 language in it yet (only D), and doesn't have intellisense
for components in the imports that I do, even after saving the file
after adding the import statements.
What OSX
On Saturday, 26 September 2015 at 12:33:45 UTC, anonymous wrote:
foreach (f; parallel(iota(1, 100+1)))
{
synchronized i += f;
}
Is this valid syntax? I've never seen synchronized used like this
before.
I've tried Sublime Text 3 editor on the Mac, but even it doesn't
seem to have the D2 language in it yet (only D), and doesn't have
intellisense for components in the imports that I do, even after
saving the file after adding the import statements.
What OSX editor do you recommend that would
On Saturday, 26 September 2015 at 09:17:10 UTC, Mike McKee wrote:
I've tried Sublime Text 3 editor on the Mac, but even it
doesn't seem to have the D2 language in it yet (only D), and
doesn't have intellisense for components in the imports that I
do, even after saving the file after adding the
On Saturday 26 September 2015 14:18, Zoidberg wrote:
> I've run into an issue, which I guess could be resolved easily,
> if I knew how...
>
> [CODE]
> ulong i = 0;
> foreach (f; parallel(iota(1, 100+1)))
> {
> i += f;
> }
> thread_joinAll();
>
I've run into an issue, which I guess could be resolved easily,
if I knew how...
[CODE]
ulong i = 0;
foreach (f; parallel(iota(1, 100+1)))
{
i += f;
}
thread_joinAll();
i.writeln;
[/CODE]
It's basically an example which adds all the numbers from 1 to
On Saturday, 26 September 2015 at 06:28:22 UTC, Russel Winder
wrote:
On Fri, 2015-09-25 at 12:54 +, John Colvin via
Digitalmars-d-learn wrote:
[…]
I vastly prefer the UFCS version, but unfortunately reduce has
its arguments the wrong way around for that if you use the
version that takes
On Saturday, 26 September 2015 at 13:09:54 UTC, Meta wrote:
On Saturday, 26 September 2015 at 12:33:45 UTC, anonymous wrote:
foreach (f; parallel(iota(1, 100+1)))
{
synchronized i += f;
}
Is this valid syntax? I've never seen synchronized used like
this before.
I'm
On Saturday, 26 September 2015 at 10:31:13 UTC, wobbles wrote:
Have you installed dkit for sublime?
As in?
https://github.com/yazd/DKit
Looks like it's alpha and doesn't run on Mac? No homebrew install?
On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote:
Why is the following code not pure:
float x = 3.14;
import std.conv : to;
auto y = x.to!string;
???
Is there a reason for it not being pure? If not, this is a
serious problem as this is such a fundamental function.
btw, on my corei5, in debug build,
reduce (using double): 11msec
non_parallel: 37msec
parallel with atomicOp: 123msec
so, that is the reason for using parallel reduce, assuming the
ulong range thing will get fixed.
On Saturday, 26 September 2015 at 10:38:29 UTC, Gary Willoughby
wrote:
Both these forms are the same. It's called UFCS (uniform
function call syntax). Here's some material to help you
understand what's going on here:
http://ddili.org/ders/d.en/ufcs.html
On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote:
Why is the following code not pure:
float x = 3.14;
import std.conv : to;
auto y = x.to!string;
???
Is there a reason for it not being pure? If not, this is a
serious problem as this is such a fundamental function.
Why is the following code not pure:
float x = 3.14;
import std.conv : to;
auto y = x.to!string;
???
Is there a reason for it not being pure? If not, this is a
serious problem as this is such a fundamental function.
This is a work-around to get a ulong result without having the
ulong as the range variable.
ulong getTerm(int i)
{
return i;
}
auto sum4 = taskPool.reduce!"a +
b"(std.algorithm.map!getTerm(iota(11)));
On Saturday, 26 September 2015 at 17:20:34 UTC, Jay Norwood wrote:
This is a work-around to get a ulong result without having the
ulong as the range variable.
ulong getTerm(int i)
{
return i;
}
auto sum4 = taskPool.reduce!"a +
b"(std.algorithm.map!getTerm(iota(11)));
or
auto
std.parallelism.reduce documentation provides an example of a
parallel sum.
This works:
auto sum3 = taskPool.reduce!"a + b"(iota(1.0,101.0));
This results in a compile error:
auto sum3 = taskPool.reduce!"a + b"(iota(1UL,101UL));
I believe there was discussion of this problem recently
On Saturday, 26 September 2015 at 13:09:54 UTC, Meta wrote:
On Saturday, 26 September 2015 at 12:33:45 UTC, anonymous wrote:
foreach (f; parallel(iota(1, 100+1)))
{
synchronized i += f;
}
Is this valid syntax? I've never seen synchronized used like
this before.
On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote:
Why is the following code not pure:
float x = 3.14;
import std.conv : to;
auto y = x.to!string;
???
Is there a reason for it not being pure? If not, this is a
serious problem as this is such a fundamental function.
On Saturday, 26 September 2015 at 09:17:10 UTC, Mike McKee wrote:
I've tried Sublime Text 3 editor on the Mac, but even it
doesn't seem to have the D2 language in it yet (only D), and
doesn't have intellisense for components in the imports that I
do, even after saving the file after adding the
26 matches
Mail list logo