PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Math Functions sqrt, pow ^ and log
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
adityaks



Joined: 02 Oct 2012
Posts: 8

PostPosted: Wed Oct 03, 2012 1:52 am    Post subject: Math Functions sqrt, pow ^ and log Reply with quote

pgfortran compiling my CUDA Fortran code is ignoring the operator ^ while it says pow cannot be used in device kernel (allowed only in emulation mode).

I found conflicting information about support for math funcitons
PGI Webpage says
Quote:
Q Does the compiler support IEEE standard-floating point arithmetic?

A The GPU accelerators available today support most of the IEEE floating-point standard. However, they do not support all the rounding modes, and some operations, notably square root, exponential, logarithm, and other transcendental functions, may not deliver full precision results. This is a hardware limitation that compilers cannot overcome.


But http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/group__CUDA__MATH__DOUBLE.html page from NVIDIA seems to have support for the said functions.

Can somebody shed more light about how to use math functionalities in device kernels?

Thanks.
Back to top
View user's profile
mkcolg



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

PostPosted: Wed Oct 03, 2012 7:30 am    Post subject: Reply with quote

Hi iamaditya,

"pow" is a C Math library function so can't be called from a CUDA Fortran device routine. The Fortran equivalent for "pow" is the "**" operator.

Hope this helps,
Mat
Back to top
View user's profile
adityaks



Joined: 02 Oct 2012
Posts: 8

PostPosted: Wed Oct 03, 2012 7:55 am    Post subject: Reply with quote

That's right, of course. I was rather vague in posting the issue.

Actually even ** was not accepted in a device kernel by the compiler(pgfortran).
PGF90-S-0000-Internal compiler error. unsupported operation 185

It sort of puts me in a fix because our fortran code uses the following functionalities (double precision)
**
sqrt
exp


So without them, I will not be able to port it to CUDA Fortran. Would you mind providing some pointers to literature, if they are already supported (double precision)?
Back to top
View user's profile
mkcolg



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

PostPosted: Wed Oct 03, 2012 8:14 am    Post subject: Reply with quote

Hi iamaditya,

These routines are all supported in CUDA Fortran so something else is going on. Can you please either post or send to PGI Customer Support (trs@pgroup.com) a reproducing example?

Thanks,
Mat
Back to top
View user's profile
adityaks



Joined: 02 Oct 2012
Posts: 8

PostPosted: Wed Oct 03, 2012 10:34 am    Post subject: Reply with quote

Hi Mat,

I tweaked the kernel a little in the meanwhile and fixed the compile error. For some reason, 10**zn2 is not valid, while 10.0**zn2 is proper

Unsupported kernel:
Code:

  attributes(global) subroutine addnum_kernel( zdarr1, zn2, zdarr3 )
    integer, device ::  zn2
    integer,device :: zdarr1(10), zdarr3(10)
    integer :: ix

    do ix = 1,10
       zdarr3(ix) = zdarr1(ix)*(10**zn2)
    end do

  end subroutine addnum_kernel


Proper, supported kernel:


Code:

  attributes(global) subroutine addnum_kernel( zdarr1, zn2, zdarr3 )
    integer, device ::  zn2
    integer,device :: zdarr1(10), zdarr3(10)
    integer :: ix

    do ix = 1,10
       zdarr3(ix) = zdarr1(ix)*(10.0**zn2)
    end do

  end subroutine addnum_kernel


- Aditya

PS.: There are issues with declaring zdarr3 etc as integer, just to warn other fellow CUDA programmers
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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