DLog and other double precision intrinsics on device

Hello

A simple question. Is possible to use DLOG(x) and DCOS(x) in the cuda device kernel. I am looking for double precision results and pgi_cuf_qrc.pdf does not specify this.

Thank you in advance.

Ahmed

Hi Ahmed,

Given Fortran is strongly typed, you’d call “log” or “cos” and then the correct version is used depending upon the data type of the argument. This is true for CUDA Fortran as well.

Hope this helps,
Mat

Hey Mat

Did you mean the data type of the variable?

So that if I say:

 Double Precision :: A, X
 A = Log (X)

or

A = Dlog(X)

Log of X will be performed to double accuracy precision?

Sorry I got lost. I think I need an example.

Ahmed

No, I’m saying you can have:

  Double Precision :: A, X 
  Real :: B, Y
  Complex :: C, Z
  A = Log (X)
  B = Log (Y)
  C = Log (Z)

Since the compiler knows “X” is double precision, the double precision version of Log will be called. While for Y, the single precision version will be called. Log will accept Complex data types as well.

This is one of the benefits of using Fortran over C.

  • Mat

Thank you Mat!