@binarybana,
Thanks for the feedback. To be clear, in your example, what I would have envisioned might have been:
use matex;
fn cool_comp(mat0: Matrix<2, f32>, mat1: Matrix<2, f32>) -> Matrix<2, f32> {
let comp = matex::compile::<FnMut<(Matrix<2, f32>, Matrix<2, f32>>)->Matrix<2, f32>>("{m = $0 + $1; return m / (m[0] + m[1])}")
comp(mat0, mat1)
}
And even though you’re not keen on working with the computations as strings, a nice thing about it is that a REPL falls out of the work in a straight forward manner.
That said, this could be made nicer for production code by implementing a language plugin:
fn cool_comp(mat0: Matrix<2, f32>, mat1: Matrix<2, f32>) -> Matrix<2, f32> {
let comp = matex::compile!(|ref x, ref y| {
m = x + y;
m / (m[0] + m[1])
});
comp(mat0, mat1)
}
Alternatively:
#[matex_openacc_style]
fn cool_comp(mat0: Matrix<2, f32>, mat1: Matrix<2, f32>) -> Matrix<2, f32> {
let mat2 = mat0 + mat1;
mat2 / (mat2[0] + mat2[1])
}
As you’re probably familiar, running matrix operations on an accelerator means copying data to and from the accelerator is non trivial and should be explicitly managed (unless you have some kind of sufficiently smart compiler/scheduler) or you end up with severe performance degradation. So I think going without something to mark the code as ‘special’ is not a good idea for Rust which tries to reduce the magic.