diff options
author | txh18 <[email protected]> | 2015-12-02 15:23:54 +0800 |
---|---|---|
committer | txh18 <[email protected]> | 2015-12-02 15:23:54 +0800 |
commit | 41a841f3e0992a578cf5c8f82ae44a552a6f8b2f (patch) | |
tree | 0a5ba8d1530290fd91febcfe69986c96be0ac895 /nerv/lib/matrix/generic/cukernel.cu | |
parent | 0c286aa6237da9e8daa7db8ed1e3805a33312926 (diff) |
changed thres_mask function of matrix to a more standard api
Diffstat (limited to 'nerv/lib/matrix/generic/cukernel.cu')
-rw-r--r-- | nerv/lib/matrix/generic/cukernel.cu | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/nerv/lib/matrix/generic/cukernel.cu b/nerv/lib/matrix/generic/cukernel.cu index b092e4a..aa830b5 100644 --- a/nerv/lib/matrix/generic/cukernel.cu +++ b/nerv/lib/matrix/generic/cukernel.cu @@ -20,14 +20,14 @@ __global__ void cudak_(log_elem)(const MATRIX_ELEM *a, MATRIX_ELEM *b, b[idx] = log(tmp); } -__global__ void cudak_(thres_mask)(MATRIX_ELEM *a, double thres, double low, double high, +__global__ void cudak_(thres_mask)(MATRIX_ELEM *a, MATRIX_ELEM *b, double thres, double low, double high, int nrow, int ncol, int stride) { int j = blockIdx.x * blockDim.x + threadIdx.x; int i = blockIdx.y * blockDim.y + threadIdx.y; long idx; if (i >= nrow || j >= ncol) return; idx = j + i * stride; - if (a[idx] < thres) + if (b[idx] < thres) a[idx] = low; else a[idx] = high; @@ -389,7 +389,7 @@ extern "C" { cudaStreamSynchronize(0); } - void cudak_(cuda_rand_uniform)(Matrix *a) { + void cudak_(cuda_rand_uniform)(const Matrix *a) { #ifdef MATRIX_USE_FLOAT curandGenerateUniform(*(a->curand_gen), MATRIX_ELEM_PTR(a), a->nrow * a->stride / sizeof(MATRIX_ELEM)); #endif @@ -398,12 +398,13 @@ extern "C" { #endif } - void cudak_(cuda_thres_mask)(const Matrix *a, double thres, double low, double high) { + void cudak_(cuda_thres_mask)(const Matrix *a, const Matrix *b, double thres, double low, double high) { dim3 threadsPerBlock(CUDA_THREADS_N, CUDA_THREADS_N); dim3 numBlocks(CEIL_DIV(a->ncol, threadsPerBlock.x), CEIL_DIV(a->nrow, threadsPerBlock.y)); cudak_(thres_mask)<<<numBlocks, threadsPerBlock>>> \ - (MATRIX_ELEM_PTR(a), thres, low, high, a->nrow, a->ncol, a->stride / sizeof(MATRIX_ELEM)); + (MATRIX_ELEM_PTR(a), MATRIX_ELEM_PTR(b), + thres, low, high, a->nrow, a->ncol, a->stride / sizeof(MATRIX_ELEM)); cudaStreamSynchronize(0); } |