Skip to content

Commit 40342f5

Browse files
committed
[flang][cuda][NFC] Add tests for device functions in cuf kernels
Using device function in cuf kernel is allowed but requires an explicit use of the cudadevice module. The two added tests make sur it works when the cudadevice module is used and failed when it is not.
1 parent bbc90f8 commit 40342f5

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

flang/test/Lower/CUDA/cuda-device-proc.cuf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,17 @@ end
8787
! CHECK: func.func private @llvm.nvvm.barrier0.and(i32) -> i32
8888
! CHECK: func.func private @llvm.nvvm.barrier0.popc(i32) -> i32
8989
! CHECK: func.func private @llvm.nvvm.barrier0.or(i32) -> i32
90+
91+
subroutine host1()
92+
integer, device :: a(32)
93+
integer :: i, j
94+
95+
block; use cudadevice
96+
!$cuf kernel do(1) <<<*,32>>>
97+
do i = 1, 32
98+
a(i) = a(i) * 2.0
99+
call syncthreads()
100+
a(i) = a(i) + a(j) - 34.0
101+
end do
102+
end block
103+
end

flang/test/Semantics/cuf09.cuf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,16 @@ program main
192192
enddo
193193
enddo
194194
end
195+
196+
subroutine host1()
197+
integer, device :: a(32)
198+
integer :: i, j
199+
200+
!$cuf kernel do(1) <<<*,32>>>
201+
do i = 1, 32
202+
a(i) = a(i) * 2.0
203+
!ERROR: 'syncthreads' may not be called in device code
204+
call syncthreads() ! missing explicit use cudadevice
205+
a(i) = a(i) + a(j) - 34.0
206+
end do
207+
end

0 commit comments

Comments
 (0)