Simple parallel foreach and summation/reduction

2018-09-19 Thread Chris Katko via Digitalmars-d-learn
All I want to do is loop from 0 to [constant] with a for or foreach, and have it split up across however many cores I have. ulong sum; foreach(i; [0 to 1 trillion]) { //flip some dice using float die_value = uniform(0F,12F); if(die_value > [constant]) sum++;

Re: How to use math functions in dcompute?

2018-09-19 Thread Sobaya via Digitalmars-d-learn
On Wednesday, 19 September 2018 at 00:22:44 UTC, Nicholas Wilson wrote: On Wednesday, 19 September 2018 at 00:11:13 UTC, Nicholas Wilson wrote: On Tuesday, 18 September 2018 at 06:25:33 UTC, Sobaya wrote: On Tuesday, 18 September 2018 at 01:39:51 UTC, Nicholas Wilson wrote: On Tuesday, 18

Re: Simple parallel foreach and summation/reduction

2018-09-19 Thread Neia Neutuladh via Digitalmars-d-learn
On Thursday, 20 September 2018 at 05:34:42 UTC, Chris Katko wrote: All I want to do is loop from 0 to [constant] with a for or foreach, and have it split up across however many cores I have. You're looking at std.parallelism.TaskPool, especially the amap and reduce functions. Should do pretty

Re: BetterC + Windows + setjmp longjmp

2018-09-19 Thread SrMordred via Digitalmars-d-learn
On Wednesday, 19 September 2018 at 11:12:41 UTC, Diederik de Groot wrote: On Wednesday, 19 September 2018 at 11:06:23 UTC, Diederik de Groot wrote: On Tuesday, 18 September 2018 at 19:45:18 UTC, SrMordred wrote: Only the exact size of the jmp_buf is important (not the details about the

Re: Pass 'this' as reference

2018-09-19 Thread Jan via Digitalmars-d-learn
On Saturday, 15 September 2018 at 20:13:51 UTC, Jonathan M Davis wrote: On Saturday, September 15, 2018 11:44:05 AM MDT Jan via Digitalmars-d-learn wrote: [...] No. variables are _always_ lvalues. An lvalue is an object which is addressable and which can therefore be assigned a value

Re: Manual delegates

2018-09-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-09-16 16:12, Guillaume Piolat wrote: Anyone has any information about the ABI of delegates? In particular how to call them with a particular "this"/frame pointer? You can explicitly set the context pointer of a delegate using the ".ptr" property: class Foo { void bar() { } }

Re: Is it possible to translate this API's C headers?

2018-09-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 18, 2018 7:39:40 AM MDT Atila Neves via Digitalmars-d- learn wrote: > On Monday, 17 September 2018 at 19:13:06 UTC, Jonathan M Davis > > wrote: > > On Monday, September 17, 2018 7:43:21 AM MDT Kagamin via > > > > Digitalmars-d-learn wrote: > >> try dpp

Re: Access to structures defined in C

2018-09-19 Thread Atila Neves via Digitalmars-d-learn
On Wednesday, 19 September 2018 at 00:46:54 UTC, Joe wrote: On Tuesday, 18 September 2018 at 13:47:50 UTC, Atila Neves wrote: Sorry, Atila, I got confused looking at my two cases. I should have said "an array of ints", e.g., int yp[] = {2, 4, 0}; int yq[] = {10, 12, 0}; That makes more

Re: BetterC + Windows + setjmp longjmp

2018-09-19 Thread Diederik de Groot via Digitalmars-d-learn
On Tuesday, 18 September 2018 at 19:45:18 UTC, SrMordred wrote: On Tuesday, 18 September 2018 at 03:09:18 UTC, Mike Parker wrote: On Tuesday, 18 September 2018 at 00:24:23 UTC, SrMordred wrote: Yes, i'm using signal(SIGSEGV, sigfn_t func), it catches correctly, but end the execution after.

Re: BetterC + Windows + setjmp longjmp

2018-09-19 Thread Diederik de Groot via Digitalmars-d-learn
On Wednesday, 19 September 2018 at 11:06:23 UTC, Diederik de Groot wrote: On Tuesday, 18 September 2018 at 19:45:18 UTC, SrMordred wrote: Only the exact size of the jmp_buf is important (not the details about the content). We only call a function with it, we never look inside. I don't own