I was trying to get this to work with the assembly script implementation of arrays, but actually wasm-ffi makes it fairly easy to define new structs, so a new array struct containing the shape and the data is being used.
const Array = new ffi.Struct({
shape: ffi.assemblyscript.array('int32'),
data: ffi.assemblyscript.array('int32')
})
Wasm sees this as a vector of i32's in the following format: [pointer to shape array, length of shape array, pointer to data array, length of data array]
Summing the following 2 dimensional array gives the correct result (using compiled code):
I think all array operations should use this data type from now on, and at some point helper functions can be created on the js side to make it less of a chore to define multi dimensional arrays in this format. (We could probably compile some Julia code that does this too)
Most attempts to try anything more complicated, such as matrix multiplication, result in missing ssavalue errors, which I'm generally assuming are due to the gcd bug, so the next step is to get the master branch onto julia 0.7 and update each branch.
Also anything above 2 dim arrays are making calls to Core.getfield. There is an implementation for this on the structs branch, though I don't know if that would actually work or why the calls are being made as yet. Apart from this there's no reason why the summing example shouldn't work for any number of dimensions.
I was trying to get this to work with the assembly script implementation of arrays, but actually wasm-ffi makes it fairly easy to define new structs, so a new array struct containing the shape and the data is being used.
Wasm sees this as a vector of i32's in the following format: [pointer to shape array, length of shape array, pointer to data array, length of data array]
Summing the following 2 dimensional array gives the correct result (using compiled code):
Produced from the Julia equivalent:
I think all array operations should use this data type from now on, and at some point helper functions can be created on the js side to make it less of a chore to define multi dimensional arrays in this format. (We could probably compile some Julia code that does this too)
Most attempts to try anything more complicated, such as matrix multiplication, result in missing ssavalue errors, which I'm generally assuming are due to the gcd bug, so the next step is to get the master branch onto julia 0.7 and update each branch.
Also anything above 2 dim arrays are making calls to
Core.getfield
. There is an implementation for this on the structs branch, though I don't know if that would actually work or why the calls are being made as yet. Apart from this there's no reason why the summing example shouldn't work for any number of dimensions.