Debian Codegraph @

flang/test/Fir/CUDA/cuda-target-rewrite.mlir

raw
1 // RUN: fir-opt --split-input-file --target-rewrite="target=x86_64-unknown-linux-gnu" %s | FileCheck %s
2
3 module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu"} {
4
5 gpu.module @testmod {
6 gpu.func @_QPvcpowdk(%arg0: !fir.ref<complex<f64>> {cuf.data_attr = #cuf.cuda<device>, fir.bindc_name = "a"}) attributes {cuf.proc_attr = #cuf.cuda_proc<global>} {
7 %0 = fir.alloca i64
8 %1 = fir.load %0 : !fir.ref<i64>
9 %2 = fir.load %arg0 : !fir.ref<complex<f64>>
10 %3 = fir.call @_FortranAzpowk(%2, %1) fastmath<contract> : (complex<f64>, i64) -> complex<f64>
11 gpu.return
12 }
13 func.func private @_FortranAzpowk(complex<f64>, i64) -> complex<f64> attributes {fir.bindc_name = "_FortranAzpowk", fir.runtime}
14 }
15
16 // CHECK-LABEL: gpu.func @_QPvcpowdk
17 // CHECK: %{{.*}} = fir.call @_FortranAzpowk(%{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (f64, f64, i64) -> tuple<f64, f64>
18 // CHECK: func.func private @_FortranAzpowk(f64, f64, i64) -> tuple<f64, f64> attributes {fir.bindc_name = "_FortranAzpowk", fir.runtime}
19 }
20
21 // -----
22
23 module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu"} {
24
25 gpu.module @testmod {
26 gpu.func @_QPtest(%arg0: complex<f64>) -> (complex<f64>) {
27 gpu.return %arg0 : complex<f64>
28 }
29 }
30 }
31
32 // CHECK-LABEL: gpu.func @_QPtest
33 // CHECK-SAME: (%arg0: f64, %arg1: f64) -> tuple<f64, f64> {
34 // CHECK: gpu.return %{{.*}} : tuple<f64, f64>
35
36 // -----
37 module attributes {gpu.container_module, fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu"} {
38
39 gpu.module @testmod {
40 gpu.func @_QPtest(%arg0: complex<f64>) -> () kernel {
41 gpu.return
42 }
43 }
44
45 func.func @main(%arg0: complex<f64>) {
46 %0 = llvm.mlir.constant(0 : i64) : i64
47 %1 = llvm.mlir.constant(0 : i32) : i32
48 gpu.launch_func @testmod::@_QPtest blocks in (%0, %0, %0) threads in (%0, %0, %0) : i64 dynamic_shared_memory_size %1 args(%arg0 : complex<f64>) {cuf.proc_attr = #cuf.cuda_proc<global>}
49 return
50 }
51
52 }
53
54 // CHECK-LABEL: gpu.func @_QPtest
55 // CHECK-SAME: (%arg0: f64, %arg1: f64) kernel {
56 // CHECK: gpu.return
57 // CHECK: gpu.launch_func @testmod::@_QPtest blocks in (%{{.*}}, %{{.*}}, %{{.*}}) threads in (%{{.*}}, %{{.*}}, %{{.*}}) : i64 dynamic_shared_memory_size %{{.*}} args(%{{.*}} : f64, %{{.*}} : f64) {cuf.proc_attr = #cuf.cuda_proc<global>}