xref: /llvm-project/mlir/test/Dialect/GPU/test-nvvm-pipeline.mlir (revision f50f9698ad012882df8dd605f5482e280c138266)
1// REQUIRES: host-supports-nvptx
2// RUN: mlir-opt %s \
3// RUN:  | mlir-opt -gpu-lower-to-nvvm-pipeline="cubin-format=isa" \
4// RUN:   | FileCheck %s
5
6// RUN: mlir-opt %s \
7// RUN:  | mlir-opt -gpu-lower-to-nvvm-pipeline="cubin-format=isa" \
8// RUN:    --mlir-print-ir-after=convert-gpu-to-nvvm 2>&1 \
9// RUN:  | FileCheck %s --check-prefixes=CHECK-NVVM
10
11// This test checks whether the GPU region is compiled correctly to PTX by
12// pipeline. It doesn't test IR for GPU side, but it can test Host IR and
13// generated PTX.
14
15// CHECK-LABEL: llvm.func @test_math(%arg0: f32) {
16func.func @test_math(%arg0 : f32) {
17    %c2 = arith.constant 2 : index
18    %c1 = arith.constant 1 : index
19    // CHECK: gpu.launch_func  @test_math_kernel::@test_math_kernel
20    // CHECK: gpu.binary @test_math_kernel  [#gpu.object<#nvvm.target
21    gpu.launch
22        blocks(%0, %1, %2) in (%3 = %c1, %4 = %c1, %5 = %c1)
23        threads(%6, %7, %8) in (%9 = %c2, %10 = %c1, %11 = %c1) {
24        // CHECK-NVVM: __nv_expf
25        %s1 = math.exp %arg0 : f32
26        gpu.printf "%f", %s1 : f32
27        gpu.terminator
28    }
29    return
30}
31