Undefined symbol error when building for rocm target

The error message is:

(tvm) [root@node1 tvm]# VM_LOG_DEBUG=DEFAULT=2 python3 example.py
/home/xuyangyang/tvm2/python/tvm/target/target.py:326: UserWarning: target_host parameter is going to be deprecated. Please pass in tvm.target.Target(target, host=target_host) instead.
  warnings.warn(
One or more operators have not been tuned. Please tune your model for better performance. Use DEBUG logging level to see more details.
Traceback (most recent call last):
  File "example.py", line 51, in <module>
    lib = relay.build(mod, target=target, target_host='llvm', params=params)
  File "/home/xuyangyang/tvm2/python/tvm/relay/build_module.py", line 364, in build
    graph_json, runtime_mod, params = bld_mod.build(
  File "/home/xuyangyang/tvm2/python/tvm/relay/build_module.py", line 161, in build
    self._build(
  File "/home/xuyangyang/tvm2/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
    raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
  7: TVMFuncCall
  6: tvm::relay::backend::RelayBuildModule::GetFunction(std::string const&, tvm::runtime::ObjectPtr<tvm::runtime::Object> const&)::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#3}::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const
  5: tvm::relay::backend::RelayBuildModule::BuildRelay(tvm::IRModule, tvm::runtime::String const&)
  4: tvm::TIRToRuntime(tvm::runtime::Map<tvm::Target, tvm::IRModule, void, void> const&, tvm::Target const&)
  3: tvm::codegen::Build(tvm::IRModule, tvm::Target)
  2: tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::runtime::Module (tvm::IRModule, tvm::Target)>::AssignTypedLambda<tvm::runtime::Module (*)(tvm::IRModule, tvm::Target)>(tvm::runtime::Module (*)(tvm::IRModule, tvm::Target), std::string)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
  1: tvm::codegen::BuildAMDGPU(tvm::IRModule, tvm::Target)
  0: tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<TVMFuncCreateFromCFunc::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#2}> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) [clone .cold]
  File "/home/xuyangyang/tvm2/python/tvm/_ffi/_ctypes/packed_func.py", line 81, in cfun
    rv = local_pyfunc(*pyargs)
  File "/home/xuyangyang/tvm2/python/tvm/contrib/rocm.py", line 118, in callback_rocm_link
    rocm_link(tmp_obj, tmp_cobj)
  File "/home/xuyangyang/tvm2/python/tvm/contrib/rocm.py", line 96, in rocm_link
    raise RuntimeError(msg)
RuntimeError: Linking error using ld.lld:
ld.lld: error: undefined symbol: __oclc_ABI_version
>>> referenced by /tmp/tmp66vb72pk/rocm_kernel.o:(__ockl_devmem_request)
>>> referenced by /tmp/tmp66vb72pk/rocm_kernel.o:(__ockl_devmem_request)
>>> referenced by /tmp/tmp66vb72pk/rocm_kernel.o:(__ockl_sanitizer_report)
>>> referenced 1 more times

The source code is:

nm output of the object file:

The rocm version is:

(tvm) [root@node1 tvm]# /opt/dtk/bin/hipcc --version
HIP version: 5.2.22451-8f78d635
clang version 14.0.0 (http://10.15.3.7/dcutoolkit/driverruntime/llvm-project.git f6fb91f87b05f2a423bd1d6a2f7382b4e83f5966)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/dtk/llvm/bin

I solved it by adding one more bitcode file to rocm.py. But currently I am not sure why does this operation is needed.

The operation of add one bitcode file to rocm.py lead to the result of compute not equal the result of opencl/cuda

What is the relative error rate?

This change is only needed for rocm 5. “500” probably means rocm version 5 and above.