[Fortran][PATCH][gomp4]: Transform OpenACC loop directive
Ilmir Usmanov
i.usmanov@samsung.com
Mon Mar 24 11:54:00 GMT 2014
Hi Tobias!
Thanks a lot for your review!
I fixed my patch.
On 20.03.2014 00:16, Tobias Burnus wrote:
>
> * !$acc cache() - parsing supported, but then aborting with a
> not-implemented error
> * OpenACC 2.0a additions.
>
> Am I right?
>
Not exactly, in addition to cache directive there are also subarrays
(array sections in terms of OpenMP) to be implemented from OpenACC 1.0.
Also, the support of OpenACC 2.0 is not full (remain ROUTINE and ATOMIC
directives and lots of clauses).
>
> For DO CONCURRENT, it is not.
I always forget about this kind of loops.
> I think we should really consider to reject DO CONCURRENT with a "not
> permitted"; it is currently not explicitly supported by OpenACC; I
> think we can still worry about it, when it will be explicitly added to
> OpenACC.
>
I don't think so.
> Issues with DO CONCURRENT:
>
> * You use "code->ext.iterator->var" - that's fine with DO but not with
> DO CONCURRENT, which uses a "code->ext.forall_iterator"
>
Fixed.
> * Do concurrent also handles multiple variables in a single statement,
> such as:
>
> integer :: i, j, b(3,5)
> DO CONCURRENT(i=1:3, j=1:5:2)
> b(i, j) = -42
> END DO
> end
>
For each variable in the statement single for loop is generated. Example
!$acc loop
DO CONCURRENT(i=1:3, j=1:5:2)
b(i, j) = -42
END DO
become
#pragma acc loop collapse(2)
for (i = 1; i < 3; i++)
for (count.0 = 0; count.0 <= 2; count.0++)
{
j = count.0*2 + 1;
b[j-1,i-1] = -42;
}
> * And do concurrent also supports masks:
>
> logical :: my_mask(3)
> integer :: i, b(3)
> b(i) = [5, 5, 2]
> my_mask = [.true., .false., .true.]
> do concurrent (i=1:3, b(i) == 5 .and. my_mask(i))
> b(i) = -42
> end do
> end
This is doable: generate mask conditions inside of the deepest for loop
(see applied patch). So, GENERIC of your example will be like:
#pragma acc loop collapse(1)
for (i = 1; i < 3; i++)
{
if (b[i-1] == 5 && my_mask[i-1])
{
b[i-1] = -42;
}
}
Is it OK now?
--
Ilmir.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Transform-OpenACC-loop-directive-to-GENERIC.patch
Type: text/x-diff
Size: 17178 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140324/0835cd2e/attachment.bin>
More information about the Gcc-patches
mailing list