Advanced Chunk Processing Library 0.2.0
A comprehensive C++ library for advanced data chunking strategies and processing operations
Loading...
Searching...
No Matches
gpu_chunking Namespace Reference

Classes

class  GPUChunking
 

Functions

__global__ void chunk_kernel (const int *data, int *chunk_boundaries, int data_size, int window_size, float threshold)
 

Function Documentation

◆ chunk_kernel()

__global__ void gpu_chunking::chunk_kernel ( const int *  data,
int *  chunk_boundaries,
int  data_size,
int  window_size,
float  threshold 
)

Definition at line 21 of file gpu_chunking.hpp.

22 {
23 int idx = blockIdx.x * blockDim.x + threadIdx.x;
24 if (idx >= data_size - window_size)
25 return;
26
27 // Compute local statistics for the window
28 float window_sum = 0.0f;
29 float window_max = data[idx];
30 float window_min = data[idx];
31
32 for (int i = 0; i < window_size; ++i) {
33 int current = data[idx + i];
34 window_sum += current;
35 window_max = max(window_max, (float)current);
36 window_min = min(window_min, (float)current);
37 }
38
39 float window_mean = window_sum / window_size;
40 float variance = 0.0f;
41
42 // Compute variance
43 for (int i = 0; i < window_size; ++i) {
44 float diff = data[idx + i] - window_mean;
45 variance += diff * diff;
46 }
47 variance /= window_size;
48
49 // Determine if this position should be a chunk boundary
50 bool is_boundary = false;
51 if (idx > 0) {
52 float prev_value = data[idx - 1];
53 float current_value = data[idx];
54 float value_diff = abs(current_value - prev_value);
55 float range = window_max - window_min;
56
57 is_boundary = (value_diff > threshold * range) && (variance > threshold * window_mean);
58 }
59
60 chunk_boundaries[idx] = is_boundary ? 1 : 0;
61}