cc_staff
1,486
edits
(adjusted indentation to be consistent) |
(adjusted indentation to be consistent) |
||
Line 160: | Line 160: | ||
<syntaxhighlight lang="cpp" line highlight="1,5"> | <syntaxhighlight lang="cpp" line highlight="1,5"> | ||
__global__ void dot(int *a, int *b, int *c){ | __global__ void dot(int *a, int *b, int *c){ | ||
int temp = a[threadIdx.x]*b[threadIdx.x]; | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 167: | Line 167: | ||
#define N 512 | #define N 512 | ||
__global__ void dot(int *a, int *b, int *c){ | __global__ void dot(int *a, int *b, int *c){ | ||
__shared__ int temp[N]; | |||
temp[threadIdx.x] = a[threadIdx.x]*b[threadIdx.x]; | |||
__syncthreads(); | |||
if(threadIdx.x==0){ | |||
int sum; for(int i=0;i<N;i++) sum+= temp[i]; | |||
*c=sum; | |||
} | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |