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/texture_synthesis/src/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/texture_synthesis/src/c')
3 files changed, 641 insertions, 0 deletions
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 @@ | |||
| 1 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include "texture.h" | ||
| 6 | #include <malloc.h> | ||
| 7 | #include "extra.h" | ||
| 8 | #define TEXTURE_MEM 1<<28 | ||
| 9 | int WIDTHin,HEIGHTin; | ||
| 10 | F2D *target, *result; | ||
| 11 | int WIDTH,HEIGHT; | ||
| 12 | int localx, localy,targetin=0; | ||
| 13 | int *atlas; | ||
| 14 | int *xloopin, *yloopin; | ||
| 15 | int *xloopout, *yloopout; | ||
| 16 | |||
| 17 | int main(int argc, char **argv) | ||
| 18 | { | ||
| 19 | SET_UP | ||
| 20 | mallopt(M_TOP_PAD, TEXTURE_MEM); | ||
| 21 | mallopt(M_MMAP_MAX, 0); | ||
| 22 | params* data; | ||
| 23 | I2D *im; | ||
| 24 | F2D* image; | ||
| 25 | data = malloc(sizeof(params)); | ||
| 26 | im = parse_flags(argc, argv); | ||
| 27 | image = fiDeepCopy(im); | ||
| 28 | init_params(data); | ||
| 29 | |||
| 30 | printf("start.\n"); | ||
| 31 | for_each_job{ | ||
| 32 | create_texture(image, data); | ||
| 33 | } | ||
| 34 | printf("end..\n"); | ||
| 35 | #ifdef CHECK | ||
| 36 | { | ||
| 37 | int ret=0; | ||
| 38 | #ifdef GENERATE_OUTPUT | ||
| 39 | fWriteMatrix(result, argv[1]); | ||
| 40 | #endif | ||
| 41 | ret = fSelfCheck(result, "expected_C.txt", 1.0); | ||
| 42 | if(ret < 0) | ||
| 43 | printf("Error in Texture Synthesis\n"); | ||
| 44 | } | ||
| 45 | #endif | ||
| 46 | iFreeHandle(im); | ||
| 47 | fFreeHandle(image); | ||
| 48 | free(data); | ||
| 49 | fFreeHandle(target); | ||
| 50 | fFreeHandle(result); | ||
| 51 | free(atlas); | ||
| 52 | WRITE_TO_FILE | ||
| 53 | return 0; | ||
| 54 | } | ||
| 55 | |||
| 56 | I2D* parse_flags(int argc, char ** argv) | ||
| 57 | { | ||
| 58 | int i, tsx,tsy; | ||
| 59 | I2D* image; | ||
| 60 | char fileNm[256]; | ||
| 61 | |||
| 62 | printf("Input image: "); | ||
| 63 | scanf("%s", fileNm); | ||
| 64 | image = readImage(fileNm); | ||
| 65 | WIDTHin = image->width; | ||
| 66 | HEIGHTin = image->height; | ||
| 67 | |||
| 68 | localx = 3; | ||
| 69 | localy = 3; | ||
| 70 | |||
| 71 | #ifdef test | ||
| 72 | WIDTH = WIDTHin*2; | ||
| 73 | HEIGHT = HEIGHTin*2; | ||
| 74 | localx = 2; | ||
| 75 | localy = 2; | ||
| 76 | #endif | ||
| 77 | #ifdef sim_fast | ||
| 78 | WIDTH = WIDTHin*2; | ||
| 79 | HEIGHT = HEIGHTin*2; | ||
| 80 | localx = 3; | ||
| 81 | localy = 3; | ||
| 82 | #endif | ||
| 83 | #ifdef sim | ||
| 84 | WIDTH = WIDTHin*3; | ||
| 85 | HEIGHT = HEIGHTin*3; | ||
| 86 | localx = 2; | ||
| 87 | localy = 2; | ||
| 88 | #endif | ||
| 89 | #ifdef sqcif | ||
| 90 | WIDTH = WIDTHin*6; | ||
| 91 | HEIGHT = HEIGHTin*6; | ||
| 92 | localx = 2; | ||
| 93 | localy = 2; | ||
| 94 | #endif | ||
| 95 | #ifdef qcif | ||
| 96 | WIDTH = WIDTHin*10; | ||
| 97 | HEIGHT = HEIGHTin*10; | ||
| 98 | localx = 2; | ||
| 99 | localy = 2; | ||
| 100 | #endif | ||
| 101 | #ifdef cif | ||
| 102 | WIDTH = WIDTHin*10; | ||
| 103 | HEIGHT = HEIGHTin*10; | ||
| 104 | localx = 3; | ||
| 105 | localy = 3; | ||
| 106 | #endif | ||
| 107 | #ifdef vga | ||
| 108 | WIDTH = WIDTHin*20; | ||
| 109 | HEIGHT = HEIGHTin*20; | ||
| 110 | localx = 3; | ||
| 111 | localy = 3; | ||
| 112 | #endif | ||
| 113 | #ifdef fullhd | ||
| 114 | WIDTH = WIDTHin*20; | ||
| 115 | HEIGHT = HEIGHTin*20; | ||
| 116 | localx = 15; | ||
| 117 | localy = 15; | ||
| 118 | #endif | ||
| 119 | #ifdef wuxga | ||
| 120 | WIDTH = WIDTHin*20; | ||
| 121 | HEIGHT = HEIGHTin*20; | ||
| 122 | localx = 5; | ||
| 123 | localy = 5; | ||
| 124 | #endif | ||
| 125 | printf("Input size\t\t- (%dx%d)\n", HEIGHTin, WIDTHin); | ||
| 126 | |||
| 127 | // xloopin = malloc(2*WIDTHin*sizeof(int)); | ||
| 128 | // yloopin = malloc(2*HEIGHTin*sizeof(int)); | ||
| 129 | // | ||
| 130 | // for(i=-WIDTHin/2;i<WIDTHin+WIDTHin/2;i++) | ||
| 131 | // { | ||
| 132 | // arrayref(xloopin,i+WIDTHin/2) = (WIDTHin+i)%WIDTHin; | ||
| 133 | // } | ||
| 134 | // | ||
| 135 | // for(i=-HEIGHTin/2;i<HEIGHTin+HEIGHTin/2;i++) | ||
| 136 | // { | ||
| 137 | // arrayref(yloopin,i+HEIGHTin/2) = (HEIGHTin+i)%HEIGHTin; | ||
| 138 | // } | ||
| 139 | // xloopin += WIDTHin/2; yloopin += HEIGHTin/2; | ||
| 140 | |||
| 141 | result = fMallocHandle(1,HEIGHT*WIDTH); | ||
| 142 | target = fMallocHandle(1, WIDTH*HEIGHT); | ||
| 143 | |||
| 144 | atlas = malloc(2*WIDTH*HEIGHT*sizeof(int)); | ||
| 145 | xloopout = malloc(2*WIDTH*sizeof(int)); | ||
| 146 | yloopout = malloc(2*HEIGHT*sizeof(int)); | ||
| 147 | |||
| 148 | for(i=-WIDTH/2;i<WIDTH+WIDTH/2;i++) | ||
| 149 | { | ||
| 150 | arrayref(xloopout,i+WIDTH/2) = (WIDTH+i)%WIDTH; | ||
| 151 | } | ||
| 152 | for(i=-HEIGHT/2;i<HEIGHT+HEIGHT/2;i++) | ||
| 153 | { | ||
| 154 | arrayref(yloopout,i+HEIGHT/2) = (HEIGHT+i)%HEIGHT; | ||
| 155 | } | ||
| 156 | xloopout += WIDTH/2; yloopout += HEIGHT/2; | ||
| 157 | |||
| 158 | if (result == NULL) | ||
| 159 | { | ||
| 160 | printf("Can't allocate %dx%d image. Exiting.\n",WIDTH,HEIGHT); | ||
| 161 | exit(1); | ||
| 162 | } | ||
| 163 | |||
| 164 | return image; | ||
| 165 | } | ||
| 166 | |||
| 167 | void init_params(params *data) | ||
| 168 | { | ||
| 169 | int i,j; | ||
| 170 | data->localx = localx; data->localy = localy; | ||
| 171 | data->widthin = WIDTHin; data->widthout = WIDTH; | ||
| 172 | data->heightin = HEIGHTin; data->heightout = HEIGHT; | ||
| 173 | |||
| 174 | |||
| 175 | if(!targetin) | ||
| 176 | { | ||
| 177 | for(i=0;i<data->heightou | ||
