File: metadirective_device_arch_codegen.cpp

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (65 lines) | stat: -rw-r--r-- 2,082 bytes parent folder | download | duplicates (3)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// REQUIRES: amdgpu-registered-target

// RUN: %clang_cc1 -fopenmp -x c++ -w -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
// RUN: %clang_cc1 -fopenmp -x c++ -w -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -target-cpu gfx906 -o - | FileCheck %s
// expected-no-diagnostics


/*===-----------------------------------------------------------------------===

Inspired from SOLLVE tests:
 - 5.0/metadirective/test_metadirective_arch_is_nvidia.c


===------------------------------------------------------------------------===*/


#define N 1024

int metadirective1() {

   int v1[N], v2[N], v3[N];

   int target_device_num, host_device_num, default_device;
   int errors = 0;

   #pragma omp target map(to:v1,v2) map(from:v3, target_device_num) device(default_device)
   {
      #pragma omp metadirective \
                   when(device={arch("amdgcn")}: teams distribute parallel for) \
                   default(parallel for)

         for (int i = 0; i < N; i++) {
	    #pragma omp atomic write
            v3[i] = v1[i] * v2[i];
         }
   }

   return errors;
}

// CHECK: define weak_odr protected amdgpu_kernel void @[[METADIRECTIVE:.+metadirective1[a-z0-9_]+]]
// CHECK: entry:
// CHECK: %{{[0-9]}} = call i32 @__kmpc_target_init
// CHECK: user_code.entry:
// CHECK: call void @[[METADIRECTIVE]]_omp_outlined
// CHECK-NOT: call void @__kmpc_parallel_51
// CHECK: ret void


// CHECK: define internal void @[[METADIRECTIVE]]_omp_outlined
// CHECK: entry:
// CHECK: call void @__kmpc_distribute_static_init
// CHECK: omp.loop.exit:
// CHECK: call void @__kmpc_distribute_static_fini


// CHECK: define internal void @[[METADIRECTIVE]]_omp_outlined_omp_outlined
// CHECK: entry:
// CHECK: call void @__kmpc_for_static_init_4
// CHECK: omp.inner.for.body:
// CHECK: store atomic {{.*}} monotonic
// CHECK: omp.loop.exit:
// CHECK-NEXT: call void @__kmpc_distribute_static_fini
// CHECK-NEXT: ret void