Skip to content

[flang][cuda] Add bind name for __clz interface #153268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flang/module/cudadevice.f90
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,11 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
end interface

interface __clz
attributes(device) integer function __clz(i) bind(c)
attributes(device) integer function __clz(i) bind(c, name='__nv_clz')
!dir$ ignore_tkr (d) i
integer, value :: i
end function
attributes(device) integer function __clzll(i) bind(c)
attributes(device) integer function __clzll(i) bind(c, name='__nv_clzll')
!dir$ ignore_tkr (d) i
integer(8), value :: i
end function
Expand Down
5 changes: 4 additions & 1 deletion flang/test/Lower/CUDA/cuda-device-proc.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ attributes(global) subroutine devsub()
res = __ffs(al)
res = __brev(ai)
resl = __brev(al)

res = __clz(ai)
res = __clz(al)
ai = __mul24(ai, ai)
ai = __umul24(ai, ai)
end
Expand Down Expand Up @@ -107,6 +108,8 @@ end
! CHECK: %{{.*}} = fir.call @__nv_ffsll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i32
! CHECK: %{{.*}} = fir.call @__nv_brev(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_brevll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i64
! CHECK: %{{.*}} = fir.call @__nv_clz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_clzll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i32

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