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/benchmarks/mser/src/c/script_mser.c | |
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/benchmarks/mser/src/c/script_mser.c')
-rw-r--r-- | SD-VBS/benchmarks/mser/src/c/script_mser.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/mser/src/c/script_mser.c b/SD-VBS/benchmarks/mser/src/c/script_mser.c new file mode 100644 index 0000000..d4a98cd --- /dev/null +++ b/SD-VBS/benchmarks/mser/src/c/script_mser.c | |||
@@ -0,0 +1,120 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include "mser.h" | ||
6 | #include <malloc.h> | ||
7 | #include "extra.h" | ||
8 | #define min(a,b) (a<b)?a:b | ||
9 | #define max(a,b) (a>b)?a:b | ||
10 | |||
11 | int main(int argc, char* argv[]) | ||
12 | { | ||
13 | SET_UP | ||
14 | int which_image; | ||
15 | int i, j, k; | ||
16 | I2D *idx; | ||
17 | I2D *I; | ||
18 | I2D *It; | ||
19 | I2D *out; | ||
20 | int rows=196, cols=98; | ||
21 | int minVal = 1000; | ||
22 | int maxVal = -1000; | ||
23 | int lev = 10; | ||
24 | |||
25 | char im1[100], im2[100]; | ||
26 | |||
27 | iArray *subs_pt, *nsubs_pt, *strides_pt, *visited_pt, *dims; | ||
28 | uiArray* joins_pt; | ||
29 | ulliArray *acc_pt, *ell_pt; | ||
30 | region_t* regions_pt; | ||
31 | pair_t* pairs_pt; | ||
32 | node_t* forest_pt; | ||
33 | |||
34 | int ndims, nel, gdl, nmer; | ||
35 | |||
36 | printf("Input Image: "); | ||
37 | scanf("%s", im1); | ||
38 | |||
39 | I = readImage(im1); | ||
40 | |||
41 | rows = I->height; | ||
42 | cols = I->width; | ||
43 | |||
44 | It = readImage(im1); | ||
45 | |||
46 | k = 0; | ||
47 | for(i=0; i<cols; i++) | ||
48 | { | ||
49 | for(j=0; j<rows; j++) | ||
50 | { | ||
51 | asubsref(It,k++) = subsref(I,j,i); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | ndims = 2; | ||
56 | nel = It->height * It->width; | ||
57 | gdl = ndims * (ndims+1)/2 + ndims; | ||
58 | nmer = NMER_MAX; | ||
59 | |||
60 | dims = malloc(sizeof(iArray) + sizeof(int)*ndims); | ||
61 | /* allocate stuff */ | ||
62 | subs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims); | ||
63 | nsubs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims); | ||
64 | strides_pt = malloc(sizeof(uiArray)+sizeof(unsigned int)*ndims); | ||
65 | visited_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel); | ||
66 | joins_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel); | ||
67 | |||
68 | regions_pt = (region_t*)malloc(sizeof(region_t)*nel); | ||
69 | pairs_pt = (pair_t*)malloc(sizeof(pair_t)*nel); | ||
70 | forest_pt = (node_t*)malloc(sizeof(node_t)*nel); | ||
71 | |||
72 | acc_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*nel) ; | ||
73 | ell_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*gdl*nmer) ; | ||
74 | |||
75 | |||
76 | out = iMallocHandle(1, nmer); | ||
77 | printf("start\n"); | ||
78 | for_each_job{ | ||
79 | idx = mser(It, 2, subs_pt, nsubs_pt, strides_pt, visited_pt, dims, | ||
80 | joins_pt, | ||
81 | regions_pt, | ||
82 | pairs_pt, | ||
83 | forest_pt, | ||
84 | acc_pt, ell_pt, | ||
85 | out); | ||
86 | } | ||
87 | printf("end..\n"); | ||
88 | |||
89 | #ifdef CHECK | ||
90 | /** Self checking - use expected.txt from data directory **/ | ||
91 | { | ||
92 | int tol, ret=0; | ||
93 | tol = 1; | ||
94 | #ifdef GENERATE_OUTPUT | ||
95 | writeMatrix(idx, argv[1]); | ||
96 | #endif | ||
97 | ret = selfCheck(idx, "expected_C.txt", tol); | ||
98 | if (ret == -1) | ||
99 | printf("Error in MSER\n"); | ||
100 | } | ||
101 | /** Self checking done **/ | ||
102 | #endif | ||
103 | free(dims); | ||
104 | free( forest_pt ) ; | ||
105 | free( pairs_pt ) ; | ||
106 | free( regions_pt ) ; | ||
107 | free( visited_pt ) ; | ||
108 | free( strides_pt ) ; | ||
109 | free( nsubs_pt ) ; | ||
110 | free( subs_pt ) ; | ||
111 | free( joins_pt ) ; | ||
112 | free( acc_pt ) ; | ||
113 | free( ell_pt ) ; | ||
114 | iFreeHandle(idx); | ||
115 | iFreeHandle(I); | ||
116 | iFreeHandle(It); | ||
117 | WRITE_TO_FILE | ||
118 | return 0; | ||
119 | } | ||
120 | |||