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

[SYCLomatic] Remove -fgpu-exclude-wrong-side-overloads to avoid other parsing errors #2662

Merged
merged 7 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10683,8 +10683,25 @@ bool clang::isBetterOverloadCandidate(
// to determine which is better.
if (S.getLangOpts().CUDA && Cand1.Function && Cand2.Function) {
FunctionDecl *Caller = S.getCurFunctionDecl(/*AllowLambda=*/true);
#ifdef SYCLomatic_CUSTOMIZATION
auto Preference1 = S.CUDA().IdentifyPreference(Caller, Cand1.Function);
auto Preference2 = S.CUDA().IdentifyPreference(Caller, Cand2.Function);
if (Preference1 != Preference2)
return Preference1 > Preference2;
// This is a workaround to align to the behavior of nvcc
const CXXMethodDecl *MD1 = dyn_cast<CXXMethodDecl>(Cand1.Function);
const CXXMethodDecl *MD2 = dyn_cast<CXXMethodDecl>(Cand2.Function);
if (MD1 && MD2 && Caller && !Caller->hasAttr<CUDAHostAttr>()) {
if ((MD1->isMoveAssignmentOperator() ||
MD1->isCopyAssignmentOperator()) &&
!(MD2->isMoveAssignmentOperator() || MD2->isCopyAssignmentOperator()))
return true;
}
return false;
#else
return S.CUDA().IdentifyPreference(Caller, Cand1.Function) >
S.CUDA().IdentifyPreference(Caller, Cand2.Function);
#endif // SYCLomatic_CUSTOMIZATION
}

// General member function overloading is handled above, so this only handles
Expand Down
4 changes: 0 additions & 4 deletions clang/lib/Tooling/CommonOptionsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,6 @@ llvm::Error CommonOptionsParser::init(
Adjuster = combineAdjusters(
std::move(Adjuster),
getInsertArgumentAdjuster("-D__NVCC__", ArgumentInsertPosition::BEGIN));
Adjuster = combineAdjusters(
std::move(Adjuster),
getInsertArgumentAdjuster("-fgpu-exclude-wrong-side-overloads",
ArgumentInsertPosition::BEGIN));
}
#endif // SYCLomatic_CUSTOMIZATION
AdjustingCompilations->appendArgumentsAdjuster(Adjuster);
Expand Down
4 changes: 0 additions & 4 deletions clang/lib/Tooling/Tooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,6 @@ int ClangTool::processFiles(llvm::StringRef File, bool &ProcessingFailed,
std::move(CudaArgsAdjuster),
getInsertArgumentAdjuster(CUDAVerMinor.c_str(),
ArgumentInsertPosition::BEGIN));
CudaArgsAdjuster = combineAdjusters(
std::move(CudaArgsAdjuster),
getInsertArgumentAdjuster("-fgpu-exclude-wrong-side-overloads",
ArgumentInsertPosition::BEGIN));
CudaArgsAdjuster =
combineAdjusters(std::move(CudaArgsAdjuster),
getInsertArgumentAdjuster(
Expand Down
8 changes: 0 additions & 8 deletions clang/test/dpct/compat_with_clang.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,8 @@
// RUN: FileCheck %s --match-full-lines --input-file %T/compat_with_clang/compat_with_clang.dp.cpp
// RUN: %if build_lit %{icpx -c -fsycl %T/compat_with_clang/compat_with_clang.dp.cpp -o %T/compat_with_clang/compat_with_clang.dp.o %}

#include "cuda_fp16.h"
#include <cstdint>

// CHECK: inline void foo1(sycl::half2 *array, sycl::half a) {
// CHECK-NEXT: array[dpct::reverse_bits<unsigned int>(123)] = {a, sycl::vec<float, 1>(2.3f).convert<sycl::half, sycl::rounding_mode::automatic>()[0]};
// CHECK-NEXT: }
__device__ inline void foo1(__half2 *array, __half a) {
array[__brev(123)] = {a, __float2half(2.3f)};
}

// CHECK: void foo2(int a, int b) {
// CHECK-NEXT: dpct::dim3 block{dpct::min(512, uint32_t(a * b))};
// CHECK-NEXT: }
Expand Down
14 changes: 14 additions & 0 deletions clang/test/dpct/compat_with_clang_4.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1
// RUN: dpct --format-range=none -out-root %T/compat_with_clang_4 %s --cuda-include-path="%cuda-path/include" --stop-on-parse-err
// RUN: FileCheck %s --match-full-lines --input-file %T/compat_with_clang_4/compat_with_clang_4.dp.cpp
// RUN: %if build_lit %{icpx -c -fsycl %T/compat_with_clang_4/compat_with_clang_4.dp.cpp -o %T/compat_with_clang_4/compat_with_clang_4.dp.o %}

#include "cuda_fp16.h"

// CHECK: inline void foo1(sycl::half2 *array, sycl::half a) {
// CHECK-NEXT: array[dpct::reverse_bits<unsigned int>(123)] = {a, sycl::vec<float, 1>(2.3f).convert<sycl::half, sycl::rounding_mode::automatic>()[0]};
// CHECK-NEXT: }
__device__ inline void foo1(__half2 *array, __half a) {
array[__brev(123)] = {a, __float2half(2.3f)};
}