Is your feature request related to a problem? Please describe.
I tried to use these CMake code for the BatchMatMulBroadcast.mlir in my PR to compile static library. -fopenmp could only be used in clang and I have ruled out the possibility that the problem arises from using clang instead of llc.
function(build_batch_matmul_broadcast_omp step)
add_custom_command(OUTPUT batch-matmul-broadcast-${step}-omp.o
COMMAND cat ${BUDDY_SOURCE_DIR}/benchmarks/OpOptimization/MatMul/BatchMatMulBroadcast.mlir |
sed 's/batch_matmul_broadcast_STEP_PLACEHOLDER/batch_matmul_broadcast_STEP_PLACEHOLDER_omp/g' |
sed 's/STEP_PLACEHOLDER/${step}/g' |
${BUDDY_MLIR_BUILD_DIR}/bin/buddy-opt
-batchmatmul-optimize="step-placeholder=${step}"
-expand-strided-metadata
-affine-super-vectorize
-lower-affine
-convert-scf-to-openmp
-convert-vector-to-llvm
-finalize-memref-to-llvm
-convert-scf-to-cf
-convert-linalg-to-llvm
-convert-openmp-to-llvm
-llvm-request-c-wrappers
-convert-func-to-llvm
-reconcile-unrealized-casts |
${LLVM_MLIR_BINARY_DIR}/mlir-translate --mlir-to-llvmir |
clang -c -x ir -O3 --target=${BUDDY_OPT_TRIPLE} -fopenmp
-o ${BUDDY_BINARY_DIR}/../benchmarks/OpOptimization/MatMul/batch-matmul-broadcast-${step}-omp.o -
)
add_library(BatchMatMulBroadcast${step}OMP STATIC batch-matmul-broadcast-${step}-omp.o)
set_target_properties(BatchMatMulBroadcast${step}OMP PROPERTIES LINKER_LANGUAGE CXX)
endfunction()
Under normal circumstances, OpenMP requires dynamic library to start. I originally wanted to try statically linking the OpenMP library, gcc has libgomp.a and the compiler can do that, but I found that the Clang/LLVM official discourages this approach. nm -n shows that the entry name of the library is named batch_matmul_broadcast_64_omp..omp_par, not starts with _mlir_ciface_, also the C++ program cannot pass the Memref parameters to the MLIR function, I guess it should be called by the OpenMP dynamic library, but I can't find the way to use it.
Describe the solution you'd like
Discuss various possibilities to solve this problem. Perhaps correctly utilizing OpenMP::OpenMP_CXX in CMake is a good idea.
Is your feature request related to a problem? Please describe.
I tried to use these CMake code for the BatchMatMulBroadcast.mlir in my PR to compile static library.
-fopenmpcould only be used in clang and I have ruled out the possibility that the problem arises from using clang instead of llc.Under normal circumstances, OpenMP requires dynamic library to start. I originally wanted to try statically linking the OpenMP library, gcc has libgomp.a and the compiler can do that, but I found that the Clang/LLVM official discourages this approach.
nm -nshows that the entry name of the library is namedbatch_matmul_broadcast_64_omp..omp_par, not starts with_mlir_ciface_, also the C++ program cannot pass the Memref parameters to the MLIR function, I guess it should be called by the OpenMP dynamic library, but I can't find the way to use it.Describe the solution you'd like
Discuss various possibilities to solve this problem. Perhaps correctly utilizing
OpenMP::OpenMP_CXXin CMake is a good idea.