Stream: git-wasmtime

Topic: wasmtime / issue #7972 Cranelift: support load and store ...


view this post on Zulip Wasmtime GitHub notifications bot (Feb 21 2024 at 04:48):

meijies opened issue #7972:

My original request is sum two variable length array element to element and store the result to result array . Below is an example:

array a : [1, 2, 3, 4, 5,  6,  7,  8,  9,  10]
array b : [1, 2, 3, 4, 5,  6,  7,  8,  9,  10]
result  : [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

According to cranelift-dynamic-vector, I found dynamic vector type currently only support scaling factors which are compile-time constants. So I have to sum element by element through a loop. For each iteration. I have to load and store the nth element by a dynamic offset, but I can't found any api to support this.

another solution is create a new address by sum a offset, but seems UB occurs.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 21 2024 at 05:28):

cfallin commented on issue #7972:

@meijies the "dynamic vector" support is very incomplete: it was originally developed by aarch64 folks to support a new ISA extension (SVE), but was never finished.

If you want to loop through an array and add values, you can generate IR that has a loop, and compute the addresses just like you might do manually in assembly language: take the base address of the array and add the index (multiplied by element size). The "API" to support this consists of iadd (integer add), imul (integer multiply) or ishl (integer shift left), and the various load instructions.

Could you describe what UB you're seeing, with examples of the CLIF and the generated assembly?

view this post on Zulip Wasmtime GitHub notifications bot (Feb 21 2024 at 05:55):

meijies closed issue #7972:

My original request is sum two variable length array element to element and store the result to result array . Below is an example:

array a : [1, 2, 3, 4, 5,  6,  7,  8,  9,  10]
array b : [1, 2, 3, 4, 5,  6,  7,  8,  9,  10]
result  : [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

According to cranelift-dynamic-vector, I found dynamic vector type currently only support scaling factors which are compile-time constants. So I have to sum element by element through a loop. For each iteration. I have to load and store the nth element by a dynamic offset, but I can't found any api to support this.

another solution is create a new address by sum a offset, but seems UB occurs.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 21 2024 at 05:55):

meijies commented on issue #7972:

@cfallin sorry, I misunderstood pointer offset, each pointer offset represents 1 byte but not 8 bytes, so for f64, the next element address = base address + index * types::F64.bytes()


Last updated: Dec 23 2024 at 12:05 UTC