On Thursday, 3 December 2020 at 16:50:39 UTC, Andre Pany wrote:
On Thursday, 3 December 2020 at 16:27:59 UTC, 9il wrote:
Hi all,

Since the first announcement [0] the original benchmark [1] has been boosted [2] with Mir-like implementations.

D+Mir:
 1. is more abstract than NumPy
 2. requires less code for multidimensional algorithms
 3. doesn't require indexing
 4. uses recursion across dimensions
5. a few times faster than NumPy for non-trivial real-world applications.

Why Mir is faster than NumPy?

1. Mir allows the compiler to generate specialized kernels while NumPy constraints a user to write code that needs to access memory twice or more times.

Another Mir killer feature is the ability to write generalized N-dimensional implementations, while Numpy code needs to have separate implementations for 1D, 2D, and 3D cases. For example, the main D loop in the benchmark can compile for 4D, 5D, and higher dimensional optimizations.

2. @nogc iteration loop. @nogc helps when you need to control what is going on with your memory allocations in the critical code part.

[0] https://forum.dlang.org/post/[email protected]
[1] https://github.com/typohnebild/numpy-vs-mir
[2] https://github.com/typohnebild/numpy-vs-mir/pull/1

The benchmark [1] has been created by Christoph Alt and Tobias Schmidt.

Kind regards,
Ilya

Hi Ilya,

Thanks a lot for sharing the update. I am currently working on porting a python package called FMPY to D. This package makes usage of numpy and I hope I can use MIR here.

Probably you may want to express FMI entities as Algebraic types rather than classes. mir.algebraic can be really helpful here

http://mir-core.libmir.org/mir_algebraic.html

Somehow it is hard to get started to learn MIR. What maybe could help python developers is to have some articles showing numpy coding and side by side the equivalent MIR coding.

It is hard for me to write articles. I will try to write a small one this year, but it would be Mir only. Maybe this benchmark can be used as an example and if one wishes to write a side-by-side comparison with NumPy I would be happy to comment and explain the D implementation and what it is doing internally.

What I miss in MIR is a function to read and write CSV files. Is s.th. like numpy.genfromtxt planned?

Unlikely I would add it but can do a code review.

Currently, we can load/safe NumPy binary data with numir

https://libmir.github.io/numir/io.html

Kind regards,
Ilya

Reply via email to