Hi all,
I am trying to run the entire TVM software stack (not just the TVM runtime) on a RISC-V CPU, but I cannot get even a simple case to run. According to the printed error messages, there seems to be an issue during the execution phase after LLVM code generation. Could you all help me figure out what might be the problem?
llvm: 15.0.7
gcc: gcc version 13.1.0 (Debian 13.1.0-6)
tvm: commit 35e74cc4c9c8dec658217ffeea85f2ba25e35a35
case:
import numpy as np
import tvm
from tvm.ir.module import IRModule
from tvm.script import tir as T
import os
a = np.arange(16).reshape(4, 4)
b = np.arange(16, 0, -1).reshape(4, 4)
c_np = a + b
@tvm.script.ir_module
class MyAdd:
@T.prim_func
def add(
A: T.Buffer((4, 4), "int64"),
B: T.Buffer((4, 4), "int64"),
C: T.Buffer((4, 4), "int64"),
):
T.func_attr({"global_symbol": "add"})
for i, j in T.grid(4,4):
with T.block("C"):
vi, vj = T.axis.remap("SS", [i, j])
C[vi, vj] = A[vi, vj] + B[vi, vj]
print(MyAdd)
rt_lib = tvm.build(
MyAdd,
target="llvm -mtriple=riscv64-linux-gnu -mcpu=generic-rv64 -mabi=lp64d -mattr=+64bit,+m,+a,+f,+d,+c"
)
print("after build...")
a_tvm = tvm.nd.array(a)
b_tvm = tvm.nd.array(b)
c_tvm = tvm.nd.array(np.empty((4,4), dtype=np.int64))
rt_lib["add"](a_tvm, b_tvm, c_tvm)
np.testing.assert_allclose(c_tvm.numpy(), c_np, rtol=1e-5)
error log:
Program received signal SIGSEGV, Segmentation fault.
0x0000003ff0dee6be in llvm::RuntimeDyldELF::computePlaceholderAddress(unsigned int, unsigned long) const ()
from /mnt/v_nfs/zifeng/v-repos/tvm/build/libtvm.so
(gdb) bt
#0 0x0000003ff0dee6be in llvm::RuntimeDyldELF::computePlaceholderAddress(unsigned int, unsigned long) const ()
from /mnt/v_nfs/zifeng/v-repos/tvm/build/libtvm.so
#1 0x0000003ff0de686e in llvm::RuntimeDyldImpl::applyExternalSymbolRelocations(llvm::StringMap<llvm::JITEvaluatedSymbol, llvm::MallocAllocator>) () from /mnt/v_nfs/zifeng/v-repos/tvm/build/libtvm.so
#2 0x0000000001c4d720 in ?? ()