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/localization/src/c/generateSample.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/localization/src/c/generateSample.c')
| -rw-r--r-- | SD-VBS/benchmarks/localization/src/c/generateSample.c | 88 |
1 files changed, 88 insertions, 0 deletions
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 @@ | |||
| 1 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include <stdio.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include "localization.h" | ||
| 8 | |||
| 9 | void generateSample(F2D *w, F2D *quat, F2D *vel, F2D *pos) | ||
| 10 | { | ||
| 11 | int rows, cols, i, j, index; | ||
| 12 | I2D *sampleXId; | ||
| 13 | F2D *retQuat, *retVel, *retPos; | ||
| 14 | |||
| 15 | sampleXId = weightedSample(w); | ||
| 16 | |||
| 17 | rows = sampleXId->height; | ||
| 18 | cols = sampleXId->width; | ||
| 19 | |||
| 20 | if(cols > 1) | ||
| 21 | printf("ERROR: Cols more than 1.. Handle this case \n"); | ||
| 22 | |||
| 23 | retQuat = fSetArray(quat->height, quat->width, 0); | ||
| 24 | retVel = fSetArray(vel->height, vel->width, 0); | ||
| 25 | retPos = fSetArray(pos->height, pos->width, 0); | ||
| 26 | |||
| 27 | for(i=0; i<rows; i++) | ||
| 28 | { | ||
| 29 | index = asubsref(sampleXId, i) - 1; | ||
| 30 | for(j=0; j<quat->width; j++) | ||
| 31 | { | ||
| 32 | subsref(retQuat,i,j) = subsref(quat,index,j); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | for(i=0; i<rows; i++) | ||
| 37 | { | ||
| 38 | index = asubsref(sampleXId, i) - 1; | ||
| 39 | for(j=0; j<vel->width; j++) | ||
| 40 | { | ||
| 41 | subsref(retVel,i,j) = subsref(vel,index,j); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | for(i=0; i<rows; i++) | ||
| 46 | { | ||
| 47 | index = asubsref(sampleXId, i) - 1; | ||
| 48 | for(j=0; j<pos->width; j++) | ||
| 49 | { | ||
| 50 | subsref(retPos,i,j) = subsref(pos,index,j); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | for(i=0; i<quat->height; i++) | ||
| 55 | { | ||
| 56 | for(j=0; j<quat->width; j++) | ||
| 57 | { | ||
| 58 | subsref(quat,i,j) = subsref(retQuat,i,j); | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | for(i=0; i<vel->height; i++) | ||
| 63 | { | ||
| 64 | for(j=0; j<vel->width; j++) | ||
| 65 | { | ||
| 66 | subsref(vel,i,j) = subsref(retVel,i,j); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | for(i=0; i<pos->height; i++) | ||
| 71 | { | ||
| 72 | for(j=0; j<pos->width; j++) | ||
| 73 | { | ||
| 74 | subsref(pos,i,j) = subsref(retPos,i,j); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | fFreeHandle(retQuat); | ||
| 79 | fFreeHandle(retVel); | ||
| 80 | fFreeHandle(retPos); | ||
| 81 | iFreeHandle(sampleXId); | ||
| 82 | |||
| 83 | return; | ||
| 84 | } | ||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | |||
