Skip to content

Commit 60170f9

Browse files
authored
[flang][cuda] Add missing interface for __powf (#153294)
`__powf` is defined in the CUDA Fortran programming guide but it's missing from our cudadevice module. Add the interface and bind name to `__nv_powf` https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/index.html#fortran-device-modules https://docs.nvidia.com/cuda/libdevice-users-guide/__nv_powf.html#__nv_powf
1 parent bce0f9d commit 60170f9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

flang/module/cudadevice.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,13 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
770770
end function
771771
end interface
772772

773+
interface
774+
attributes(device) real(4) function __powf(x,y) bind(c, name='__nv_powf')
775+
!dir$ ignore_tkr (d) x, y
776+
real(4), value :: x, y
777+
end function
778+
end interface
779+
773780
interface __brev
774781
attributes(device) integer function __brev(i) bind(c, name='__nv_brev')
775782
!dir$ ignore_tkr (d) i

flang/test/Lower/CUDA/cuda-device-proc.cuf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ attributes(global) subroutine devsub()
6363
af = __cosf(af)
6464
ai = __mul24(ai, ai)
6565
ai = __umul24(ai, ai)
66+
af = __powf(af, af)
6667
end
6768

6869
! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
@@ -114,6 +115,7 @@ end
114115
! CHECK: %{{.*}} = fir.call @__nv_cosf(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
115116
! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
116117
! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
118+
! CHECK: %{{.*}} = fir.call @__nv_powf(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32, f32) -> f32
117119

118120
subroutine host1()
119121
integer, device :: a(32)

0 commit comments

Comments
 (0)