Skip to content

Commit 1acb101

Browse files
authored
[flang][cuda] Set correct bind(c) name for __popc (#152795)
1 parent 75b3cc9 commit 1acb101

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

flang/module/cudadevice.f90

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

756756
interface __popc
757-
attributes(device) integer function __popc(i) bind(c)
757+
attributes(device) integer function __popc(i) bind(c, name='__nv_popc')
758758
!dir$ ignore_tkr (d) i
759759
integer, value :: i
760760
end function
761-
attributes(device) integer function __popcll(i) bind(c)
761+
attributes(device) integer function __popcll(i) bind(c, name='__nv_popcll')
762762
!dir$ ignore_tkr (d) i
763763
integer(8), value :: i
764764
end function

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ attributes(global) subroutine devsub()
1111
integer(8) :: al
1212
integer(8) :: time
1313
integer :: smalltime
14+
integer(4) :: res
1415

1516
call syncthreads()
1617
call syncwarp(1)
@@ -49,6 +50,9 @@ attributes(global) subroutine devsub()
4950
smalltime = clock()
5051
time = clock64()
5152
time = globalTimer()
53+
54+
res = __popc(ai)
55+
res = __popc(al)
5256
end
5357

5458
! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
@@ -89,6 +93,9 @@ end
8993
! CHECK: %{{.*}} = nvvm.read.ptx.sreg.clock64 : i64
9094
! CHECK: %{{.*}} = nvvm.read.ptx.sreg.globaltimer : i64
9195

96+
! CHECK: %{{.*}} = fir.call @__nv_popc(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
97+
! CHECK: %{{.*}} = fir.call @__nv_popcll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i32
98+
9299
subroutine host1()
93100
integer, device :: a(32)
94101
integer, device :: ret

0 commit comments

Comments
 (0)