[GSoC 2019] Interested in Baremetal D Runtime and project ideas
9il
ilyayaroshenko at gmail.com
Mon Apr 8 04:28:47 UTC 2019
On Sunday, 7 April 2019 at 11:10:02 UTC, Stefanos Baziotis wrote:
> On Sunday, 7 April 2019 at 07:27:01 UTC, 9il wrote:
>
>> Very interesting, it would be nice to have SIMD convolution
>> algorithms in D.
> I'm not an expert in image convolution, but any proposals
> are welcome.
>
>> We need a few D language extensions:
>> 1. multiple auto ref values
>> 2. more clever alias syntax for templates (it is required for
>> data science libraries in D)
>> 3. opApply and foreach API design rework (requires 1.)
>
> Can you please explain more 1. and 2. ?
>
>>
>> As a small bonus, I will pay an additional $400 for each D
>> language extension merged to DMD.
>
> That's kind :). For me, certainly not needed though.
>
>>
>> Let me know if you would like to work during GSoC on one of
>> the related directions and especially DIPs.
>
> Yes.
>
>> ilyayaroshenko at google mail
>
> I will reach you by mail.
Copy-pasted the answer here, maybe someone has good ideas for
syntax.
1. Multiple auto ref values.
D allows returning a single value from a function. To return
multiple values few workarounds can be used:
a. Add additional arguments as ref/out parameters.
b. Use std.type.Tuple
Both of them don't allow to return multiple values by reference:
for example, references on array/container elements.
To return multiple values by reference we can use
c. Add additional arguments as ref/out pointer parameters
d. Use mir.functional.RefTuple
Both of them don't well fit to modern D, Mir, and future generic
containers. For example, Mir's Series consist as pair of two
arrays (keys and values), keys are sorted. It would be awesome to
use D Range syntax (front, popFront, empty) to iterate Series by
reference. Also, it would be very good for performance, for D
GC-free reference-counted libraries.
The possible (but may not be the best) syntax is:
auto ref fun(int[] a)
{
return (a[0], a[1] * 3.4); // returns ref int and double
}
void handle(ref int a, double b)
{
a = cast(int) (b * b);
}
int twice(int a) { a * 2; }
void main()
{
int[] ar = [1, 2];
handle(fun(ar));
auto (i : &$0, f, e : $0 + $1, f : $1.twice) = fun(ar);
// i is a pointer to ar[0], type of int*
// d stores a values of a[1] * 3.4, type of double
// e stores value ar[0] + a[1] * 3.4, type of double
// f stores value ar[0] * 2, type of int
}
2. This DIP for clever alias syntax is the fix for the following
issues:
https://issues.dlang.org/show_bug.cgi?id=16486
https://issues.dlang.org/show_bug.cgi?id=16465
The brief DIP idea is that the code like below should work:
alias PackedUpperTriangularMatrix(T) = Slice!(StairsIterator!(T*,
"-"));
// fails, issue 16486
auto foo(T)(PackedUpperTriangularMatrix!T m)
{
}
// Current workaround: it is too crazy for users to
// know what is StairsIterator!(T*, "-")).
auto foo(T)(Slice!(StairsIterator!(T*, "-")) m)
{
}
Currently used Slice types in Lubeck / Production code
Slice!(double*) - D slice analog
Slice!(double*, 1, Universal) - BLAS vector, used in mir-lapack
and mir-blas.
Slice!(double*, 2) - Contiguous matrix, that has an efficient
loop for iteration over elements, see mir.algorithm.iteration
sources.
Slice!(double*, 2, Canonical) - BLAS/LAPACK matrix
representation, used in mir-lapack and mir.blas
Slice!(double*, N, Universal) - zero copy view to work with
ndarray in numpy, see also low level API bindgins, and high level
bindings
Slice!(StairsIterator!(double*, "+")) and ...
Slice!(StairsIterator!(double*, "-")) - packed storage for
triangular matrixes, for BLAS/LAPACK
Slice!(ChopIterator!(size_t*, uint*)); - Memory efficient graph
representation without labels.
Possible future Slice types (2019?):
Slice!(double*, 1, Contiguous, string*) - like Pandas Series
Slice!(double*, 2, Contiguous, LabelT1*, LabelT2*) - like Pandas
DataFrame
Slice!(double*, 2, Contiguous, LabelT1*, LabelT2*, LabelT3*) -
like Pandas Panel
Slice!(ChopIterator!(size_t*, uint*), 1, Contiguous, string*); -
Memory efficient graph representation with labels.
Slice!(ChopIterator!(size_t*, Slice!(double*, 1, Contiguous,
uint*))) - Sparse Matrix representation that can be used to
interact with existing C/C++/Fortran libraries
More information about the Digitalmars-d
mailing list