[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-03 Thread Pierre van Houtryve via cfe-commits
https://github.com/Pierre-vh closed https://github.com/llvm/llvm-project/pull/83558 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-03 Thread Matt Arsenault via cfe-commits
@@ -6,32 +6,32 @@ // R600-based processors. // -// RUN: %clang -E -dM -target r600 -mcpu=r600 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s -DCPU=r600 -// RUN: %clang -E -dM -target r600 -mcpu=rv630 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s -DCPU=r600

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-02 Thread Yaxun Liu via cfe-commits
yxsamliu wrote: When clang does host compilation, it essentially makes an assumption that the generated IR for host does not depend on the assumed GPU arch, or, the generated IR may be affected by assumed GPU arch, but it won't affect the program output. This is true in most cases. For

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Yaxun Liu via cfe-commits
yxsamliu wrote: in HIP headers, warpSize is defined with __AMDGCN_WAVEFRONT_SIZE and there are a bunch of uses of __AMDGCN_WAVEFRONT_SIZE or warpSize as constants: https://github.com/search?q=repo%3AROCm%2Fclr%20__AMDGCN_WAVEFRONT_SIZE=code These can be fixed relatively easily by conditioning

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Yaxun Liu via cfe-commits
yxsamliu wrote: for example, rocprim assumes warpSize is constant https://github.com/ROCm/rocPRIM/blob/6325547d514b46d1ab51aff0195851b3fcc626d1/rocprim/include/rocprim/intrinsics/thread.hpp#L54 since device_warp_size() is used as non-type template arguments and these code are not conditioned

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Yaxun Liu via cfe-commits
@@ -4306,10 +4306,10 @@ // Begin amdgcn tests -// RUN: %clang -mcpu=gfx803 -E -dM %s -o - 2>&1 \ +// RUN: %clang -mcpu=gfx803 -E -dM -Xclang -fcuda-is-device %s -o - 2>&1 \ yxsamliu wrote: C code compiled with target amdgcn should not

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Yaxun Liu via cfe-commits
@@ -6,32 +6,32 @@ // R600-based processors. // -// RUN: %clang -E -dM -target r600 -mcpu=r600 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s -DCPU=r600 -// RUN: %clang -E -dM -target r600 -mcpu=rv630 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s -DCPU=r600

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Yaxun Liu via cfe-commits
yxsamliu wrote: Did you try this patch with internal PSDB? This will likely break all HIP programs. This is because HIP is single source program and users usually expect the common device-side predefined macros is seen in both host and device compilations. e.g. they could write a kernel

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Pierre van Houtryve via cfe-commits
Pierre-vh wrote: > This was the original behavior of my patch, but I reverted it because it > broke all the HIP headers that were unintentionally relying on this. Has that > been resolved? Was an issue opened for that? How many headers are affected?

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Joseph Huber via cfe-commits
jhuber6 wrote: This was the original behavior of my patch, but I reverted it because it broke all the HIP headers that were unintentionally relying on this. Has that been resolved? https://github.com/llvm/llvm-project/pull/83558 ___ cfe-commits

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Pierre van Houtryve via cfe-commits
https://github.com/Pierre-vh updated https://github.com/llvm/llvm-project/pull/83558 >From 3730631ac58425f559f4bc3cfe3da89e6367c1c5 Mon Sep 17 00:00:00 2001 From: pvanhout Date: Fri, 1 Mar 2024 12:43:55 +0100 Subject: [PATCH 1/2] [clang][AMDGPU] Don't define feature macros on host code Those

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Matt Arsenault via cfe-commits
@@ -292,8 +292,14 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions , } Builder.defineMacro(Twine("__") + Twine(CanonName) + Twine("__")); + + // Don't emit feature macros in host code because in such cases the + // feature list is not accurate. + if

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Pierre van Houtryve (Pierre-vh) Changes Those macros are unreliable because our features are mostly uninitialized at that stage, so any macro we define is unreliable. Fixes SWDEV-447308 --- Full diff:

[clang] [clang][AMDGPU] Don't define feature macros on host code (PR #83558)

2024-03-01 Thread Pierre van Houtryve via cfe-commits
https://github.com/Pierre-vh created https://github.com/llvm/llvm-project/pull/83558 Those macros are unreliable because our features are mostly uninitialized at that stage, so any macro we define is unreliable. Fixes SWDEV-447308 >From 3730631ac58425f559f4bc3cfe3da89e6367c1c5 Mon Sep 17