GPUMLib  0.2.2
GPU Machine Learning Library
CenterAttribution.cu
1 /*
2  Ricardo Quintas is a MSc Student at the University of Coimbra, Portugal
3  Copyright (C) 2009, 2010 Ricardo Quintas
4 
5  This file is part of GPUMLib.
6 
7  GPUMLib is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #include "../Common/CudaDefinitions.h"
21 #include "RBFkernels.h"
22 
23 KERNEL CenterAttribution(cudafloat *Output, int output_width, int *attrib_center){
24 
25  int bx = blockIdx.x;
26  int by = blockIdx.y;
27 
28  int idnx = blockIdx.x*blockDim.x + threadIdx.x;
29  int idny = blockIdx.y*blockDim.y + threadIdx.y;
30 
31  double min_tmp = Output[idny*output_width];
32  int idx = 0;
33 
34  for(int j = 0; j < output_width; j++){
35  if(Output[idny*output_width+j] < min_tmp){
36  min_tmp = Output[idny*output_width+j];
37  idx = j;
38  }
39  }
40 
41  attrib_center[idny] = idx;
42 }
43 
44 extern "C" void KernelCenterAttribution(cudafloat *Output, int output_height, int output_width, int *attrib_center)
45 {
46  int blockSize = 16;
47 
48  int wBlocks = 1;
49  int hBlocks = output_height/blockSize + ((output_height%blockSize == 0)?0:1);
50 
51  dim3 grid(wBlocks,hBlocks);
52  dim3 threads(blockSize,blockSize);
53  CenterAttribution<<<grid,threads>>>(Output, output_width, attrib_center);
54 }
#define KERNEL
Defines the type of a kernel function.
void KernelCenterAttribution(cudafloat *Output, int output_height, int output_width, int *attrib_center)
float cudafloat