test03.cu文件中的代码:
1 #include <stdio.h>
2 //#include <cuda.h>
3 #include "cutil.h"
4 //#include "device_functions.h"
5 #include "sm_12_atomic_functions.h"
6 #define SIZE 100 * 1024 * 1024
7
8 void generateRandomCharArray(unsigned char *, int );
9 __global__ void histo_kernel(unsigned char *, unsigned int *, int);
10
11 int main()
12 {
13 unsigned char *buffer = (unsigned char *)malloc(SIZE * sizeof(char));
14 generateRandomCharArray(buffer, SIZE);
15 cudaEvent_t start, stop;
16 CUDA_SAFE_CALL(cudaEventCreate( &start));
17 CUDA_SAFE_CALL(cudaEventCreate( &stop));
18 CUDA_SAFE_CALL(cudaEventRecord(start, 0));
19 unsigned char *dev_buffer;
20 unsigned int *dev_histo;
21 CUDA_SAFE_CALL(cudaMalloc((void **)&dev_buffer, SIZE * sizeof(char)));