Hello! I’m trying to reuse the assembly code generated by TVM with my own C++ code and I get a segmentation fault. I use ‘intel’ as the OpenMP option when I built TVM. The command I use to build my own code is like:
as kernel.asm -o kernel.o
g++ kernel.o -shared -fPIC -m64 -o kernel.so
g++ -std=c++11 -O2 -fPIC \
-I/home/moderato/Documents/incubator-tvm/include \
-I/home/moderato/Documents/incubator-tvm/3rdparty/dmlc-core/include \
-I/home/moderato/Documents/incubator-tvm/3rdparty/dlpack/include \
-L/home/moderato/Documents/incubator-tvm/build \
-L/usr/local/lib/ -liomp5 \
cpu_bench.cpp \
-o cpu_bench \
-ldl -pthread -lcnpy -lz -ltvm_runtime
When I trace the error down using gdb, I got some output like this:
#0 0x00007fb27c628293 in ?? () from kernel.so
#1 0x00007fb299d3a7e2 in TVMBackendParallelLaunch._omp_fn.0 () from /home/moderato/Documents/incubator-tvm/build/libtvm_runtime.so
#2 0x00007fb27d85d638 in __kmp_api_GOMP_parallel_40_alias () from /usr/local/lib/libiomp5.so
#3 0x00007fb299d3a935 in TVMBackendParallelLaunch () from /home/moderato/Documents/incubator-tvm/build/libtvm_runtime.so
#4 0x00007fb27c627e71 in ?? () from kernel.so
#5 0x00007fb299d1fea0 in tvm::runtime::WrapPackedFunc(int (*)(void*, int*, int), tvm::runtime::ObjectPtr<tvm::runtime::Object> const&)::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const [clone .isra.88] () from /home/moderato/Documents/incubator-tvm/build/libtvm_runtime.so
#6 0x0000000000402762 in benchmark_generated_cpu(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int, int, int, int, int, bool, int, int, int, int, bool, int, bool, bool) ()
#7 0x00000000004032cd in benchmarkWithWorkloadString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int) ()
#8 0x0000000000401c3e in main ()
Looks like the error occurs when TVMBackendParallelLaunch tries to launch some function, but I have no idea how to go one step deeper. Anyone can help? Did I miss anything when I compile and link the code?
Thanks in advance!