Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang][OpenMP][AMDGPU] Allow REAL(10) to compile on AMDGPU #129742

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

kparzysz
Copy link
Contributor

@kparzysz kparzysz commented Mar 4, 2025

This will allow the following code to compile

program p
  real(10) :: x
  !$omp target
    continue
  !$omp end target
end

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir flang:openmp labels Mar 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 4, 2025

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

@llvm/pr-subscribers-flang-openmp

Author: Krzysztof Parzyszek (kparzysz)

Changes

This will allow the following code to compile

program p
  real(10) :: x
  !$omp target
    continue
  !$omp end target
end

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

2 Files Affected:

  • (modified) flang/include/flang/Tools/TargetSetup.h (+6-1)
  • (added) flang/test/Lower/OpenMP/real10.f90 (+13)
diff --git a/flang/include/flang/Tools/TargetSetup.h b/flang/include/flang/Tools/TargetSetup.h
index d167f44fe2fd7..ee05d891db353 100644
--- a/flang/include/flang/Tools/TargetSetup.h
+++ b/flang/include/flang/Tools/TargetSetup.h
@@ -42,9 +42,14 @@ namespace Fortran::tools {
     targetCharacteristics.set_hasSubnormalFlushingControl(/*kind=*/8);
   }
 
-  if (targetTriple.getArch() != llvm::Triple::ArchType::x86_64) {
+  switch (targetTriple.getArch()) {
+  case llvm::Triple::ArchType::amdgcn:
+  case llvm::Triple::ArchType::x86_64:
+    break;
+  default:
     targetCharacteristics.DisableType(
         Fortran::common::TypeCategory::Real, /*kind=*/10);
+    break;
   }
 
   // Check for kind=16 support. See flang/runtime/Float128Math/math-entries.h.
diff --git a/flang/test/Lower/OpenMP/real10.f90 b/flang/test/Lower/OpenMP/real10.f90
new file mode 100644
index 0000000000000..0a092ebf6317e
--- /dev/null
+++ b/flang/test/Lower/OpenMP/real10.f90
@@ -0,0 +1,13 @@
+!REQUIRES: amdgpu-registered-target
+
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -triple amdgcn -fopenmp -fopenmp-is-target-device -o - %s | FileCheck %s
+
+!CHECK: hlfir.declare %0 {uniq_name = "_QFEx"} : (!fir.ref<f80>) -> (!fir.ref<f80>, !fir.ref<f80>)
+
+program p
+  real(10) :: x
+  !$omp target
+    continue
+  !$omp end target
+end
+

@dpalermo dpalermo self-requested a review March 4, 2025 17:09
@abidh abidh self-requested a review March 4, 2025 17:11
Copy link
Contributor

@abidh abidh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ronlieb ronlieb self-requested a review March 5, 2025 20:15
@kparzysz kparzysz merged commit 44c6a23 into llvm:main Mar 5, 2025
15 checks passed
@kparzysz kparzysz deleted the users/kparzysz/real10 branch March 5, 2025 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang:openmp flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants