<commit_before>#include <gtest/gtest.h>
#include <thrust/device_vector.h>
#include <libsgm.h>
#include "internal.h"
#include "generator.hpp"

static bool is_cuda_input(sgm::EXECUTE_INOUT type) { return (type & 0x1) > 0; }
static bool is_cuda_output(sgm::EXECUTE_INOUT type) { return (type & 0x2) > 0; }

class LibSGM : public testing::TestWithParam<std::tuple<int, int, int, sgm::EXECUTE_INOUT>>
{
public:
	static constexpr int WIDTH = 1024, HEIGHT = 440;
	int input_depth_bits_;
	int output_depth_bits_;
	int disparity_size_;
	sgm::EXECUTE_INOUT inout_type_;

	size_t src_size_, dst_size_;
	thrust::device_vector<uint8_t> d_src_left_, d_src_right_, d_dst_;
	thrust::host_vector<uint8_t>   h_src_left_, h_src_right_, h_dst_;

	virtual void SetUp()
	{
		std::tie(input_depth_bits_, output_depth_bits_, disparity_size_, inout_type_) = GetParam();
		src_size_ = WIDTH * HEIGHT * input_depth_bits_ / 8;
		dst_size_ = WIDTH * HEIGHT * output_depth_bits_ / 8;

		h_src_left_  = generate_random_sequence<uint8_t>(src_size_);
		h_src_right_ = generate_random_sequence<uint8_t>(src_size_);

		if(is_cuda_input(inout_type_))
		{
			d_src_left_ = h_src_left_;
			d_src_right_ = h_src_right_;
		}

		if(is_cuda_output(inout_type_))
		{
			d_dst_.resize(dst_size_);
		}
		else
		{
			h_dst_.resize(dst_size_);
		}
	}
};

TEST_P(LibSGM, Integrated)
{

	void *src_left, *src_right;
	if(is_cuda_input(inout_type_))
	{
		src_left = d_src_left_.data().get();
		src_right = d_src_right_.data().get();
	}
	else
	{
		src_left = h_src_left_.data();
		src_right = h_src_right_.data();
	}

	void *dst;
	if(is_cuda_output(inout_type_))
	{
		dst = d_dst_.data().get();
	}
	else
	{
		dst = h_dst_.data();
	}

	sgm::StereoSGM sgm(WIDTH, HEIGHT, disparity_size_, input_depth_bits_, output_depth_bits_, inout_type_);
	sgm.execute(src_left, src_right, dst);

	CudaKernelCheck();
}

INSTANTIATE_TEST_CASE_P(LibSGM_Test, LibSGM, testing::Combine(
	testing::Values(8, 16),
	testing::Values(8, 16),
	testing::Values(64, 128),
	testing::Values(
		sgm::EXECUTE_INOUT_HOST2HOST,
		sgm::EXECUTE_INOUT_HOST2CUDA,
		sgm::EXECUTE_INOUT_CUDA2HOST,
		sgm::EXECUTE_INOUT_CUDA2CUDA
	)
));
<commit_msg>Remove additional newline<commit_after>#include <gtest/gtest.h>
#include <thrust/device_vector.h>
#include <libsgm.h>
#include "internal.h"
#include "generator.hpp"

static bool is_cuda_input(sgm::EXECUTE_INOUT type) { return (type & 0x1) > 0; }
static bool is_cuda_output(sgm::EXECUTE_INOUT type) { return (type & 0x2) > 0; }

class LibSGM : public testing::TestWithParam<std::tuple<int, int, int, sgm::EXECUTE_INOUT>>
{
public:
	static constexpr int WIDTH = 1024, HEIGHT = 440;
	int input_depth_bits_;
	int output_depth_bits_;
	int disparity_size_;
	sgm::EXECUTE_INOUT inout_type_;

	size_t src_size_, dst_size_;
	thrust::device_vector<uint8_t> d_src_left_, d_src_right_, d_dst_;
	thrust::host_vector<uint8_t>   h_src_left_, h_src_right_, h_dst_;

	virtual void SetUp()
	{
		std::tie(input_depth_bits_, output_depth_bits_, disparity_size_, inout_type_) = GetParam();
		src_size_ = WIDTH * HEIGHT * input_depth_bits_ / 8;
		dst_size_ = WIDTH * HEIGHT * output_depth_bits_ / 8;

		h_src_left_  = generate_random_sequence<uint8_t>(src_size_);
		h_src_right_ = generate_random_sequence<uint8_t>(src_size_);

		if(is_cuda_input(inout_type_))
		{
			d_src_left_ = h_src_left_;
			d_src_right_ = h_src_right_;
		}

		if(is_cuda_output(inout_type_))
		{
			d_dst_.resize(dst_size_);
		}
		else
		{
			h_dst_.resize(dst_size_);
		}
	}
};

TEST_P(LibSGM, Integrated)
{

	void *src_left, *src_right;
	if(is_cuda_input(inout_type_))
	{
		src_left = d_src_left_.data().get();
		src_right = d_src_right_.data().get();
	}
	else
	{
		src_left = h_src_left_.data();
		src_right = h_src_right_.data();
	}

	void *dst;
	if(is_cuda_output(inout_type_))
	{
		dst = d_dst_.data().get();
	}
	else
	{
		dst = h_dst_.data();
	}

	sgm::StereoSGM sgm(WIDTH, HEIGHT, disparity_size_, input_depth_bits_, output_depth_bits_, inout_type_);
	sgm.execute(src_left, src_right, dst);

	CudaKernelCheck();
}

INSTANTIATE_TEST_CASE_P(LibSGM_Test, LibSGM, testing::Combine(
	testing::Values(8, 16),
	testing::Values(8, 16),
	testing::Values(64, 128),
	testing::Values(
		sgm::EXECUTE_INOUT_HOST2HOST,
		sgm::EXECUTE_INOUT_HOST2CUDA,
		sgm::EXECUTE_INOUT_CUDA2HOST,
		sgm::EXECUTE_INOUT_CUDA2CUDA
	)
));
{'fraction_non_alphanumeric': 0.1300624855357556, 'fraction_numerical': 0.015737097894006017, 'mean_word_length': 5.711180124223603, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, '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': '1157868', 'n_tokens_mistral': 1983, 'n_tokens_neox': 1834, 'n_words': 280}