summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/c/sdvbs_common.h
diff options
context:
space:
mode:
authorLeo Chan <leochanj@live.unc.edu>2020-10-22 01:53:21 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-10-22 01:56:35 -0400
commitd17b33131c14864bd1eae275f49a3f148e21cf29 (patch)
tree0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/c/sdvbs_common.h
parent601ed25a4c5b66cb75315832c15613a727db2c26 (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.h139
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/********************************
2Author: 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
12typedef struct
13{
14 int width;
15 int height;
16 int data[];
17}I2D;
18
19typedef struct
20{
21 int width;
22 int height;
23 unsigned int data[];
24}UI2D;
25
26typedef 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 **/
38I2D* readImage(const char* pathName);;
39F2D* readFile(unsigned char* fileName);
40
41
42/** Memory allocation functions **/
43I2D* iMallocHandle(int rows, int cols);
44F2D* fMallocHandle(int rows, int cols);
45F2D* fResetHandle(F2D* out, int rows, int cols);
46UI2D* uiMallocHandle(int rows, int cols);
47
48void iFreeHandle(I2D* out);
49void fFreeHandle(F2D* out);
50void uiFreeHandle(UI2D* out);
51
52/** Memory copy/set function **/
53I2D* iSetArray(int rows, int cols, int val);
54void iResetArray(I2D* out, int rows, int cols, int val);
55F2D* fSetArray(int rows, int cols, float val);
56void fResetArray(F2D* out, int rows, int cols, float val);
57I2D* iDeepCopy(I2D* in);
58F2D* fDeepCopy(F2D* in);
59F2D* fCopy(F2D* in, F2D* out);
60I2D* iDeepCopyRange(I2D* in, int startRow, int numberRows, int startCol, int numberCols);
61F2D* fDeepCopyRange(F2D* in, int startRow, int numberRows, int startCol, int numberCols);
62F2D* fiDeepCopy(I2D* in);
63void fiCopy(F2D* out, I2D* in);
64I2D* ifDeepCopy(F2D* in);
65
66
67/** Matrix operations - concatenation, reshape **/
68F2D* ffVertcat(F2D* matrix1, F2D* matrix2);
69I2D* iVertcat(I2D* matrix1, I2D* matrix2);
70F2D* fHorzcat(F2D* a, F2D* b);
71I2D* iHorzcat(I2D* a, I2D* b);
72F2D* horzcat(F2D* a, F2D* b, F2D* c);
73F2D* fTranspose(F2D* a);
74I2D* iTranspose(I2D* a);
75F2D* fReshape(F2D* in, int rows, int cols);
76I2D* iReshape(I2D* in, int rows, int cols);
77
78
79/** Binary Operations **/
80F2D* fDivide(F2D* a, float b);
81F2D* fMdivide(F2D* a, F2D* b);
82F2D* ffDivide(F2D* a, F2D* b);
83F2D* ffTimes(F2D* a, float b);
84F2D* fTimes(F2D* a, F2D* b);
85I2D* iTimes(I2D* a, I2D* b);
86F2D* fMtimes(F2D* a, F2D* b);
87F2D* ifMtimes(I2D* a, F2D* b);
88F2D* fMinus(F2D* a, F2D* b);
89I2D* iMinus(I2D* a, I2D* b);
90I2D* isMinus(I2D* a, int b);
91F2D* fPlus(F2D* a, F2D* b);
92I2D* isPlus(I2D* a, int b);
93
94
95/** Filtering operations **/
96F2D* calcSobel_dX(F2D* imageIn);
97F2D* calcSobel_dY(F2D* imageIn);
98F2D* ffConv2(F2D* a, F2D* b);
99F2D* fiConv2(I2D* a, F2D* b);
100F2D* ffConv2_dY(F2D* a, F2D* b);
101F2D* ffiConv2(F2D* a, I2D* b);
102I2D* iiConv2(I2D* a, I2D* b);
103
104
105/** Image Transformations - resize, integration etc **/
106F2D* imageResize(F2D* imageIn);
107F2D* imageBlur(I2D* imageIn);
108F2D* imageReblur(I2D* imageIn, F2D* imageOut, F2D* tempOut, I2D* kernel);
109
110
111/** Support functions **/
112F2D* fFind3(F2D* in);
113F2D* fSum2(F2D* inMat, int dir);
114F2D* fSum(F2D* inMat);
115I2D* iSort(I2D* in, int dim);
116F2D* fSort(F2D* in, int dim);
117I2D* iSortIndices(I2D* in, int dim);
118I2D* fSortIndices(F2D* input, int dim);
119I2D* fResortIndices(F2D* input, int dim, F2D* in, I2D* ind);
120F2D* randnWrapper(int m, int n);
121F2D* randWrapper(int m, int n);
122
123
124/** Checking functions **/
125int selfCheck(I2D* in1, char* path, int tol);
126int fSelfCheck(F2D* in1, char* path, float tol);
127void writeMatrix(I2D* input, char* inpath);
128void fWriteMatrix(F2D* input, char* inpath);
129int iCheck(I2D* in1, I2D* in2);
130
131/** Timing functions **/
132unsigned int* photonEndTiming();
133unsigned int* photonStartTiming();
134unsigned int* photonReportTiming(unsigned int* startCycles,unsigned int* endCycles);
135void photonPrintTiming(unsigned int * elapsed);
136
137
138#endif
139