-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddmatrix_gpu.cu
31 lines (23 loc) · 1.25 KB
/
addmatrix_gpu.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// includes, system
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
// includes CUDA
#include <cuda_runtime.h>
#include <helper_functions.h> // helper functions for SDK examples
#define N 4194304
#define CHECK(call) \
{ \
const cudaError_t error = call; \
if (error != cudaSuccess) \
{ \
fprintf(stderr, "Error: %s:%d, ", __FILE__, __LINE__); \
fprintf(stderr, "code: %d, reason: %s\n", error, \
cudaGetErrorString(error)); \
exit(EXIT_FAILURE); \
} \
}
extern "C" void addVectorCpu(int numberElements, float **firstArray, float **secondArray, float **resultArray);
extern "C" void addMatrixCpu(int numberElements, float **firstMatrix, float **secondMatrix, float **resultMatrix);
extern "C" __global__ void addMatrixGpu(int width, int height, float **firstMatrix, float *secondMatrix, float **resultMatrix);