diff options
author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/c/sdvbs_common.h | |
parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (diff) |
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to:
- Use libextra to loop as realtime jobs
- Preallocate memory before starting their main computation
- Accept input via stdin instead of via argc
Does not include the SD-VBS matlab code.
Fixes libextra execution in LITMUS^RT.
Diffstat (limited to 'SD-VBS/common/c/sdvbs_common.h')
-rw-r--r-- | SD-VBS/common/c/sdvbs_common.h | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/SD-VBS/common/c/sdvbs_common.h b/SD-VBS/common/c/sdvbs_common.h new file mode 100644 index 0000000..14e28b2 --- /dev/null +++ b/SD-VBS/common/c/sdvbs_common.h | |||
@@ -0,0 +1,139 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #ifndef _SDVBS_COMMON_ | ||
6 | #define _SDVBS_COMMON_ | ||
7 | |||
8 | #include <stdio.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <math.h> | ||
11 | |||
12 | typedef struct | ||
13 | { | ||
14 | int width; | ||
15 | int height; | ||
16 | int data[]; | ||
17 | }I2D; | ||
18 | |||
19 | typedef struct | ||
20 | { | ||
21 | int width; | ||
22 | int height; | ||
23 | unsigned int data[]; | ||
24 | }UI2D; | ||
25 | |||
26 | typedef struct | ||
27 | { | ||
28 | int width; | ||
29 | int height; | ||
30 | float data[]; | ||
31 | }F2D; | ||
32 | |||
33 | #define subsref(a,i,j) a->data[(i) * a->width + (j)] | ||
34 | #define asubsref(a,i) a->data[i] | ||
35 | #define arrayref(a,i) a[i] | ||
36 | |||
37 | /** Image read and write **/ | ||
38 | I2D* readImage(const char* pathName);; | ||
39 | F2D* readFile(unsigned char* fileName); | ||
40 | |||
41 | |||
42 | /** Memory allocation functions **/ | ||
43 | I2D* iMallocHandle(int rows, int cols); | ||
44 | F2D* fMallocHandle(int rows, int cols); | ||
45 | F2D* fResetHandle(F2D* out, int rows, int cols); | ||
46 | UI2D* uiMallocHandle(int rows, int cols); | ||
47 | |||
48 | void iFreeHandle(I2D* out); | ||
49 | void fFreeHandle(F2D* out); | ||
50 | void uiFreeHandle(UI2D* out); | ||
51 | |||
52 | /** Memory copy/set function **/ | ||
53 | I2D* iSetArray(int rows, int cols, int val); | ||
54 | void iResetArray(I2D* out, int rows, int cols, int val); | ||
55 | F2D* fSetArray(int rows, int cols, float val); | ||
56 | void fResetArray(F2D* out, int rows, int cols, float val); | ||
57 | I2D* iDeepCopy(I2D* in); | ||
58 | F2D* fDeepCopy(F2D* in); | ||
59 | F2D* fCopy(F2D* in, F2D* out); | ||
60 | I2D* iDeepCopyRange(I2D* in, int startRow, int numberRows, int startCol, int numberCols); | ||
61 | F2D* fDeepCopyRange(F2D* in, int startRow, int numberRows, int startCol, int numberCols); | ||
62 | F2D* fiDeepCopy(I2D* in); | ||
63 | void fiCopy(F2D* out, I2D* in); | ||
64 | I2D* ifDeepCopy(F2D* in); | ||
65 | |||
66 | |||
67 | /** Matrix operations - concatenation, reshape **/ | ||
68 | F2D* ffVertcat(F2D* matrix1, F2D* matrix2); | ||
69 | I2D* iVertcat(I2D* matrix1, I2D* matrix2); | ||
70 | F2D* fHorzcat(F2D* a, F2D* b); | ||
71 | I2D* iHorzcat(I2D* a, I2D* b); | ||
72 | F2D* horzcat(F2D* a, F2D* b, F2D* c); | ||
73 | F2D* fTranspose(F2D* a); | ||
74 | I2D* iTranspose(I2D* a); | ||
75 | F2D* fReshape(F2D* in, int rows, int cols); | ||
76 | I2D* iReshape(I2D* in, int rows, int cols); | ||
77 | |||
78 | |||
79 | /** Binary Operations **/ | ||
80 | F2D* fDivide(F2D* a, float b); | ||
81 | F2D* fMdivide(F2D* a, F2D* b); | ||
82 | F2D* ffDivide(F2D* a, F2D* b); | ||
83 | F2D* ffTimes(F2D* a, float b); | ||
84 | F2D* fTimes(F2D* a, F2D* b); | ||
85 | I2D* iTimes(I2D* a, I2D* b); | ||
86 | F2D* fMtimes(F2D* a, F2D* b); | ||
87 | F2D* ifMtimes(I2D* a, F2D* b); | ||
88 | F2D* fMinus(F2D* a, F2D* b); | ||
89 | I2D* iMinus(I2D* a, I2D* b); | ||
90 | I2D* isMinus(I2D* a, int b); | ||
91 | F2D* fPlus(F2D* a, F2D* b); | ||
92 | I2D* isPlus(I2D* a, int b); | ||
93 | |||
94 | |||
95 | /** Filtering operations **/ | ||
96 | F2D* calcSobel_dX(F2D* imageIn); | ||
97 | F2D* calcSobel_dY(F2D* imageIn); | ||
98 | F2D* ffConv2(F2D* a, F2D* b); | ||
99 | F2D* fiConv2(I2D* a, F2D* b); | ||
100 | F2D* ffConv2_dY(F2D* a, F2D* b); | ||
101 | F2D* ffiConv2(F2D* a, I2D* b); | ||
102 | I2D* iiConv2(I2D* a, I2D* b); | ||
103 | |||
104 | |||
105 | /** Image Transformations - resize, integration etc **/ | ||
106 | F2D* imageResize(F2D* imageIn); | ||
107 | F2D* imageBlur(I2D* imageIn); | ||
108 | F2D* imageReblur(I2D* imageIn, F2D* imageOut, F2D* tempOut, I2D* kernel); | ||
109 | |||
110 | |||
111 | /** Support functions **/ | ||
112 | F2D* fFind3(F2D* in); | ||
113 | F2D* fSum2(F2D* inMat, int dir); | ||
114 | F2D* fSum(F2D* inMat); | ||
115 | I2D* iSort(I2D* in, int dim); | ||
116 | F2D* fSort(F2D* in, int dim); | ||
117 | I2D* iSortIndices(I2D* in, int dim); | ||
118 | I2D* fSortIndices(F2D* input, int dim); | ||
119 | I2D* fResortIndices(F2D* input, int dim, F2D* in, I2D* ind); | ||
120 | F2D* randnWrapper(int m, int n); | ||
121 | F2D* randWrapper(int m, int n); | ||
122 | |||
123 | |||
124 | /** Checking functions **/ | ||
125 | int selfCheck(I2D* in1, char* path, int tol); | ||
126 | int fSelfCheck(F2D* in1, char* path, float tol); | ||
127 | void writeMatrix(I2D* input, char* inpath); | ||
128 | void fWriteMatrix(F2D* input, char* inpath); | ||
129 | int iCheck(I2D* in1, I2D* in2); | ||
130 | |||
131 | /** Timing functions **/ | ||
132 | unsigned int* photonEndTiming(); | ||
133 | unsigned int* photonStartTiming(); | ||
134 | unsigned int* photonReportTiming(unsigned int* startCycles,unsigned int* endCycles); | ||
135 | void photonPrintTiming(unsigned int * elapsed); | ||
136 | |||
137 | |||
138 | #endif | ||
139 | |||