I have a multi-file (3 .cpp files and 2 .h files) C++ code that uses new, new[], delete, and delete[] operators to allocate large chunks of memory and performs some floating point operations (requires division by sqrt()). The program compiles and runs well with regular g++ and produces the required output. I now want to convert it to RISC-V instructions.
I first used the GNU RISC-V compiler toolchain to compile the program with following command:
riscv32-unknown-elf-g++ -w -march=rv32imafc -mabi=ilp32f -DPREALLOCATE=1 -mcmodel=medany -fno-common -static -Iinclude/ f1.cpp f2.cpp f3.cpp -o executable
here executable is the compiled binary file.
Since no errors are thrown at compile time, I proceeded to run the whisper simulator as follows:
whisper --isa imafc --target executable --logfile mylog --profileinst prfl
where mylog and prfl are output file paths.
The log file generated exceeds 6 GB in size and it doesn't terminate, so I assume that it is stuck in some infinite loop.
I tried adding the _start() function and tohost variable which didn't work either (same problem as 3 above).
I generated an object dump for executable and captured the (hex) addresses of starting address of main(), its ending address and address of tohost and passed them as parameters to --startpc, --endpc and --tohost respectively, in which case, the program was aborted after 64 illegal operations and ~300 MB of log file.
I think I am making some mistake. Kindly help me fix this issue or share the correct steps to generate the RISC-V assembly instructions for my C++ program.
I have a multi-file (3 .cpp files and 2 .h files) C++ code that uses new, new[], delete, and delete[] operators to allocate large chunks of memory and performs some floating point operations (requires division by sqrt()). The program compiles and runs well with regular g++ and produces the required output. I now want to convert it to RISC-V instructions.
I first used the GNU RISC-V compiler toolchain to compile the program with following command:
riscv32-unknown-elf-g++ -w -march=rv32imafc -mabi=ilp32f -DPREALLOCATE=1 -mcmodel=medany -fno-common -static -Iinclude/ f1.cpp f2.cpp f3.cpp -o executable
here executable is the compiled binary file.Since no errors are thrown at compile time, I proceeded to run the whisper simulator as follows:
whisper --isa imafc --target executable --logfile mylog --profileinst prfl
where mylog and prfl are output file paths.The log file generated exceeds 6 GB in size and it doesn't terminate, so I assume that it is stuck in some infinite loop.
I tried adding the _start() function and tohost variable which didn't work either (same problem as 3 above).
I generated an object dump for executable and captured the (hex) addresses of starting address of main(), its ending address and address of tohost and passed them as parameters to
--startpc
,--endpc
and--tohost
respectively, in which case, the program was aborted after 64 illegal operations and ~300 MB of log file.I think I am making some mistake. Kindly help me fix this issue or share the correct steps to generate the RISC-V assembly instructions for my C++ program.