isce3 0.25.0
Loading...
Searching...
No Matches
cuArrays.h
Go to the documentation of this file.
1
9
10// code guard
11#ifndef __CUARRAYS_H
12#define __CUARRAYS_H
13
14// cuda dependencies
15#include <cuda.h>
16#include <driver_types.h>
17
18#include <iostream>
19#include <fstream>
20#include <cstdlib>
21#include <ctime>
22
23
24template <typename T>
25class cuArrays{
26
27public:
28 int height;
29 int width; // y, col, across, range, along the sight
30 int size; // one image size, height*width
31 int countW; // number of images along width direction
32 int countH; // number of images along height direction
33 int count; // countW*countH, number of images
34 T* devData; // pointer to data in device (gpu) memory
35 T* hostData; // pointer to data in host (cpu) memory
36
37 bool is_allocated; // whether the data is allocated in device memory
38 bool is_allocatedHost; // whether the data is allocated in host memory
39
40 // default constructor, empty
41 cuArrays() : width(0), height(0), size(0), countW(0), countH(0), count(0),
42 is_allocated(0), is_allocatedHost(0),
43 devData(0), hostData(0) {}
44
45 // constructor for single image
46 cuArrays(size_t h, size_t w) : width(w), height(h), countH(1), countW(1), count(1),
47 is_allocated(0), is_allocatedHost(0),
48 devData(0), hostData(0)
49 {
50 size = w*h;
51 }
52
53 // constructor for multiple images with a total count
54 cuArrays(size_t h, size_t w, size_t n) : width(w), height(h), countH(1), countW(n), count(n),
55 is_allocated(0), is_allocatedHost(0),
56 devData(0), hostData(0)
57 {
58 size = w*h;
59 }
60
61 // constructor for multiple images with (countH, countW)
62 cuArrays(size_t h, size_t w, size_t ch, size_t cw) : width(w), height(h), countW(cw), countH(ch),
63 is_allocated(0), is_allocatedHost(0),
64 devData(0), hostData(0)
65 {
66 size = w*h;
67 count = countH*countW;
68 }
69
70 // memory allocation
71 void allocate();
72 void allocateHost();
73 void deallocate();
74 void deallocateHost();
75
76 // copy data between device and host memories
77 void copyToHost(cudaStream_t stream);
78 void copyToDevice(cudaStream_t stream);
79
80 // get the total size
81 size_t getSize()
82 {
83 return size*count;
84 }
85
86 // get the total size in byte
87 inline long getByteSize()
88 {
89 return width*height*count*sizeof(T);
90 }
91
92 // destructor
93 ~cuArrays()
94 {
95 if(is_allocated)
96 deallocate();
97 if(is_allocatedHost)
98 deallocateHost();
99 }
100
101 // set zeroes
102 void setZero(cudaStream_t stream);
103 // output when debugging
104 void debuginfo(cudaStream_t stream) ;
105 void debuginfo(cudaStream_t stream, float factor);
106 // write to files
107 void outputToFile(std::string fn, cudaStream_t stream);
108 void outputHostToFile(std::string fn);
109
110};
111
112#endif //__CUARRAYS_H
113//end of file
Definition cuArrays.h:25
int height
x, row, down, length, azimuth, along the track
Definition cuArrays.h:28

Generated for ISCE3.0 by doxygen 1.13.2.