From e0cce7cfcb19f69fa98d1484dd9d5a1f09c7c763 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Tue, 12 Aug 2025 13:32:14 -0700 Subject: [PATCH] [flang][cuda] Add bind name for __double2int_XX interfaces --- flang/module/cudadevice.f90 | 22 +++++++++++----------- flang/test/Lower/CUDA/cuda-device-proc.cuf | 10 ++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90 index 1b3c98b3e3f96..072d015813034 100644 --- a/flang/module/cudadevice.f90 +++ b/flang/module/cudadevice.f90 @@ -444,29 +444,29 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi') end function end interface - interface __double2int_rn - attributes(device) integer function __double2int_rn(r) bind(c) + interface __double2int_rd + attributes(device) integer function __double2int_rd(r) bind(c, name='__nv_double2int_rd') !dir$ ignore_tkr (d) r double precision, value :: r end function end interface - interface __double2int_rz - attributes(device) integer function __double2int_rz(r) bind(c) + interface __double2int_rn + attributes(device) integer function __double2int_rn(r) bind(c, name='__nv_double2int_rn') !dir$ ignore_tkr (d) r double precision, value :: r end function end interface interface __double2int_ru - attributes(device) integer function __double2int_ru(r) bind(c) + attributes(device) integer function __double2int_ru(r) bind(c, name='__nv_double2int_ru') !dir$ ignore_tkr (d) r double precision, value :: r end function end interface - interface __double2int_rd - attributes(device) integer function __double2int_rd(r) bind(c) + interface __double2int_rz + attributes(device) integer function __double2int_rz(r) bind(c, name='__nv_double2int_rz') !dir$ ignore_tkr (d) r double precision, value :: r end function @@ -501,28 +501,28 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi') end interface interface __double2float_rn - attributes(device) real function __double2float_rn(r) bind(c) + attributes(device) real function __double2float_rn(r) bind(c, name='__nv_double2float_rn') !dir$ ignore_tkr (d) r double precision, value :: r end function end interface interface __double2float_rz - attributes(device) real function __double2float_rz(r) bind(c) + attributes(device) real function __double2float_rz(r) bind(c, name='__nv_double2float_rz') !dir$ ignore_tkr (d) r double precision, value :: r end function end interface interface __double2float_ru - attributes(device) real function __double2float_ru(r) bind(c) + attributes(device) real function __double2float_ru(r) bind(c, name='__nv_double2float_ru') !dir$ ignore_tkr (d) r double precision, value :: r end function end interface interface __double2float_rd - attributes(device) real function __double2float_rd(r) bind(c) + attributes(device) real function __double2float_rd(r) bind(c, name='__nv_double2float_rd') !dir$ ignore_tkr (d) r double precision, value :: r end function diff --git a/flang/test/Lower/CUDA/cuda-device-proc.cuf b/flang/test/Lower/CUDA/cuda-device-proc.cuf index 24600291b788a..32bad0e79645c 100644 --- a/flang/test/Lower/CUDA/cuda-device-proc.cuf +++ b/flang/test/Lower/CUDA/cuda-device-proc.cuf @@ -58,6 +58,11 @@ attributes(global) subroutine devsub() res = __ffs(al) res = __brev(ai) resl = __brev(al) + + ai = __double2int_rd(ad) + ai = __double2int_rn(ad) + ai = __double2int_ru(ad) + ai = __double2int_rz(ad) end ! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc} @@ -105,6 +110,11 @@ end ! CHECK: %{{.*}} = fir.call @__nv_brev(%{{.*}}) proc_attrs fastmath : (i32) -> i32 ! CHECK: %{{.*}} = fir.call @__nv_brevll(%{{.*}}) proc_attrs fastmath : (i64) -> i64 +! CHECK: %{{.*}} = fir.call @__nv_double2int_rd(%{{.*}}) proc_attrs fastmath : (f64) -> i32 +! CHECK: %{{.*}} = fir.call @__nv_double2int_rn(%{{.*}}) proc_attrs fastmath : (f64) -> i32 +! CHECK: %{{.*}} = fir.call @__nv_double2int_ru(%{{.*}}) proc_attrs fastmath : (f64) -> i32 +! CHECK: %{{.*}} = fir.call @__nv_double2int_rz(%{{.*}}) proc_attrs fastmath : (f64) -> i32 + subroutine host1() integer, device :: a(32) integer, device :: ret