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

[AMDGPU][True16][Clang] support true16 target feature in clang driver #133298

Closed
wants to merge 1 commit into from

Conversation

broxigarchen
Copy link
Contributor

@broxigarchen broxigarchen commented Mar 27, 2025

Add a true16 clang option to turn on true16 mode(by default off) in amdgpu.

This allows to turn on true16 and enable testing for this feature. This patch be removed after we validated true16 feature and set it to be the default mode.

@broxigarchen broxigarchen changed the title [AMDGPU][True16][Driver] add true16 feature in clang driver [AMDGPU][True16][Driver] support true16 feature option in clang driver Mar 27, 2025
Copy link

github-actions bot commented Mar 27, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@broxigarchen broxigarchen force-pushed the main-add-real-true16 branch 4 times, most recently from 4285b82 to fee2c8d Compare March 27, 2025 18:57
@broxigarchen broxigarchen force-pushed the main-add-real-true16 branch from fee2c8d to bd63009 Compare March 27, 2025 20:33
@broxigarchen broxigarchen changed the title [AMDGPU][True16][Driver] support true16 feature option in clang driver [AMDGPU][True16][Driver] support true16 target feature in clang driver Mar 27, 2025
@broxigarchen broxigarchen marked this pull request as ready for review March 27, 2025 20:44
@broxigarchen broxigarchen changed the title [AMDGPU][True16][Driver] support true16 target feature in clang driver [AMDGPU][True16][Clang] support true16 target feature in clang driver Mar 27, 2025
@broxigarchen broxigarchen requested a review from jwanggit86 March 27, 2025 20:44
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:AMDGPU clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Mar 27, 2025
@broxigarchen broxigarchen requested review from Sisyph and kosarev March 27, 2025 20:44
@llvmbot
Copy link
Member

llvmbot commented Mar 27, 2025

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-backend-amdgpu

Author: Brox Chen (broxigarchen)

Changes

Add a true16 clang option to turn on true16 mode(by default off) in GFX11Plus amdgpu.

This allows to turn on true16 and enable testing for this feature. This patch be removed after we validated true16 feature and set it to be the default mode.


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

3 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+3)
  • (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+4)
  • (modified) clang/test/Driver/amdgpu-features.c (+5)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index a7fcb160d3867..68179d7835440 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5182,6 +5182,9 @@ defm wavefrontsize64 : SimpleMFlag<"wavefrontsize64",
 defm amdgpu_precise_memory_op
     : SimpleMFlag<"amdgpu-precise-memory-op", "Enable", "Disable",
                   " precise memory mode (AMDGPU only)">;
+defm real_true16: SimpleMFlag<"real-true16",
+  "enable real-true16 in GFX11Plus", "enable real-true16 mode",
+  " real-true16 mode (AMDGPU only)">;
 
 def munsafe_fp_atomics : Flag<["-"], "munsafe-fp-atomics">,
   Visibility<[ClangOption, CC1Option]>, Alias<fatomic_ignore_denormal_mode>;
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 1c5bb08568801..ce0cba5aa536a 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -707,6 +707,10 @@ void amdgpu::getAMDGPUTargetFeatures(const Driver &D,
                    options::OPT_mno_amdgpu_precise_memory_op, false))
     Features.push_back("+precise-memory");
 
+  if (Args.hasFlag(options::OPT_mreal_true16, options::OPT_mno_real_true16,
+                   false))
+    Features.push_back("+real-true16");
+
   handleTargetFeaturesGroup(D, Triple, Args, Features,
                             options::OPT_m_amdgpu_Features_Group);
 }
diff --git a/clang/test/Driver/amdgpu-features.c b/clang/test/Driver/amdgpu-features.c
index 864744db203e9..f46f0251cadfc 100644
--- a/clang/test/Driver/amdgpu-features.c
+++ b/clang/test/Driver/amdgpu-features.c
@@ -38,3 +38,8 @@
 
 // RUN: %clang -### -target amdgcn -mcpu=gfx1010 -mno-amdgpu-precise-memory-op %s 2>&1 | FileCheck --check-prefix=NO-PREC-MEM %s
 // NO-PREC-MEM-NOT: {{".*precise-memory"}}
+
+// RUN: %clang -### -target amdgcn -mcpu=gfx1100 -mreal-true16 %s 2>&1 | FileCheck --check-prefix=REAL16 %s
+// RUN: %clang -### -target amdgcn -mcpu=gfx1100 -mno-real-true16 %s 2>&1 | FileCheck --check-prefix=NO-REAL16 %s
+// REAL16: "-target-feature" "+real-true16"
+// NO-REAL16-NOT: {{".*real-true16"}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants