# Fortran accelerator problem

**URL:** <https://forums.developer.nvidia.com/t/fortran-accelerator-problem/131541>\
**Category:** Legacy PGI Compilers (archived)\
**Created:** [January 25, 2010, 10:53pm UTC](https://forums.developer.nvidia.com/t/fortran-accelerator-problem/131541 "2010-01-25T22:53:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robschi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@robschi](https://forums.developer.nvidia.com/u/robschi)\
**Post date:** [January 25, 2010, 10:53pm UTC](https://forums.developer.nvidia.com/t/fortran-accelerator-problem/131541/1 "2010-01-25T22:53:28Z")

</div>

Consider the following trivial program:

_program nv  
parameter(idim=10000)  
real a(idim),b(idim)  
a(1:idim)=0.0  
b(1:idim)=0.0  
!$acc region  
do k=1,5000  
do i=1,idim  
a(i)=a(i)+ sin(i1.0)cos(i1.0)  
end do  
end do  
b(1:idim)=a(1:idim)0.71  
a(1)=b(idim)  
!$acc end region  
write(,) a(1),a(idim),b(idim)  
end program nv_

When I compile it with  
pgf90 nv.f90 and run it I get

time ./a.out  
1033.070 1455.028 1033.070

real 0m3.451s  
user 0m3.403s  
sys 0m0.003s  
  
  
When I try to use the GPU and compile it with  
pgf90 -ta=nvidia,cc11 nv.f90  
I get

time ./a.out  
2273.086 1455.028 1033.070

real 0m0.215s  
user 0m0.114s  
sys 0m0.097s

Note, that the result is different. It seems that the assignment  
a(1)=b(idim)  
is not executed.

Is this a correct behaviour? Are simple assignments not allowed in the GPU code?  
i  
The compiler version is 10.1. And all runs on a Fedora 11 system.  
Thanks in advance.  
Robert

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [January 29, 2010, 8:17pm UTC](https://forums.developer.nvidia.com/t/fortran-accelerator-problem/131541/2 "2010-01-29T20:17:49Z")

</div>

Hi Robert,

Currently kernels are only created from loops. So your scalar assignment is being missed. This is a known deficiency which our engineers are working on addressing. To help things along, I sent a report to our engineers (TPR#16548).

To work around this limitation, either perform the scalar assignment on the host or put the scalar assignment in a loop that’s executed only once.

For example:

```nohighlight
        program nv
        parameter(idim=10000)
        real a(idim),b(idim)
        a(1:idim)=0.0
        b(1:idim)=0.0
!$acc region
        do k=1,5000
          do i=1,idim
            a(i)=a(i)+ sin(i*1.0)*cos(i*1.0)
          end do
        end do
        b(1:idim)=a(1:idim)*0.71
!$acc end region
        a(1)=b(idim)
        write(*,*) a(1),a(idim),b(idim)
        end program nv

```

or

```nohighlight
        program nv
        parameter(idim=10000)
        real a(idim),b(idim)
        a(1:idim)=0.0
        b(1:idim)=0.0
!$acc region
        do k=1,5000
          do i=1,idim
            a(i)=a(i)+ sin(i*1.0)*cos(i*1.0)
          end do
        end do
        b(1:idim)=a(1:idim)*0.71
        do k=1,1
          a(k)=b(idim)
        enddo
!$acc end region
        write(*,*) a(1),a(idim),b(idim)
        end program nv

```

Hope this helps,  
Mat

---

<div class="post-metadata">

**Author:** ![tull](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@tull](https://forums.developer.nvidia.com/u/tull)\
**Post date:** [November 18, 2011, 2:23am UTC](https://forums.developer.nvidia.com/t/fortran-accelerator-problem/131541/3 "2011-11-18T02:23:40Z")

</div>

Robert,

This was logged as TPR 16548, and our QA groups has verified this is  
working as of the 11.6 release.

Thanks for the report.

regards,  
dave
