HISTOGRAM, CAPP

In statistics, a histogram is a plot of 'possible values of elements' on x-axis vs 'frequency of occurrence' of that element' on y-axis. In this benchmark, we generate an array of dimensions nx times ny. Associated with each element ("pixel") of the array is a randomly generated n-bit value (between 0 to 2^n-1). Next, we are counting the frequency of occurrence of each element and storing this in another array (hist) of size 2^n. This is how we obtain the histogram of input array. Histograms are used extensively in the field of Image Processing.

Code Snippet
 
// int: size = 262144, pixel_value
// int: depth = 16 (depth := number of bits per pixel).
// int: array, hist
// The image "array" has a data distribution such that half of the memory accesses made by the array "hist" have a stride less than 128.
// Array "hist" is of size depth.

Code snippet


for( i = 0; i < size; i++ )
   hist[(int)array[i]]++;