-
Notifications
You must be signed in to change notification settings - Fork 823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
float type printf error using spike #1143
Comments
Printing of floating point numbers comes from your C library, which is likely newlib, which has lots of compile-time options for floating-point support. Assuming support was compiled in, you might need to add to your link line: And you might want to build newlib with I'm closing this issue as it's not a Spike problem. You can reopen if you conclude otherwise. |
Is newlib a part of riscv-isa-sim(spike) or riscv-pk? or I need to install newlib in addition? Could you please give me a complete overflow to doing this? thus print float type collectly? this problem also lead to user load segfault for running coremark using spike pk.[https://github.com//issues/1140] |
@dshm - This is NOT a spike problem. You must link your code with proper 'printf' library. Some libraries do NOT include floating point support (to save space). Spike should NOT be used to run Coremark as it is NOT cycle-accurate simulator. Reported values will be meaningless ... |
Spike is running the program you gave it. If that program was not compiled correctly, and apparently it was not, then you will not get the results you expect. This is the issue tracker for the Spike simulator, not a support forum for newlib or other software compilation questions. |
So where is the offical forum or link to discuss above problems? like errors of using spike or pk? Could you please give a link? It's a little hard and unfriendly for new users. Thanks |
The errors become visible when you run your program in Spike, but that's tantamount to blaming the computer for the bugs in your code. Where did you get your C compiler You need to add something to your compile line that will enable floating-point You could also ask in the sw-dev mailing list. |
float type and double type can't printed corrcctly using spike pk, the code is simple as below:
#include<stdio.h>
int main()
{
double b=7.7;
float a=5.6;
printf("float test %f\n", a);
printf("double test %f\n", b);
printf("end of float test\n");
return 0;
}
I write above code in floattest.c and run "riscv64-unknown-elf-gcc -o floattest ./floattest.c ; spike pk floattest" then I get the output as below, the float and double type variables are printed as f. Is it an error in spike?
bbl loader
float test f
double test f
end of float test
spike version: master branch, commit id ab3225a
pk version: master branch, commit id 7e9b671c0415dfd7b562ac934feb9380075d4aa2
for spike:
mkdir build;cd build
../configure --prefix=$RISCV
make
make install
for pk
mkdir build; cd build
../configure --prefix=$RISCV --host=riscv64-unknown-elf --with-arch=rv64gc_zifencei
make
make install
Does it wrong to use --with-arch=rv64gc_zifencei to build pk? I referenced riscv-software-src/riscv-pk#260 for help. without --with-arch=rv64gc_zifencei pk can't build successful and report Error: unrecognized opcode `fence.i'
The text was updated successfully, but these errors were encountered: