-
Notifications
You must be signed in to change notification settings - Fork 793
[SYCL] Allow _Bitint of size greater than 128 bits when -fintelfpga i… #6152
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
Changes from all commits
ccd1d1a
c308ba8
2f91417
d8629a7
da2d0d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2306,7 +2306,7 @@ QualType Sema::BuildBitIntType(bool IsUnsigned, Expr *BitWidth, | |
} | ||
|
||
const TargetInfo &TI = getASTContext().getTargetInfo(); | ||
if (NumBits > TI.getMaxBitIntWidth()) { | ||
if (NumBits > TI.getMaxBitIntWidth() && !Context.getLangOpts().IntelFPGA) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't there be some code handling the larger size for this target? Is just removing the error enough? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it is enough. The actual handling is done by the backend or via library calls. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, this is not enough. We need to make sure we don't emit anything too large for the LLVM backend. IMO, the RIGHT place for this is probably to get the proper target-info for the FPGA to change its answer to 'getMaxBitIntWidth' based on the FPGA status to the LLVM max value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If we go with this way in any following patch, 2048 is a reasonable upper-bound limit for the FPGA target. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To clarify: My concern is this: https://llvm.org/doxygen/classllvm_1_1IntegerType.html#af13295ff815293f6c5708ebdbae1338da1ccefdf8a7414a6829f888e5071e0379 if there is a reasonable max for the FPGA target, we should definitely do that too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change looks wrong to me -- LLVM has a max bit width size that we must ensure the user stays within the bounds of. Passing the intel FPGA flag won't make a bit of difference in that case, it'll just crash in the backend. |
||
Diag(Loc, diag::err_bit_int_max_size) | ||
<< IsUnsigned << static_cast<uint64_t>(TI.getMaxBitIntWidth()); | ||
return QualType(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %clang_cc1 -no-opaque-pointers -fsycl-is-host -fintelfpga -triple x86_64 -emit-llvm %s -o - | FileCheck %s | ||
|
||
// This test checks that we generate appropriate code for division | ||
// operations of _BitInts of size greater than 128 bits, since it | ||
// is allowed when -fintelfpga is enabled. | ||
|
||
// CHECK: define{{.*}} void @_Z3fooDB211_S_(i211* {{.*}} sret(i211) align 8 %agg.result, i211* {{.*}} byval(i211) align 8 %[[ARG1:[0-9]+]], i211* {{.*}} byval(i211) align 8 %[[ARG2:[0-9]+]]) | ||
signed _BitInt(211) foo(signed _BitInt(211) a, signed _BitInt(211) b) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good test, now try it with |
||
// CHECK: %[[VAR_A:a]].addr = alloca i211, align 8 | ||
// CHECK: %[[VAR_B:b]].addr = alloca i211, align 8 | ||
// CHECK: %[[VAR_A]] = load i211, i211* %[[ARG1]], align 8 | ||
// CHECK: %[[VAR_B]] = load i211, i211* %[[ARG2]], align 8 | ||
// CHECK: store i211 %[[VAR_A]], i211* %[[VAR_A]].addr, align 8 | ||
// CHECK: store i211 %[[VAR_B]], i211* %[[VAR_B]].addr, align 8 | ||
// CHECK: %[[TEMP1:[0-9]+]] = load i211, i211* %[[VAR_A]].addr, align 8 | ||
// CHECK: %[[TEMP2:[0-9]+]] = load i211, i211* %[[VAR_B]].addr, align 8 | ||
// CHECK: %div = sdiv i211 %[[TEMP1]], %[[TEMP2]] | ||
// CHECK: store i211 %div, i211* %agg.result, align 8 | ||
// CHECK: %[[RES:[0-9+]]] = load i211, i211* %agg.result, align 8 | ||
// CHECK: store i211 %[[RES]], i211* %agg.result, align 8 | ||
// CHECK: ret void | ||
return a / b; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// RUN: %clang_cc1 -no-opaque-pointers -fsycl-is-device -fintelfpga -triple spir64_fpga -IInputs -emit-llvm %s -o - | FileCheck %s | ||
|
||
// This test checks that we generate appropriate code for division | ||
// operations of _BitInts of size greater than 128 bits, since it | ||
// is allowed when -fintelfpga is enabled. | ||
|
||
#include "Inputs/sycl.hpp" | ||
|
||
// CHECK: define{{.*}} void @_Z3fooDB211_S_(i211 addrspace(4)* {{.*}} sret(i211) align 8 %agg.result, i211* {{.*}} byval(i211) align 8 %[[ARG1:[0-9]+]], i211* {{.*}} byval(i211) align 8 %[[ARG2:[0-9]+]]) | ||
signed _BitInt(211) foo(signed _BitInt(211) a, signed _BitInt(211) b) { | ||
// CHECK: %[[VAR_A:a]] = load i211, i211* %[[ARG1]], align 8 | ||
// CHECK: %[[VAR_B:b]] = load i211, i211* %[[ARG2]], align 8 | ||
// CHECK: %[[RES:div]] = sdiv i211 %[[VAR_A]], %[[VAR_B]] | ||
// CHECK: store i211 %[[RES]], i211 addrspace(4)* %agg.result, align 8 | ||
// CHECK: ret void | ||
return a / b; | ||
} | ||
|
||
int main() { | ||
sycl::handler h; | ||
auto lambda = []() { | ||
_BitInt(211) a, b = 3, c = 4; | ||
a = foo(b, c); | ||
}; | ||
h.single_task(lambda); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %clang_cc1 -opaque-pointers -fsycl-is-host -fintelfpga -triple x86_64 -emit-llvm %s -o - | FileCheck %s | ||
|
||
// This test checks that we generate appropriate code for division | ||
// operations of _BitInts of size greater than 128 bits, since it | ||
// is allowed when -fintelfpga is enabled. | ||
|
||
// CHECK: define{{.*}} void @_Z3fooDB211_S_(ptr {{.*}} sret(i211) align 8 %agg.result, ptr {{.*}} byval(i211) align 8 %[[ARG1:[0-9]+]], ptr {{.*}} byval(i211) align 8 %[[ARG2:[0-9]+]]) | ||
signed _BitInt(211) foo(signed _BitInt(211) a, signed _BitInt(211) b) { | ||
// CHECK: %[[VAR_A:a]].addr = alloca i211, align 8 | ||
// CHECK: %[[VAR_B:b]].addr = alloca i211, align 8 | ||
// CHECK: %[[VAR_A]] = load i211, ptr %[[ARG1]], align 8 | ||
// CHECK: %[[VAR_B]] = load i211, ptr %[[ARG2]], align 8 | ||
// CHECK: store i211 %[[VAR_A]], ptr %[[VAR_A]].addr, align 8 | ||
// CHECK: store i211 %[[VAR_B]], ptr %[[VAR_B]].addr, align 8 | ||
// CHECK: %[[TEMP1:[0-9]+]] = load i211, ptr %[[VAR_A]].addr, align 8 | ||
// CHECK: %[[TEMP2:[0-9]+]] = load i211, ptr %[[VAR_B]].addr, align 8 | ||
// CHECK: %div = sdiv i211 %[[TEMP1]], %[[TEMP2]] | ||
// CHECK: store i211 %div, ptr %agg.result, align 8 | ||
// CHECK: %[[RES:[0-9+]]] = load i211, ptr %agg.result, align 8 | ||
// CHECK: store i211 %[[RES]], ptr %agg.result, align 8 | ||
// CHECK: ret void | ||
return a / b; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// RUN: %clang_cc1 -opaque-pointers -fsycl-is-device -fintelfpga -triple spir64_fpga -IInputs -emit-llvm %s -o - | FileCheck %s | ||
|
||
// This test checks that we generate appropriate code for division | ||
// operations of _BitInts of size greater than 128 bits, since it | ||
// is allowed when -fintelfpga is enabled. | ||
|
||
#include "Inputs/sycl.hpp" | ||
|
||
// CHECK: define{{.*}} void @_Z3fooDB211_S_(ptr addrspace(4) {{.*}} sret(i211) align 8 %agg.result, ptr {{.*}} byval(i211) align 8 %[[ARG1:[0-9]+]], ptr {{.*}} byval(i211) align 8 %[[ARG2:[0-9]+]]) | ||
signed _BitInt(211) foo(signed _BitInt(211) a, signed _BitInt(211) b) { | ||
// CHECK: %[[VAR_A:a]] = load i211, ptr %[[ARG1]], align 8 | ||
// CHECK: %[[VAR_B:b]] = load i211, ptr %[[ARG2]], align 8 | ||
// CHECK: %[[RES:div]] = sdiv i211 %[[VAR_A]], %[[VAR_B]] | ||
// CHECK: store i211 %[[RES]], ptr addrspace(4) %agg.result, align 8 | ||
// CHECK: ret void | ||
return a / b; | ||
} | ||
|
||
int main() { | ||
sycl::handler h; | ||
auto lambda = []() { | ||
_BitInt(211) a, b = 3, c = 4; | ||
a = foo(b, c); | ||
}; | ||
h.single_task(lambda); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -fintelfpga -verify=device-intelfpga -fsyntax-only %s | ||
// RUN: %clang_cc1 -fsycl-is-host -fintelfpga -verify=host-intelfpga -fsyntax-only %s | ||
// RUN: %clang_cc1 -fsycl-is-device -verify=device -fsyntax-only %s | ||
// RUN: %clang_cc1 -fsycl-is-host -verify=host -fsyntax-only %s | ||
|
||
// Tests that we do not issue errors for _Bitints of size greater than 128 | ||
// when -fintelfpga is enabled. The backend is expected to be able to handle | ||
// this. When -fintelfpga is not passed, we continue to diagnose. | ||
|
||
// device-intelfpga-no-diagnostics | ||
// host-intelfpga-no-diagnostics | ||
// device-error@+2 3{{signed _BitInt of bit sizes greater than 128 not supported}} | ||
// host-error@+1 3{{signed _BitInt of bit sizes greater than 128 not supported}} | ||
signed _BitInt(211) foo(signed _BitInt(211) a, signed _BitInt(211) b) { | ||
return a / b; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.