Skip to content

Out-of-bounds error message often omits or shows incorrect bounds for negative indices. #280

Description

@GagaLP

The out-of-bounds (OOB) error message displays incorrect information when the bounds start at [0,0,0] and the access is off by one. For example, I encountered the following error:

[2024-09-04 16:41:12.700] [0] [error] Out-of-bounds access detected in device kernel T4: accessor 1 attempted to access buffer B3 indices between [0,0,0] - [12,41,1] and outside the declared range [0,0,0] - [12,41,1].

While creating a minimal example, I found that the OOB message is sometimes omitted entirely. Here's a sample code snippet that reproduces this issue:

#include <celerity.h>

int main(void) {
	celerity::distr_queue q;

	constexpr size_t size = 256;
	celerity::buffer<float, 2> matrix{{size, size}};

	q.submit([&](celerity::handler& cgh) {
		celerity::accessor matrix_acc{matrix, cgh, celerity::access::one_to_one{}, celerity::write_only, celerity::no_init};
		cgh.parallel_for(celerity::range<2>(size, size), [=](celerity::item<2> item) {
			matrix_acc[{item.get_id(0) - 1, item.get_id(1)}] = 0;
		});
	});


	return EXIT_SUCCESS;
}

When only one index of a 2D accessor is out-of-bounds (specifically when the index is -1), the error message is completely omitted. However, when both indices are out-of-bounds (both set to -1), the following error message appears:

[2024-09-04 17:33:57.485] [0] [error] Out-of-bounds access detected in device kernel T1: accessor 0 attempted to access buffer B0 indicies between [0,0,0] - [255,255,1] and outside the declared range [0,0,0] - [256,256,1].

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions