Skip to content

Conversation

clementval
Copy link
Contributor

No description provided.

@clementval clementval requested a review from wangzpgi August 15, 2025 00:07
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Aug 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 15, 2025

@llvm/pr-subscribers-flang-fir-hlfir

Author: Valentin Clement (バレンタイン クレメン) (clementval)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/153713.diff

2 Files Affected:

  • (modified) flang/module/cudadevice.f90 (+3-3)
  • (modified) flang/test/Lower/CUDA/cuda-libdevice.cuf (+27)
diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index ffc3a3b170ca6..e6e818bdd5249 100644
--- a/flang/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -654,21 +654,21 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
   end interface
 
   interface __double2loint
-    attributes(device) integer function __double2loint(r) bind(c)
+    attributes(device) integer function __double2loint(r) bind(c, name='__nv_double2loint')
       !dir$ ignore_tkr (d) r
       double precision, value :: r
     end function
   end interface
 
   interface __double2hiint
-    attributes(device) integer function __double2hiint(r) bind(c)
+    attributes(device) integer function __double2hiint(r) bind(c, name='__nv_double2hiint')
       !dir$ ignore_tkr (d) r
       double precision, value :: r
     end function
   end interface
 
   interface __hiloint2double
-    attributes(device) double precision function __hiloint2double(i, j) bind(c)
+    attributes(device) double precision function __hiloint2double(i, j) bind(c, name='__nv_hiloint2double')
       !dir$ ignore_tkr (d) i, (d) j
       integer, value :: i, j
     end function
diff --git a/flang/test/Lower/CUDA/cuda-libdevice.cuf b/flang/test/Lower/CUDA/cuda-libdevice.cuf
index f9c5dcc5fc4c3..ecc05e79b1cd7 100644
--- a/flang/test/Lower/CUDA/cuda-libdevice.cuf
+++ b/flang/test/Lower/CUDA/cuda-libdevice.cuf
@@ -244,3 +244,30 @@ end subroutine
 ! CHECK: %{{.*}} = fir.call @__nv_float2uint_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
 ! CHECK: %{{.*}} = fir.call @__nv_float2uint_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
 ! CHECK: %{{.*}} = fir.call @__nv_float2uint_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
+
+attributes(global) subroutine test_double2loint()
+  integer :: res
+  double precision :: r
+  res = __double2loint(r)
+end subroutine
+
+! CHECK-LABEL: _QPtest_double2loint
+! CHECK: %{{.*}} = fir.call @__nv_double2loint(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i32
+
+attributes(global) subroutine test_double2hiint()
+  integer :: res
+  double precision :: r
+  res = __double2hiint(r)
+end subroutine
+  
+! CHECK-LABEL: _QPtest_double2hiint
+! CHECK: %{{.*}} = fir.call @__nv_double2hiint(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i32
+
+attributes(global) subroutine test_hiloint2double()
+  double precision :: res
+  integer :: i, j
+  res = __hiloint2double(i, j)
+end subroutine
+
+! CHECK-LABEL: _QPtest_hiloint2double
+! CHECK: %{{.*}} = fir.call @__nv_hiloint2double(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> f64

@clementval clementval merged commit 583499a into llvm:main Aug 15, 2025
12 checks passed
@clementval clementval deleted the cuf__hiloint2double branch August 15, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants