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/common/c/iiConv2.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/common/c/iiConv2.c')
-rw-r--r-- | SD-VBS/common/c/iiConv2.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/SD-VBS/common/c/iiConv2.c b/SD-VBS/common/c/iiConv2.c new file mode 100644 index 0000000..436b206 --- /dev/null +++ b/SD-VBS/common/c/iiConv2.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include "sdvbs_common.h" | ||
6 | |||
7 | I2D* iiConv2(I2D* a, I2D* b) | ||
8 | { | ||
9 | I2D *c; | ||
10 | I2D *out; | ||
11 | int ma, na, mb, nb, ci, cj, i, j, m, n; | ||
12 | int r_index, c_index; | ||
13 | |||
14 | ma = a->height; | ||
15 | na = a->width; | ||
16 | |||
17 | mb = b->height; | ||
18 | nb = b->width; | ||
19 | |||
20 | r_index = ceil((mb + 1.0)/2.0); | ||
21 | c_index = ceil((nb + 1.0)/2.0); | ||
22 | |||
23 | ci = ma+mb-1; | ||
24 | cj = na+nb-1; | ||
25 | |||
26 | c = iSetArray(ci, cj, 0); | ||
27 | |||
28 | for(i=0; i<ci; i++) | ||
29 | { | ||
30 | for(j=0; j<cj; j++) | ||
31 | { | ||
32 | for(m=0; m<ma; m++) | ||
33 | { | ||
34 | for(n=0; n<na; n++) | ||
35 | { | ||
36 | if( (i-m)>=0 && (j-n)>=0 && (i-m)<mb && (j-n)<nb ) | ||
37 | subsref(c,i,j) += subsref(a,m,n) * subsref(b,i-m,j-n); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | } | ||
42 | } | ||
43 | |||
44 | out = iMallocHandle(ma, na); | ||
45 | for(i=0; i<ma; i++) | ||
46 | { | ||
47 | for(j=0; j<na; j++) | ||
48 | { | ||
49 | subsref(out,i,j) = subsref(c,(i+r_index-1),(j+c_index-1)); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | |||
54 | return out; | ||
55 | } | ||