From 62f484057859ba9ec5061d2ac5476a074d255e20 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Wed, 13 Aug 2025 11:35:59 -0700 Subject: [PATCH 1/2] [flang][cuda] Add bind name for __ull2double_rX interfaces --- flang/module/cudadevice.f90 | 14 +++++++------- flang/test/Lower/CUDA/cuda-device-proc.cuf | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90 index 6cc18f4cbc18c..03860e200cdd8 100644 --- a/flang/module/cudadevice.f90 +++ b/flang/module/cudadevice.f90 @@ -667,29 +667,29 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi') end function end interface - interface __ull2double_rn - attributes(device) double precision function __ull2double_rn(i) bind(c) + interface __ull2double_rd + attributes(device) double precision function __ull2double_rd(i) bind(c, name='__nv_ull2double_rd') !dir$ ignore_tkr (d) i integer(8), value :: i end function end interface - interface __ull2double_rz - attributes(device) double precision function __ull2double_rz(i) bind(c) + interface __ull2double_rn + attributes(device) double precision function __ull2double_rn(i) bind(c, name='__nv_ull2double_rn') !dir$ ignore_tkr (d) i integer(8), value :: i end function end interface interface __ull2double_ru - attributes(device) double precision function __ull2double_ru(i) bind(c) + attributes(device) double precision function __ull2double_ru(i) bind(c, name='__nv_ull2double_ru') !dir$ ignore_tkr (d) i integer(8), value :: i end function end interface - interface __ull2double_rd - attributes(device) double precision function __ull2double_rd(i) bind(c) + interface __ull2double_rz + attributes(device) double precision function __ull2double_rz(i) bind(c, name='__nv_ull2double_rz') !dir$ ignore_tkr (d) i integer(8), value :: i end function diff --git a/flang/test/Lower/CUDA/cuda-device-proc.cuf b/flang/test/Lower/CUDA/cuda-device-proc.cuf index f9ec0c773fe80..47b92de8f9a89 100644 --- a/flang/test/Lower/CUDA/cuda-device-proc.cuf +++ b/flang/test/Lower/CUDA/cuda-device-proc.cuf @@ -83,6 +83,10 @@ attributes(global) subroutine devsub() af = __powf(af, af) ad = __dsqrt_rd(ad) ad = __dsqrt_ru(ad) + ad = __ull2double_rd(al) + ad = __ull2double_rn(al) + ad = __ull2double_ru(al) + ad = __ull2double_rz(al) end ! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc} From c28cc262b2cf3da49b01814034ad17179189964a Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Wed, 13 Aug 2025 14:20:39 -0700 Subject: [PATCH 2/2] Add missing checks --- flang/test/Lower/CUDA/cuda-device-proc.cuf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flang/test/Lower/CUDA/cuda-device-proc.cuf b/flang/test/Lower/CUDA/cuda-device-proc.cuf index 47b92de8f9a89..9dd77a516063d 100644 --- a/flang/test/Lower/CUDA/cuda-device-proc.cuf +++ b/flang/test/Lower/CUDA/cuda-device-proc.cuf @@ -157,6 +157,10 @@ end ! CHECK: %{{.*}} = fir.call @__nv_powf(%{{.*}}, %{{.*}}) proc_attrs fastmath : (f32, f32) -> f32 ! CHECK: %{{.*}} = fir.call @__nv_dsqrt_rd(%{{.*}}) proc_attrs fastmath : (f64) -> f64 ! CHECK: %{{.*}} = fir.call @__nv_dsqrt_ru(%{{.*}}) proc_attrs fastmath : (f64) -> f64 +! CHECK: %{{.*}} = fir.call @__nv_ull2double_rd(%{{.*}}) proc_attrs fastmath : (i64) -> f64 +! CHECK: %{{.*}} = fir.call @__nv_ull2double_rn(%{{.*}}) proc_attrs fastmath : (i64) -> f64 +! CHECK: %{{.*}} = fir.call @__nv_ull2double_ru(%{{.*}}) proc_attrs fastmath : (i64) -> f64 +! CHECK: %{{.*}} = fir.call @__nv_ull2double_rz(%{{.*}}) proc_attrs fastmath : (i64) -> f64 subroutine host1() integer, device :: a(32)