File: omptarget-declare-target-llvm-device.mlir

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (34 lines) | stat: -rw-r--r-- 1,559 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s

// This test the generation of additional load operations for declare target link variables
// inside of target op regions when lowering to IR for device. Unfortunately as the host file is not
// passed as a module attribute, we miss out on the metadata and entryinfo.
//
// Unfortunately, only so much can be tested as the device side is dependent on a *.bc
// file created by the host and appended as an attribute to the module.

module attributes {omp.is_target_device = true} {
  // CHECK-DAG: @_QMtest_0Esp_decl_tgt_ref_ptr = weak global ptr null, align 8
  llvm.mlir.global external @_QMtest_0Esp() {addr_space = 0 : i32, omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : i32 {
    %0 = llvm.mlir.constant(0 : i32) : i32
    llvm.return %0 : i32
  }

  llvm.func @_QQmain() attributes {} {
    %0 = llvm.mlir.addressof @_QMtest_0Esp : !llvm.ptr

  // CHECK-DAG:   omp.target:                                       ; preds = %user_code.entry
  // CHECK-DAG: %[[V:.*]] = load ptr, ptr @_QMtest_0Esp_decl_tgt_ref_ptr, align 8
  // CHECK-DAG: store i32 1, ptr %[[V]], align 4
  // CHECK-DAG: br label %omp.region.cont
    %map = omp.map.info var_ptr(%0 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
    omp.target   map_entries(%map -> %arg0 : !llvm.ptr) {
      ^bb0(%arg0: !llvm.ptr):
      %1 = llvm.mlir.constant(1 : i32) : i32
      llvm.store %1, %arg0 : i32, !llvm.ptr
      omp.terminator
    }

    llvm.return
  }
}