| 1179 | //----------------------------------------------------------------------------- |
| 1180 | |
| 1181 | static unsigned int |
| 1182 | legacySelectPattern( |
| 1183 | BlasFunctionID funcID, |
| 1184 | unsigned int maxImages) |
| 1185 | { |
| 1186 | unsigned int id, i, n; |
| 1187 | MatrixRole mrole; |
| 1188 | MemoryPattern *pat; |
| 1189 | int score, maxScore = -1; |
| 1190 | |
| 1191 | id = -1; |
| 1192 | /* |
| 1193 | * Lookup all patterns, and assign a score per each matrix for |
| 1194 | * each pattern: |
| 1195 | * 0 - matrix is not cached |
| 1196 | * 2 - matrix is cached and stored in an image |
| 1197 | * 3 - matrix is cached and not stored in an image |
| 1198 | * |
| 1199 | * Find the pattern with the best score |
| 1200 | */ |
| 1201 | pat = clblasSolvers[funcID].memPatterns; |
| 1202 | |
| 1203 | for (i = 0; i < clblasSolvers[funcID].nrPatterns; i++, pat++) { |
| 1204 | score = 0; |
| 1205 | n = 0; |
| 1206 | |
| 1207 | for (mrole = MATRIX_A; mrole <= MATRIX_B; mrole++) { |
| 1208 | if (isMatrixCached(pat, mrole)) { |
| 1209 | if (isMatrixInImage(pat, mrole)) { |
| 1210 | n++; |
| 1211 | score += 2; |
| 1212 | } |
| 1213 | else { |
| 1214 | score += 3; |
| 1215 | } |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | if (n > maxImages) { |
| 1220 | continue; |
| 1221 | } |
| 1222 | |
| 1223 | if (score > maxScore) { |
| 1224 | maxScore = score; |
| 1225 | id = i; |
| 1226 | } |
| 1227 | } |
| 1228 | |
| 1229 | return id; |
| 1230 | } |
| 1231 | //----------------------------------------------------------------------------- |
| 1232 | |
| 1233 | unsigned int |
no test coverage detected