summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Bakita <jbakita@cs.unc.edu>2021-03-07 19:14:19 -0500
committerJoshua Bakita <jbakita@cs.unc.edu>2021-03-07 19:25:21 -0500
commit899765845196007c695a2f858dbe3a41b8db4a2b (patch)
tree98754916059357c0829fd8acc73130565d866ace
parentafcfb8ee7b005edeba8163f00ce5300cf77ede85 (diff)
SD-VBS: Fix memory leaks and tweak allocation bounds
- Fix leaks in localization, multi_ncut, svm, and texture_synthesis - Lower preallocation for sift and texture_synthesis to match memory profile with QCIF - Remove trailing whitespace in script_localization.c
-rw-r--r--SD-VBS/benchmarks/localization/src/c/script_localization.c203
-rw-r--r--SD-VBS/benchmarks/multi_ncut/src/c/script_multi_ncut.c1
-rw-r--r--SD-VBS/benchmarks/sift/src/c/script_sift.c2
-rw-r--r--SD-VBS/benchmarks/svm/src/c/script_svm.c21
-rw-r--r--SD-VBS/benchmarks/texture_synthesis/src/c/script_texture_synthesis.c4
-rw-r--r--SD-VBS/benchmarks/texture_synthesis/src/c/texture.c2
6 files changed, 119 insertions, 114 deletions
diff --git a/SD-VBS/benchmarks/localization/src/c/script_localization.c b/SD-VBS/benchmarks/localization/src/c/script_localization.c
index ed37132..ddd2215 100644
--- a/SD-VBS/benchmarks/localization/src/c/script_localization.c
+++ b/SD-VBS/benchmarks/localization/src/c/script_localization.c
@@ -78,7 +78,7 @@ int main(int argc, char* argv[])
78 vel = fSetArray(n, 3, 0); 78 vel = fSetArray(n, 3, 0);
79 ones = fSetArray(n,1,1); 79 ones = fSetArray(n,1,1);
80 80
81 81
82 F2D *randn; 82 F2D *randn;
83 83
84 randn = randWrapper(n,3); 84 randn = randWrapper(n,3);
@@ -96,38 +96,38 @@ int main(int argc, char* argv[])
96 } 96 }
97 97
98 98
99 99
100 { 100 {
101 F2D *eulAngle, *randn; 101 F2D *eulAngle, *randn;
102 eulAngle = fSetArray(n, 3, 0); 102 eulAngle = fSetArray(n, 3, 0);
103 randn = randWrapper(n,1); 103 randn = randWrapper(n,1);
104 104
105 for(i=0; i<n; i++) 105 for(i=0; i<n; i++)
106 { 106 {
107 subsref(eulAngle, i, 2) = subsref(randn, i, 0) * 2 * pi; 107 subsref(eulAngle, i, 2) = subsref(randn, i, 0) * 2 * pi;
108 } 108 }
109 109
110 eul1 = eul2quat(eulAngle); 110 eul1 = eul2quat(eulAngle);
111 fFreeHandle(eulAngle); 111 fFreeHandle(eulAngle);
112 112
113 eulAngle = fSetArray(1, 3, 0); 113 eulAngle = fSetArray(1, 3, 0);
114 subsref(eulAngle, 0, 0) = pi; 114 subsref(eulAngle, 0, 0) = pi;
115 eul2 = eul2quat(eulAngle); 115 eul2 = eul2quat(eulAngle);
116 116
117 fFreeHandle(randn); 117 fFreeHandle(randn);
118 fFreeHandle(eulAngle); 118 fFreeHandle(eulAngle);
119 } 119 }
120 120
121 quat = quatMul(eul1, eul2); 121 quat = quatMul(eul1, eul2);
122 fFreeHandle(eul1); 122 fFreeHandle(eul1);
123 fFreeHandle(eul2); 123 fFreeHandle(eul2);
124 124
125 i=0; 125 i=0;
126 index = iSetArray(1,1,-1); 126 index = iSetArray(1,1,-1);
127 sType = iSetArray(1,1,-1); 127 sType = iSetArray(1,1,-1);
128 isEOF = iSetArray(1,1,-1); 128 isEOF = iSetArray(1,1,-1);
129 129
130 130
131 rows =0; 131 rows =0;
132 cols = 5; 132 cols = 5;
133 STDDEV_GPSPos = fSetArray(3,3,0); 133 STDDEV_GPSPos = fSetArray(3,3,0);
@@ -136,36 +136,36 @@ int main(int argc, char* argv[])
136 while(1) 136 while(1)
137 { 137 {
138 icount=icount+1; 138 icount=icount+1;
139 139
140 /* 140 /*
141 S = 4 141 S = 4
142 A = 3 142 A = 3
143 G = 2 143 G = 2
144 V = 1 144 V = 1
145 */ 145 */
146 146
147 sData = readSensorData(index, fid, sType, isEOF); 147 sData = readSensorData(index, fid, sType, isEOF);
148 rows++; 148 rows++;
149 149
150 150
151 151
152 if( asubsref(sType,0) ==2) 152 if( asubsref(sType,0) ==2)
153 { 153 {
154 154
155 //Motion model 155 //Motion model
156 156
157 { 157 {
158 int i; 158 int i;
159 F2D *t, *t1; 159 F2D *t, *t1;
160 F2D *abc, *abcd; 160 F2D *abc, *abcd;
161 int qD_r=0, qD_c=0; 161 int qD_r=0, qD_c=0;
162 F2D *cosA, *sinA; 162 F2D *cosA, *sinA;
163 163
164 t = fDeepCopyRange(sData, 0, 1, 0, 3); 164 t = fDeepCopyRange(sData, 0, 1, 0, 3);
165 gyro = fMtimes(ones, t); 165 gyro = fMtimes(ones, t);
166 abc = fMallocHandle(gyro->height, gyro->width); 166 abc = fMallocHandle(gyro->height, gyro->width);
167 t1 = fDeepCopy(randW); 167 t1 = fDeepCopy(randW);
168 168
169 for(i=0; i<(n*3); i++) 169 for(i=0; i<(n*3); i++)
170 { 170 {
171 asubsref(t1,i) = asubsref(randW,i) * M_STDDEV_GYRO; 171 asubsref(t1,i) = asubsref(randW,i) * M_STDDEV_GYRO;
@@ -174,103 +174,99 @@ int main(int argc, char* argv[])
174 } 174 }
175 fFreeHandle(t1); 175 fFreeHandle(t1);
176 abcd = fSum2(abc, 2); 176 abcd = fSum2(abc, 2);
177 177
178 norm_gyro = fMallocHandle(abcd->height,abcd->width); 178 norm_gyro = fMallocHandle(abcd->height,abcd->width);
179 angleAlpha = fMallocHandle(abcd->height, abcd->width); 179 angleAlpha = fMallocHandle(abcd->height, abcd->width);
180 180
181 for(i=0; i<(abcd->height*abcd->width); i++) 181 for(i=0; i<(abcd->height*abcd->width); i++)
182 { 182 {
183 asubsref(norm_gyro, i) = sqrt(asubsref(abcd,i)); 183 asubsref(norm_gyro, i) = sqrt(asubsref(abcd,i));
184 asubsref(angleAlpha,i) = asubsref(norm_gyro,i) * gyroTimeInterval; 184 asubsref(angleAlpha,i) = asubsref(norm_gyro,i) * gyroTimeInterval;
185 } 185 }
186 186
187 qD_r += angleAlpha->height + gyro->height; 187 qD_r += angleAlpha->height + gyro->height;
188 qD_c += angleAlpha->width + 3; 188 qD_c += angleAlpha->width + 3;
189 189
190 fFreeHandle(t); 190 fFreeHandle(t);
191 fFreeHandle(abcd); 191 fFreeHandle(abcd);
192 192
193 cosA = fSetArray(angleAlpha->height, angleAlpha->width, 0); 193 cosA = fSetArray(angleAlpha->height, angleAlpha->width, 0);
194 sinA = fSetArray(angleAlpha->height, angleAlpha->width, 0); 194 sinA = fSetArray(angleAlpha->height, angleAlpha->width, 0);
195 195
196 for(i=0; i<(cosA->height*cosA->width); i++) 196 for(i=0; i<(cosA->height*cosA->width); i++)
197 asubsref(cosA,i) = cos( asubsref(angleAlpha,i) /2 ); 197 asubsref(cosA,i) = cos( asubsref(angleAlpha,i) /2 );