<commit_before>#include "../tests.h"

// Parallel reduction sum

bool test4() {
	static const size_t N = 1024;

	using namespace cl::sycl;

	{
		queue myQueue;

		buffer<int> V(N);

		myQueue.submit([&](handler& cgh) {
			auto v = V.get_access<access::mode::read_write>(cgh);

			// Init
			cgh.parallel_for<class init>(range<1>(N), [=](id<1> index) {
				v[index] = index;
			});

			// Calculate reduction sum
			for(size_t stride = 1; stride < N; stride *= 2) {
				cgh.parallel_for<class reduction_sum>(range<1>(N / 2 / stride), [=](id<1> index) {
					auto i = 2 * stride * index;
					v[i] += v[i + stride];
				});
			}
		});

		auto v = V.get_access<access::mode::read, access::target::host_buffer>();
		int sum = ((uint64_t)N * (uint64_t)(N - 1)) / 2;

		if(v[0] != sum) {
			debug() << "wrong sum, should be" << sum << "- is" << v[0];
				return false;
			}
		}

	return true;
}
<commit_msg>tests - fixed test4 to properly pass the stride.<commit_after>#include "../tests.h"

// Parallel reduction sum

bool test4() {
	static const size_t N = 1024;

	using namespace cl::sycl;

	{
		queue myQueue;

		buffer<int> V(N);
		buffer<int> stride_(1);
		{
			auto s = stride_.get_access<access::mode::discard_write, access::target::host_buffer>();
			s[0] = 1;
		}

		myQueue.submit([&](handler& cgh) {
			auto v = V.get_access<access::mode::read_write>(cgh);

			// Init
			cgh.parallel_for<class init>(range<1>(N), [=](id<1> index) {
				v[index] = index;
			});

			auto s = stride_.get_access<access::mode::read_write>(cgh);

			// Calculate reduction sum
			for(size_t stride = 1; stride < N; stride *= 2) {
				cgh.parallel_for<class reduction_sum>(range<1>(N / 2 / stride), [=](id<1> index) {
					auto i = 2 * s[0] * index;
					v[i] += v[i + s[0]];
					s[0] *= 2;
				});
			}
		});

		auto v = V.get_access<access::mode::read, access::target::host_buffer>();
		int sum = ((uint64_t)N * (uint64_t)(N - 1)) / 2;

		if(v[0] != sum) {
			debug() << "wrong sum, should be" << sum << "- is" << v[0];
				return false;
			}
		}

	return true;
}

{'fraction_non_alphanumeric': 0.20126705653021443, 'fraction_numerical': 0.024366471734892786, 'mean_word_length': 3.097804391217565, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3672145', 'n_tokens_mistral': 948, 'n_tokens_neox': 792, 'n_words': 178}