Skip to content

Commit

Permalink
[flang][cuda] Add bind(c) interfaces for __fadd_rd and __fadd_ru
Browse files Browse the repository at this point in the history
  • Loading branch information
clementval committed Jan 10, 2025
1 parent 3c9c94a commit 6dc8676
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions flang/module/cudadevice.f90
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,18 @@ attributes(device) subroutine threadfence_system()
end interface
public :: threadfence_system

interface
attributes(device) function __fadd_rd(x, y) bind(c, name='__nv_fadd_rd')
real :: x, y, __fadd_rd
end function
end interface
public :: __fadd_rd

interface
attributes(device) function __fadd_ru(x, y) bind(c, name='__nv_fadd_ru')
real :: x, y, __fadd_ru
end function
end interface
public :: __fadd_ru

end module
17 changes: 17 additions & 0 deletions flang/test/Lower/CUDA/cuda-intrinsic.cuf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s

module mod1
type int
real :: inf, sup
end type int
contains
attributes(global) subroutine fadd(c, a, b)
type (int) :: c, a, b
c%inf = __fadd_rd(a%inf, b%inf)
c%sup = __fadd_ru(a%sup, b%sup)
end subroutine
end

! CHECK-LABEL: func.func @_QMmod1Pfadd
! CHECK: fir.call @__nv_fadd_rd
! CHECK: fir.call @__nv_fadd_ru

0 comments on commit 6dc8676

Please sign in to comment.