Skip to content

Commit a8f1f1b

Browse files
authored
[flang][cuda] Add interfaces for __logf, __log2f and __log10f (#153611)
1 parent 86482df commit a8f1f1b

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

flang/module/cudadevice.f90

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,27 @@ attributes(device,host) logical function on_device() bind(c)
16641664
end function
16651665
end interface
16661666

1667+
interface __log2f
1668+
attributes(device) real function __log2f(r) bind(c, name='__nv_log2f')
1669+
!dir$ ignore_tkr (d) r
1670+
real, value :: r
1671+
end function
1672+
end interface
1673+
1674+
interface __log10f
1675+
attributes(device) real function __log10f(r) bind(c, name='__nv_log10f')
1676+
!dir$ ignore_tkr (d) r
1677+
real, value :: r
1678+
end function
1679+
end interface
1680+
1681+
interface __logf
1682+
attributes(device) real function __logf(r) bind(c, name='__nv_logf')
1683+
!dir$ ignore_tkr (d) r
1684+
real, value :: r
1685+
end function
1686+
end interface
1687+
16671688
contains
16681689

16691690
attributes(device) subroutine syncthreads()

flang/test/Lower/CUDA/cuda-libdevice.cuf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ end subroutine
2020
! CHECK-LABEL: _QPtest_usad
2121
! CHECK: %{{.*}} = fir.call @__nv_usad(%{{.*}}, %{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32, i32) -> i32
2222

23+
attributes(global) subroutine test_log()
24+
real :: res
25+
real :: r
26+
res = __logf(r)
27+
res = __log2f(r)
28+
res = __log10f(r)
29+
end subroutine
30+
31+
! CHECK-LABEL: _QPtest_log
32+
! CHECK: %{{.*}} = fir.call @__nv_logf(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
33+
! CHECK: %{{.*}} = fir.call @__nv_log2f(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
34+
! CHECK: %{{.*}} = fir.call @__nv_log10f(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
35+
2336
attributes(global) subroutine test_sinf()
2437
real :: res
2538
real :: r
@@ -37,3 +50,4 @@ end subroutine
3750

3851
! CHECK-LABEL: _QPtest_tanf
3952
! CHECK: %{{.*}} = fir.call @__nv_tanf(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
53+

0 commit comments

Comments
 (0)