OSDN Git Service

modified: utilsrc/src/Admin/Makefile
[eos/others.git] / utiltools / X86MAC64 / cuda / samples / 3_Imaging / histogram / histogram_gold.cpp
1 /*
2  * Copyright 1993-2013 NVIDIA Corporation.  All rights reserved.
3  *
4  * Please refer to the NVIDIA end user license agreement (EULA) associated
5  * with this source code for terms and conditions that govern your use of
6  * this software. Any use, reproduction, disclosure, or distribution of
7  * this software and related documentation outside the terms of the EULA
8  * is strictly prohibited.
9  *
10  */
11
12
13
14 #include <assert.h>
15 #include "histogram_common.h"
16
17
18
19 extern "C" void histogram64CPU(
20     uint *h_Histogram,
21     void *h_Data,
22     uint byteCount
23 )
24 {
25     for (uint i = 0; i < HISTOGRAM64_BIN_COUNT; i++)
26         h_Histogram[i] = 0;
27
28     assert(sizeof(uint) == 4 && (byteCount % 4) == 0);
29
30     for (uint i = 0; i < (byteCount / 4); i++)
31     {
32         uint data = ((uint *)h_Data)[i];
33         h_Histogram[(data >>  2) & 0x3FU]++;
34         h_Histogram[(data >> 10) & 0x3FU]++;
35         h_Histogram[(data >> 18) & 0x3FU]++;
36         h_Histogram[(data >> 26) & 0x3FU]++;
37     }
38 }
39
40
41
42 extern "C" void histogram256CPU(
43     uint *h_Histogram,
44     void *h_Data,
45     uint byteCount
46 )
47 {
48     for (uint i = 0; i < HISTOGRAM256_BIN_COUNT; i++)
49         h_Histogram[i] = 0;
50
51     assert(sizeof(uint) == 4 && (byteCount % 4) == 0);
52
53     for (uint i = 0; i < (byteCount / 4); i++)
54     {
55         uint data = ((uint *)h_Data)[i];
56         h_Histogram[(data >>  0) & 0xFFU]++;
57         h_Histogram[(data >>  8) & 0xFFU]++;
58         h_Histogram[(data >> 16) & 0xFFU]++;
59         h_Histogram[(data >> 24) & 0xFFU]++;
60     }
61 }