Skip to content

[flang][cuda] Add bind name for __fss interface #152803

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 12, 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 @@ -743,11 +743,11 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
end interface

interface __ffs
attributes(device) integer function __ffs(i) bind(c)
attributes(device) integer function __ffs(i) bind(c, name='__nv_ffs')
!dir$ ignore_tkr (d) i
integer, value :: i
end function
attributes(device) integer function __ffsll(i) bind(c)
attributes(device) integer function __ffsll(i) bind(c, name='__nv_ffsll')
!dir$ ignore_tkr (d) i
integer(8), value :: i
end function
Expand Down
4 changes: 4 additions & 0 deletions flang/test/Lower/CUDA/cuda-device-proc.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ attributes(global) subroutine devsub()

res = __popc(ai)
res = __popc(al)
res = __ffs(ai)
res = __ffs(al)
end

! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
Expand Down Expand Up @@ -95,6 +97,8 @@ end

! CHECK: %{{.*}} = fir.call @__nv_popc(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_popcll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i32
! CHECK: %{{.*}} = fir.call @__nv_ffs(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_ffsll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i32

subroutine host1()
integer, device :: a(32)
Expand Down