Branchless Programming in C++Understanding the hardware and using it efficiently – Computing resources of a CPU – Pipelining – Branch prediction and hardware loop unrolling ● Conditional code vs efficiency ● Optimizing conditional v2[i+2]: v1[i+2]: a[i+2]:Branchless Computing 24 BRANCH PREDICTION: ANTIDOTE TO BRANCHES ● Well-pipelined code: a += v1[i] + v2[i] ● CPUs have branch predi ctorsBranchless Computing 25 LOOP UNROLLING cmp[i]:v3[i]==0 jump if true a[i]:a+=v1[i]+v2[i] jump a[i]:a+=v1[i]*v2[i] ...Branchless Computing 28 BRANCH PREDICTION: ANTIDOTE TO BRANCHES ● Speculatively pipelined code: a += (v3[i]) ? (v1[i]+v2[i]) :0 码力 | 61 页 | 9.08 MB | 6 月前3
Finding Bugs using Path-Sensitive Static Analysisbool cond) { int var = 0; // branch 1 if (p != nullptr) { var = 1; } // branch 2 if (cond) { var = 2; p = nullptr; } // branch 3 if (var == 1) { *p = 42; Not taking branch 1, but taking branch 3 • All warnings on infeasible paths are noise • Need info on the whole state! void path_sensitive(int *p, bool cond) { int var = 0; // branch 1 if (p (p != nullptr) { var = 1; } // branch 2 if (cond) { var = 2; p = nullptr; } // branch 3 if (var == 1) { *p = 42; // Null dereference? } }Flow-sensitive analysis0 码力 | 35 页 | 14.13 MB | 6 月前3
COMPOSABLE C++return types uniform. occurs from failing to keep return types uniform. auto calculate_recursively(branch_t) -> collection_t; auto calculate_recursively(leaf1_t) -> value_t; auto calculate_recursively(leaf2_t) leaf) -> int { return size(leaf); }, [] (const auto& branch) -> int { return transform_reduce( begin(branch), end(branch), 0, plus{}, [] (const auto& t) -> T& leaf) { return t_op(leaf); }, [&] (const auto& branch) { return std::transform_reduce( std::begin(branch), std::end(branch), i, r_op, [&] (const auto& t) { return reduce_tree(t0 码力 | 124 页 | 8.28 MB | 6 月前3
Performance Engineering: Being Friendly to Your HardwareIncoming branch • Instruction alignment • Instruction fusingBranch prediction 42 Branching Fetch L1I • Governs fetching of next instruction blocks • A set of tables • Branch history • Branch site site • Branch target • Repetitive patterns • Really complex • High cost of errorInstruction decoding 43 Branching Fetch Decode L1I • Multiple instructions get decoded in parallel • Even for variable length instructions is: - Complex - Serial - Slow • Fetch block size • Linear fetch vs incoming branch 44Instruction decoding 45 Branching Fetch Decode Queue ROM Cache L1I • Decoded operations0 码力 | 111 页 | 2.23 MB | 6 月前3
Conan 1.19 Documentationalso available. As you can see, any manipulation of the code can be done, such as checking out any branch or tag, or patching the source code. In this example, we are adding two lines to the existing CMake pack-reused 17 Unpacking objects: 100% (17/17), done. Switched to a new branch 'static_shared' Branch 'static_shared' set up to track remote branch 'static_shared' from 'origin'. Hello/1.1@user/channel: Copying ersion_mode Now, some developer does some changes to PkgA, and do a pull request to the develop branch, and we want our CI to build the new binaries for the dependants packages, down to the final application0 码力 | 609 页 | 4.88 MB | 1 年前3
Conan 1.20 Documentationalso available. As you can see, any manipulation of the code can be done, such as checking out any branch or tag, or patching the source code. In this example, we are adding two lines to the existing CMake pack-reused 17 Unpacking objects: 100% (17/17), done. Switched to a new branch 'static_shared' Branch 'static_shared' set up to track remote branch 'static_shared' from 'origin'. Hello/1.1@user/channel: Copying ersion_mode Now, some developer does some changes to PkgA, and do a pull request to the develop branch, and we want our CI to build the new binaries for the dependants packages, down to the final application0 码力 | 611 页 | 4.89 MB | 1 年前3
Conan 1.18 Documentationalso available. As you can see, any manipulation of the code can be done, such as checking out any branch or tag, or patching the source code. In this example, we are adding two lines to the existing CMake pack-reused 17 Unpacking objects: 100% (17/17), done. Switched to a new branch 'static_shared' Branch 'static_shared' set up to track remote branch 'static_shared' from 'origin'. Hello/1.1@user/channel: Copying ersion_mode Now, some developer does some changes to PkgA, and do a pull request to the develop branch, and we want our CI to build the new binaries for the dependants packages, down to the final application0 码力 | 584 页 | 4.80 MB | 1 年前3
Conan 1.21 Documentationalso available. As you can see, any manipulation of the code can be done, such as checking out any branch or tag, or patching the source code. In this example, we are adding two lines to the existing CMake pack-reused 17 Unpacking objects: 100% (17/17), done. Switched to a new branch 'static_shared' Branch 'static_shared' set up to track remote branch 'static_shared' from 'origin'. Hello/1.1@user/channel: Copying ersion_mode Now, some developer does some changes to PkgA, and do a pull request to the develop branch, and we want our CI to build the new binaries for the dependants packages, down to the final application0 码力 | 621 页 | 4.92 MB | 1 年前3
Conan 1.22 Documentationalso available. As you can see, any manipulation of the code can be done, such as checking out any branch or tag, or patching the source code. In this example, we are adding two lines to the existing CMake pack-reused 17 Unpacking objects: 100% (17/17), done. Switched to a new branch 'static_shared' Branch 'static_shared' set up to track remote branch 'static_shared' from 'origin'. Hello/1.1@user/channel: Copying ersion_mode Now, some developer does some changes to PkgA, and do a pull request to the develop branch, and we want our CI to build the new binaries for the dependants packages, down to the final application0 码力 | 629 页 | 4.98 MB | 1 年前3
Conan 1.23 Documentationalso available. As you can see, any manipulation of the code can be done, such as checking out any branch or tag, or patching the source code. In this example, we are adding two lines to the existing CMake pack-reused 17 Unpacking objects: 100% (17/17), done. Switched to a new branch 'static_shared' Branch 'static_shared' set up to track remote branch 'static_shared' from 'origin'. Hello/1.1@user/channel: Copying ersion_mode Now, some developer does some changes to PkgA, and do a pull request to the develop branch, and we want our CI to build the new binaries for the dependants packages, down to the final application0 码力 | 637 页 | 5.04 MB | 1 年前3
共 109 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11













