From: j@bitminer.ca Subject: proposed www pages with advice on cpu extensions To: Tech Date: Sun, 14 Jul 2024 18:03:36 -0400 Hi @tech, After the extended discussion on elf_aux_info, I wrote down what I learned in the form of changes to the porting specialtopics.html file. Comments, corrections? (upcoming emulation of arm64 MIDR not included.) J Index: index.html =================================================================== RCS file: /cvs/www/faq/ports/index.html,v diff -u -p -r1.37 index.html --- index.html 15 Jul 2020 21:52:04 -0000 1.37 +++ index.html 14 Jul 2024 21:46:26 -0000 @@ -72,6 +72,7 @@ Porter's Handbook
  • Audio Applications
  • Manual Pages
  • rc.d(8) Scripts +
  • Optimizing with CPU Extensions

    Port Testing Guide

    Index: specialtopics.html =================================================================== RCS file: /cvs/www/faq/ports/specialtopics.html,v diff -u -p -r1.90 specialtopics.html --- specialtopics.html 4 Nov 2022 23:46:22 -0000 1.90 +++ specialtopics.html 14 Jul 2024 21:46:27 -0000 @@ -30,6 +30,7 @@ Ports - Special Porting Topics
  • Audio Applications
  • Manual Pages
  • rc.d(8) Scripts +
  • Optimizing with CPU Extensions
    @@ -1237,7 +1238,7 @@ daemon="${TRUEPREFIX}/sbin/munin-node" pexp="/usr/bin/perl -wT ${daemon}${daemon_flags:+ ${daemon_flags}}" rc_pre() { - install -d -o _munin /var/run/munin + install -d -o _munin /var/run/munin } rc_cmd $1 @@ -1246,3 +1247,111 @@ rc_cmd $1 A template script can also be found in the templates directory of your ports tree. + +

    Optimizing with CPU Extensions

    + +This section provides information on selecting CPU instruction +extensions, or CPU features, for ports. + +

    +Ports that do intensive numerics or intensive text processing may benefit from +various CPU features available for amd64, arm64, or powerpc64 architectures. + +However, be aware that ports are built and used on many user and OpenBSD +developer machines and these may not possess such features. +Here are some guidelines for making ports operate reliably across similar +architectures with varying CPU features. + +

    CPU features

    + +Most CPU architectures are decades old and have evolved to add +numeric performance features like AVX (amd64), Neon/ASIMD (arm64), +or VSX (powerpc64). +Some features are added for kernels to improve or defend +against CPU defects like Spectre, or to inform the kernel that +the hardware is updated to fix those defects. + +

    +Generally, CPU features intended for kernels are not interesting +to user code. +On the other hand, some CPU features for user code +require kernel support to work, otherwise results are unpredictable +or the code aborts. +Examples include those listed above. + +

    +Kernel support for features varies according to the OpenBSD release +and model of CPU. +The function elf_aux_info(3) provides indicators of which features +are available. + +

    Ports with CPU features enabled

    + +Any port must work on the base CPU model used to build or run OpenBSD. +Some users have amd64 machines that are decades old and expect ports +to work on them. +Therefore performance-enhancing features, if used, must be +optional, and automatic. + +

    +For users, "to work" means the program operates reliably and is +tested according to software built-in tests or the porter's own tests. + +

    +Enabling optional CPU features means those tests have to be repeated with +the features enabled and disabled. +The dynamic switching between feature "on" and "off" must also be tested. +This can more than double or triple the test effort. + +

    +Additionally, adding optional CPU features raise the risk of compiler +problems that may result in incorrect results. + +

    +Here is a checklist of considerations: + +

    + +

    +Some current ports that select on CPU features include: + +

    +