Skip to content
Open
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
6 changes: 3 additions & 3 deletions clang/lib/CodeGen/Targets/AMDGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ void AMDGPUTargetCodeGenInfo::setFunctionDeclAttributes(
M.handleAMDGPUFlatWorkGroupSizeAttr(F, FlatWGS, ReqdWGS);
} else if (M.getLangOpts().SYCLIsDevice) {
if (const auto *SYCLReqdWGS = FD->getAttr<SYCLReqdWorkGroupSizeAttr>()) {
auto GetDim = [](std::optional<llvm::APSInt> V) -> unsigned {
return V ? (unsigned)V->getZExtValue() : 1;
auto GetDim = [](std::optional<llvm::APSInt> V) -> uint64_t {
return V ? V->getZExtValue() : 1;
};
unsigned Size = GetDim(SYCLReqdWGS->getXDimVal()) *
uint64_t Size = GetDim(SYCLReqdWGS->getXDimVal()) *
GetDim(SYCLReqdWGS->getYDimVal()) *
GetDim(SYCLReqdWGS->getZDimVal());
std::string AttrVal = llvm::utostr(Size) + "," + llvm::utostr(Size);
Expand Down
27 changes: 27 additions & 0 deletions clang/test/CodeGenSYCL/reqd-work-group-size-overflow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple amdgcn-amd-amdhsa -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s

// The product of the reqd_work_group_size dimensions below is 2^32, which
// overflows a 32-bit unsigned integer. Check that the resulting
// amdgpu-flat-work-group-size function attribute reflects the full 64-bit
// product instead of a wrapped-around 32-bit value.

#include "Inputs/sycl.hpp"

using namespace sycl;
queue q;

class FunctorOverflow {
public:
[[sycl::reqd_work_group_size(65536, 65536)]] void operator()() const {}
};

int main() {
q.submit([&](handler &h) {
FunctorOverflow f;
h.single_task<class kernel_overflow>(f);
});
return 0;
}

// CHECK: define {{.*}} void @{{.*}}kernel_overflow() #[[ATTR:[0-9]+]]
// CHECK: attributes #[[ATTR]] = { {{.*}}"amdgpu-flat-work-group-size"="4294967296,4294967296"{{.*}} }
Loading