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

Prevent signed integer overflow in check_scan_over_group #776

Merged
merged 10 commits into from
Sep 13, 2023
7 changes: 5 additions & 2 deletions tests/group_functions/group_scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ struct joint_scan_group {

sycl::nd_range<D> executionRange(work_group_range, work_group_range);

const size_t sizes[3] = {5, work_group_size / 2, 3 * work_group_size};
const size_t sizes[2] = {5, 2};
for (size_t size : sizes) {
check_scan<D, T, U>(queue, size, executionRange, OperatorT(), op_name,
false);
Expand Down Expand Up @@ -257,7 +257,7 @@ struct init_joint_scan_group {

size_t work_group_size = work_group_range.size();

const size_t sizes[3] = {5, work_group_size / 2, 3 * work_group_size};
const size_t sizes[2] = {5, 2};
for (size_t size : sizes) {
check_scan<D, T, U, I>(queue, size, executionRange, OperatorT(),
op_name, true);
Expand Down Expand Up @@ -385,6 +385,9 @@ template <int D, typename T, typename U = T, typename OpT>
void check_scan_over_group(sycl::queue& queue, sycl::range<D> range, OpT op,
const std::string& op_name, bool with_init) {
auto range_size = range.size();
REQUIRE(((range_size * (range_size + 1) / 2) + T(init)) <=
std::numeric_limits<T>::max());

ScanOverGroupDataStruct<T, U> host_data{range_size};
{
auto ref_input_sycl = host_data.create_ref_input_buffer();
Expand Down