Skip to content

Commit df808df

Browse files
authored
[flang][cuda] Add bind(c) interfaces for __fadd_rd and __fadd_ru (llvm#122535)
Function like `__fadd_rd ` and `__fadd_ru ` need to be converted to the cuda equivalent.
1 parent 82aac16 commit df808df

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

flang/module/cudadevice.f90

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,20 @@ attributes(device) subroutine threadfence_system()
7171
end interface
7272
public :: threadfence_system
7373

74+
interface
75+
attributes(device) function __fadd_rd(x, y) bind(c, name='__nv_fadd_rd')
76+
real, intent(in) :: x, y
77+
real :: __fadd_rd
78+
end function
79+
end interface
80+
public :: __fadd_rd
81+
82+
interface
83+
attributes(device) function __fadd_ru(x, y) bind(c, name='__nv_fadd_ru')
84+
real, intent(in) :: x, y
85+
real :: __fadd_ru
86+
end function
87+
end interface
88+
public :: __fadd_ru
89+
7490
end module
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
2+
3+
module mod1
4+
type int
5+
real :: inf, sup
6+
end type int
7+
contains
8+
attributes(global) subroutine fadd(c, a, b)
9+
type (int) :: c, a, b
10+
c%inf = __fadd_rd(a%inf, b%inf)
11+
c%sup = __fadd_ru(a%sup, b%sup)
12+
end subroutine
13+
end
14+
15+
! CHECK-LABEL: func.func @_QMmod1Pfadd
16+
! CHECK: fir.call @__nv_fadd_rd
17+
! CHECK: fir.call @__nv_fadd_ru

0 commit comments

Comments
 (0)