Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 1 | # Web UI for configuration of the CMSIS-DSP Build |
| 2 | # |
| 3 | # How to install |
| 4 | # pip install streamlit |
| 5 | # |
| 6 | # How to use |
Christophe Favergeon | 5bc9e87 | 2021-04-28 14:00:00 +0200 | [diff] [blame] | 7 | # streamlit run cmsisdspconfig.py |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 8 | # |
| 9 | import streamlit as st |
| 10 | import textwrap |
| 11 | import re |
| 12 | |
| 13 | |
| 14 | st.set_page_config(page_title="CMSIS-DSP Configuration",layout="wide" ) |
| 15 | |
| 16 | # Options requiring a special management |
| 17 | NOTSTANDARD=["allTables","allInterpolations","allFFTs","Float16"] |
| 18 | |
| 19 | HELIUM=False |
| 20 | |
| 21 | config={} |
| 22 | |
Christophe Favergeon | 5bc9e87 | 2021-04-28 14:00:00 +0200 | [diff] [blame] | 23 | # Used in UI |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 24 | config["allTables"] = True |
| 25 | config["allFFTs"] = True |
| 26 | config["allInterpolations"] = True |
| 27 | config["MVEI"]=False |
| 28 | config["MVEF"]=False |
| 29 | config["NEON"]=False |
| 30 | config["HELIUM"]=False |
Christophe Favergeon | 7450136 | 2021-03-02 08:38:01 +0100 | [diff] [blame] | 31 | config["HELIUMEXPERIMENTAL"]=False |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 32 | config["Float16"]=True |
| 33 | config["HOST"]=False |
| 34 | |
| 35 | config["COS_F32"]=False |
| 36 | config["COS_Q31"]=False |
| 37 | config["COS_Q15"]=False |
| 38 | config["SIN_F32"]=False |
| 39 | config["SIN_Q31"]=False |
| 40 | config["SIN_Q15"]=False |
| 41 | config["SIN_COS_F32"]=False |
| 42 | config["SIN_COS_Q31"]=False |
| 43 | config["LMS_NORM_Q31"]=False |
| 44 | config["LMS_NORM_Q15"]=False |
| 45 | config["CMPLX_MAG_Q31"]=False |
| 46 | config["CMPLX_MAG_Q15"]=False |
Christophe Favergeon | 18bfe33 | 2021-09-30 09:01:14 +0200 | [diff] [blame] | 47 | config["CMPLX_MAG_FAST_Q15"]=False |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 48 | |
Christophe Favergeon | 5bc9e87 | 2021-04-28 14:00:00 +0200 | [diff] [blame] | 49 | config["CFFT_RADIX2_Q15"]=False |
| 50 | config["CFFT_RADIX4_Q15"]=False |
| 51 | config["CFFT_RADIX2_Q31"]=False |
| 52 | config["CFFT_RADIX4_Q31"]=False |
| 53 | |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 54 | config["BASICMATH"]=True |
| 55 | config["COMPLEXMATH"]=True |
| 56 | config["CONTROLLER"]=True |
| 57 | config["FASTMATH"]=True |
| 58 | config["FILTERING"]=True |
| 59 | config["MATRIX"]=True |
| 60 | config["STATISTICS"]=True |
| 61 | config["SUPPORT"]=True |
| 62 | config["TRANSFORM"]=True |
| 63 | config["SVM"]=True |
| 64 | config["BAYES"]=True |
| 65 | config["DISTANCE"]=True |
| 66 | config["INTERPOLATION"]=True |
Christophe Favergeon | af1c54b | 2021-02-15 14:15:10 +0100 | [diff] [blame] | 67 | config["QUATERNIONMATH"]=True |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 68 | |
| 69 | config["LOOPUNROLL"]=True |
| 70 | config["ROUNDING"]=False |
| 71 | config["MATRIXCHECK"]=False |
| 72 | config["AUTOVECTORIZE"] = False |
| 73 | |
Christophe Favergeon | 5bc9e87 | 2021-04-28 14:00:00 +0200 | [diff] [blame] | 74 | # Used as options in command line |
| 75 | # in case the UI option is worded differently |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 76 | realname={} |
| 77 | realname["COS_F32"]="ARM_COS_F32" |
| 78 | realname["COS_Q31"]="ARM_COS_Q31" |
| 79 | realname["COS_Q15"]="ARM_COS_Q15" |
| 80 | realname["SIN_F32"]="ARM_SIN_F32" |
| 81 | realname["SIN_Q31"]="ARM_SIN_Q31" |
| 82 | realname["SIN_Q15"]="ARM_SIN_Q15" |
| 83 | realname["SIN_COS_F32"]="ARM_SIN_COS_F32" |
| 84 | realname["SIN_COS_Q31"]="ARM_SIN_COS_Q31" |
| 85 | realname["LMS_NORM_Q31"]="ARM_LMS_NORM_Q31" |
| 86 | realname["LMS_NORM_Q15"]="ARM_LMS_NORM_Q15" |
| 87 | realname["CMPLX_MAG_Q31"]="ARM_CMPLX_MAG_Q31" |
| 88 | realname["CMPLX_MAG_Q15"]="ARM_CMPLX_MAG_Q15" |
Christophe Favergeon | 18bfe33 | 2021-09-30 09:01:14 +0200 | [diff] [blame] | 89 | realname["CMPLX_MAG_FAST_Q15"]="ARM_CMPLX_MAG_FAST_Q15" |
Christophe Favergeon | 5bc9e87 | 2021-04-28 14:00:00 +0200 | [diff] [blame] | 90 | realname["CFFT_RADIX2_Q15"]="ARM_CFFT_RADIX2_Q15" |
| 91 | realname["CFFT_RADIX4_Q15"]="ARM_CFFT_RADIX4_Q15" |
| 92 | realname["CFFT_RADIX2_Q31"]="ARM_CFFT_RADIX2_Q31" |
| 93 | realname["CFFT_RADIX4_Q31"]="ARM_CFFT_RADIX4_Q31" |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 94 | |
| 95 | defaulton={} |
| 96 | defaulton["LOOPUNROLL"]=True |
| 97 | defaulton["BASICMATH"]=True |
| 98 | defaulton["COMPLEXMATH"]=True |
| 99 | defaulton["CONTROLLER"]=True |
| 100 | defaulton["FASTMATH"]=True |
| 101 | defaulton["FILTERING"]=True |
| 102 | defaulton["MATRIX"]=True |
| 103 | defaulton["STATISTICS"]=True |
| 104 | defaulton["SUPPORT"]=True |
| 105 | defaulton["TRANSFORM"]=True |
| 106 | defaulton["SVM"]=True |
| 107 | defaulton["BAYES"]=True |
| 108 | defaulton["DISTANCE"]=True |
| 109 | defaulton["INTERPOLATION"]=True |
Christophe Favergeon | af1c54b | 2021-02-15 14:15:10 +0100 | [diff] [blame] | 110 | defaulton["QUATERNIONMATH"]=True |
| 111 | |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 112 | |
| 113 | CFFTSIZE=[16,32,64,128,256,512,1024,2048,4096] |
| 114 | CFFTDATATYPE=['F64','F32','F16','Q31','Q15'] |
| 115 | |
| 116 | RFFTFASTSIZE=[32,64,128,256,512,1024,2048,4096] |
| 117 | RFFTFASTDATATYPE=['F64','F32','F16'] |
| 118 | |
| 119 | RFFTSIZE=[32,64,128,256,512,1024,2048,4096,8192] |
| 120 | RFFTDATATYPE=['F32','Q31','Q15'] |
| 121 | |
| 122 | DCTSIZE=[128,512,2048,8192] |
| 123 | DCTDATATYPE=['F32','Q31','Q15'] |
| 124 | |
| 125 | def joinit(iterable, delimiter): |
| 126 | # Intersperse a delimiter between element of a list |
| 127 | it = iter(iterable) |
| 128 | yield next(it) |
| 129 | for x in it: |
| 130 | yield delimiter |
| 131 | yield x |
| 132 | |
| 133 | def options(l): |
| 134 | return("".join(joinit(l," "))) |
| 135 | |
| 136 | def computeCmakeOptions(config): |
| 137 | global defaulton |
| 138 | cmake={} |
| 139 | if not config["allTables"]: |
| 140 | cmake["CONFIGTABLE"]=True |
| 141 | if config["allInterpolations"]: |
| 142 | cmake["ALLFAST"]=True |
| 143 | if config["allFFTs"]: |
| 144 | cmake["ALLFFT"]=True |
| 145 | if config["Float16"]: |
| 146 | cmake["FLOAT16"]=True |
| 147 | else: |
| 148 | cmake["DISABLEFLOAT16"]=True |
| 149 | |
| 150 | for c in config: |
| 151 | if not (c in NOTSTANDARD): |
| 152 | if c in defaulton: |
| 153 | if not config[c]: |
| 154 | if c in realname: |
| 155 | cmake[realname[c]]=False |
| 156 | else: |
| 157 | cmake[c]=False |
| 158 | else: |
| 159 | if config[c]: |
| 160 | if c in realname: |
| 161 | cmake[realname[c]]=True |
| 162 | else: |
| 163 | cmake[c]=True |
| 164 | return cmake |
| 165 | |
| 166 | def removeDuplicates(l): |
| 167 | return list(dict.fromkeys(l)) |
| 168 | |
| 169 | def genCMakeOptions(config): |
| 170 | r=[] |
| 171 | cmake = computeCmakeOptions(config) |
| 172 | for c in cmake: |
| 173 | if cmake[c]: |
| 174 | r.append("-D%s=ON" % c) |
| 175 | else: |
| 176 | r.append("-D%s=OFF" % c) |
| 177 | return(removeDuplicates(r),cmake) |
| 178 | |
| 179 | def test(cmake,s): |
| 180 | global defaulton |
| 181 | if s in defaulton and not (s in cmake): |
| 182 | return True |
| 183 | return(s in cmake and cmake[s]) |
| 184 | |
| 185 | def cfftCF32Config(cmake,size): |
| 186 | result=[] |
| 187 | if test(cmake,"CFFT_F32_%d" % size): |
| 188 | a="-DARM_TABLE_TWIDDLECOEF_F32_%d" % size |
| 189 | if HELIUM: |
| 190 | b = "-DARM_TABLE_BITREVIDX_FXT_%d" % size |
| 191 | else: |
| 192 | b = "-DARM_TABLE_BITREVIDX_FLT_%d" % size |
| 193 | result=[a,b] |
| 194 | return(result) |
| 195 | |
| 196 | def cfftCF16Config(cmake,size): |
| 197 | result=[] |
| 198 | if test(cmake,"CFFT_F16_%d" % size): |
| 199 | result =["-DARM_TABLE_TWIDDLECOEF_F16_%d" % size] |
| 200 | result.append("-DARM_TABLE_BITREVIDX_FXT_%d" % size) |
| 201 | result.append("-DARM_TABLE_BITREVIDX_FLT_%d" % size) |
| 202 | return(result) |
| 203 | |
| 204 | def cfftCF64Config(cmake,size): |
| 205 | result=[] |
| 206 | if test(cmake,"CFFT_F64_%d" % size): |
| 207 | result =["-DARM_TABLE_TWIDDLECOEF_F64_%d" % size] |
| 208 | result.append("-DARM_TABLE_BITREVIDX_FLT64_%d" % size) |
| 209 | return(result) |
| 210 | |
| 211 | |
| 212 | def cfftCFixedConfig(cmake,dt,size): |
| 213 | result=[] |
| 214 | if test(cmake,"CFFT_%s_%d" % (dt,size)): |
| 215 | a="-DARM_TABLE_TWIDDLECOEF_%s_%d" % (dt,size) |
| 216 | b = "-DARM_TABLE_BITREVIDX_FXT_%d" % size |
| 217 | result=[a,b] |
| 218 | return(result) |
| 219 | |
| 220 | def crfftFastCF64Config(cmake,size): |
| 221 | result=[] |
| 222 | s1 = size >> 1 |
| 223 | if test(cmake,"RFFT_FAST_F64_%d" % size): |
| 224 | result =[] |
| 225 | result.append("-DARM_TABLE_TWIDDLECOEF_F64_%d" % s1) |
| 226 | result.append("-DARM_TABLE_BITREVIDX_FLT64_%d" % s1) |
| 227 | result.append("-DARM_TABLE_TWIDDLECOEF_RFFT_F64_%d" % size) |
| 228 | result.append("-DARM_TABLE_TWIDDLECOEF_F64_%d" % s1) |
| 229 | |
| 230 | return(result) |
| 231 | |
| 232 | def crfftFastCF32Config(cmake,size): |
| 233 | result=[] |
| 234 | s1 = size >> 1 |
| 235 | if test(cmake,"RFFT_FAST_F32_%d" % size): |
| 236 | result =[] |
| 237 | result.append("-DARM_TABLE_TWIDDLECOEF_F32_%d" % s1) |
| 238 | result.append("-DARM_TABLE_BITREVIDX_FLT_%d" % s1) |
| 239 | result.append("-DARM_TABLE_TWIDDLECOEF_RFFT_F32_%d" % size) |
| 240 | |
| 241 | return(result) |
| 242 | |
| 243 | def crfftFastCF16Config(cmake,size): |
| 244 | result=[] |
| 245 | s1 = size >> 1 |
| 246 | if test(cmake,"RFFT_FAST_F16_%d" % size): |
| 247 | result =[] |
| 248 | result.append("-DARM_TABLE_TWIDDLECOEF_F16_%d" % s1) |
| 249 | result.append("-DARM_TABLE_BITREVIDX_FLT_%d" % s1) |
| 250 | result.append("-DARM_TABLE_BITREVIDX_FXT_%d" % s1) |
| 251 | result.append("-DARM_TABLE_TWIDDLECOEF_RFFT_F16_%d" % size) |
| 252 | |
| 253 | return(result) |
| 254 | |
| 255 | # Deprecated RFFT used in DCT |
| 256 | def crfftF32Config(cmake,size): |
| 257 | result=[] |
| 258 | s1 = size >> 1 |
| 259 | if test(cmake,"RFFT_FAST_F16_%d" % size): |
| 260 | result =[] |
| 261 | result.append("-DARM_TABLE_REALCOEF_F32") |
| 262 | result.append("-ARM_TABLE_BITREV_%d" % s1) |
| 263 | result.append("-ARM_TABLE_TWIDDLECOEF_F32_%d" % s1) |
| 264 | |
| 265 | return(result) |
| 266 | |
| 267 | |
| 268 | def crfftFixedConfig(cmake,dt,size): |
| 269 | result=[] |
| 270 | s1 = size >> 1 |
| 271 | if test(cmake,"RFFT_%s_%d" % (dt,size)): |
| 272 | result =[] |
| 273 | result.append("-DARM_TABLE_REALCOEF_%s" % dt) |
| 274 | result.append("-DARM_TABLE_TWIDDLECOEF_%s_%d" % (dt,s1)) |
| 275 | result.append("-DARM_TABLE_BITREVIDX_FXT_%d" % s1) |
| 276 | |
| 277 | return(result) |
| 278 | |
| 279 | |
| 280 | def dctConfig(cmake,dt,size): |
| 281 | result=[] |
| 282 | if test(cmake,"DCT4_%s_%d" % (dt,size)): |
| 283 | result =[] |
| 284 | result.append("-DARM_TABLE_DCT4_%s_%d" % (dt,size)) |
| 285 | result.append("-DARM_TABLE_REALCOEF_F32") |
| 286 | result.append("-DARM_TABLE_BITREV_1024" ) |
| 287 | result.append("-DARM_TABLE_TWIDDLECOEF_%s_4096" % dt) |
| 288 | |
| 289 | return(result) |
| 290 | |
| 291 | # Convert cmake options to make flags |
| 292 | def interpretCmakeOptions(cmake): |
| 293 | r=[] |
| 294 | if test(cmake,"CONFIGTABLE"): |
| 295 | r.append("-DARM_DSP_CONFIG_TABLES") |
| 296 | # In Make configuration we build all modules. |
| 297 | # So the code for FFT and FAST maths may be included |
| 298 | # so we allow the table to be included if they are needed. |
| 299 | r.append("-DARM_FAST_ALLOW_TABLES") |
| 300 | r.append("-DARM_FFT_ALLOW_TABLES") |
| 301 | for size in CFFTSIZE: |
| 302 | r += cfftCF32Config(cmake,size) |
| 303 | r += cfftCF16Config(cmake,size) |
| 304 | r += cfftCF64Config(cmake,size) |
| 305 | r += cfftCFixedConfig(cmake,"Q31",size) |
| 306 | r += cfftCFixedConfig(cmake,"Q15",size) |
| 307 | |
| 308 | for size in RFFTFASTSIZE: |
| 309 | r += crfftFastCF64Config(cmake,size) |
| 310 | r += crfftFastCF32Config(cmake,size) |
| 311 | r += crfftFastCF16Config(cmake,size) |
| 312 | |
| 313 | for size in RFFTSIZE: |
| 314 | r += crfftFixedConfig(cmake,"F32",size) |
| 315 | r += crfftFixedConfig(cmake,"Q31",size) |
| 316 | r += crfftFixedConfig(cmake,"Q15",size) |
| 317 | |
| 318 | for size in DCTSIZE: |
| 319 | r += dctConfig(cmake,"F32",size) |
| 320 | r += dctConfig(cmake,"Q31",size) |
| 321 | r += dctConfig(cmake,"Q15",size) |
| 322 | |
| 323 | |
| 324 | |
| 325 | if test(cmake,"ALLFAST"): |
| 326 | r.append("-DARM_ALL_FAST_TABLES") |
| 327 | if test(cmake,"ALLFFT"): |
| 328 | r.append("-DARM_ALL_FFT_TABLES") |
| 329 | |
| 330 | if test(cmake,"LOOPUNROLL"): |
| 331 | r.append("-DARM_MATH_LOOPUNROLL") |
| 332 | if test(cmake,"ROUNDING"): |
| 333 | r.append("-DARM_MATH_ROUNDING") |
| 334 | if test(cmake,"MATRIXCHECK"): |
| 335 | r.append("-DARM_MATH_MATRIX_CHECK") |
| 336 | if test(cmake,"AUTOVECTORIZE"): |
| 337 | r.append("-DARM_MATH_AUTOVECTORIZE") |
| 338 | if test(cmake,"DISABLEFLOAT16"): |
| 339 | r.append("-DDISABLEFLOAT16") |
| 340 | if test(cmake,"NEON"): |
| 341 | r.append("-DARM_MATH_NEON") |
| 342 | r.append("-DARM_MATH_NEON_EXPERIMENTAL") |
| 343 | if test(cmake,"HOST"): |
| 344 | r.append("-D__GNUC_PYTHON__") |
| 345 | |
| 346 | if test(cmake,"ARM_COS_F32"): |
| 347 | r.append("-DARM_TABLE_SIN_F32") |
| 348 | if test(cmake,"ARM_COS_Q31"): |
| 349 | r.append("-DARM_TABLE_SIN_Q31") |
| 350 | if test(cmake,"ARM_COS_Q15"): |
| 351 | r.append("-DARM_TABLE_SIN_Q15") |
| 352 | |
| 353 | if test(cmake,"ARM_SIN_F32"): |
| 354 | r.append("-DARM_TABLE_SIN_F32") |
| 355 | if test(cmake,"ARM_SIN_Q31"): |
| 356 | r.append("-DARM_TABLE_SIN_Q31") |
| 357 | if test(cmake,"ARM_SIN_Q15"): |
| 358 | r.append("-DARM_TABLE_SIN_Q15") |
| 359 | |
| 360 | if test(cmake,"ARM_SIN_COS_F32"): |
| 361 | r.append("-DARM_TABLE_SIN_F32") |
| 362 | if test(cmake,"ARM_SIN_COS_Q31"): |
| 363 | r.append("-DARM_TABLE_SIN_Q31") |
| 364 | |
| 365 | if test(cmake,"ARM_LMS_NORM_Q31"): |
| 366 | r.append("-DARM_TABLE_RECIP_Q31") |
| 367 | |
| 368 | if test(cmake,"ARM_LMS_NORM_Q15"): |
| 369 | r.append("-DARM_TABLE_RECIP_Q15") |
| 370 | |
| 371 | if test(cmake,"ARM_CMPLX_MAG_Q31"): |
| 372 | r.append("-DARM_TABLE_FAST_SQRT_Q31_MVE") |
| 373 | |
| 374 | if test(cmake,"ARM_CMPLX_MAG_Q15"): |
Christophe Favergeon | 18bfe33 | 2021-09-30 09:01:14 +0200 | [diff] [blame] | 375 | r.append("-DARM_TABLE_FAST_SQRT_Q31_MVE") |
| 376 | |
| 377 | if test(cmake,"ARM_CMPLX_MAG_FAST_Q15"): |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 378 | r.append("-DARM_TABLE_FAST_SQRT_Q15_MVE") |
| 379 | |
| 380 | if test(cmake,"MVEI"): |
| 381 | r.append("-DARM_MATH_MVEI") |
| 382 | |
| 383 | if test(cmake,"MVEF"): |
| 384 | r.append("-DARM_MATH_MVEF") |
| 385 | |
Christophe Favergeon | 7450136 | 2021-03-02 08:38:01 +0100 | [diff] [blame] | 386 | if test(cmake,"HELIUMEXPERIMENTAL"): |
| 387 | r.append("-DARM_MATH_HELIUM_EXPERIMENTAL") |
| 388 | |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 389 | if test(cmake,"HELIUM") or test(cmake,"MVEF") or test(cmake,"MVEI"): |
| 390 | r.append("-IPrivateInclude") |
| 391 | |
| 392 | if test(cmake,"NEON") or test(cmake,"NEONEXPERIMENTAL"): |
| 393 | r.append("-IComputeLibrary/Include") |
| 394 | |
Christophe Favergeon | 5bc9e87 | 2021-04-28 14:00:00 +0200 | [diff] [blame] | 395 | if test(cmake,"ARM_CFFT_RADIX2_Q15") or test(cmake,"ARM_CFFT_RADIX4_Q15"): |
| 396 | r.append("-DARM_TABLE_TWIDDLECOEF_Q15_4096") |
| 397 | r.append("-DARM_TABLE_BITREV_1024") |
| 398 | |
| 399 | if test(cmake,"ARM_CFFT_RADIX2_Q31") or test(cmake,"ARM_CFFT_RADIX4_Q31"): |
| 400 | r.append("-DARM_TABLE_TWIDDLECOEF_Q31_4096") |
| 401 | r.append("-DARM_TABLE_BITREV_1024") |
| 402 | |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 403 | return (removeDuplicates(r)) |
| 404 | |
| 405 | def genMakeOptions(config): |
| 406 | cmake = computeCmakeOptions(config) |
| 407 | r=interpretCmakeOptions(cmake) |
| 408 | return(r,cmake) |
| 409 | |
| 410 | |
| 411 | def check(config,s,name=None,comment=None): |
| 412 | if comment is not None: |
| 413 | st.sidebar.text(comment) |
| 414 | if name is None: |
| 415 | config[s]=st.sidebar.checkbox(s,value=config[s]) |
| 416 | else: |
| 417 | config[s]=st.sidebar.checkbox(name,value=config[s]) |
| 418 | return(config[s]) |
| 419 | |
| 420 | def genconfig(config,transform,sizes,datatypes): |
| 421 | global realname |
| 422 | for size in sizes: |
| 423 | for dt in datatypes: |
| 424 | s="%s_%s_%s" % (transform,dt,size) |
| 425 | config[s] = False |
| 426 | realname[s] = s |
| 427 | |
| 428 | def hasDCTF32(config): |
| 429 | result=False |
| 430 | for size in DCTSIZE: |
| 431 | s="DCT4_F32_%s" % size |
| 432 | if config[s]: |
| 433 | result = True |
| 434 | return(result) |
| 435 | |
| 436 | def multiselect(config,name,options): |
| 437 | default=[] |
| 438 | for r in options: |
| 439 | if config[r]: |
| 440 | default.append(r) |
| 441 | result=st.sidebar.multiselect(name,options,default=default) |
| 442 | for r in options: |
| 443 | config[r] = False |
| 444 | for r in result: |
| 445 | config[r] = True |
| 446 | |
| 447 | def genui(config,transform,sizes,datatypes): |
| 448 | keepF32 = True |
| 449 | # RFFT F32 is deprecated and needed only for DCT4 |
| 450 | if transform == "RFFT": |
| 451 | keepF32 = hasDCTF32(config) |
| 452 | selected=st.sidebar.multiselect("Sizes",sizes) |
| 453 | for size in selected: |
| 454 | options=[] |
| 455 | for dt in datatypes: |
| 456 | if dt != "F32" or keepF32: |
| 457 | s="%s_%s_%s" % (transform,dt,size) |
| 458 | options.append(s) |
| 459 | multiselect(config,"Nb = %d" % size,options) |
| 460 | |
| 461 | |
| 462 | def configMake(config): |
| 463 | st.sidebar.header('Table Configuration') |
| 464 | st.sidebar.info("Several options to include only the tables needed in an app and minimize code size.") |
| 465 | if not check(config,"allTables","All tables included"): |
| 466 | |
| 467 | if not check(config,"allFFTs","All FFT tables included"): |
| 468 | st.sidebar.markdown("#### CFFT") |
| 469 | genui(config,"CFFT",CFFTSIZE,CFFTDATATYPE) |
| 470 | |
| 471 | st.sidebar.info("Following transforms are using the CFFT. You need to enable the needed CFFTs above.") |
| 472 | |
| 473 | st.sidebar.markdown("#### RFFT FAST") |
| 474 | genui(config,"RFFT_FAST",RFFTFASTSIZE,RFFTFASTDATATYPE) |
| 475 | st.sidebar.markdown("#### DCT4") |
| 476 | genui(config,"DCT4",DCTSIZE,DCTDATATYPE) |
| 477 | st.sidebar.markdown("#### RFFT") |
| 478 | genui(config,"RFFT",RFFTSIZE,RFFTDATATYPE) |
Christophe Favergeon | 5bc9e87 | 2021-04-28 14:00:00 +0200 | [diff] [blame] | 479 | |
| 480 | st.sidebar.markdown("#### Radix2 and Radix4 CFFT") |
| 481 | st.sidebar.info("Those functions are deprecated") |
| 482 | multiselect(config,"Radix",["CFFT_RADIX2_Q15","CFFT_RADIX4_Q15","CFFT_RADIX2_Q31","CFFT_RADIX4_Q31"]) |
| 483 | |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 484 | |
| 485 | |
| 486 | |
| 487 | |
| 488 | if not check(config,"allInterpolations",'All interpolation tables included'): |
| 489 | selected=st.sidebar.multiselect("Functions",["Cosine","Sine","SineCosine","Normalized LMS"]) |
| 490 | for s in selected: |
| 491 | if s == "Cosine": |
| 492 | multiselect(config,"Cosine",["COS_F32","COS_Q31","COS_Q15"]) |
| 493 | if s == "Sine": |
| 494 | multiselect(config,"Sine",["SIN_F32","SIN_Q31","SIN_Q15"]) |
| 495 | if s == "SineCosine": |
| 496 | multiselect(config,"SineCosine",["SIN_COS_F32","SIN_COS_Q31"]) |
| 497 | if s == "Normalized LMS": |
| 498 | multiselect(config,"Normalized LMS",["LMS_NORM_Q31","LMS_NORM_Q15"]) |
| 499 | |
| 500 | if config["MVEI"]: |
| 501 | st.sidebar.markdown("#### Complex Magnitude") |
Christophe Favergeon | 18bfe33 | 2021-09-30 09:01:14 +0200 | [diff] [blame] | 502 | multiselect(config,"Complex Magnitude",["CMPLX_MAG_Q31","CMPLX_MAG_Q15","CMPLX_MAG_FAST_Q15"]) |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 503 | |
| 504 | |
| 505 | |
| 506 | def configCMake(config): |
| 507 | multiselect(config,"Folders",["BASICMATH", |
| 508 | "COMPLEXMATH", |
| 509 | "CONTROLLER", |
| 510 | "FASTMATH", |
| 511 | "FILTERING", |
| 512 | "MATRIX", |
| 513 | "STATISTICS", |
| 514 | "SUPPORT", |
| 515 | "TRANSFORM", |
| 516 | "SVM", |
| 517 | "BAYES", |
| 518 | "DISTANCE", |
Christophe Favergeon | af1c54b | 2021-02-15 14:15:10 +0100 | [diff] [blame] | 519 | "INTERPOLATION","QUATERNIONMATH"]) |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 520 | configMake(config) |
| 521 | |
| 522 | genconfig(config,"CFFT",CFFTSIZE,CFFTDATATYPE) |
| 523 | genconfig(config,"RFFT_FAST",RFFTFASTSIZE,RFFTFASTDATATYPE) |
| 524 | genconfig(config,"RFFT",RFFTSIZE,RFFTDATATYPE) |
| 525 | genconfig(config,"DCT4",DCTSIZE,DCTDATATYPE) |
| 526 | |
| 527 | st.title('CMSIS-DSP Configuration') |
| 528 | |
| 529 | st.warning("It is a work in progress. Only a small subset of the combinations has been tested.") |
| 530 | |
| 531 | st.sidebar.header('Feature Configuration') |
| 532 | st.sidebar.info("To build on host. All features will be enabled.") |
| 533 | forHost=check(config,"HOST") |
| 534 | |
| 535 | if not forHost: |
| 536 | st.sidebar.info("Enable or disable float16 support") |
| 537 | check(config,"Float16") |
| 538 | |
| 539 | st.sidebar.info("Some configurations for the CMSIS-DSP code.") |
| 540 | check(config,"LOOPUNROLL") |
| 541 | st.sidebar.text("Decrease performances when selected:") |
| 542 | check(config,"ROUNDING") |
| 543 | check(config,"MATRIXCHECK") |
| 544 | |
Christophe Favergeon | 7450136 | 2021-03-02 08:38:01 +0100 | [diff] [blame] | 545 | st.sidebar.header('Vector extensions') |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 546 | st.sidebar.info("Enable vector code. It is not automatic for Neon. Use of Helium will enable new options to select some interpolation tables.") |
| 547 | archi=st.sidebar.selectbox("Vector",('None','Helium','Neon')) |
| 548 | if archi == 'Neon': |
| 549 | config["NEON"]=True |
| 550 | if archi == 'Helium': |
| 551 | multiselect(config,"MVE configuration",["MVEI","MVEF"]) |
| 552 | HELIUM=True |
Christophe Favergeon | 7450136 | 2021-03-02 08:38:01 +0100 | [diff] [blame] | 553 | st.sidebar.info("When checked some experimental versions will be enabled and may be less performant than scalar version depending on the architecture.") |
| 554 | check(config,"HELIUMEXPERIMENTAL") |
Christophe Favergeon | a391d77 | 2021-02-10 10:56:33 +0100 | [diff] [blame] | 555 | if archi != 'None': |
| 556 | st.sidebar.info("When autovectorization is on, pure C code will be compiled. The version with C intrinsics won't be compiled.") |
| 557 | check(config,"AUTOVECTORIZE") |
| 558 | |
| 559 | |
| 560 | |
| 561 | st.sidebar.header('Build Method') |
| 562 | |
| 563 | st.sidebar.info("With cmake, some folders can be removed from the build.") |
| 564 | selected=st.sidebar.selectbox('Select', ("Make","Cmake"),index=1) |
| 565 | |
| 566 | |
| 567 | |
| 568 | if selected == "Make": |
| 569 | if not forHost: |
| 570 | configMake(config) |
| 571 | result,cmake=genMakeOptions(config) |
| 572 | else: |
| 573 | if not forHost: |
| 574 | configCMake(config) |
| 575 | result,cmake=genCMakeOptions(config) |
| 576 | |
| 577 | st.header('Build options for %s command line' % selected) |
| 578 | |
| 579 | if selected == "Make": |
| 580 | if test(cmake,"FLOAT16"): |
| 581 | st.info("Float16 is selected. You may need to pass compiler specific options for the compiler to recognize the float16 type.") |
| 582 | |
| 583 | mode=st.selectbox("Mode",["txt","MDK","sh","bat"]) |
| 584 | |
| 585 | if mode=="txt": |
| 586 | st.code(textwrap.fill(options(result))) |
| 587 | |
| 588 | if mode=="MDK": |
| 589 | opts=options(result) |
| 590 | includes="" |
| 591 | maybeincludes=re.findall(r'\-I([^\s]+)',opts) |
| 592 | # Managed in MDK pack file |
| 593 | #if maybeincludes: |
| 594 | # includes = maybeincludes |
| 595 | # st.text("Following include directories must be added") |
| 596 | # st.code(includes) |
| 597 | opts=re.sub(r'\-D','',opts) |
| 598 | opts=re.sub(r'\-I[^\s]+','',opts) |
| 599 | st.text("MDK Preprocessor Symbols ") |
| 600 | st.code(opts) |
| 601 | |
| 602 | |
| 603 | if mode=="sh": |
| 604 | lines=options(result).split() |
| 605 | txt="" |
| 606 | for l in lines: |
| 607 | txt += " %s \\\n" % l |
| 608 | txt += "\n" |
| 609 | st.code(txt) |
| 610 | |
| 611 | if mode=="bat": |
| 612 | lines=options(result).split() |
| 613 | txt="" |
| 614 | for l in lines: |
| 615 | txt += " %s ^\n" % l |
| 616 | txt += "\n" |
| 617 | st.code(txt) |
| 618 | |