#pragma once
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <vector>
#include <stdint.h>
void check_cuda_error(cudaError_t error, const char *msg);

template <typename T>
static constexpr T max_value_unsigned = ~static_cast<T>(0);

template <typename T>
static constexpr T max_value_signed =
    static_cast<T>(
        (static_cast<std::make_unsigned_t<T>>(1) << (sizeof(T) * 8 - 1)) - 1
    );

template<typename data_type>
    __device__ data_type my_abs_int(data_type x) {
         return x < 0 ? -x : x;
}

uint64_t coalescence_padded_size(uint64_t max_hit_count, uint64_t total_thread_count, uint64_t block_size);
uint64_t coalescence_padded_size(uint64_t max_hit_count, uint64_t hpw_times_block_size);
uint64_t block_count(uint64_t thread_count, uint32_t block_size);

void sync_host_streams(std::vector<cudaStream_t> &  streams);


