From 2ae4e95dda5d9aebe888acd5c5d618fb3b45c7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Clement=20=28=E3=83=90=E3=83=AC=E3=83=B3?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=B3=20=E3=82=AF=E3=83=AC=E3=83=A1?= =?UTF-8?q?=E3=83=B3=29?= Date: Tue, 12 Aug 2025 23:30:43 -0700 Subject: [PATCH] [flang][cuda] Add bind name for __ddiv_XX interfaces (#153271) --- flang/module/cudadevice.f90 | 8 ++++---- flang/test/Lower/CUDA/cuda-device-proc.cuf | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90 index f7b7d856ecb9..82571704032f 100644 --- a/flang/module/cudadevice.f90 +++ b/flang/module/cudadevice.f90 @@ -710,28 +710,28 @@ implicit none end interface interface __ddiv_rn - attributes(device) double precision function __ddiv_rn(x,y) bind(c) + attributes(device) double precision function __ddiv_rn(x,y) bind(c, name='__nv_ddiv_rn') !dir$ ignore_tkr (d) x, (d) y double precision, value :: x, y end function end interface interface __ddiv_rz - attributes(device) double precision function __ddiv_rz(x,y) bind(c) + attributes(device) double precision function __ddiv_rz(x,y) bind(c, name='__nv_ddiv_rz') !dir$ ignore_tkr (d) x, (d) y double precision, value :: x, y end function end interface interface __ddiv_ru - attributes(device) double precision function __ddiv_ru(x,y) bind(c) + attributes(device) double precision function __ddiv_ru(x,y) bind(c, name='__nv_ddiv_ru') !dir$ ignore_tkr (d) x, (d) y double precision, value :: x, y end function end interface interface __ddiv_rd - attributes(device) double precision function __ddiv_rd(x,y) bind(c) + attributes(device) double precision function __ddiv_rd(x,y) bind(c, name='__nv_ddiv_rd') !dir$ ignore_tkr (d) x, (d) y double precision, value :: x, y end function diff --git a/flang/test/Lower/CUDA/cuda-device-proc.cuf b/flang/test/Lower/CUDA/cuda-device-proc.cuf index 6c56f8616c40..ae336445532b 100644 --- a/flang/test/Lower/CUDA/cuda-device-proc.cuf +++ b/flang/test/Lower/CUDA/cuda-device-proc.cuf @@ -61,9 +61,14 @@ attributes(global) subroutine devsub() res = __clz(ai) res = __clz(al) af = __cosf(af) + ad = __ddiv_rn(ad, ad) + ad = __ddiv_rz(ad, ad) + ad = __ddiv_ru(ad, ad) + ad = __ddiv_rd(ad, ad) ai = __mul24(ai, ai) ai = __umul24(ai, ai) af = __powf(af, af) + end ! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc} @@ -113,6 +118,10 @@ end ! CHECK: %{{.*}} = fir.call @__nv_clz(%{{.*}}) proc_attrs fastmath : (i32) -> i32 ! CHECK: %{{.*}} = fir.call @__nv_clzll(%{{.*}}) proc_attrs fastmath : (i64) -> i32 ! CHECK: %{{.*}} = fir.call @__nv_cosf(%{{.*}}) proc_attrs fastmath : (f32) -> f32 +! CHECK: %{{.*}} = fir.call @__nv_ddiv_rn(%{{.*}}, %{{.*}}) proc_attrs fastmath : (f64, f64) -> f64 +! CHECK: %{{.*}} = fir.call @__nv_ddiv_rz(%{{.*}}, %{{.*}}) proc_attrs fastmath : (f64, f64) -> f64 +! CHECK: %{{.*}} = fir.call @__nv_ddiv_ru(%{{.*}}, %{{.*}}) proc_attrs fastmath : (f64, f64) -> f64 +! CHECK: %{{.*}} = fir.call @__nv_ddiv_rd(%{{.*}}, %{{.*}}) proc_attrs fastmath : (f64, f64) -> f64 ! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs fastmath : (i32, i32) -> i32 ! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs fastmath : (i32, i32) -> i32 ! CHECK: %{{.*}} = fir.call @__nv_powf(%{{.*}}, %{{.*}}) proc_attrs fastmath : (f32, f32) -> f32