Debian Codegraph @

clang/test/AST/ast-dump-atomic-options.hip

raw
1 // RUN: %clang_cc1 -ast-dump %s | FileCheck %s
2 // RUN: %clang_cc1 -ast-dump -fcuda-is-device %s | FileCheck %s
3 // RUN: %clang_cc1 -ast-dump -fcuda-is-device %s \
4 // RUN: -fatomic-fine-grained-memory -fatomic-ignore-denormal-mode \
5 // RUN: | FileCheck %s
6
7 #include "Inputs/cuda.h"
8
9 // CHECK-LABEL: FunctionDecl {{.*}} test_default
10 // CHECK-NOT: AttributedStmt
11 // CHECK-NOT: AtomicAttr
12 // CHECK: CompoundStmt
13 // CHECK-NEXT: `-AtomicExpr
14 __device__ __host__ void test_default(float *a) {
15 __scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
16 }
17
18 // CHECK-LABEL: FunctionDecl {{.*}} test_one
19 // CHECK: `-AttributedStmt
20 // CHECK-NEXT: |-AtomicAttr {{.*}} no_remote_memory{{$}}
21 // CHECK-NEXT: `-CompoundStmt
22 // CHECK-NEXT: `-AtomicExpr
23 __device__ __host__ void test_one(float *a) {
24 [[clang::atomic(no_remote_memory)]] {
25 __scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
26 }
27 }
28
29 // CHECK-LABEL: FunctionDecl {{.*}} test_two
30 // CHECK: `-AttributedStmt
31 // CHECK-NEXT: |-AtomicAttr {{.*}} remote_memory ignore_denormal_mode{{$}}
32 // CHECK-NEXT: `-CompoundStmt
33 // CHECK-NEXT: `-AtomicExpr
34 __device__ __host__ void test_two(float *a) {
35 [[clang::atomic(remote_memory, ignore_denormal_mode)]] {
36 __scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
37 }
38 }
39
40 // CHECK-LABEL: FunctionDecl {{.*}} test_three
41 // CHECK: `-AttributedStmt
42 // CHECK-NEXT: |-AtomicAttr {{.*}} no_remote_memory fine_grained_memory no_ignore_denormal_mode{{$}}
43 // CHECK-NEXT: `-CompoundStmt
44 // CHECK-NEXT: `-AtomicExpr
45 __device__ __host__ void test_three(float *a) {
46 [[clang::atomic(no_remote_memory, fine_grained_memory, no_ignore_denormal_mode)]] {
47 __scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
48 }
49 }
50
51 // CHECK-LABEL: FunctionDecl {{.*}} test_duplicate
52 // CHECK: `-AttributedStmt
53 // CHECK-NEXT: |-AtomicAttr {{.*}} no_remote_memory{{$}}
54 // CHECK-NEXT: `-CompoundStmt
55 // CHECK-NEXT: `-AtomicExpr
56 __device__ __host__ void test_duplicate(float *a) {
57 [[clang::atomic(no_remote_memory, no_remote_memory)]] {
58 __scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
59 }
60 }
61
62 // CHECK-LABEL: FunctionDecl {{.*}} test_conflict
63 // CHECK: `-AttributedStmt
64 // CHECK-NEXT: |-AtomicAttr {{.*}} remote_memory{{$}}
65 // CHECK-NEXT: `-CompoundStmt
66 // CHECK-NEXT: `-AtomicExpr
67 __device__ __host__ void test_conflict(float *a) {
68 [[clang::atomic(no_remote_memory, remote_memory)]] {
69 __scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
70 }
71 }
72
73 // CHECK-LABEL: FunctionDecl {{.*}} test_multiple_attrs
74 // CHECK: `-AttributedStmt
75 // CHECK-NEXT: |-AtomicAttr {{.*}} no_remote_memory{{$}}
76 // CHECK-NEXT: |-AtomicAttr {{.*}} remote_memory{{$}}
77 // CHECK-NEXT: `-CompoundStmt
78 // CHECK-NEXT: `-AtomicExpr
79 __device__ __host__ void test_multiple_attrs(float *a) {
80 [[clang::atomic(no_remote_memory)]] [[clang::atomic(remote_memory)]] {
81 __scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
82 }
83 }
84
85 // CHECK-LABEL: FunctionDecl {{.*}} test_nested
86 // CHECK: CompoundStmt
87 // CHECK: |-AtomicExpr
88 // CHECK: `-AttributedStmt
89 // CHECK-NEXT: |-AtomicAttr {{.*}} remote_memory fine_grained_memory no_ignore_denormal_mode{{$}}
90 // CHECK-NEXT: `-CompoundStmt
91 // CHECK: |-AtomicExpr
92 // CHECK: |-AttributedStmt
93 // CHECK-NEXT: |-AtomicAttr {{.*}} no_remote_memory{{$}}
94 // CHECK-NEXT: `-CompoundStmt
95 // CHECK-NEXT: `-AtomicExpr
96 // CHECK: `-AttributedStmt
97 // CHECK-NEXT: |-AtomicAttr {{.*}} no_fine_grained_memory{{$}}
98 // CHECK-NEXT: `-CompoundStmt
99 // CHECK-NEXT: `-AtomicExpr
100 __device__ __host__ void test_nested(float *a) {
101 __scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
102 [[clang::atomic(remote_memory, fine_grained_memory, no_ignore_denormal_mode)]] {
103 __scoped_atomic_fetch_max(a, 2, __ATOMIC_SEQ_CST, __MEMORY_SCOPE_DEVICE);
104 [[clang::atomic(no_remote_memory)]] {
105 __scoped_atomic_fetch_min(a, 3, __ATOMIC_ACQUIRE, __MEMORY_SCOPE_WRKGRP);
106 }
107 [[clang::atomic(no_fine_grained_memory)]] {
108 __scoped_atomic_fetch_sub(a, 4, __ATOMIC_RELEASE, __MEMORY_SCOPE_WVFRNT);
109 }
110 }
111 }
112
113 // CHECK-LABEL: FunctionTemplateDecl {{.*}} test_template
114 // CHECK: |-FunctionDecl {{.*}} test_template 'void (T *)'
115 // CHECK: | |-CompoundStmt
116 // CHECK: | | `-AttributedStmt
117 // CHECK: | | |-AtomicAttr {{.*}} no_remote_memory fine_grained_memory no_ignore_denormal_mode{{$}}
118 // CHECK: | | `-CompoundStmt
119 // CHECK: | | `-CallExpr {{.*}} '<dependent type>'
120 // CHECK: `-FunctionDecl {{.*}} used test_template 'void (float *)' implicit_instantiation
121 // CHECK: |-CompoundStmt
122 // CHECK: | `-AttributedStmt
123 // CHECK: | |-AtomicAttr {{.*}} no_remote_memory fine_grained_memory no_ignore_denormal_mode{{$}}
124 // CHECK: | `-CompoundStmt
125 // CHECK: | `-AtomicExpr {{.*}} 'float'
126 template<typename T>
127 __device__ __host__ void test_template(T *a) {
128 [[clang::atomic(no_remote_memory, fine_grained_memory, no_ignore_denormal_mode)]] {
129 __scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
130 }
131 }
132
133 __device__ __host__ void test_template_caller() {
134 float *p;
135 test_template(p);
136 }