tomojitakasu / PocketSDR

Other
229 stars 73 forks source link

AVX2 instruction forced breaks execution on non-AVX2 CPUs #16

Open jmfriedt opened 1 month ago

jmfriedt commented 1 month ago

Commit 99c6231 added OPTIONS = -DAVX2 -mavx2 -mfma to lib/build/libsdr.mk, leading to

 pocket_dump[3030167] trap invalid opcode ip:55fc619549b8 sp:7ffe82b923b0 error:0 in pocket_dump[55fc61953000+4000]

when executed on non-AVX2 CPUs. A test on the CPU capability when compiling would be nice, e.g. on the Intel(R) Core(TM) i5-3610ME of my Panasonic CF-19 the /proc/cpuinfo tells

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts vnmi md_clear flush_l1d

not including AVX2 support. I believe this is also valid in pocket_acq/makefile, pocket_snap/makefile and pocket_trk/makefile

jmfriedt commented 1 month ago

Replacing

    OPTIONS = -DAVX2 -mavx2 -mfma

with

    ifeq ($(shell grep -o avx2 /proc/cpuinfo | head -1),avx2)
       OPTIONS = -DAVX2 -mavx2 -mfma
    endif

seems to solve the issue (as done later to test ARM64 architecture)