|
|
@ -7,7 +7,7 @@ __kernel void square(__global float* inputData, |
|
|
|
} |
|
|
|
|
|
|
|
// TODO |
|
|
|
// |
|
|
|
// id := get_global_id(0) |
|
|
|
// histogram[data[id]] := histogram[data[id]] + 1 |
|
|
|
// |
|
|
|
// SYNCHRONIZATION! |
|
|
@ -27,7 +27,7 @@ void histogram_global(__global int* data, __global int* histogram) |
|
|
|
// lhistogram[LID] := 0 |
|
|
|
// BARRIER |
|
|
|
// |
|
|
|
// Add data to local histogram |
|
|
|
// lhistogram[data[id]] := lhistogram[data[id]] + 1 |
|
|
|
// |
|
|
|
// BARRIER |
|
|
|
// |
|
|
@ -47,7 +47,7 @@ void histogram_local(__global int* data, __global int* histogram, __local int* l |
|
|
|
|
|
|
|
atomic_add(&lhistogram[data[id]], 1.0f); |
|
|
|
|
|
|
|
barrier(CLK_GLOBAL_MEM_FENCE); // LOCAL??? |
|
|
|
barrier(CLK_LOCAL_MEM_FENCE); // LOCAL??? |
|
|
|
|
|
|
|
if (lid < histogramSize) { |
|
|
|
atomic_add(&histogram[lid], lhistogram[lid]); |
|
|
@ -69,7 +69,7 @@ void reduce_global(__global float* data) |
|
|
|
{ |
|
|
|
int id = get_global_id(0); |
|
|
|
|
|
|
|
// one right shift is = divide number by two |
|
|
|
// one right shift = divide number by two |
|
|
|
for (size_t s = get_global_size(0) / 2; s > 0; s >>= 1) { |
|
|
|
if (id < s) { |
|
|
|
data[id] = data[id] + data[id + s]; |
|
|
@ -175,6 +175,9 @@ void compact_exscan(__global int* pred, __global int* prefSum) |
|
|
|
// VALUE := data[ID] |
|
|
|
// BARRIER |
|
|
|
// IF pred[ID] == 1 THEN |
|
|
|
// IF ID == 0 THEN |
|
|
|
// data[0] = VALUE |
|
|
|
// ELSE |
|
|
|
// data[prefSum[ID]] = VALUE |
|
|
|
__kernel |
|
|
|
void compact_compact(__global int* data, __global int* pred, __global int* prefSum) |
|
|
|