From d6245fabb836666628dc3fca60aa270462310ab2 Mon Sep 17 00:00:00 2001 From: leila saadatifard Date: Wed, 5 Apr 2017 13:34:54 -0500 Subject: [PATCH] fix the bug in local_max about casting size_t to int --- stim/iVote/ivote2/local_max.cuh | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/stim/iVote/ivote2/local_max.cuh b/stim/iVote/ivote2/local_max.cuh index 38b7096..0da2a85 100644 --- a/stim/iVote/ivote2/local_max.cuh +++ b/stim/iVote/ivote2/local_max.cuh @@ -10,30 +10,22 @@ namespace stim{ // this kernel calculates the local maximum for finding the cell centers template - __global__ void cuda_local_max(T* gpuCenters, T* gpuVote, int conn, size_t x, size_t y){ + __global__ void cuda_local_max(T* gpuCenters, T* gpuVote, int conn, int x, int y){ // calculate the 2D coordinates for this current thread. - size_t xi = blockIdx.x * blockDim.x + threadIdx.x; - size_t yi = blockIdx.y * blockDim.y + threadIdx.y; + int xi = blockIdx.x * blockDim.x + threadIdx.x; + int yi = blockIdx.y * blockDim.y + threadIdx.y; if(xi >= x || yi >= y) return; // convert 2D coordinates to 1D - size_t i = yi * x + xi; + int i = yi * x + xi; gpuCenters[i] = 0; //initialize the value at this location to zero T val = gpuVote[i]; - //compare to the threshold - //if(val < final_t) return; - - //define an array to store indices with same vote value - /*int * IdxEq; - IdxEq = new int [2*conn]; - int n = 0;*/ - for(int xl = xi - conn; xl < xi + conn; xl++){ for(int yl = yi - conn; yl < yi + conn; yl++){ if(xl >= 0 && xl < x && yl >= 0 && yl < y){ @@ -42,8 +34,7 @@ namespace stim{ return; } if (gpuVote[il] == val){ - /*IdxEq[n] = il; - n = n+1;*/ + if( il > i){ return; } @@ -51,12 +42,7 @@ namespace stim{ } } } - /*if (n!=0){ - if(IdxEq[n/2] !=i){ - return; - } - } */ - //gpuCenters[i] = 1; + gpuCenters[i] = gpuVote[i]; } -- libgit2 0.21.4