Menu

Safest CPU options for time-critical code, targeting users of recent x64 machines

Help
Elena
2023-03-12
2023-03-14
  • Elena

    Elena - 2023-03-12

    Hi, I apologize in advance for my question not being possibly too specific. Keep in mind that I am not very expert with CPU architectures and low level HW details. Also, I could never ask for help on StackOverflow because, as a too generic question, it would suddently be down-voted and banned :( So I am trying here hoping this is the right place.

    I am a C++ music plugin developer, targeting Windows 64 users on "averagely recent" x64 machines - where with "averagely recent" I can't be more specific sadly (deciding this is not easy !), let's say users of CPUs not older than 10 years or so up to the most recent and powerful ones.

    Real-time DSP code, despite efficiently written, must also be compiled with all available optimizations and most profiteable CPU options - the latter choice being problematic. I am not using any inline assembly or explicit vectorizations or intrinsics (honestly I am not expert with those). But for certain time-critical parts, I tend to exploit fused multiply-adds instructions a lot, which I could verify on actual benchmarking they can make the difference.

    Problem is, GCC does NOT generate fma instructions by default, and setting the highest optimizations flags and -m64 is not enough for those. I have to either set -mfma or -march=x86-64-v3 (no less than v3). Sadly, some beta testers of my plugins, in particular one with a recent enough Celeron, report a crash when loading a plugin compiled with -march=x86-64-v3. And I have still to test what happens with just -mfma. While all is fine on my i7 8700K of course.

    So to my question:
    if one wanted to be 100% safe with users (excluding users of very old CPUs), yet being sure that all the most recent x64 instructions and features are fully exploited for efficiency, which CPU options should he specify for compiling ?
    I personally hate having to distribute two or more versions of my plugins compiled for different architectures, even because I would proceed by trial and error, not being particularly expert with these HW details and with all the possible CPU architectures !

    Any relevant help is appreciated, thanks.

     
  • Elena

    Elena - 2023-03-14

    Hi, is it possible that nobody can reply ? Or at least, can you please suggest which is the proper forum where to ask such a question ?

    I can now add more details if they may help... I tried either -mfma and -march=x86-64-v3 on a Celeron N5095A but it crashes, while it runs fine without those flags. I honestly cannot easily explain the reason even after having checked the specs on Intel site. If somebody can help me I would really appreciate it.

     

Log in to post a comment.