Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[SPIR] Set MaxAtomicInlineWidth minimum size to 32 for spir32 and 64 for spir64#148997

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
wenju-he merged 1 commit intollvm:mainfromwenju-he:spir-MaxAtomicInlineWidth
Jul 17, 2025

Conversation

wenju-he
Copy link
Contributor

@wenju-hewenju-he commentedJul 16, 2025
edited
Loading

Set MaxAtomicInlineWidth the same way as SPIR-V targets in3cfd0c0. This PR fixes build warning in scoped atomic built-in in#146814:warning: large atomic operation may incur significant performance penalty; the access size (2 bytes) exceeds the max lock-free size (0 bytes) [-Watomic-alignment]

…for spir64Set MaxAtomicInlineWidth the same way as SPIR-V targets in3cfd0c0.This PR fixes build warning in scoped atomic built-in inllvm#146814:`warning: large atomic operation may incur significant performance penalty`
@llvmbotllvmbot added clangClang issues not falling into any other category clang:frontendLanguage frontend issues, e.g. anything involving "Sema" labelsJul 16, 2025
@llvmbot
Copy link
Member

@llvm/pr-subscribers-clang

Author: Wenju He (wenju-he)

Changes

Set MaxAtomicInlineWidth the same way as SPIR-V targets in3cfd0c0. This PR fixes build warning in scoped atomic built-in in #146814:warning: large atomic operation may incur significant performance penalty


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

2 Files Affected:

  • (modified) clang/lib/Basic/Targets/SPIR.h (+6)
  • (added) clang/test/CodeGenOpenCL/scoped-atomic.cl (+18)
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.hindex 1abf798d93129..c13b286cd7916 100644--- a/clang/lib/Basic/Targets/SPIR.h+++ b/clang/lib/Basic/Targets/SPIR.h@@ -264,6 +264,9 @@ class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {     PointerWidth = PointerAlign = 32;     SizeType = TargetInfo::UnsignedInt;     PtrDiffType = IntPtrType = TargetInfo::SignedInt;+    // SPIR32 has support for atomic ops if atomic extension is enabled.+    // Take the maximum because it's possible the Host supports wider types.+    MaxAtomicInlineWidth = std::max<unsigned char>(MaxAtomicInlineWidth, 32);     resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"                     "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");   }@@ -281,6 +284,9 @@ class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {     PointerWidth = PointerAlign = 64;     SizeType = TargetInfo::UnsignedLong;     PtrDiffType = IntPtrType = TargetInfo::SignedLong;+    // SPIR64 has support for atomic ops if atomic extension is enabled.+    // Take the maximum because it's possible the Host supports wider types.+    MaxAtomicInlineWidth = std::max<unsigned char>(MaxAtomicInlineWidth, 64);     resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"                     "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");   }diff --git a/clang/test/CodeGenOpenCL/scoped-atomic.cl b/clang/test/CodeGenOpenCL/scoped-atomic.clnew file mode 100644index 0000000000000..ec7e936684a3a--- /dev/null+++ b/clang/test/CodeGenOpenCL/scoped-atomic.cl@@ -0,0 +1,18 @@+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown -verify+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple spir64-unknown-unknown -verify++// expected-no-diagnostics++int fi1a(int *i) {+  int v;+  __scoped_atomic_load(i, &v, __ATOMIC_RELAXED, __MEMORY_SCOPE_DEVICE);+  return v;+}++#ifdef __SPIR64__+long fl1a(long *i) {+  long v;+  __scoped_atomic_load(i, &v, __ATOMIC_RELAXED, __MEMORY_SCOPE_DEVICE);+  return v;+}+#endif

Copy link
Contributor

@baderbader left a comment

Choose a reason for hiding this comment

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

Thanks!

@wenju-hewenju-he merged commitb413982 intollvm:mainJul 17, 2025
14 of 15 checks passed
@wenju-hewenju-he deleted the spir-MaxAtomicInlineWidth branchJuly 17, 2025 01:02
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@baderbaderbader approved these changes

@frasercrmckfrasercrmckfrasercrmck approved these changes

@svenvhsvenvhAwaiting requested review from svenvh

@AlexVlxAlexVlxAwaiting requested review from AlexVlx

Assignees
No one assigned
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"clangClang issues not falling into any other category
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@wenju-he@llvmbot@bader@frasercrmck

[8]ページ先頭

©2009-2025 Movatter.jp