riscv-isa-sim icon indicating copy to clipboard operation
riscv-isa-sim copied to clipboard

Spike has no output and program execution never ends.

Open tak-ka3 opened this issue 3 years ago • 3 comments

Problem

When I execute spike command, nothing is output.

I wrote this easiest C source code

int main() {
        return 0;
}

, and compiled it with the following command.

$ riscv64-unknown-elf-gcc hello.c -o hello
$ spike pk hello

Then nothing was output. What should I do to execute spike simulation? Even if I executed spike ./riscv64_github/riscv64-unknown-elf/bin/pk hello command, the result was the same.

MY env

compiler

I used rvv-next branch in https://github.com/riscv-collab/riscv-gnu-toolchain and riscv-gcc-rvv-next branch in https://github.com/riscv-collab/riscv-gcc to build. I want to use rvv instructions.

$ riscv64-unknown-elf-gcc -v
Using built-in specs.
COLLECT_GCC=riscv64-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/home/hiraoka/riscv64_github/libexec/gcc/riscv64-unknown-elf/12.2.0/lto-wrapper
Target: riscv64-unknown-elf
Configured with: /home/hiraoka/research/riscv-llvm/riscv-gnu-toolchain/riscv-gcc/configure --target=riscv64-unknown-elf --prefix=/home/hiraoka/riscv64_github --disable-shared --disable-threads --enable-languages=c,c++ --with-pkgversion=geb96155f49d --with-system-zlib --enable-tls --with-newlib --with-sysroot=/home/hiraoka/riscv64_github/riscv64-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-tm-clone-registry --src=.././riscv-gcc --disable-multilib --with-abi=lp64d --with-arch=rv64gcv --with-tune=rocket --with-isa-spec=2.2 'CFLAGS_FOR_TARGET=-Os   -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-Os   -mcmodel=medlow'
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 12.2.0 (geb96155f49d)

spike

I used master branch in this repo(https://github.com/riscv-software-src/riscv-isa-sim) to build. I used the command described here(https://github.com/riscv-software-src/riscv-isa-sim#build-steps).

pk

I used master branch in the repo(https://github.com/riscv-software-src/riscv-pk). to build. I built using the following command.

$ cd build
$ ../configure --prefix=/home/hiraoka/riscv64_github --host=riscv64-unknown-elf --with-arch=rv64gcv
$ make 
$ make install

tak-ka3 avatar Nov 22 '22 05:11 tak-ka3

No output is the expected behavior here, because the program you’re running produces no output. It’s the same as if you compiled and ran that program on your host machine.

aswaterman avatar Nov 22 '22 05:11 aswaterman

The way I explained my situation was not good. Spike has no output and program execution never ends like an endless loop. To stop the execution I have to execute ctr+c. Also even if I try the following code, there is no output and program never ends.

#include <stdio.h>

int main() {
        printf("Hello, World\n");
        return 0;
}

tak-ka3 avatar Nov 22 '22 06:11 tak-ka3

Like this spile_anime

tak-ka3 avatar Nov 22 '22 08:11 tak-ka3

Hi, @aswaterman I retried to build RVV simulator env in my other Ubuntu PC. Then I encountered the same error as above after switching to rvv-next branch from master branch in riscv-gnu-toolchain repository(https://github.com/riscv-collab/riscv-gnu-toolchain) and simulating with spike pk hello command. That means before swiching I can simulate RISC-V instructions except for RVV instructions using spike. I wanted to simulate RVV instructions and I used rvv-next branch. If I want to do them, do I not have to use rvv-next branch and are there other ways to simulate RVV instructions using spike?

Thanks,

tak-ka3 avatar Nov 30 '22 05:11 tak-ka3

Sorry, I can't help debug this. You'll have to figure it out yourself. All I can say is that Spike support for the V extension is known to be functional. Something in your software environment is presumably not working correctly.

aswaterman avatar Nov 30 '22 05:11 aswaterman

Silly question, are you enabling the V extension in Spike by using --isa=rv64gcv?

aswaterman avatar Nov 30 '22 05:11 aswaterman

Even if I execute spike pk hello --isa=rv64gcv, spike doesn't work.

tak-ka3 avatar Nov 30 '22 05:11 tak-ka3

Arguments to Spike need to immediately follow spike. In that position, it is an argument to hello. As in, spike --isa=rv64gcv pk hello

aswaterman avatar Nov 30 '22 05:11 aswaterman

Ah, thanks. But even though I execute spike --isa=rv64gcv pk hello, it doesn't work.

tak-ka3 avatar Nov 30 '22 05:11 tak-ka3

You're own your own, then. You can try single-stepping through the execution and seeing where things go wrong, but that requires understanding of the internals of pk and the userspace runtime. Sorry I can't help any further.

aswaterman avatar Nov 30 '22 05:11 aswaterman

Thank you for your advice! I want to do know just only the site written about the way to debug pk at the end, if you know.

tak-ka3 avatar Nov 30 '22 05:11 tak-ka3

BTW, here is proof that this can work. I used the most recent spike, most recent pk, and gcc 11.2.0.

$ cat test.c
#include <stdio.h>
int main()
{
  unsigned long vlmax;
  asm ("vsetvli %0, x0, e8, m8, ta, ma" : "=r" (vlmax));
  printf("For SEW=8 LMUL=8, VLMAX=%lu\n", vlmax);
  return 0;
}
$ riscv64-unknown-elf-gcc -march=rv64gcv test.c
$ spike --isa=rv64gcv pk a.out
bbl loader
For SEW=8 LMUL=8, VLMAX=128
$ 

aswaterman avatar Nov 30 '22 05:11 aswaterman

Can you include <riscv_vector.h> to use RVV intrinsics without errors?

tak-ka3 avatar Nov 30 '22 05:11 tak-ka3

Nope. It's an older version of the compiler. Sorry.

aswaterman avatar Nov 30 '22 06:11 aswaterman

Anyway, this pretty clearly isn't a Spike bug, so I'm going to close the issue.

aswaterman avatar Nov 30 '22 06:11 aswaterman