LLVM Discussion Forums

Problems using mlir-cpu-runner

Hello everybody,

I try to make some 4-month-old compilation scripts involving mlir-cpu-runner to work, and I get a weird error.

My mlir source is the following file called “xxx.mlir”:

func @print_int(i32)
func @abc() {
    %c42_i32 = constant 42 : i32
    call @print_int(%c42_i32) : (i32) -> ()
    return
}

The execution command (which I used in April) is:
mlir-cpu-runner -O3 -e abc -entry-point-result=void -shared-libs=./externc.so xxx.mlir
I have also tried:
mlir-cpu-runner -O3 -e=abc -entry-point-result=void -shared-libs=./externc.so xxx.mlir

The output is in both cases:
Error: entry point not found

What is the problem?

Note: the externc.so library contains the implementation of print_int. You can simply comment the function call to print_int and remove the --shared option to mlir-cpu-runner. The error message is the same…

Thanks,
Dumitru

Can you give s/abc/main a quick try?

I have changed abc->main in both xxx.mlir and in the command line.
Same error. I have also tried without the “-e” option, hoping “main” is a default choice.

BTW, here is my LLVM build version (about 1 month old, I think):

LLVM (http://llvm.org/):
  LLVM version 12.0.0git
  Optimized build with assertions.
  Default target: x86_64-apple-darwin19.3.0
  Host CPU: haswell

Dumitru

I don’t know what the old flow used to be, but don’t you need to lower this to llvm prior to invoking the cpu runner? The following works for me.

mlir-opt  --convert-std-to-llvm xxx.mlir | \
  mlir-cpu-runner -O3 -e abc -entry-point-result=void

@aartbik My old scripts did not have the lowering. I also tried it with lowering now, and I have the same error message. Does it work for you?

Using the following (vector.print is similar to what you define above, it is provided in our runtime support library).

func @abc() {
  %c42_i32 = constant 42 : i32
  vector.print %c42_i32 : i32
  return
}

I get:

mlir-cpu-runner -O3 -e abc -entry-point-result=void  \
  -shared-libs=libmlir_runner_utils.so  xxx.mlir

Error: entry point not found

But with lowering (note that I need to lower from vector now, but same idea):

mlir-opt --convert-vector-to-llvm xxx.mlir | \
mlir-cpu-runner -O3 -e abc -entry-point-result=void  \
  -shared-libs=libmlir_runner_utils.so

42
1 Like

Thanks. Now it works. I don’t understand what went wrong. There may be some character I copied in the command line which looked the same but was not.

1 Like

I think your function @abc is getting erased or renamed - you’d have to dump it some way after the last lowering in MLIR to see what’s happening.

Regarding the lowering, mlir-cpu-runner used to work on standard dialect, then on standard functions with LLVM dialect inside, but it has been migrated to only work with the LLVM dialect. It looks for an llvm.func op with the entry point symbol.

The conversion process may fail, e.g., if the function signature contains an unsupported type such as tensor, at which point the standard function will persist in the IR and will not be found by the runner. The conversion is partial and non-destructive, meaning mlir-opt won’t fail if there have been failures in converting some functions, but just skip them.

1 Like