-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcuDevMat.h
More file actions
38 lines (38 loc) · 1.62 KB
/
cuDevMat.h
File metadata and controls
38 lines (38 loc) · 1.62 KB
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
31
32
33
34
35
36
37
38
#ifndef CUDEVMAT_H_
#define CUDEVMAT_H_
#include<cuda_runtime.h>
#include<stdio.h>
#include<cuComplex.h>
#include<cublas_v2.h>
#include"cuMacro.h"
// write devmat because when in kernel dynamicly allocate 1kB space and the number of thread is 32x32 it will throw "out of memory" exception
// so we allocate the memory in host thread and set a pointer to record the kernel space usage
class cuDevMat{
private:
int height;
int width;
cuComplex *data;
char *begin; // the begin position of the thread
size_t *pointer; // use shared memory to record every thread space usage
public:
__device__ cuDevMat();
__device__ cuDevMat(int h, int w, char *threadMem, size_t *p);
__device__ cuDevMat(const cuDevMat &mat);
__device__ ~cuDevMat();
__device__ void init(int h, int w, char *threadMem, size_t *p);
__device__ void release();
__device__ int get_h() const;
__device__ int get_w() const;
__device__ cuComplex * get_data() const;
__device__ char * get_mem() const;
__device__ size_t * get_pointer() const;
__device__ cuComplex & at(int i, int j) const; // access elements in the device return reference type
__device__ void set(int i, int j, cuComplex x);
__device__ void display() const;
__device__ cuComplex det();
__device__ cuDevMat inv(); // only for 3X3
__device__ cuDevMat invParal();
__device__ cuDevMat mul(cuDevMat mat, cuComplex alpha);
__device__ cuDevMat her(cuComplex alpha);
};
#endif