Compiling Tests for RISC-V

I’m trying to have tests be created for RISC-V. In particular I’m looking at the GemmTest. From what I understand because GemmTest depends on libjit_matmul_f I should be building libjit targeting RISC-V. However, doing only that does not result in the test/GemmTest binary being built for RISC-V. Is there something else I should be doing?

From the build log I can see that GemmTest gets compiled twice. The first time GemmTest.cpp is compiled into GemmTest.cpp.o. Then again later on, after some supporting libraries are built I assume, GemmTest.cpp.o is compiled into the executable GemmTest binary. Would someone be kind enough to explain what each compilation step does, and which step(s) I should be looking at in order to build GemmTest for another target?

Hey Derek,

GemmTest is actually a pretty straightforward CMake executable, so you can ignore a bunch of the libjit complexity. The bits of CMake that are most interesting here are:

Do note that these targets are disabled when building with MSVC; I don’t remember why since I haven’t built on Windows myself.

Bert

Hi Bert,

Thanks for the reply. So from these two CMakeLists.txt I can see that GemmTest depends on CPURuntimeNative, etc, and CPURuntimeNative is built using the libjit files. I know for the libjit files you can build them for a different architecture by
adding "-target " into: https://github.com/pytorch/glow/blob/71f2ec208b1306f422da7fb1562254eb225d32ae/lib/Backends/CPU/CMakeLists.txt#L16

However, I am unable to find such an option/figure out what to change that will allow me to have GemmTest be compiled for another architecture ie ARM or RISC-V. Is this possible? Or would it better for me to write my own test case? In which case again are there any pointers on how I would build it for another architecture already supported by the LLVM?

Ah, I see the confusion - the cmake options you’re pointing to are for building libjit as bytecode, to be later loaded by the Glow runtime. You want to configure the cmake project for cross-compilation to build a RISC-V binary

Yep is it possible to configure the cmake project for cross-compilations to build a RISC-V binary? Or would it be better for me to try and emit a RISC-V bundle through model-runner/image-classifier?

You can definitely configure CMake to do cross compilation though I’ve not done it with Glow myself (here’s, e.g., an example of how to cross-compile llvm/clang itself: https://llvm.org/docs/HowToCrossCompileLLVM.html). The main things to do are to set --target and --sysroot appropriately in your CMAKE_CXX_FLAGS.