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