Skip to content

Instantly share code, notes, and snippets.

@sbugrov
Created September 2, 2017 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbugrov/9e3473fbe1477a886ddec08a800aea6b to your computer and use it in GitHub Desktop.
Save sbugrov/9e3473fbe1477a886ddec08a800aea6b to your computer and use it in GitHub Desktop.
__global__ void kMartixSubstractMatrix(const float *m1, const float *m2, float *output) {
/* Computes the (elementwise) difference between two arrays
Inputs:
m1: array
m2: array
output: array,the results of the computation are to be stored here
*/
const int id = blockIdx.x * blockDim.x + threadIdx.x;
output[id] = m1[id] - m2[id];
}
__device__ float* dMartixSubstractMatrix(const float *m1, const float *m2, float *output, const int width, const int height){
kMartixSubstractMatrix <<< width, height >>> ( m1, m2, output );
cudaDeviceSynchronize();
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment