Skip to content

Conversation

@clementval
Copy link
Contributor

No description provided.

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

llvmbot commented Aug 12, 2025

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

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

Changes

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

2 Files Affected:

  • (modified) flang/module/cudadevice.f90 (+10-4)
  • (modified) flang/test/Lower/CUDA/cuda-device-proc.cuf (+7)
diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index 1b3c98b3e3f96..b63ab0f40f540 100644
--- a/flang/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -372,6 +372,12 @@ attributes(device) subroutine sincospi(x, y, z) bind(c,name='__nv_sincospi')
     procedure :: sincospi
   end interface
 
+  interface
+    attributes(device) real(4) function __cosf(x) bind(c, name='__nv_cosf')
+      real(4), value :: x
+    end function
+  end interface
+
   interface
     attributes(device) real(4) function cospif(x) bind(c,name='__nv_cospif')
       real(4), value :: x
@@ -431,14 +437,14 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
   end interface
 
   interface __float2half_rn
-    attributes(device) real(2) function __float2half_rn(r) bind(c)
+    attributes(device) real(2) function __float2half_rn(r) bind(c, name='__nv_float2half_rn')
       !dir$ ignore_tkr (d) r
       real, value :: r
     end function
   end interface
 
   interface __half2float
-    attributes(device) real function __half2float(i) bind(c)
+    attributes(device) real function __half2float(i) bind(c, name='__nv_half2float')
       !dir$ ignore_tkr (d) i
       real(2), value :: i
     end function
@@ -676,14 +682,14 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
   end interface
 
   interface __mul24
-    attributes(device) integer function __mul24(i,j) bind(c)
+    attributes(device) integer function __mul24(i,j) bind(c, name='__nv_mul24')
       !dir$ ignore_tkr (d) i, (d) j
       integer, value :: i,j
     end function
   end interface
 
   interface __umul24
-    attributes(device) integer function __umul24(i,j) bind(c)
+    attributes(device) integer function __umul24(i,j) bind(c, name='__nv_umul24')
       !dir$ ignore_tkr (d) i, (d) j
       integer, value :: i,j
     end function
diff --git a/flang/test/Lower/CUDA/cuda-device-proc.cuf b/flang/test/Lower/CUDA/cuda-device-proc.cuf
index 24600291b788a..8e15afdc4a9c9 100644
--- a/flang/test/Lower/CUDA/cuda-device-proc.cuf
+++ b/flang/test/Lower/CUDA/cuda-device-proc.cuf
@@ -58,6 +58,9 @@ attributes(global) subroutine devsub()
   res = __ffs(al)
   res = __brev(ai)
   resl = __brev(al)
+
+  ai = __mul24(ai, ai)
+  ai = __umul24(ai, ai)
 end
 
 ! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
@@ -105,6 +108,10 @@ end
 ! CHECK: %{{.*}} = fir.call @__nv_brev(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
 ! CHECK: %{{.*}} = fir.call @__nv_brevll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i64
 
+! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
+! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
+
+
 subroutine host1()
   integer, device :: a(32)
   integer, device :: ret

@clementval clementval merged commit 587b6ce into llvm:main Aug 13, 2025
12 checks passed
@clementval clementval deleted the cuf_mul24 branch August 13, 2025 05:02
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