These are chat archives for libmir/public

24th
Nov 2016
Sebastian Wilzbach
@wilzbach
Nov 24 2016 00:31
Wow - great discussion btw :)
Nicholas Wilson
@thewilsonator
Nov 24 2016 08:09
I've got basic pcg working. There's still heaps of typedefs to go and the extended generators.
Ilya Yaroshenko
@9il
Nov 24 2016 08:09
Awesome
Engines are already split
So, it should be easy to create the PR
Nicholas Wilson
@thewilsonator
Nov 24 2016 08:10
It is split
as in can merge w/o conflicts
#1
Ilya Yaroshenko
@9il
Nov 24 2016 09:22
real uniform rand ((-1, 1)) and real UniformVariable ([a, b)) was added
@wilzbach Could you please port Discrete and NaiveDiscrete?
Also, we can build other random distributions (Vairables) now
Looking forward for new PRs :fire:
Johan Engelen
@JohanEngelen
Nov 24 2016 12:49
@9il You mentioned something like "no classes ... because of performance". Do you have a few examples of where class performance is poor ?
(beyond the obvious virtual function calls and non-devirtualization?)
Ilya Yaroshenko
@9il
Nov 24 2016 12:50
no, only performance reason is non-devirtualization
Johan Engelen
@JohanEngelen
Nov 24 2016 12:51
in that case, do you have an example of where devirt should be possible, but isn't done?
Ilya Yaroshenko
@9il
Nov 24 2016 12:51
it was about Engines
Johan Engelen
@JohanEngelen
Nov 24 2016 12:51
ah ok
so the exact returned class type is unknown, devirt is impossible ?
Ilya Yaroshenko
@9il
Nov 24 2016 12:51
For distributions memory allocation is a problem
I don’t know where devirtualization is possible (probably only for final classes for now)
Another major issue with classes is that they require DRuntime to be linked.
Johan Engelen
@JohanEngelen
Nov 24 2016 12:54
auto a = new A; a.virtualFunc(); is easily devirtualized. (also when the new A is returned by a function)
yeah...
but you could make the class extern(C++) to not require druntime maybe?
it's not a comment meant to change the random package. I'd just like to know what things you run up against and what the compiler can do to improve it.
Ilya Yaroshenko
@9il
Nov 24 2016 12:57
extern(C++) should be allocated anyway (requires GC).
Johan Engelen
@JohanEngelen
Nov 24 2016 12:57
yeah...
I think I would like D much better when it was a "better C++"
;)
Nicholas Wilson
@thewilsonator
Nov 24 2016 12:58
I'd like to be able to easily (without too much effort) adapt this library to work with DCompute, which currently bans classes.
Ilya Yaroshenko
@9il
Nov 24 2016 12:59
@thewilsonator Do you think it can be done without code duplication?
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:00
Also with struct I can control them with a pointer, class references can't be address spaced properly.
@9il sure all a module requires is nothrow, nogc, no global variables and ideally no use of ref (to anything not stack allocated).
The only thing of concern is that the convenience template aliases will get codegenned causing bloat.
Ilya Yaroshenko
@9il
Nov 24 2016 13:03
Mir random uses ref a lot. But only for stack allocated Engines

The only thing of concern is that the convenience template aliases will get codegenned causing bloat.

Don’t understand, could you give an example?

Nicholas Wilson
@thewilsonator
Nov 24 2016 13:04
Yeah, ref should work fine with stack allocated vars (because address space 0 is the private addrspace for OpenCL and the generic for CUDA).
Module scope template aliases will cause the template to be codegenned even if it is not used.
see Instansiate!foo.
somewhere in phobos (can't remember where)
Ilya Yaroshenko
@9il
Nov 24 2016 13:06
Yep, this is how we doing for now
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:11
Did you want me to do anything more for #1 ?
Ilya Yaroshenko
@9il
Nov 24 2016 13:17
@thewilsonator I have added few commnets. Please update all docs.
I will also add travis tests.
(i mean public docs)
Plus, we need to test it.
Does O is always half of S?
Ilya Yaroshenko
@9il
Nov 24 2016 13:24
It looks like we can define O opCall(O = S)()
Can not we?
Also please use Uint instead of S and T instead of O
Ilya Yaroshenko
@9il
Nov 24 2016 13:33
The documentation quality should be like in Phobos
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:38
T is for private helper templates. These can be changed yo Uint. O and S are the output type and the state type. These can be different. What to do here?
Ilya Yaroshenko
@9il
Nov 24 2016 13:39
O is weird char
Other Engines uses Uint instead of S.
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:39
Rename to Output_type and State_type?
Is there a distinction between the two in other engines?
Ilya Yaroshenko
@9il
Nov 24 2016 13:40
No, in other engines they are the same
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:41
Ah, in PCG they can (and sometimes should) be different.
Ilya Yaroshenko
@9il
Nov 24 2016 13:42
I think you should change S to Uint and just remove O
Instead of O you can use ReturnType!output
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:45
The instansiations go the other way. i.e. engine!(O,Uint,output!(O,Uint)...)
Ilya Yaroshenko
@9il
Nov 24 2016 13:45
Why they go that way? Any reason?
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:46
because the output function is a parameter of the engine, not the other way around.
Ilya Yaroshenko
@9il
Nov 24 2016 13:48
Just engine!(output!(O,Uint)...) is good enough. You can use ReturnType and Parameters (?) to extract Uint and O.
ReturnType!output opCall()
and alias Uint = Parameters!output[0]
Also all outputs functions should be documented
please use /++ +/ instead of /** * * * */
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:51
Oh, O and Uint get defined in the alias. Ahh now I see.
Re docs: noted.
Ilya Yaroshenko
@9il
Nov 24 2016 13:55
About GPUs: unpredictableSeed should be reimplemented (it calls systems functions)
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:56
Yeah, it will need to be passed as parameters
Ilya Yaroshenko
@9il
Nov 24 2016 13:56
Ah, ok, looks good
Nicholas Wilson
@thewilsonator
Nov 24 2016 13:58
At least, I don't know of any other way to get entropy inside a kernel.
Im going to sleep now, hopefully I'll finish the PR by the weekend, got stuff to do tomorrow. 'Night.
Ilya Yaroshenko
@9il
Nov 24 2016 14:00
BB, have a good night! and thank for the PR!