ModularM
Modular2y ago
6 replies
taalhaataahir01022001

LLVM Intrinsics

I'm trying to use llvm.matrix.transpose intrinsic like following:
from sys.intrinsics import llvm_intrinsic
fn main():
    alias intrin: StringLiteral = "llvm.matrix.transpose"

    alias T0 = SIMD[DType.int32, 4]
    alias T1 = Scalar[DType.int32]
    alias T2 = Scalar[DType.int32]
    alias type = SIMD[DType.int32, 4]
    alias has_side_effect: Bool = False

    var a: SIMD[DType.int32, 4] = SIMD[DType.int32, 4] (1, 2, 3, 4)
    var rows: Scalar[DType.int32] = 4
    var cols: Scalar[DType.int32] = 1

    var result = llvm_intrinsic[intrin, type, T0, T1, T2, has_side_effect] (a, rows, cols)
    print(result)

But Mojo is crashing:
LLVM ERROR: Cannot select: intrinsic %llvm.matrix.transpose
Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes.
Stack dump:
0.    Running pass 'Function Pass Manager' on module '<split-module>'.
1.    Running pass 'X86 DAG->DAG Instruction Selection' on function '@main'
 #0 0x00005f31328dc487 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/talha/.modular/pkg/packages.modular.com_max/bin/mojo+0x128c487)
 ...
 ...
mojo crashed!
Please file a bug report.
Aborted (core dumped)

My input and output types looks OK as I've followed it from here: https://llvm.org/docs/LangRef.html#llvm-matrix-transpose-intrinsic

Also I've tried using other intrinsics and they are working fine. e.g., llvm.vector.reduce.add:
from sys.intrinsics import llvm_intrinsic

fn main():
  alias intrin: StringLiteral = "llvm.vector.reduce.add"
  alias T0 = SIMD[DType.int32, 4]
  alias type = Scalar[DType.int32]
  alias has_side_effect: Bool = False

  var a: SIMD[DType.int32, 4] = SIMD[DType.int32, 4] (1, 2, 3, 40)

  var result = llvm_intrinsic[intrin, type, T0, has_side_effect] (a)

  print(result)

And it outputs 46 correctly.
Can anyone guide me what I'm doing wrong while using the llvm.matrix intrinsic?
Was this page helpful?