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. --- .../benchmarks/texture_synthesis/src/MEX/innerProd | Bin 0 -> 12222 bytes .../texture_synthesis/src/MEX/innerProd.c | 52 +++ .../texture_synthesis/src/MEX/innerProd.ctf | Bin 0 -> 174395 bytes .../texture_synthesis/src/MEX/innerProd.prj | 233 ++++++++++++ .../texture_synthesis/src/MEX/innerProd_main.c | 103 ++++++ .../src/MEX/innerProd_mcc_component_data.c | 151 ++++++++ .../texture_synthesis/src/MEX/mccExcludedFiles.log | 12 + .../src/c/script_texture_synthesis.c | 197 ++++++++++ .../benchmarks/texture_synthesis/src/c/texture.c | 396 +++++++++++++++++++++ .../benchmarks/texture_synthesis/src/c/texture.h | 48 +++ 10 files changed, 1192 insertions(+) create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd.c create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd.ctf create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd.prj create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd_main.c create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd_mcc_component_data.c create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/MEX/mccExcludedFiles.log create mode 100644 SD-VBS/benchmarks/texture_synthesis/src/c/script_texture_synthesis.c create mode 100644 SD-VBS/benchmarks/texture_synthesis/src/c/texture.c create mode 100644 SD-VBS/benchmarks/texture_synthesis/src/c/texture.h (limited to 'SD-VBS/benchmarks/texture_synthesis/src') diff --git a/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd b/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd new file mode 100755 index 0000000..e3b1f28 Binary files /dev/null and b/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd differ diff --git a/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd.c b/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd.c new file mode 100755 index 0000000..9649dda --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd.c @@ -0,0 +1,52 @@ +/* +RES = innerProd(MAT); + Computes mat'*mat + Odelia Schwartz, 8/97. +*/ + +#define V4_COMPAT +#include + +#include +#include +#include +#include +#include + +void mexFunction(int nlhs, /* Num return vals on lhs */ + Matrix *plhs[], /* Matrices on lhs */ + int nrhs, /* Num args on rhs */ + Matrix *prhs[] /* Matrices on rhs */ + ) +{ + register double *res, *mat, tmp; + register int len, wid, i, k, j, jlen, ilen, imat, jmat; + Matrix *arg; + + /* get matrix input argument */ + /* should be matrix in which num rows >= num columns */ + arg=prhs[0]; + mat= mxGetPr(arg); + len = (int) mxGetM(arg); + wid = (int) mxGetN(arg); + if ( wid > len ) + printf("innerProd: Warning: width %d is greater than length %d.\n",wid,len); + plhs[0] = (Matrix *) mxCreateFull(wid,wid,REAL); + if (plhs[0] == NULL) + mexErrMsgTxt(sprintf("Error allocating %dx%d result matrix",wid,wid)); + res = mxGetPr(plhs[0]); + + for(i=0, ilen=0; i + + + + + /u/kvs/VisionBenchmark/texture_synthesis/src + /pkg/matlab/toolbox/compiler/deploy + /pkg/matlab/toolbox/matlab/general + /pkg/matlab/toolbox/matlab/ops + /pkg/matlab/toolbox/matlab/lang + /pkg/matlab/toolbox/matlab/elmat + /pkg/matlab/toolbox/matlab/elfun + /pkg/matlab/toolbox/matlab/specfun + /pkg/matlab/toolbox/matlab/matfun + /pkg/matlab/toolbox/matlab/datafun + /pkg/matlab/toolbox/matlab/polyfun + /pkg/matlab/toolbox/matlab/funfun + /pkg/matlab/toolbox/matlab/sparfun + /pkg/matlab/toolbox/matlab/scribe + /pkg/matlab/toolbox/matlab/graph2d + /pkg/matlab/toolbox/matlab/graph3d + /pkg/matlab/toolbox/matlab/specgraph + /pkg/matlab/toolbox/matlab/graphics + /pkg/matlab/toolbox/matlab/uitools + /pkg/matlab/toolbox/matlab/strfun + /pkg/matlab/toolbox/matlab/imagesci + /pkg/matlab/toolbox/matlab/iofun + /pkg/matlab/toolbox/matlab/audiovideo + /pkg/matlab/toolbox/matlab/timefun + /pkg/matlab/toolbox/matlab/datatypes + /pkg/matlab/toolbox/matlab/verctrl + /pkg/matlab/toolbox/matlab/codetools + /pkg/matlab/toolbox/matlab/helptools + /pkg/matlab/toolbox/matlab/demos + /pkg/matlab/toolbox/matlab/timeseries + /pkg/matlab/toolbox/matlab/hds + /pkg/matlab/toolbox/matlab/guide + /pkg/matlab/toolbox/matlab/plottools + /pkg/matlab/toolbox/local + /pkg/matlab/toolbox/shared/controllib + /pkg/matlab/toolbox/simulink/simulink + /pkg/matlab/toolbox/simulink/blocks + /pkg/matlab/toolbox/simulink/components + /pkg/matlab/toolbox/simulink/fixedandfloat + /pkg/matlab/toolbox/simulink/fixedandfloat/fxpdemos + /pkg/matlab/toolbox/simulink/fixedandfloat/obsolete + /pkg/matlab/toolbox/simulink/simdemos + /pkg/matlab/toolbox/simulink/simdemos/aerospace + /pkg/matlab/toolbox/simulink/simdemos/automotive + /pkg/matlab/toolbox/simulink/simdemos/simfeatures + /pkg/matlab/toolbox/simulink/simdemos/simgeneral + /pkg/matlab/toolbox/simulink/dee + /pkg/matlab/toolbox/shared/dastudio + /pkg/matlab/toolbox/shared/glue + /pkg/matlab/toolbox/stateflow/stateflow + /pkg/matlab/toolbox/rtw/rtw + /pkg/matlab/toolbox/simulink/simulink/modeladvisor + /pkg/matlab/toolbox/simulink/simulink/modeladvisor/fixpt + /pkg/matlab/toolbox/simulink/simulink/MPlayIO + /pkg/matlab/toolbox/simulink/simulink/dataobjectwizard + /pkg/matlab/toolbox/shared/fixedpointlib + /pkg/matlab/toolbox/simulink/dataimportexport + /pkg/matlab/toolbox/shared/hdlshared + /pkg/matlab/toolbox/rtw/rtwdemos + /pkg/matlab/toolbox/rtw/rtwdemos/rsimdemos + /pkg/matlab/toolbox/rtw/targets/asap2/asap2 + /pkg/matlab/toolbox/rtw/targets/asap2/asap2/user + /pkg/matlab/toolbox/rtw/targets/common/can/blocks + /pkg/matlab/toolbox/rtw/targets/common/configuration/resource + /pkg/matlab/toolbox/rtw/targets/common/tgtcommon + /pkg/matlab/toolbox/stateflow/sfdemos + /pkg/matlab/toolbox/stateflow/coder + /pkg/matlab/toolbox/bioinfo/bioinfo + /pkg/matlab/toolbox/bioinfo/biolearning + /pkg/matlab/toolbox/bioinfo/microarray + /pkg/matlab/toolbox/bioinfo/mass_spec + /pkg/matlab/toolbox/bioinfo/proteins + /pkg/matlab/toolbox/bioinfo/biomatrices + /pkg/matlab/toolbox/bioinfo/biodemos + /pkg/matlab/toolbox/bioinfo/graphtheory + /pkg/matlab/toolbox/commblks/commblks + /pkg/matlab/toolbox/commblks/commmasks + /pkg/matlab/toolbox/commblks/commmex + /pkg/matlab/toolbox/commblks/commblksdemos + /pkg/matlab/toolbox/commblks/commblksobsolete/v3 + /pkg/matlab/toolbox/commblks/commblksobsolete/v2p5 + /pkg/matlab/toolbox/commblks/commblksobsolete/v2 + /pkg/matlab/toolbox/comm/comm + /pkg/matlab/toolbox/comm/commdemos + /pkg/matlab/toolbox/comm/commdemos/commdocdemos + /pkg/matlab/toolbox/comm/commobsolete + /pkg/matlab/toolbox/compiler + /pkg/matlab/toolbox/control/control + /pkg/matlab/toolbox/control/ctrlguis + /pkg/matlab/toolbox/control/ctrlobsolete + /pkg/matlab/toolbox/control/ctrlutil + /pkg/matlab/toolbox/control/ctrldemos + /pkg/matlab/toolbox/shared/slcontrollib + /pkg/matlab/toolbox/curvefit/curvefit + /pkg/matlab/toolbox/curvefit/cftoolgui + /pkg/matlab/toolbox/shared/optimlib + /pkg/matlab/toolbox/database/database + /pkg/matlab/toolbox/database/dbdemos + /pkg/matlab/toolbox/database/vqb + /pkg/matlab/toolbox/dspblks/dspblks + /pkg/matlab/toolbox/dspblks/dspmasks + /pkg/matlab/toolbox/dspblks/dspmex + /pkg/matlab/toolbox/dspblks/dspdemos + /pkg/matlab/toolbox/shared/filterdesignlib + /pkg/matlab/toolbox/rtw/targets/ecoder + /pkg/matlab/toolbox/rtw/targets/ecoder/ecoderdemos + /pkg/matlab/toolbox/rtw/targets/mpt + /pkg/matlab/toolbox/rtw/targets/mpt/mpt + /pkg/matlab/toolbox/rtw/targets/mpt/user_specific + /pkg/matlab/toolbox/fixedpoint/fixedpoint + /pkg/matlab/toolbox/fixedpoint/fidemos + /pkg/matlab/toolbox/fixedpoint/fimex + /pkg/matlab/toolbox/fixpoint + /pkg/matlab/toolbox/gads + /pkg/matlab/toolbox/gads/gads + /pkg/matlab/toolbox/gads/gadsdemos + /pkg/matlab/toolbox/ident/ident + /pkg/matlab/toolbox/ident/idobsolete + /pkg/matlab/toolbox/ident/idguis + /pkg/matlab/toolbox/ident/idutils + /pkg/matlab/toolbox/ident/iddemos + /pkg/matlab/toolbox/ident/idhelp + /pkg/matlab/toolbox/images/images + /pkg/matlab/toolbox/images/imuitools + /pkg/matlab/toolbox/images/imdemos + /pkg/matlab/toolbox/images/iptutils + /pkg/matlab/toolbox/shared/imageslib + /pkg/matlab/toolbox/images/medformats + /pkg/matlab/toolbox/instrument/instrument + /pkg/matlab/toolbox/instrument/instrumentdemos + /pkg/matlab/toolbox/map/map + /pkg/matlab/toolbox/map/mapdemos + /pkg/matlab/toolbox/map/mapdisp + /pkg/matlab/toolbox/map/mapformats + /pkg/matlab/toolbox/map/mapproj + /pkg/matlab/toolbox/shared/mapgeodesy + /pkg/matlab/toolbox/slvnv/simcoverage + /pkg/matlab/toolbox/nnet + /pkg/matlab/toolbox/nnet/nncontrol + /pkg/matlab/toolbox/nnet/nndemos + /pkg/matlab/toolbox/nnet/nnet + /pkg/matlab/toolbox/nnet/nnet/nnanalyze + /pkg/matlab/toolbox/nnet/nnet/nncustom + /pkg/matlab/toolbox/nnet/nnet/nndistance + /pkg/matlab/toolbox/nnet/nnet/nnformat + /pkg/matlab/toolbox/nnet/nnet/nninit + /pkg/matlab/toolbox/nnet/nnet/nnlearn + /pkg/matlab/toolbox/nnet/nnet/nnnetinput + /pkg/matlab/toolbox/nnet/nnet/nnnetwork + /pkg/matlab/toolbox/nnet/nnet/nnperformance + /pkg/matlab/toolbox/nnet/nnet/nnplot + /pkg/matlab/toolbox/nnet/nnet/nnprocess + /pkg/matlab/toolbox/nnet/nnet/nnsearch + /pkg/matlab/toolbox/nnet/nnet/nntopology + /pkg/matlab/toolbox/nnet/nnet/nntrain + /pkg/matlab/toolbox/nnet/nnet/nntransfer + /pkg/matlab/toolbox/nnet/nnet/nnweight + /pkg/matlab/toolbox/nnet/nnguis + /pkg/matlab/toolbox/nnet/nnguis/nftool + /pkg/matlab/toolbox/nnet/nnguis/nntool + /pkg/matlab/toolbox/nnet/nnobsolete + /pkg/matlab/toolbox/nnet/nnresource + /pkg/matlab/toolbox/nnet/nnutils + /pkg/matlab/toolbox/optim + /pkg/matlab/toolbox/pde + /pkg/matlab/toolbox/robust/robust + /pkg/matlab/toolbox/robust/rctlmi + /pkg/matlab/toolbox/robust/rctutil + /pkg/matlab/toolbox/robust/rctdemos + /pkg/matlab/toolbox/robust/rctobsolete/robust + /pkg/matlab/toolbox/robust/rctobsolete/lmi + /pkg/matlab/toolbox/robust/rctobsolete/mutools/commands + /pkg/matlab/toolbox/robust/rctobsolete/mutools/subs + /pkg/matlab/toolbox/signal/signal + /pkg/matlab/toolbox/signal/sigtools + /pkg/matlab/toolbox/signal/sptoolgui + /pkg/matlab/toolbox/signal/sigdemos + /pkg/matlab/toolbox/shared/spcuilib + /pkg/matlab/toolbox/slcontrol/slcontrol + /pkg/matlab/toolbox/slcontrol/slctrlguis + /pkg/matlab/toolbox/slcontrol/slctrlutil + /pkg/matlab/toolbox/slcontrol/slctrldemos + /pkg/matlab/toolbox/splines + /pkg/matlab/toolbox/stats + /pkg/matlab/toolbox/symbolic + /pkg/matlab/toolbox/vipblks/vipblks + /pkg/matlab/toolbox/vipblks/vipmasks + /pkg/matlab/toolbox/vipblks/vipmex + /pkg/matlab/toolbox/vipblks/vipdemos + /pkg/matlab/toolbox/wavelet/wavelet + /pkg/matlab/toolbox/wavelet/wmultisig1d + /pkg/matlab/toolbox/wavelet/wavedemo + /pkg/matlab/work + /pkg/matlab/toolbox/vr/vr + /pkg/matlab/toolbox/vr/vrdemos + + + + + + main + innerProd + + exe + false + ../MEX + ../MEX + false + false + + false + + + + false + + + + + + + /u/kvs/VisionBenchmark/texture_synthesis/src/innerProd.m + + + + + + diff --git a/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd_main.c b/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd_main.c new file mode 100755 index 0000000..3c828de --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd_main.c @@ -0,0 +1,103 @@ +/* + * MATLAB Compiler: 4.4 (R2006a) + * Date: Thu Jul 24 17:19:07 2008 + * Arguments: "-B" "macro_default" "-m" "-W" "main" "-T" "link:exe" "-d" + * "../MEX" "innerProd.m" + */ + +#include +#include "mclmcr.h" +#ifdef __cplusplus +extern "C" { +#endif + +extern mclComponentData __MCC_innerProd_component_data; + +#ifdef __cplusplus +} +#endif + +static HMCRINSTANCE _mcr_inst = NULL; + + +static int mclDefaultPrintHandler(const char *s) +{ + return fwrite(s, sizeof(char), strlen(s), stdout); +} + +static int mclDefaultErrorHandler(const char *s) +{ + int written = 0, len = 0; + len = strlen(s); + written = fwrite(s, sizeof(char), len, stderr); + if (len > 0 && s[ len-1 ] != '\n') + written += fwrite("\n", sizeof(char), 1, stderr); + return written; +} + + +/* This symbol is defined in shared libraries. Define it here + * (to nothing) in case this isn't a shared library. + */ +#ifndef LIB_innerProd_C_API +#define LIB_innerProd_C_API /* No special import/export declaration */ +#endif + +LIB_innerProd_C_API +bool MW_CALL_CONV innerProdInitializeWithHandlers( + mclOutputHandlerFcn error_handler, + mclOutputHandlerFcn print_handler +) +{ + if (_mcr_inst != NULL) + return true; + if (!mclmcrInitialize()) + return false; + if (!mclInitializeComponentInstance(&_mcr_inst, + &__MCC_innerProd_component_data, + true, NoObjectType, ExeTarget, + error_handler, print_handler)) + return false; + return true; +} + +LIB_innerProd_C_API +bool MW_CALL_CONV innerProdInitialize(void) +{ + return innerProdInitializeWithHandlers(mclDefaultErrorHandler, + mclDefaultPrintHandler); +} + +LIB_innerProd_C_API +void MW_CALL_CONV innerProdTerminate(void) +{ + if (_mcr_inst != NULL) + mclTerminateInstance(&_mcr_inst); +} + +int run_main(int argc, const char **argv) +{ + int _retval; + /* Generate and populate the path_to_component. */ + char path_to_component[(PATH_MAX*2)+1]; + separatePathName(argv[0], path_to_component, (PATH_MAX*2)+1); + __MCC_innerProd_component_data.path_to_component = path_to_component; + if (!innerProdInitialize()) { + return -1; + } + _retval = mclMain(_mcr_inst, argc, argv, "innerProd", 1); + if (_retval == 0 /* no error */) mclWaitForFiguresToDie(NULL); + innerProdTerminate(); + mclTerminateApplication(); + return _retval; +} + +int main(int argc, const char **argv) +{ + if (!mclInitializeApplication( + __MCC_innerProd_component_data.runtime_options, + __MCC_innerProd_component_data.runtime_option_count)) + return 0; + + return mclRunMain(run_main, argc, argv); +} diff --git a/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd_mcc_component_data.c b/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd_mcc_component_data.c new file mode 100755 index 0000000..df204ee --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/MEX/innerProd_mcc_component_data.c @@ -0,0 +1,151 @@ +/* + * MATLAB Compiler: 4.4 (R2006a) + * Date: Thu Jul 24 17:19:07 2008 + * Arguments: "-B" "macro_default" "-m" "-W" "main" "-T" "link:exe" "-d" + * "../MEX" "innerProd.m" + */ + +#include "mclmcr.h" + +#ifdef __cplusplus +extern "C" { +#endif +const unsigned char __MCC_innerProd_session_key[] = { + 'B', 'C', 'C', '8', 'A', 'E', 'C', 'F', '0', '7', '5', '2', 'D', 'F', + 'F', '9', '4', '2', '0', 'B', '6', 'F', '5', 'B', 'E', 'A', 'E', '4', + 'C', '2', 'F', '5', '4', 'D', '1', '4', '6', '3', 'B', 'A', '5', '1', + 'D', '8', '3', '7', 'F', '5', '4', '6', 'C', '1', 'D', 'B', '9', '3', + 'C', 'D', 'A', 'D', 'F', '3', '5', 'F', '5', 'A', '2', 'D', '9', 'A', + '4', '4', '6', 'D', 'C', '5', '3', '7', '7', '5', '7', '2', '3', '0', + 'E', '2', 'E', '7', '0', 'F', '7', '4', 'B', 'A', '8', 'B', '9', '8', + '5', '8', 'D', 'D', '3', '3', '3', '7', '9', 'E', '8', '1', '3', '9', + '1', '2', 'A', '6', 'B', '0', '4', '8', 'F', 'D', '9', 'D', '3', '5', + '2', '8', '4', '3', '7', '3', '1', 'D', '7', '0', 'E', '0', '0', '3', + 'D', '9', '7', '3', '0', 'F', '8', '7', '0', 'C', 'A', 'B', '4', '1', + 'F', '0', '4', '5', 'E', '1', '7', '4', 'C', 'E', '6', 'A', 'C', 'D', + 'C', '6', 'F', '8', '6', '5', 'F', '5', '1', 'A', '6', '9', 'F', 'E', + '7', '9', 'A', '3', 'E', '7', 'C', '6', '2', '3', '7', 'C', 'E', '9', + 'A', '0', '6', '3', '5', '9', '3', '4', '1', '5', '9', 'D', '9', '2', + '4', 'B', '1', '0', '6', '0', 'A', '3', '5', '8', '2', '1', '8', '4', + 'E', 'B', 'C', 'D', 'B', '6', '4', '7', 'F', 'D', '9', 'A', '3', '3', + 'D', '0', '1', '5', 'C', '2', '1', 'B', '5', 'C', '1', '5', '9', '3', + '0', '4', '6', '1', '\0'}; + +const unsigned char __MCC_innerProd_public_key[] = { + '3', '0', '8', '1', '9', 'D', '3', '0', '0', 'D', '0', '6', '0', '9', + '2', 'A', '8', '6', '4', '8', '8', '6', 'F', '7', '0', 'D', '0', '1', + '0', '1', '0', '1', '0', '5', '0', '0', '0', '3', '8', '1', '8', 'B', + '0', '0', '3', '0', '8', '1', '8', '7', '0', '2', '8', '1', '8', '1', + '0', '0', 'C', '4', '9', 'C', 'A', 'C', '3', '4', 'E', 'D', '1', '3', + 'A', '5', '2', '0', '6', '5', '8', 'F', '6', 'F', '8', 'E', '0', '1', + '3', '8', 'C', '4', '3', '1', '5', 'B', '4', '3', '1', '5', '2', '7', + '7', 'E', 'D', '3', 'F', '7', 'D', 'A', 'E', '5', '3', '0', '9', '9', + 'D', 'B', '0', '8', 'E', 'E', '5', '8', '9', 'F', '8', '0', '4', 'D', + '4', 'B', '9', '8', '1', '3', '2', '6', 'A', '5', '2', 'C', 'C', 'E', + '4', '3', '8', '2', 'E', '9', 'F', '2', 'B', '4', 'D', '0', '8', '5', + 'E', 'B', '9', '5', '0', 'C', '7', 'A', 'B', '1', '2', 'E', 'D', 'E', + '2', 'D', '4', '1', '2', '9', '7', '8', '2', '0', 'E', '6', '3', '7', + '7', 'A', '5', 'F', 'E', 'B', '5', '6', '8', '9', 'D', '4', 'E', '6', + '0', '3', '2', 'F', '6', '0', 'C', '4', '3', '0', '7', '4', 'A', '0', + '4', 'C', '2', '6', 'A', 'B', '7', '2', 'F', '5', '4', 'B', '5', '1', + 'B', 'B', '4', '6', '0', '5', '7', '8', '7', '8', '5', 'B', '1', '9', + '9', '0', '1', '4', '3', '1', '4', 'A', '6', '5', 'F', '0', '9', '0', + 'B', '6', '1', 'F', 'C', '2', '0', '1', '6', '9', '4', '5', '3', 'B', + '5', '8', 'F', 'C', '8', 'B', 'A', '4', '3', 'E', '6', '7', '7', '6', + 'E', 'B', '7', 'E', 'C', 'D', '3', '1', '7', '8', 'B', '5', '6', 'A', + 'B', '0', 'F', 'A', '0', '6', 'D', 'D', '6', '4', '9', '6', '7', 'C', + 'B', '1', '4', '9', 'E', '5', '0', '2', '0', '1', '1', '1', '\0'}; + +static const char * MCC_innerProd_matlabpath_data[] = + { "innerProd/", "toolbox/compiler/deploy/", "$TOOLBOXMATLABDIR/general/", + "$TOOLBOXMATLABDIR/ops/", "$TOOLBOXMATLABDIR/lang/", + "$TOOLBOXMATLABDIR/elmat/", "$TOOLBOXMATLABDIR/elfun/", + "$TOOLBOXMATLABDIR/specfun/", "$TOOLBOXMATLABDIR/matfun/", + "$TOOLBOXMATLABDIR/datafun/", "$TOOLBOXMATLABDIR/polyfun/", + "$TOOLBOXMATLABDIR/funfun/", "$TOOLBOXMATLABDIR/sparfun/", + "$TOOLBOXMATLABDIR/scribe/", "$TOOLBOXMATLABDIR/graph2d/", + "$TOOLBOXMATLABDIR/graph3d/", "$TOOLBOXMATLABDIR/specgraph/", + "$TOOLBOXMATLABDIR/graphics/", "$TOOLBOXMATLABDIR/uitools/", + "$TOOLBOXMATLABDIR/strfun/", "$TOOLBOXMATLABDIR/imagesci/", + "$TOOLBOXMATLABDIR/iofun/", "$TOOLBOXMATLABDIR/audiovideo/", + "$TOOLBOXMATLABDIR/timefun/", "$TOOLBOXMATLABDIR/datatypes/", + "$TOOLBOXMATLABDIR/verctrl/", "$TOOLBOXMATLABDIR/codetools/", + "$TOOLBOXMATLABDIR/helptools/", "$TOOLBOXMATLABDIR/demos/", + "$TOOLBOXMATLABDIR/timeseries/", "$TOOLBOXMATLABDIR/hds/", + "$TOOLBOXMATLABDIR/guide/", "$TOOLBOXMATLABDIR/plottools/", + "toolbox/local/", "toolbox/compiler/", "toolbox/database/database/" }; + +static const char * MCC_innerProd_classpath_data[] = + { "java/jar/toolbox/database.jar" }; + +static const char * MCC_innerProd_libpath_data[] = + { "" }; + +static const char * MCC_innerProd_app_opts_data[] = + { "" }; + +static const char * MCC_innerProd_run_opts_data[] = + { "" }; + +static const char * MCC_innerProd_warning_state_data[] = + { "" }; + + +mclComponentData __MCC_innerProd_component_data = { + + /* Public key data */ + __MCC_innerProd_public_key, + + /* Component name */ + "innerProd", + + /* Component Root */ + "", + + /* Application key data */ + __MCC_innerProd_session_key, + + /* Component's MATLAB Path */ + MCC_innerProd_matlabpath_data, + + /* Number of directories in the MATLAB Path */ + 36, + + /* Component's Java class path */ + MCC_innerProd_classpath_data, + /* Number of directories in the Java class path */ + 1, + + /* Component's load library path (for extra shared libraries) */ + MCC_innerProd_libpath_data, + /* Number of directories in the load library path */ + 0, + + /* MCR instance-specific runtime options */ + MCC_innerProd_app_opts_data, + /* Number of MCR instance-specific runtime options */ + 0, + + /* MCR global runtime options */ + MCC_innerProd_run_opts_data, + /* Number of MCR global runtime options */ + 0, + + /* Component preferences directory */ + "innerProd_EEEFF7AADF2C5D8569D4742763DAC0AB", + + /* MCR warning status data */ + MCC_innerProd_warning_state_data, + /* Number of MCR warning status modifiers */ + 0, + + /* Path to component - evaluated at runtime */ + NULL + +}; + +#ifdef __cplusplus +} +#endif + + diff --git a/SD-VBS/benchmarks/texture_synthesis/src/MEX/mccExcludedFiles.log b/SD-VBS/benchmarks/texture_synthesis/src/MEX/mccExcludedFiles.log new file mode 100755 index 0000000..981940f --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/MEX/mccExcludedFiles.log @@ -0,0 +1,12 @@ +This file contains the list of various toolbox functions that are not +included in the CTF file. An error will be thrown if any of these functions + are called at run-time. Some of these functions may be from toolboxes +that you are not using in your application. The reason for this is that +these toolboxes have overloaded some methods that are called by your code. +If you know which toolboxes are being used by your code, you can use the -p + flag with the -N flag to list these toolboxes explicitly. This will +cause MATLAB Compiler to only look for functions in the specified toolbox +directories in addition to the MATLAB directories. Refer to the MCC +documentation for more information on this. + +0 item(s) excluded by M-file compilabilty rules. diff --git a/SD-VBS/benchmarks/texture_synthesis/src/c/script_texture_synthesis.c b/SD-VBS/benchmarks/texture_synthesis/src/c/script_texture_synthesis.c new file mode 100644 index 0000000..01ddefd --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/c/script_texture_synthesis.c @@ -0,0 +1,197 @@ +/******************************** +Author: Sravanthi Kota Venkata +********************************/ + +#include "texture.h" +#include +#include "extra.h" +#define TEXTURE_MEM 1<<28 +int WIDTHin,HEIGHTin; +F2D *target, *result; +int WIDTH,HEIGHT; +int localx, localy,targetin=0; +int *atlas; +int *xloopin, *yloopin; +int *xloopout, *yloopout; + +int main(int argc, char **argv) +{ + SET_UP + mallopt(M_TOP_PAD, TEXTURE_MEM); + mallopt(M_MMAP_MAX, 0); + params* data; + I2D *im; + F2D* image; + data = malloc(sizeof(params)); + im = parse_flags(argc, argv); + image = fiDeepCopy(im); + init_params(data); + + printf("start.\n"); + for_each_job{ + create_texture(image, data); + } + printf("end..\n"); +#ifdef CHECK +{ + int ret=0; +#ifdef GENERATE_OUTPUT + fWriteMatrix(result, argv[1]); +#endif + ret = fSelfCheck(result, "expected_C.txt", 1.0); + if(ret < 0) + printf("Error in Texture Synthesis\n"); +} +#endif + iFreeHandle(im); + fFreeHandle(image); + free(data); + fFreeHandle(target); + fFreeHandle(result); + free(atlas); + WRITE_TO_FILE + return 0; +} + +I2D* parse_flags(int argc, char ** argv) +{ + int i, tsx,tsy; + I2D* image; + char fileNm[256]; + + printf("Input image: "); + scanf("%s", fileNm); + image = readImage(fileNm); + WIDTHin = image->width; + HEIGHTin = image->height; + + localx = 3; + localy = 3; + +#ifdef test + WIDTH = WIDTHin*2; + HEIGHT = HEIGHTin*2; + localx = 2; + localy = 2; +#endif +#ifdef sim_fast + WIDTH = WIDTHin*2; + HEIGHT = HEIGHTin*2; + localx = 3; + localy = 3; +#endif +#ifdef sim + WIDTH = WIDTHin*3; + HEIGHT = HEIGHTin*3; + localx = 2; + localy = 2; +#endif +#ifdef sqcif + WIDTH = WIDTHin*6; + HEIGHT = HEIGHTin*6; + localx = 2; + localy = 2; +#endif +#ifdef qcif + WIDTH = WIDTHin*10; + HEIGHT = HEIGHTin*10; + localx = 2; + localy = 2; +#endif +#ifdef cif + WIDTH = WIDTHin*10; + HEIGHT = HEIGHTin*10; + localx = 3; + localy = 3; +#endif +#ifdef vga + WIDTH = WIDTHin*20; + HEIGHT = HEIGHTin*20; + localx = 3; + localy = 3; +#endif +#ifdef fullhd + WIDTH = WIDTHin*20; + HEIGHT = HEIGHTin*20; + localx = 15; + localy = 15; +#endif +#ifdef wuxga + WIDTH = WIDTHin*20; + HEIGHT = HEIGHTin*20; + localx = 5; + localy = 5; +#endif + printf("Input size\t\t- (%dx%d)\n", HEIGHTin, WIDTHin); + +// xloopin = malloc(2*WIDTHin*sizeof(int)); +// yloopin = malloc(2*HEIGHTin*sizeof(int)); +// +// for(i=-WIDTHin/2;ilocalx = localx; data->localy = localy; + data->widthin = WIDTHin; data->widthout = WIDTH; + data->heightin = HEIGHTin; data->heightout = HEIGHT; + + + if(!targetin) + { + for(i=0;iheightout;i++) + { + for(j=0;jwidthout;j++) + { + asubsref(target,a(j,i,data->widthout)+R) = 1.0; +// asubsref(target,a(j,i,data->widthout)+G) = 1.0; +// asubsref(target,a(j,i,data->widthout)+B) = 1.0; + } + } + } + + for(i=0;iheightout;i++) + { + for(j=0;jwidthout;j++) + { + asubsref(result,a(j,i,data->widthout)+R) = 1.0; +// asubsref(result,a(j,i,data->widthout)+G) = 1.0; +// asubsref(result,a(j,i,data->widthout)+B) = 1.0; + } + } +} diff --git a/SD-VBS/benchmarks/texture_synthesis/src/c/texture.c b/SD-VBS/benchmarks/texture_synthesis/src/c/texture.c new file mode 100644 index 0000000..fb0f1ae --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/c/texture.c @@ -0,0 +1,396 @@ +/******************************** +Author: Sravanthi Kota Venkata +********************************/ + +#include "texture.h" +#include + +int vrstartx, vrfinishx, vrstarty, vrfinishy; +extern params data; +int* candlistx, *candlisty; +int *atlas; +int anotherpass=0,maxcand = 40; +F2D *target, *result; +int *xloopout, *yloopout; +int *xloopin, *yloopin; + +double compare_rest(F2D *image,int x, int y, F2D *tar,int x1, int y1, params* data); + +/********************************* +This is the main texture synthesis function. Called just once +from main to generate image from 'image' into 'result'. +Synthesis parameters (image and neighborhood sizes) are in global +'data-> structure. +*********************************/ + +//void create_texture(F2D *image, F2D *result, params *data) +void create_texture(F2D *image, params *data) +{ + + int i,j,k, ncand, bestx,besty; + double diff,curdiff; + int tsx,tsy; + srand48(1); + candlistx = (int*)malloc(sizeof(int)*(data->localx*(data->localy+1)+1)); + candlisty = (int*)malloc(sizeof(int)*(data->localx*(data->localy+1)+1)); +// if(!anotherpass) init(result, image,data); + if(!anotherpass) init(image,data); + + for(i=0;iheightout-data->localy/2;i++) + { + for(j=0;jwidthout;j++) + { + // First, create a list of candidates for particular pixel. + if(anotherpass) ncand = create_all_candidates(j,i, data); + else ncand = create_candidates(j,i, data); + + // If there are multiple candidates, choose the best based on L_2 norm + + if(ncand > 1) + { + diff = 1e10; + for(k=0;kwidthout)+R) = asubsref(image,a(bestx,besty,data->widthin)+R); +// asubsref(result,a(j,i,data->widthout)+G) = asubsref(image,a(bestx,besty,data->widthin)+G); +// asubsref(result,a(j,i,data->widthout)+B) = asubsref(image,a(bestx,besty,data->widthin)+B); + arrayref(atlas,aa(j,i)) = bestx; + arrayref(atlas,aa(j,i)+1) = besty; + } + } + + // Use full neighborhoods for the last few rows. This is a small + // fraction of total area - can be ignored for optimization purposes. + + for(;iheightout;i++) + { + for(j=0;jwidthout;j++) + { + ncand = create_all_candidates(j,i,data); + if(ncand > 1) + { + diff = 1e10; + for(k=0;kwidthout)+R) = asubsref(image,a(bestx,besty,data->widthin)+R); +// asubsref(result,a(j,i,data->widthout)+G) = asubsref(image,a(bestx,besty,data->widthin)+G); +// asubsref(result,a(j,i,data->widthout)+B) = asubsref(image,a(bestx,besty,data->widthin)+B); + arrayref(atlas,aa(j,i)) = bestx; + arrayref(atlas,aa(j,i)+1) = besty; + } + } + + /********************************* + End of main texture synthesis loop + *********************************/ + + for(i=0;ilocaly/2;i++) + { + for(j=0;jwidthout;j++) + { + ncand = create_all_candidates(j,i,data); + if(ncand > 1) + { + diff = 1e10; + for(k=0;kwidthout)+R) = asubsref(image,a(bestx,besty,data->widthin)+R); +// asubsref(result,a(j,i,data->widthout)+G) = asubsref(image,a(bestx,besty,data->widthin)+G); +// asubsref(result,a(j,i,data->widthout)+B) = asubsref(image,a(bestx,besty,data->widthin)+B); + arrayref(atlas,aa(j,i)) = bestx; + arrayref(atlas,aa(j,i)+1) = besty; + } + } +} + +// Creates a list of valid candidates for given pixel using only L-shaped causal area + +int create_candidates(int x,int y, params* data) +{ + int address,i,j,k,n = 0; + for(i=0;i<=data->localy/2;i++) + { + for(j=-data->localx/2;j<=data->localx/2;j++) + { + if(i==0 && j>=0) + continue; + address = aa( arrayref(xloopout,x+j), arrayref(yloopout,y-i) ); + arrayref(candlistx,n) = arrayref(atlas,address) - j; + arrayref(candlisty,n) = arrayref(atlas,address+1) + i; + + if( arrayref(candlistx,n) >= vrfinishx || arrayref(candlistx,n) < vrstartx) + { + arrayref(candlistx,n) = vrstartx + (int)(drand48()*(vrfinishx-vrstartx)); + arrayref(candlisty,n) = vrstarty + (int)(drand48()*(vrfinishy-vrstarty)); + n++; + continue; + } + + if( arrayref(candlisty,n) >= vrfinishy ) + { + arrayref(candlisty,n) = vrstarty + (int)(drand48()*(vrfinishy-vrstarty)); + arrayref(candlistx,n) = vrstartx + (int)(drand48()*(vrfinishx-vrstartx)); + n++; + continue; + } + + for(k=0;klocaly/2;i<=data->localy/2;i++) + { + for(j=-data->localx/2;j<=data->localx/2;j++) + { + if(i==0 && j>=0) + continue; +// printf("Entering = (%d,%d)\n", i,j); + address = aa( arrayref(xloopout,x+j), arrayref(yloopout,y-i) ); + arrayref(candlistx,n) = arrayref(atlas,address)-j; + arrayref(candlisty,n) = arrayref(atlas,address+1)+i; + + if( arrayref(candlistx,n) >= vrfinishx || arrayref(candlistx,n) < vrstartx) + { + arrayref(candlistx,n) = vrstartx + (int)(drand48()*(vrfinishx-vrstartx)); + arrayref(candlisty,n) = vrstarty + (int)(drand48()*(vrfinishy-vrstarty)); + n++; +// printf("1: (%d,%d)\t%d\n", i,j,n); + continue; + } + + if( arrayref(candlisty,n) >= vrfinishy || arrayref(candlisty,n) < vrstarty) + { + arrayref(candlisty,n) = vrstarty + (int)(drand48()*(vrfinishy-vrstarty)); + arrayref(candlistx,n) = vrstartx + (int)(drand48()*(vrfinishx-vrstartx)); + n++; +// printf("2: (%d,%d)\t%d\n", i,j,n); + continue; + } + + for(k=0;klocalx/2; vrstarty = data->localy/2; + vrfinishx = data->widthin-data->localx/2; + vrfinishy = data->heightin-data->localy/2; + for(i=0;iheightout;i++) + { + for(j=0;jwidthout;j++) + { + if( + asubsref(target,a(j,i,data->widthout)+R) == 1.0 +// && asubsref(target,a(j,i,data->widthout)+G) == 1.0 +// && asubsref(target,a(j,i,data->widthout)+B) == 1.0 + ) + { + tmpx = vrstartx + (int)(drand48()*(vrfinishx-vrstartx)); + tmpy = vrstarty + (int)(drand48()*(vrfinishy-vrstarty)); + if(!anotherpass) + { + arrayref(atlas,aa(j,i)) = tmpx; + arrayref(atlas,aa(j,i)+1) = tmpy; + asubsref(result,a(j,i,data->widthout)+R) = asubsref(image,a(tmpx,tmpy,data->widthin)+R); +// asubsref(result,a(j,i,data->widthout)+G) = asubsref(image,a(tmpx,tmpy,data->widthin)+G); +// asubsref(result,a(j,i,data->widthout)+B) = asubsref(image,a(tmpx,tmpy,data->widthin)+B); + } + } + } + } + + return; +} + + +// Compares two square neighborhoods, returns L_2 difference + +double compare_full_neighb(F2D *image,int x, int y, F2D *image1,int x1, int y1, params* data) +{ + double tmp,res = 0; + int i,j,addr,addr1; + for(i=-(data->localy/2);i<=data->localy/2;i++) + { + for(j=-(data->localx/2);j<=data->localx/2;j++) + { + if( !( i > 0 && y1 > data->localy && y1+i < data->heightout) ) + { + addr = a(x+j,y+i,data->widthin); + addr1 = a( arrayref(xloopout,x1+j), arrayref(yloopout,y1+i), data->widthout); + + tmp = asubsref(image,addr+R) - asubsref(image1,addr1+R); + res += tmp*tmp; +// tmp = asubsref(image,addr+G) - asubsref(image1,addr1+G); +// res += tmp*tmp; +// tmp = asubsref(image,addr+B) - asubsref(image1,addr1+B); +// res += tmp*tmp; + } + } + } + + return res; +} + +// Compares two L-shaped neighborhoods, returns L_2 difference + +double compare_neighb(F2D *image,int x, int y, F2D *image1,int x1, int y1, params* data) +{ + double tmp,res = 0; + int i,j,addr1,addr; + for(i=-(data->localy/2);i<0;i++) + { + for(j=-(data->localx/2);j<=data->localx/2;j++) + { + addr = a(x+j,y+i,data->widthin); + addr1 = a( arrayref(xloopout,x1+j), arrayref(yloopout,y1+i), data->widthout); + + tmp = asubsref(image,addr+R) - asubsref(image1,addr1+R); + res += tmp*tmp; +// tmp = asubsref(image,addr+G) - asubsref(image1,addr1+G); +// res += tmp*tmp; +// tmp = asubsref(image,addr+B) - asubsref(image1,addr1+B); +// res += tmp*tmp; + } + } + + for(j=-(data->localx/2);j<0;j++) + { + addr = a(x+j,y,data->widthin); + addr1 = a( arrayref(xloopout,x1+j), y1, data->widthout); + + tmp = asubsref(image,addr+R) - asubsref(image1,addr1+R); + res += tmp*tmp; +// tmp = asubsref(image,addr+G) - asubsref(image1,addr1+G); +// res += tmp*tmp; +// tmp = asubsref(image,addr+B) - asubsref(image1,addr1+B); +// res += tmp*tmp; + } + + return res; +} + +double compare_rest(F2D *image,int x, int y, F2D *tar,int x1, int y1, params* data) +{ + double tmp,res = 0; + int i,j,addr,addr1; + + for(i=(data->localy/2);i>0;i--) + { + for(j=-(data->localx/2);j<=data->localx/2;j++) + { + addr = a(x+j,y+i,data->widthin); + addr1 = a( arrayref(xloopout,x1+j), arrayref(yloopout,y1+i), data->widthout); + + if( asubsref(tar,addr1+R) != 1.0) //KVS? + { + tmp = asubsref(image,addr+R) - asubsref(tar,addr1+R); + res += tmp*tmp; +// tmp = asubsref(image,addr+G) - asubsref(tar,addr1+G); +// res += tmp*tmp; +// tmp = asubsref(image,addr+B) - asubsref(tar,addr1+B); +// res += tmp*tmp; + } + } + } + + for(j=(data->localx/2);j>0;j--) + { + addr = a(x+j,y,data->widthin); + addr1 = a( arrayref(xloopout,x1+j), y1, data->widthout); + if( asubsref(tar,addr1+R) != 1.0) // KVS? + { + tmp = asubsref(image,addr+R) - asubsref(tar,addr1+R); + res += tmp*tmp; +// tmp = asubsref(image,addr+G) - asubsref(tar,addr1+G); +// res += tmp*tmp; +// tmp = asubsref(image,addr+B) - asubsref(tar,addr1+B); +// res += tmp*tmp; + } + } + + return res; +} + diff --git a/SD-VBS/benchmarks/texture_synthesis/src/c/texture.h b/SD-VBS/benchmarks/texture_synthesis/src/c/texture.h new file mode 100644 index 0000000..9819c03 --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/c/texture.h @@ -0,0 +1,48 @@ +/******************************** +Author: Sravanthi Kota Venkata +********************************/ + +#ifndef _TEXTURE_ +#define _TEXTURE_ + +#include "sdvbs_common.h" + +#define R 0 +#define G 1 +#define B 2 +#define a(x,y,W) (1*((y)*(W)+(x))) +#define aa(x,y) (2*((y)*data->widthout+(x))) + +typedef float pixelvalue; + +typedef struct +{ + double sign, diff; + int x,y; + int secondx, secondy; +}signature; + +typedef struct{ + int localx, localy, localz; + int widthin, widthout; + int heightin, heightout; + int nfin, nfout; +}params; + +void *SIGNATURES; + +//void create_texture(F2D *image, F2D *result, params *data); +void create_texture(F2D *image, params *data); +I2D* parse_flags(int argc, char ** argv); +void init_params(params *data); +//void init(F2D *result, F2D *image, params* data); +void init(F2D *image, params* data); +double compare_full_neighb(F2D *image,int x, int y, F2D *image1,int x1, int y1, params* data); +double compare_neighb(F2D *image,int x, int y, F2D *image1,int x1, int y1, params* data); +int create_candidates(int x,int y, params* data); +int create_all_candidates(int x,int y, params* data); + +#endif + + + -- cgit v1.2.2