Skip to content
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

[flang][cuda] Add bind(c) interfaces for __fadd_rd and __fadd_ru #122535

Merged
merged 3 commits into from
Jan 11, 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
16 changes: 16 additions & 0 deletions flang/module/cudadevice.f90
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,20 @@ 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, intent(in) :: x, y
real :: __fadd_rd
end function
end interface
public :: __fadd_rd

interface
attributes(device) function __fadd_ru(x, y) bind(c, name='__nv_fadd_ru')
real, intent(in) :: x, y
real :: __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
Loading