81 size_t b = (1 + std::sqrt(1 + 8 *
i)) / 2;
82 size_t a =
i - b * (b - 1) / 2;
143 for (
size_t i = 0;
i < size; ++
i)
211 if (
section == std::numeric_limits<uintmax_t>::max())
Provides utility functions and classes for CUDA operations.
constexpr size_t get_num_threads()
Gets the total number of threads in the kernel launch (compile-time).
T * memset_within_device(T *d_arr, size_t size, int value)
Sets a region of device memory to a specific byte value.
T * copy_from_device(const T *d_arr, size_t size)
Allocates host memory and copies data from device memory to it.
void device_free(T *d_arr)
Frees memory on the CUDA device.
T * copy_to_device(T *d_arr, const T *arr, size_t size)
Copies data from host memory to existing device memory.
__device__ __forceinline__ size_t get_tid()
Gets the global thread ID within a CUDA kernel launch.
T * alloc_to_device(size_t size)
Allocates memory on the CUDA device.
size_t seq_find_mismatch(const uintmax_t *const arr1, const uintmax_t *const arr2, size_t size)
Sequential implementation of finding the first mismatching word between two arrays.
__global__ void par_get_section_diff(uintmax_t *tree, uintmax_t *section, size_t n)
Parallel kernel to identify and record the index of the first non-zero element.
__global__ void naive_leftmost_prisoner(uintmax_t *p, size_t n)
Parallel kernel to find the leftmost non-zero element in an array.
size_t par_find_mismatch(const uintmax_t *const d_a, const uintmax_t *const b, uintmax_t *d_large_block, size_t n)
GPU-accelerated implementation of finding the first mismatching word with pre-allocated memory.
uintmax_t * alloc_large_block_to_device(size_t n)
Allocates a large block of device memory for parallel mismatch operations.
__global__ void par_sig_sqrt(const uintmax_t *const p1, uintmax_t *p2, uintmax_t *sig_out, size_t n)
CUDA kernel that implements the first phase of the square root decomposition.