From d17b33131c14864bd1eae275f49a3f148e21cf29 Mon Sep 17 00:00:00 2001 From: Leo Chan Date: Thu, 22 Oct 2020 01:53:21 -0400 Subject: 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. --- SD-VBS/benchmarks/mser/src/c/script_mser.c | 120 +++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 SD-VBS/benchmarks/mser/src/c/script_mser.c (limited to 'SD-VBS/benchmarks/mser/src/c/script_mser.c') 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 @@ +/******************************** +Author: Sravanthi Kota Venkata +********************************/ + +#include "mser.h" +#include +#include "extra.h" +#define min(a,b) (ab)?a:b + +int main(int argc, char* argv[]) +{ + SET_UP + int which_image; + int i, j, k; + I2D *idx; + I2D *I; + I2D *It; + I2D *out; + int rows=196, cols=98; + int minVal = 1000; + int maxVal = -1000; + int lev = 10; + + char im1[100], im2[100]; + + iArray *subs_pt, *nsubs_pt, *strides_pt, *visited_pt, *dims; + uiArray* joins_pt; + ulliArray *acc_pt, *ell_pt; + region_t* regions_pt; + pair_t* pairs_pt; + node_t* forest_pt; + + int ndims, nel, gdl, nmer; + + printf("Input Image: "); + scanf("%s", im1); + + I = readImage(im1); + + rows = I->height; + cols = I->width; + + It = readImage(im1); + + k = 0; + for(i=0; iheight * It->width; + gdl = ndims * (ndims+1)/2 + ndims; + nmer = NMER_MAX; + + dims = malloc(sizeof(iArray) + sizeof(int)*ndims); + /* allocate stuff */ + subs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims); + nsubs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims); + strides_pt = malloc(sizeof(uiArray)+sizeof(unsigned int)*ndims); + visited_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel); + joins_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel); + + regions_pt = (region_t*)malloc(sizeof(region_t)*nel); + pairs_pt = (pair_t*)malloc(sizeof(pair_t)*nel); + forest_pt = (node_t*)malloc(sizeof(node_t)*nel); + + acc_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*nel) ; + ell_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*gdl*nmer) ; + + + out = iMallocHandle(1, nmer); + printf("start\n"); + for_each_job{ + idx = mser(It, 2, subs_pt, nsubs_pt, strides_pt, visited_pt, dims, + joins_pt, + regions_pt, + pairs_pt, + forest_pt, + acc_pt, ell_pt, + out); + } + printf("end..\n"); + +#ifdef CHECK + /** Self checking - use expected.txt from data directory **/ + { + int tol, ret=0; + tol = 1; +#ifdef GENERATE_OUTPUT + writeMatrix(idx, argv[1]); +#endif + ret = selfCheck(idx, "expected_C.txt", tol); + if (ret == -1) + printf("Error in MSER\n"); + } + /** Self checking done **/ +#endif + free(dims); + free( forest_pt ) ; + free( pairs_pt ) ; + free( regions_pt ) ; + free( visited_pt ) ; + free( strides_pt ) ; + free( nsubs_pt ) ; + free( subs_pt ) ; + free( joins_pt ) ; + free( acc_pt ) ; + free( ell_pt ) ; + iFreeHandle(idx); + iFreeHandle(I); + iFreeHandle(It); + WRITE_TO_FILE + return 0; +} + -- cgit v1.2.2