Skip to content

Commit dcf67ec

Browse files
clementvalgithub-actions[bot]
authored andcommitted
Automerge: [flang][cuda] Add bind name for __mul24 and __umul24 (#153307)
2 parents 2880492 + 587b6ce commit dcf67ec

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

flang/module/cudadevice.f90

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,12 @@ attributes(device) subroutine sincospi(x, y, z) bind(c,name='__nv_sincospi')
372372
procedure :: sincospi
373373
end interface
374374

375+
interface
376+
attributes(device) real(4) function __cosf(x) bind(c, name='__nv_cosf')
377+
real(4), value :: x
378+
end function
379+
end interface
380+
375381
interface
376382
attributes(device) real(4) function cospif(x) bind(c,name='__nv_cospif')
377383
real(4), value :: x
@@ -431,14 +437,14 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
431437
end interface
432438

433439
interface __float2half_rn
434-
attributes(device) real(2) function __float2half_rn(r) bind(c)
440+
attributes(device) real(2) function __float2half_rn(r) bind(c, name='__nv_float2half_rn')
435441
!dir$ ignore_tkr (d) r
436442
real, value :: r
437443
end function
438444
end interface
439445

440446
interface __half2float
441-
attributes(device) real function __half2float(i) bind(c)
447+
attributes(device) real function __half2float(i) bind(c, name='__nv_half2float')
442448
!dir$ ignore_tkr (d) i
443449
real(2), value :: i
444450
end function
@@ -676,14 +682,14 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
676682
end interface
677683

678684
interface __mul24
679-
attributes(device) integer function __mul24(i,j) bind(c)
685+
attributes(device) integer function __mul24(i,j) bind(c, name='__nv_mul24')
680686
!dir$ ignore_tkr (d) i, (d) j
681687
integer, value :: i,j
682688
end function
683689
end interface
684690

685691
interface __umul24
686-
attributes(device) integer function __umul24(i,j) bind(c)
692+
attributes(device) integer function __umul24(i,j) bind(c, name='__nv_umul24')
687693
!dir$ ignore_tkr (d) i, (d) j
688694
integer, value :: i,j
689695
end function

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ attributes(global) subroutine devsub()
5858
res = __ffs(al)
5959
res = __brev(ai)
6060
resl = __brev(al)
61+
62+
ai = __mul24(ai, ai)
63+
ai = __umul24(ai, ai)
6164
end
6265

6366
! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
@@ -105,6 +108,10 @@ end
105108
! CHECK: %{{.*}} = fir.call @__nv_brev(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
106109
! CHECK: %{{.*}} = fir.call @__nv_brevll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i64
107110

111+
! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
112+
! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
113+
114+
108115
subroutine host1()
109116
integer, device :: a(32)
110117
integer, device :: ret

0 commit comments

Comments
 (0)