PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

matrix reduction using cuda fortran and GPU
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Tue Dec 11, 2012 4:28 pm    Post subject: Reply with quote

Quote:
I am using PGI 12.3 only, could this be the problem??
Yep, that's it. 12.3 did have a Linux Beta version of OpenACC, but 12.6 was the first full release and the first release to support Windows.

Code:
how can I compile using 12.3 and using acc since acc only added to 12.6 and above??
You can use the PGI Accelerator Model instead. The syntax is mostly the same:

Code:
% cat test.f90
!
! Fortran Console Application
! Generated by PGI Visual Fortran(R)
! 12/10/2012 3:02:36 PM
!

program pgiacc1

use accel_lib
implicit none

integer :: nx,ny,i,j,ak,it,ak2,foo
integer, allocatable, dimension (:,:) :: A
integer :: start_time(8), end_time(8)
CHARACTER (LEN = 12) REAL_CLOCK (3)
CALL DATE_AND_TIME (REAL_CLOCK (1), REAL_CLOCK (2),&
REAL_CLOCK (3), start_time )

nx = 3000
ny = 3000
ak = 0

allocate (a(nx,ny))
A(1:nx,1:ny) = 2
!$acc data region copyin(A)
do it=1,10000
!$acc region 
do i = 1, nx
do j = 1, ny
ak = ak + A(i,j)
enddo
enddo
!$acc end region
ak2 = foo(ak)
enddo
!$acc end data region

write(*,*) 'ak = ' ,ak2
write(*,*)
CALL DATE_AND_TIME (REAL_CLOCK (1), REAL_CLOCK (2),&
REAL_CLOCK (3), end_time )
write(*,10) 'PROGRAM STARTED AT: ', START_TIME(5), START_TIME(6),&
START_TIME(7), START_TIME(8)
write(*,15) 'PROGRAM ENDED AT: ', end_time(5), end_time(6), &
end_time(7),end_time(8)
continue
deallocate(a)
10 format(1X, A, I2.2, ':', I2.2, ':', I2.2, ':', I3.3)
15 format(1X, A, I2.2, ':', I2.2, ':', I2.2, ':', I3.3)

end program pgiacc1

function foo(ak)
  integer foo
  integer ak, tmp
  tmp=ak
  ak = 0
  foo=tmp
end function foo
Back to top
View user's profile
Dolf



Joined: 22 Mar 2012
Posts: 100

PostPosted: Thu Dec 13, 2012 11:00 am    Post subject: RE: Reply with quote

It worked fine for me now, but still not impressed with the speed.
If I have to do it using kernel subroutines (no acc), how would I do the reduction using this method?

also, I want to compile my code to run on linux machine, is PGI fortran compiler free for linux?
I just downloaded the tar.gz file (Fortran workstation for linux), is it straight forward installation process? or I have to do something special?

thanks.
Dolf
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Thu Dec 13, 2012 5:18 pm    Post subject: Reply with quote

Quote:
It worked fine for me now, but still not impressed with the speed.

A reduction is not the best algorithm for an Accelerator. You can get some speed-up if the problem is large enough, but not a huge amount. Using a reduction in combination of a larger data parallel algorithm is usually ok.

Quote:
If I have to do it using kernel subroutines (no acc), how would I do the reduction using this method?
To do this algorithm in CUDA is a fairly difficult. I should say it's easy to do poorlly, but hard to do it well.

I have an example of a simple (i.e. poor) partial sum reduction in this article: http://www.pgroup.com/lit/articles/insider/v2n1a4.htm

A better one can be found in the source code from this article: http://www.pgroup.com/lit/articles/insider/v3n3a2.htm

Quote:
also, I want to compile my code to run on linux machine, is PGI fortran compiler free for linux?
No. We do offer cross-platform licenses, however, it looks like your license is from Windows only. Please contact PGI Sales (sales@pgroup.com) for more information on upgrading your license.

Quote:
I just downloaded the tar.gz file (Fortran workstation for linux), is it straight forward installation process? or I have to do something special?
It's fairly simple, the only complexity is getting the license manager running. See PGI Installation Guide for details.

- Mat
Back to top
View user's profile
Dolf



Joined: 22 Mar 2012
Posts: 100

PostPosted: Fri Dec 14, 2012 12:57 pm    Post subject: RE: Reply with quote

Hi Matt,

I have installed the pgi for linux, created a trial license keys with pgroup.com as per installation document requested, turned on the license server on, but still can't compile a simple fortran code using pgf90 acc1.f90 -o acc.exe
it gives me the following error:
[root@cmlds5 bin]# pgf90 acc1.f90 -o acc.exe
pgf90-Error-Please run makelocalrc to complete your installation

anything I missed??
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Fri Dec 14, 2012 2:41 pm    Post subject: Reply with quote

Quote:
pgf90-Error-Please run makelocalrc to complete your installation

anything I missed?
This means that your installation failed. Which OS are you using and were there any errors during installation?

- Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Page 4 of 7

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group