This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
void main() { | |
"Hellow World".writeln; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
F dotProduct(F)(in F[] a, in F[] b) @trusted | |
if(is(F == double) || is(F == float)) | |
in | |
{ | |
assert(a.length == b.length); | |
} | |
out(result) | |
{ | |
assert(!result.isNaN); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(; ap < sbe; ap+=4*M, bp+=4*M) | |
{ | |
auto a0 = load(cast(VP)ap+0); | |
auto a1 = load(cast(VP)ap+1); | |
auto a2 = load(cast(VP)ap+2); | |
auto a3 = load(cast(VP)ap+3); | |
auto b0 = load(cast(VP)bp+0); | |
auto b1 = load(cast(VP)bp+1); | |
auto b2 = load(cast(VP)bp+2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.section .text._D4simd10dotproduct18__T10dotProductTfZ10dotProductFNexAfxAfZf,"axG",@progbits,_D4simd10dotproduct18__T10dotProductTfZ10dotProductFNexAfxAfZf,comdat | |
.p2align 4,,15 | |
.weak _D4simd10dotproduct18__T10dotProductTfZ10dotProductFNexAfxAfZf | |
.type _D4simd10dotproduct18__T10dotProductTfZ10dotProductFNexAfxAfZf, @function | |
_D4simd10dotproduct18__T10dotProductTfZ10dotProductFNexAfxAfZf: | |
.LFB412: | |
.cfi_startproc | |
mov rdx, rdi | |
lea r10, [rsi+rdi*4] | |
and rdi, -32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sgemm(Order.RowMajor, Transpose.NoTrans, Transpose.NoTrans, | |
dl, wl, tl, 1.0, pdt.ptr, tl, ptw.ptr, wl, 0.0, qdw.ptr, wl); | |
qdw.array[] /= ndw.array[]; | |
sgemm(Order.RowMajor, Transpose. Trans, Transpose.NoTrans, | |
tl, wl, dl, 1.0, pdt.ptr, tl, qdw.ptr, wl, 0.0, rtw.ptr, wl); | |
rtw.array[] *= ptw.array[]; | |
sgemm(Order.RowMajor, Transpose.NoTrans, Transpose. Trans, | |
dl, tl, wl, 1.0, qdw.ptr, wl, ptw.ptr, wl, 0.0, rdt.ptr, tl); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach(d; 0..dl) | |
{ | |
auto pt = pdt[d]; | |
auto nw = ndw[d]; | |
auto qw = qdw[d]; | |
foreach(w; 0..wl) | |
qwd[w, d] = qw[w] = nw[w] / dotProduct(pt, pwt[w]); | |
} | |
foreach(t; 0..tl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Matrix(T) | |
{ | |
this(size_t height, size_t width) | |
{ | |
ptr = (new T[height * width]).ptr; | |
this.height = height; | |
this.width = width; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio, std.datetime, std.uuid, std.conv; | |
struct NEW_UUID | |
{ | |
union | |
{ | |
ulong[2] ulongs; | |
static if(size_t.sizeof == 4) | |
uint[4] uints; | |
UUID id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.datetime, std.stdio, std.uuid, std.traits; | |
void main() | |
{ | |
import std.datetime, std.stdio, std.conv; | |
string str = "24c24a92-5fc8-11e5-9d70-feff819cdc9f"; | |
ID id = ID("24c24a92-5fc8-11e5-9d70-feff819cdc9f"); | |
UUID uuid = UUID("24c24a92-5fc8-11e5-9d70-feff819cdc9f"); | |
size_t len; | |
auto b = benchmark!( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.experimental.ndslice; | |
//3D += number | |
void nd_test_val(Slice!(3, double*) slice, double value) | |
{ | |
slice[] += value; | |
} | |
//3D += 1D | |
void nd_test_slice1(Slice!(3, double*) slice, Slice!(1, double*) value) |
OlderNewer