count 2d array element

#include <cuda_runtime.h> __global__ void count_2d_equal_kernel ( const int * input, int * output, int N, int M, int K) { int idx = blockDim.x * blockIdx.x + threadIdx.x; int idy = blockDim.y * blockIdx.y + threadIdx.y; if ((idx < N && idy < M) && input[idx * M + idy] == K) atomicAdd(output, 1 ); } // input, output are device pointers (i.e. pointers to memory on the GPU) extern "C" void solve(…