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/localization/src/c/generateSample.c | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 SD-VBS/benchmarks/localization/src/c/generateSample.c (limited to 'SD-VBS/benchmarks/localization/src/c/generateSample.c') diff --git a/SD-VBS/benchmarks/localization/src/c/generateSample.c b/SD-VBS/benchmarks/localization/src/c/generateSample.c new file mode 100644 index 0000000..3acb4d7 --- /dev/null +++ b/SD-VBS/benchmarks/localization/src/c/generateSample.c @@ -0,0 +1,88 @@ +/******************************** +Author: Sravanthi Kota Venkata +********************************/ + +#include +#include +#include "localization.h" + +void generateSample(F2D *w, F2D *quat, F2D *vel, F2D *pos) +{ + int rows, cols, i, j, index; + I2D *sampleXId; + F2D *retQuat, *retVel, *retPos; + + sampleXId = weightedSample(w); + + rows = sampleXId->height; + cols = sampleXId->width; + + if(cols > 1) + printf("ERROR: Cols more than 1.. Handle this case \n"); + + retQuat = fSetArray(quat->height, quat->width, 0); + retVel = fSetArray(vel->height, vel->width, 0); + retPos = fSetArray(pos->height, pos->width, 0); + + for(i=0; iwidth; j++) + { + subsref(retQuat,i,j) = subsref(quat,index,j); + } + } + + for(i=0; iwidth; j++) + { + subsref(retVel,i,j) = subsref(vel,index,j); + } + } + + for(i=0; iwidth; j++) + { + subsref(retPos,i,j) = subsref(pos,index,j); + } + } + + for(i=0; iheight; i++) + { + for(j=0; jwidth; j++) + { + subsref(quat,i,j) = subsref(retQuat,i,j); + } + } + + for(i=0; iheight; i++) + { + for(j=0; jwidth; j++) + { + subsref(vel,i,j) = subsref(retVel,i,j); + } + } + + for(i=0; iheight; i++) + { + for(j=0; jwidth; j++) + { + subsref(pos,i,j) = subsref(retPos,i,j); + } + } + + fFreeHandle(retQuat); + fFreeHandle(retVel); + fFreeHandle(retPos); + iFreeHandle(sampleXId); + + return; +} + + + + -- cgit v1.2.2