-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenACC_code.f90
43 lines (32 loc) · 959 Bytes
/
OpenACC_code.f90
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
program OpenACC_code
implicit none
integer, parameter :: dp = selected_real_kind(15,307)
real, dimension(:), allocatable :: a, b
real(dp) :: start_t, end_t
integer, parameter :: n = 1000000
integer :: i
call cpu_time(start_t)
do i = 1, 100
call random_seed
allocate(a(n), b(n))
call random_number(a)
!$acc data copy(a,b)
call process(a, b, n)
!$acc end data
deallocate(a, b)
enddo
call cpu_time(end_t)
write(*,20) end_t-start_t
20 format('Total elapsed time is ', f10.5, ' seconds.')
contains
subroutine process( a, b, n )
real, intent(inout) :: a(n), b(n)
integer, intent(in) :: n
integer :: i
!$acc parallel loop
do i = 1, n
b(i) = exp(sin(a(i)))
enddo
!$acc end parallel
end subroutine process
end program OpenACC_code