Branchless Programming
硬體中的分支預測器(Branch Prediction)會影響程式的速度 如果loop中的if一直猜錯會降低程式速度 例如下面的程式array有沒有sort,就會影響速度 for (int i = 0; i < N; i++) if (a[i] < P) s += a[i]; https://en.algorithmica.org/hpc/pipelining/branching/
硬體中的分支預測器(Branch Prediction)會影響程式的速度 如果loop中的if一直猜錯會降低程式速度 例如下面的程式array有沒有sort,就會影響速度 for (int i = 0; i < N; i++) if (a[i] < P) s += a[i]; https://en.algorithmica.org/hpc/pipelining/branching/