-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
do concurrent
is usually used to invoke a standard language-level parallelism, including GPU offloading. But, if the flag for it is not set, then it doesn't do much other than, perhaps, some multithreading.
It does not seem to clash with OpenACC in my experimentation so far (https://fortran-lang.discourse.group/t/how-does-openacc-collapse-interact-with-do-concurrent/6887).
With it, we can do this:
!$acc parallel loop collapse(4) gang vector default(present)
do concurrent (j = 1:sys_size, q = 0:p, l = 0:n, k = 0:m)
rhs_vf(j)%sf(k, l, q) = 1d0/dx(k)* &
(flux_n(1)%vf(j)%sf(k - 1, l, q) &
- flux_n(1)%vf(j)%sf(k, l, q))
end do
instead of this
!$acc parallel loop collapse(4) gang vector default(present)
do j = 1, sys_size
do q = 0, p
do l = 0, n
do k = 0, m
rhs_vf(j)%sf(k, l, q) = 1d0/dx(k)* &
(flux_n(1)%vf(j)%sf(k - 1, l, q) &
- flux_n(1)%vf(j)%sf(k, l, q))
end do
end do
end do
end do
I think we can still pull out a sequential loop as needed, like this:
!$acc parallel loop collapse(3) gang vector default(present)
do concurrent (j = 1:sys_size, q = 0:p, l = 0:n)
!$acc parallel seq
do k = 0,m
rhs_vf(j)%sf(k, l, q) = 1d0/dx(k)* &
(flux_n(1)%vf(j)%sf(k - 1, l, q) &
- flux_n(1)%vf(j)%sf(k, l, q))
end do
end do
While not an actual code improvement per se, it does seem quite helpful for readability. We go from 8 lines of code for a loop to 2.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers