xref: /llvm-project/flang/test/Semantics/cuf-device-procedures01.cuf (revision 652ff20140d79544db4dfa21314fc62c3c9182e5)
1! RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
2
3! Test CUDA Fortran intrinsic can pass semantic
4
5attributes(global) subroutine devsub()
6  implicit none
7  integer :: ret
8
9  ! 3.6.4. Synchronization Functions
10  call syncthreads()
11  call syncwarp(1)
12  call threadfence()
13  call threadfence_block()
14  call threadfence_system()
15  ret = syncthreads_and(1)
16  ret = syncthreads_count(1)
17  ret = syncthreads_or(1)
18end
19
20! CHECK-LABEL: Subprogram scope: devsub
21! CHECK: syncthreads (Subroutine): Use from syncthreads in cudadevice
22! CHECK: syncthreads_and (Function): Use from syncthreads_and in cudadevice
23! CHECK: syncthreads_count (Function): Use from syncthreads_count in cudadevice
24! CHECK: syncthreads_or (Function): Use from syncthreads_or in cudadevice
25! CHECK: syncwarp (Subroutine): Use from syncwarp in cudadevice
26! CHECK: threadfence (Subroutine): Use from threadfence in cudadevice
27! CHECK: threadfence_block (Subroutine): Use from threadfence_block in cudadevice
28! CHECK: threadfence_system (Subroutine): Use from threadfence_system in cudadevice
29
30subroutine host()
31  real(4) :: af
32  real(8) :: ad
33  integer(4) :: ai
34  integer(8) :: al
35  call syncthreads()
36  ai = atomicadd(ai, 1_4)
37  al = atomicadd(al, 1_8)
38  af = atomicadd(af, 1.0_4)
39  ad = atomicadd(ad, 1.0_8)
40end subroutine
41
42! CHECK-LABEL: Subprogram scope: host
43! CHECK: atomicadd, EXTERNAL: HostAssoc{{$}}
44! CHECK: syncthreads, EXTERNAL: HostAssoc{{$}}
45