summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/svm/src/c/usps_read_partial.c
diff options
context:
space:
mode:
authorLeo Chan <leochanj@live.unc.edu>2020-10-22 01:53:21 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-10-22 01:56:35 -0400
commitd17b33131c14864bd1eae275f49a3f148e21cf29 (patch)
tree0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/benchmarks/svm/src/c/usps_read_partial.c
parent601ed25a4c5b66cb75315832c15613a727db2c26 (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/svm/src/c/usps_read_partial.c')
-rw-r--r--SD-VBS/benchmarks/svm/src/c/usps_read_partial.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/svm/src/c/usps_read_partial.c b/SD-VBS/benchmarks/svm/src/c/usps_read_partial.c
new file mode 100644
index 0000000..9cc9df0
--- /dev/null
+++ b/SD-VBS/benchmarks/svm/src/c/usps_read_partial.c
@@ -0,0 +1,85 @@
1/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "svm.h"
6
7F2D* usps_read_partial(F2D* dcell1, F2D* dcell2, int idx, int opt, int dim, int iterations)
8{
9 F2D *ret, *X, *Y;
10 F2D *ADD;
11 int i, j, k, m, n;
12
13 F2D *temp, *temp1;
14
15 if(opt == 1)
16 {
17 for(i=0; i<iterations; i++)
18 {
19 if(i==0)
20 {
21 X = fMallocHandle(dim, dcell1->width);
22 for(m=0; m<dim; m++)
23 {
24 for(n=0; n<dcell1->width; n++)
25 {
26 subsref(X,m,n) = subsref(dcell1,m,n);
27 }
28 }
29 }
30 else
31 {
32 temp = fDeepCopy(X);
33 fFreeHandle(X);
34 temp1 = fMallocHandle(dim, dcell2->width);
35
36 for(m=0; m<dim; m++)
37 {
38 for(n=0; n<dcell2->width; n++)
39 {
40 subsref(temp1,m,n) = subsref(dcell2,m,n);
41 }
42 }
43 X = ffVertcat(temp, temp1);
44 fFreeHandle(temp);
45 fFreeHandle(temp1);
46 }
47 }
48 ret = fDeepCopy(X);
49 fFreeHandle(X);
50 }
51 else
52 {
53 for(i=0; i<iterations; i++)
54 {
55 if(idx == -1)
56 ADD = fSetArray(dim, 1, i+1);
57 else
58 {
59 if( i!= idx)
60 ADD = fSetArray(dim, 1, -1);
61 else
62 ADD = fSetArray(dim, 1, 1);
63 }
64 if(i==0)
65 {
66 Y = fDeepCopy(ADD);
67 }
68 else
69 {
70 F2D* t = fDeepCopy(Y);
71 fFreeHandle(Y);
72 Y = ffVertcat(t, ADD);
73 fFreeHandle(t);
74 }
75 fFreeHandle(ADD);
76 }
77 ret = fDeepCopy(Y);
78 fFreeHandle(Y);
79 }
80
81 return ret;
82}
83
84
85