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