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/sift/src/c/script_sift.c | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 SD-VBS/benchmarks/sift/src/c/script_sift.c (limited to 'SD-VBS/benchmarks/sift/src/c/script_sift.c') diff --git a/SD-VBS/benchmarks/sift/src/c/script_sift.c b/SD-VBS/benchmarks/sift/src/c/script_sift.c new file mode 100644 index 0000000..0b2f106 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/script_sift.c @@ -0,0 +1,83 @@ +/******************************** +Author: Sravanthi Kota Venkata +********************************/ + +#include +#include +#include "sift.h" +#include +#include "extra.h" +#define SIFT_MEM 1<<29 +void normalizeImage(F2D* image) +{ + int i; + int rows; + int cols; + + int tempMin = 10000, tempMax = -1; + rows = image->height; + cols = image->width; + + for(i=0; i<(rows*cols); i++) + if(tempMin > asubsref(image,i)) + tempMin = asubsref(image,i); + + for(i=0; i<(rows*cols); i++) + asubsref(image,i) = asubsref(image,i) - tempMin; + + for(i=0; i<(rows*cols); i++) + if(tempMax < asubsref(image,i)) + tempMax = asubsref(image,i); + + for(i=0; i<(rows*cols); i++) + asubsref(image,i) = ( asubsref(image,i) / (tempMax+0.0) ); +} + +int main(int argc, char* argv[]) +{ + SET_UP + mallopt(M_TOP_PAD, SIFT_MEM); + mallopt(M_MMAP_MAX, 0); + I2D* im; + F2D *image; + int rows, cols, i, j; + F2D* frames; + unsigned int* startTime, *endTime, *elapsed; + + char imSrc[100]; + printf("Input image: "); + scanf("%s", imSrc); + im = readImage(imSrc); + image = fiDeepCopy(im); + rows = image->height; + cols = image->width; + + + printf("start\n"); + for_each_job{ + image = fiDeepCopy(im); + normalizeImage(image); + /** Extract sift features for the normalized image **/ + frames = sift(image); + } + printf("end..\n"); + +#ifdef CHECK + { + int ret=0; + float tol = 0.2; +#ifdef GENERATE_OUTPUT + fWriteMatrix(frames, argv[1]); +#endif + ret = fSelfCheck(frames, "expected_C.txt", tol); + if (ret == -1) + printf("Error in SIFT\n"); + } +#endif + + iFreeHandle(im); + fFreeHandle(frames); + WRITE_TO_FILE + return 0; +} + -- cgit v1.2.2