[flang-commits] [flang] [flang][cuda] Move interface to __cuda_device (PR #122771)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Mon Jan 13 11:25:51 PST 2025
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/122771
Move the __fadd interfaces to a `__cuda_device` module so we can reuse them downstream.
>From a36f4a20db48225f31a52a37ae636b7a0b3e56b8 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Mon, 13 Jan 2025 11:24:44 -0800
Subject: [PATCH] [flang][cuda] Move interface to __cuda_device
---
flang/module/__cuda_device.f90 | 32 ++++++++++++++++++++++++++++++++
flang/module/cudadevice.f90 | 17 +----------------
flang/tools/f18/CMakeLists.txt | 6 +++++-
3 files changed, 38 insertions(+), 17 deletions(-)
create mode 100644 flang/module/__cuda_device.f90
diff --git a/flang/module/__cuda_device.f90 b/flang/module/__cuda_device.f90
new file mode 100644
index 00000000000000..81b1f5aa334bbf
--- /dev/null
+++ b/flang/module/__cuda_device.f90
@@ -0,0 +1,32 @@
+!===-- module/__cuda_device.f90 --------------------------------------------===!
+!
+! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+! See https://llvm.org/LICENSE.txt for license information.
+! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+!
+!===------------------------------------------------------------------------===!
+
+! This module contains CUDA Fortran interfaces used in cudadevice.f90.
+
+module __cuda_device
+implicit none
+
+ ! Set PRIVATE by default to explicitly only export what is meant
+ ! to be exported by this MODULE.
+
+ interface
+ attributes(device) function __fadd_rd(x, y) bind(c, name='__nv_fadd_rd')
+ real, intent(in), value :: x, y
+ real :: __fadd_rd
+ end function
+ end interface
+ public :: __fadd_rd
+
+ interface
+ attributes(device) function __fadd_ru(x, y) bind(c, name='__nv_fadd_ru')
+ real, intent(in), value :: x, y
+ real :: __fadd_ru
+ end function
+ end interface
+ public :: __fadd_ru
+end module
diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index e06c706538fe63..b07f82be6a7243 100644
--- a/flang/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -9,6 +9,7 @@
! CUDA Fortran procedures available in device subprogram
module cudadevice
+ use __cuda_device, only: __fadd_rd, __fadd_ru
implicit none
! Set PRIVATE by default to explicitly only export what is meant
@@ -71,20 +72,4 @@ attributes(device) subroutine threadfence_system()
end interface
public :: threadfence_system
- interface
- attributes(device) function __fadd_rd(x, y) bind(c, name='__nv_fadd_rd')
- real, intent(in) :: x, y
- real :: __fadd_rd
- end function
- end interface
- public :: __fadd_rd
-
- interface
- attributes(device) function __fadd_ru(x, y) bind(c, name='__nv_fadd_ru')
- real, intent(in) :: x, y
- real :: __fadd_ru
- end function
- end interface
- public :: __fadd_ru
-
end module
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 4362fcf0537616..cc2bc5b8eb5ce2 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -21,6 +21,7 @@ set(MODULES_WITHOUT_IMPLEMENTATION
"__ppc_intrinsics"
"mma"
"__cuda_builtins"
+ "__cuda_device"
"cudadevice"
"ieee_arithmetic"
"ieee_exceptions"
@@ -67,9 +68,12 @@ if (NOT CMAKE_CROSSCOMPILING)
elseif(${filename} STREQUAL "__ppc_intrinsics" OR
${filename} STREQUAL "mma")
set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__ppc_types.mod)
- elseif(${filename} STREQUAL "cudadevice")
+ elseif(${filename} STREQUAL "__cuda_device")
set(opts -fc1 -xcuda)
set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__cuda_builtins.mod)
+ elseif(${filename} STREQUAL "cudadevice")
+ set(opts -fc1 -xcuda)
+ set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__cuda_device.mod)
else()
set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
if(${filename} STREQUAL "iso_fortran_env")
More information about the flang-commits
mailing list