[flang-commits] [flang] [flang][cuda] Fix module registration (PR #113358)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Tue Oct 22 12:26:05 PDT 2024


Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/113358 at github.com>


https://github.com/clementval updated https://github.com/llvm/llvm-project/pull/113358

>From deec9bb79d4eaed0225b9493d769833b3088cc44 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?= <clementval at gmail.com>
Date: Tue, 22 Oct 2024 11:43:44 -0700
Subject: [PATCH 1/3] [flang][cuda] Fix module registration

---
 flang/runtime/CUDA/registration.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/flang/runtime/CUDA/registration.cpp b/flang/runtime/CUDA/registration.cpp
index aed275e964680e..b83a43efaf500b 100644
--- a/flang/runtime/CUDA/registration.cpp
+++ b/flang/runtime/CUDA/registration.cpp
@@ -14,13 +14,16 @@ namespace Fortran::runtime::cuda {
 
 extern "C" {
 
-extern void **__cudaRegisterFatBinary(void *data);
+extern void **__cudaRegisterFatBinary(void *);
+extern void __cudaRegisterFatBinaryEnd(void *);
 extern void __cudaRegisterFunction(void **fatCubinHandle, const char *hostFun,
     char *deviceFun, const char *deviceName, int thread_limit, uint3 *tid,
     uint3 *bid, dim3 *bDim, dim3 *gDim, int *wSize);
 
 void *RTDECL(CUFRegisterModule)(void *data) {
-  return __cudaRegisterFatBinary(data);
+  void** fatHandle = __cudaRegisterFatBinary(data);
+  __cudaRegisterFatBinaryEnd(fatHandle);
+  return fatHandle;
 }
 
 void RTDEF(CUFRegisterFunction)(void **module, const char *fct) {

>From 02664a40a8132a5651480c49ec2563ada7dee46c 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?= <clementval at gmail.com>
Date: Tue, 22 Oct 2024 12:05:35 -0700
Subject: [PATCH 2/3] clang-format

---
 flang/runtime/CUDA/registration.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/runtime/CUDA/registration.cpp b/flang/runtime/CUDA/registration.cpp
index b83a43efaf500b..67379c1547522a 100644
--- a/flang/runtime/CUDA/registration.cpp
+++ b/flang/runtime/CUDA/registration.cpp
@@ -21,7 +21,7 @@ extern void __cudaRegisterFunction(void **fatCubinHandle, const char *hostFun,
     uint3 *bid, dim3 *bDim, dim3 *gDim, int *wSize);
 
 void *RTDECL(CUFRegisterModule)(void *data) {
-  void** fatHandle = __cudaRegisterFatBinary(data);
+  void **fatHandle = __cudaRegisterFatBinary(data);
   __cudaRegisterFatBinaryEnd(fatHandle);
   return fatHandle;
 }

>From 96844264c24909612353f545775ff5c77f02352a 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?= <clementval at gmail.com>
Date: Tue, 22 Oct 2024 12:25:57 -0700
Subject: [PATCH 3/3] Use brace init

---
 flang/runtime/CUDA/registration.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/runtime/CUDA/registration.cpp b/flang/runtime/CUDA/registration.cpp
index 67379c1547522a..e5d9503e95fd8f 100644
--- a/flang/runtime/CUDA/registration.cpp
+++ b/flang/runtime/CUDA/registration.cpp
@@ -21,7 +21,7 @@ extern void __cudaRegisterFunction(void **fatCubinHandle, const char *hostFun,
     uint3 *bid, dim3 *bDim, dim3 *gDim, int *wSize);
 
 void *RTDECL(CUFRegisterModule)(void *data) {
-  void **fatHandle = __cudaRegisterFatBinary(data);
+  void **fatHandle{__cudaRegisterFatBinary(data)};
   __cudaRegisterFatBinaryEnd(fatHandle);
   return fatHandle;
 }



More information about the flang-commits mailing list