Stream: git-wasmtime

Topic: wasmtime / issue #9508 Does cranelift support the f16cons...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 02:48):

abc767234318 opened issue #9508:

I constructed a clif file that contains the f16const instruction, and I got an error when I used the following command.

qemu-riscv64 -L /usr/riscv64-linux-gnu/ -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib  clif-util test test.clif

The error is:

 ERROR cranelift_filetests::concurrent > FAIL: failed to parse test.clif
FAIL test.clif: failed to parse test.clif

Caused by:
    16: Unknown opcode: 'f16const'
1 tests
Error: 1 failure

In addition, I found a test file for the f16const instruction in the cranelift/filetests/filetests/isa/riscv64/f16const.clif.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 05:31):

cfallin commented on issue #9508:

Interesting -- it seems we should, since it's in a test and tests are passing on CI.

A few things to verify:

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 07:00):

abc767234318 closed issue #9508:

I constructed a clif file that contains the f16const instruction, and I got an error when I used the following command.

qemu-riscv64 -L /usr/riscv64-linux-gnu/ -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib  clif-util test test.clif

The error is:

 ERROR cranelift_filetests::concurrent > FAIL: failed to parse test.clif
FAIL test.clif: failed to parse test.clif

Caused by:
    16: Unknown opcode: 'f16const'
1 tests
Error: 1 failure

In addition, I found a test file for the f16const instruction in the cranelift/filetests/filetests/isa/riscv64/f16const.clif.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 07:00):

abc767234318 commented on issue #9508:

Interesting -- it seems we should, since it's in a test and tests are passing on CI.

A few things to verify:

It seems that my version of wasmtime is wrong, I will close this issue.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 09:55):

abc767234318 reopened issue #9508:

I constructed a clif file that contains the f16const instruction, and I got an error when I used the following command.

qemu-riscv64 -L /usr/riscv64-linux-gnu/ -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib  clif-util test test.clif

The error is:

 ERROR cranelift_filetests::concurrent > FAIL: failed to parse test.clif
FAIL test.clif: failed to parse test.clif

Caused by:
    16: Unknown opcode: 'f16const'
1 tests
Error: 1 failure

In addition, I found a test file for the f16const instruction in the cranelift/filetests/filetests/isa/riscv64/f16const.clif.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 09:55):

abc767234318 commented on issue #9508:

@cfallin Here is my CLIF input file.
output.zip

However, I still can't run this file by using the following command line:

qemu-riscv64 -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib riscv64gc-unknown-linux-gnu/debug/clif-util run -v output.clif

The error is :

output.clif: The target ISA specified in the file is not compatible with the host ISA
1 file
Error: 1 failure

And I try to run the f16const.clif, it also outputs the similar error:

qemu-riscv64 -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib riscv64gc-unknown-linux-gnu/debug/clif-util run
-v ../cranelift/filetests/filetests/isa/riscv64/f16const.clif
../cranelift/filetests/filetests/isa/riscv64/f16const.clif: The target ISA specified in the file is not compatible with the host ISA
1 file
Error: 1 failure

The commit version of my wasmtime is:

~/wasmtime$ git rev-parse HEAD
c255a853f47188f43fb004389581fccc74bfc362

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 10:00):

bjorn3 commented on issue #9508:

You are probably missing target riscv64 at the top of the test file (didn't download your zip).

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 12:14):

afonso360 commented on issue #9508:

FP16 on the RISC-V backend is only supported with the Zfh extension. You need to add the has_zfh flag to the target field. (i.e. target riscv64 has_zfh)

You also have to specify support for the Zfh extension in qemu otherwise it likely won't run the test. There's a flag somewhere to do it, I don't know exactly what it is.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 12:15):

afonso360 edited a comment on issue #9508:

FP16 on the RISC-V backend is only supported with the Zfh extension. You need to add the has_zfh flag to the target field. (i.e. target riscv64 has_zfh)

You also have to specify support for the Zfh extension in qemu otherwise it likely won't run the test. There's a flag somewhere to do it, I don't know exactly what it is.

I should also note, there are some operations that we don't yet support for FP16.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 12:26):

bjorn3 commented on issue #9508:

FP16 on the RISC-V backend is only supported with the Zfh extension.

For cg_clif f16const and f16 arguments and return values will need to work unconditionally. Math on f16 can be lowered to libcalls just fine when Zfh is not enabled however.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 13:47):

afonso360 commented on issue #9508:

I'm not entirely sure how it's currently implemented, but I think that should work. We already save and restore the entire registers, instead of just the used portion. I haven't tested that yet though.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2024 at 18:08):

afonso360 commented on issue #9508:

@abc767234318 I'm not entirely sure why the clif-util run command doesn't work, but running the test with clif-util test does work on my machine.

I also tried to run clif-util compile --target riscv64 --set has_zfh output.clif, but that failed because we don't support f128 types.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 20 2024 at 09:54):

abc767234318 commented on issue #9508:

@abc767234318 I'm not entirely sure why the clif-util run command doesn't work, but running the test with clif-util test does work on my machine.

I also tried to run clif-util compile --target riscv64 --set has_zfh output.clif, but that failed because we don't support f128 types.

Where can I find the set of IR instructions supported by each cpu architecture? I also found that x86 cpu don't seem to support the iconst.i128 instruction.

The line 13 is v7 = iconst.i128 -2319861032952027390, but I get the following error

 ERROR cranelift_filetests::concurrent > FAIL: failed to parse file_tests/multi_func.clif
FAIL file_tests/multi_func.clif: failed to parse file_tests/multi_func.clif

Caused by:
    13: expected one of the following type: i8, i16, i32 or i64
1 tests
Error: 1 failure

view this post on Zulip Wasmtime GitHub notifications bot (Nov 20 2024 at 10:11):

bjorn3 commented on issue #9508:

iconst.i128 is not allowed on any architecture afaik. You have to use two iconst.i64 + an iconcat with both halves to get an i128. The iconst instruction only accepts a 64bit immediate value.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 20 2024 at 17:35):

cfallin commented on issue #9508:

To add a bit more: we don't support iconst.i128 because it would imply that the size of an InstructionData is at least 128 bits (16 bytes) plus the opcode; whereas we try to keep the entire InstructionData to 16 bytes for performance and memory-overhead reasons. The tradeoff is that the one instruction that has a huge immediate (iconst.i128) is not possible to encode directly.


Last updated: Nov 22 2024 at 16:03 UTC