Skip to content

Commit 136c558

Browse files
authored
[flang][cuda] Add bind name for __clz interface (#153268)
1 parent 98164d4 commit 136c558

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

flang/module/cudadevice.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,11 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
738738
end interface
739739

740740
interface __clz
741-
attributes(device) integer function __clz(i) bind(c)
741+
attributes(device) integer function __clz(i) bind(c, name='__nv_clz')
742742
!dir$ ignore_tkr (d) i
743743
integer, value :: i
744744
end function
745-
attributes(device) integer function __clzll(i) bind(c)
745+
attributes(device) integer function __clzll(i) bind(c, name='__nv_clzll')
746746
!dir$ ignore_tkr (d) i
747747
integer(8), value :: i
748748
end function

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ attributes(global) subroutine devsub()
5858
res = __ffs(al)
5959
res = __brev(ai)
6060
resl = __brev(al)
61-
61+
res = __clz(ai)
62+
res = __clz(al)
6263
ai = __mul24(ai, ai)
6364
ai = __umul24(ai, ai)
6465
end
@@ -107,6 +108,8 @@ end
107108
! CHECK: %{{.*}} = fir.call @__nv_ffsll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i32
108109
! CHECK: %{{.*}} = fir.call @__nv_brev(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
109110
! CHECK: %{{.*}} = fir.call @__nv_brevll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i64
111+
! CHECK: %{{.*}} = fir.call @__nv_clz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
112+
! CHECK: %{{.*}} = fir.call @__nv_clzll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i32
110113

111114
! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
112115
! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32

0 commit comments

Comments
 (0)