Comments (16)
auto b = 6.iota.array.sliced(2, 3);
Current version is already clear auto b = 6.iota.sliced(2, 3).slice;
from mir.
for ndslice
module common range is Slice
;)
from mir.
Current version is already clear auto b = 6.iota.sliced(2, 3).slice;
... but not efficient as 6.iota.sliced(2, 3).slice
gets translated to 6.iota.sliced(2, 3).byElement.array.sliced!replaceArrayWithPointer(slice.shape)
- would be nice if we could avoid the duplicate allocation. slice
already allocates, we just want to fill it.
from mir.
No, it is already fast
from mir.
see implementation
from mir.
would be nice if we could avoid the duplicate allocation. slice already allocates, we just want to fill it.
Yeah just saw it - ignore my complaints for now. sorry.
from mir.
It does make a huge difference - m1 and m3 take roughly twice the time (I guess the 20% are the overhead created from byElement
) or am I missing something here?
fastest: 1
rel. diff for 0: 1.871
rel. diff for 1: 1.000
rel. diff for 2: 1.855
All unit tests have been run successfully.
dub test 21.39s user 0.38s system 99% cpu 21.772 total
auto m1()
{
size_t k = 100, s1 = 10, s2 = 10;
import std.range: iota;
import mir.ndslice.slice: slice, sliced;
auto r = iota(k).sliced(s1, s2).slice;
assert(r[9, 9] == k - 1);
}
auto m2()
{
size_t k = 100, s1 = 10, s2 = 10;
import std.range: iota;
import mir.ndslice.slice: slice;
import mir.ndslice.selection: byElement;
auto r = slice!ulong(s1, s2);
auto range = iota(k);
foreach(ref el; r.byElement)
{
el = range.front;
range.popFront;
}
assert(r[9, 9] == k - 1);
}
auto m3()
{
size_t k = 100, s1 = 10, s2 = 10;
import std.range: iota;
import mir.ndslice.slice: slice, sliced;
import mir.ndslice.selection: byElement;
auto r = slice!ulong(s1, s2);
auto range = iota(k);
r[] = range.sliced(s1, s2);
assert(r[9, 9] == k - 1);
}
unittest
{
auto n = 1_000_000;
import std.datetime: benchmark;
auto result = benchmark!(m1, m2, m3)(n);
import std.stdio;
import std.range: enumerate;
import std.algorithm: map, minPos;
auto rs = [result[0], result[1], result[2]].map!`a.length`;
auto minEl = rs.enumerate.minPos!`a.value < b.value`.front;
writeln("fastest: ", minEl.index);
foreach (i, el; rs.enumerate)
writefln("rel. diff for %d: %.3f", i , el * 1. / minEl.value);
}
from mir.
LDC results?
from mir.
LDC results?
nope - dmd, but with ldc
it's still measurable!.
fastest: 1
rel. diff for 0: 1.225
rel. diff for 1: 1.000
rel. diff for 2: 1.273
All unit tests have been run successfully.
dub test --compiler=ldc 21.21s user 0.88s system 99% cpu 22.208 total
from mir.
add --build=unittest-nobounds
from mir.
add --build=unittest-nobounds
add --build=release-nobounds
from mir.
add --build=release-nobounds
ldc: Unknown command line argument '-disable-boundscheck'. Try: 'ldc -help'
ldc: Did you mean '-disable-dfa-sched'?
from mir.
ok, lets just --build=release
from mir.
done - I was shocked a bit initially because the runtime went done from 20s to less than a second, but I added a global variable (which is printed) to add the result of the verification assert.
fastest: 2
rel. diff for 0: 2.079
rel. diff for 1: 1.780
rel. diff for 2: 1.000
true
dub --compiler=ldc --build=release 28.88s user 0.09s system 100% cpu 28.958 total
I verified the output by running in multiple orders.
from mir.
oh, I thought the implementation is differ. Thanks, will be fixed
from mir.
Fixed
from mir.
Related Issues (20)
- Special optimization for compile time known kernels HOT 1
- Separable filters support for DCV HOT 1
- Package mir contains invalid dependency cpuid (ci=1) HOT 5
- libmir.so missing from .gitignore HOT 1
- cannot infer argument types, expected 1 argument, not 2 in opApply on Slice HOT 2
- auto a=[[1,2],[3,4]].ndarray; // how to do that? (doens't compile) HOT 3
- Error: cannot append type int[] to type Slice!(2LU, int*) HOT 2
- mir vs ndslice conflict in dmd vs ldc when compiling with dub on ubuntu HOT 2
- Tiny Mersenne Twister HOT 1
- regression test to make sure at least latest dub versions work? currently broken HOT 1
- dot, norm, asum to mir.math.sum HOT 1
- mir-random does not compile with latest ldc on raspberry pi HOT 4
- How to reference the library HOT 6
- FFT? HOT 1
- OpenCL implementation? HOT 1
- can't understand how `sliced` definition compiles HOT 3
- Failing on Buildkite HOT 3
- rand!float() exponent problem HOT 3
- mir-algorithm dependency fails to build because of mir-core with ldc2 and gdc HOT 4
- Deprecation warnings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mir.