In the noble Docker container I have been running the following program:
#include <stdio.h>
#include <stdint.h>
#define VECTOR_SIZE 8 // Number of 64-bit elements
void store_vector_values(int64_t* buffer) {
int64_t values[VECTOR_SIZE] = {0x1000000000000001, 0x2, 0x3, 0x4, 0x5, 0x6,
0x7, 0x8};
// Inline assembly to load values into the vector register and store them
asm volatile (
"vsetvli t0, zero, e64, m2;" // Set vector length to 2 elements of 64
bits
"vle64.v v0, (%0);" // Load values into vector register v0
"vse64.v v0, (%1);" // Store the contents of v0 into the
buffer
:
: "r"(values), "r"(buffer) // Input operands
: "v0", "t0", "memory" // Clobbered registers
);
}
int main() {
int64_t buffer[VECTOR_SIZE] = {0}; // Buffer to store 64-bit values
for (int i = 0; i < VECTOR_SIZE; i++) {
printf("buffer[%d] = 0x%lx\n", i, buffer[i]);
}
store_vector_values(buffer);
// Output the stored values for verification
printf("Stored vector values:\n");
for (int i = 0; i < VECTOR_SIZE; i++) {
printf("buffer[%d] = 0x%lx\n", i, buffer[i]);
}
return 0;
}
And received this output:
./test
buffer[0] = 0x0
buffer[1] = 0x0
buffer[2] = 0x0
buffer[3] = 0x0
buffer[4] = 0x0
buffer[5] = 0x0
buffer[6] = 0x0
buffer[7] = 0x0
Stored vector values:
buffer[0] = 0x1000000000000001
buffer[1] = 0x2
buffer[2] = 0x3
buffer[3] = 0x4
buffer[4] = 0x0
buffer[5] = 0x0
buffer[6] = 0x0
buffer[7] = 0x0
So it seems that QEMU can emulate the vse64.v instruction. It is not
clear to me why for "m2" four elements are transferred and not two.
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2133188
Title:
Illegal instruction in memset under qemu-user for riscv64
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/2133188/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs