Working with Asynchrony Generically: A Tour of C++ Executors
EXAMPLE: LAUNCHING CONCURRENT WORK namespace ex = std::execution; int compute_intensive(int); int main() { unifex::static_thread_pool pool{8}; ex::scheduler auto sched = pool.get_scheduler(); ex::sender EXAMPLE: LAUNCHING CONCURRENT WORK namespace ex = std::execution; int compute_intensive(int); int main() { unifex::static_thread_pool pool{8}; ex::scheduler auto sched = pool.get_scheduler(); ex::sender Use pipe syntax if you want to. namespace ex = std::execution; int compute_intensive(int); int main() { unifex::static_thread_pool pool{8}; ex::scheduler auto sched = pool.get_scheduler(); ex::sender0 码力 | 121 页 | 7.73 MB | 5 月前3C++23: An Overview of Almost All New and Updated Features
Copy is a prvalue Example: void process(int&& value) { std::println("{}", value); } void process_all(const std::vector& data) { for (auto& i : data) { process(auto(i)); } }25 Agenda C++23 Collection Support34 Trim Whitespace Before Line Splicing What is the output of the following? int main() { int i = 1 // \ + 42 ; std::cout << i; } It’s undefined by the standard pre C++23 wrapper headers (e.g. ::fopen()) Standard Library Modules42 Modern “Hello World”: import std; int main() { std::println("Hello World!"); } Standard Library Modules43 Agenda C++23 Core Language 0 码力 | 105 页 | 759.96 KB | 5 月前3C++20's
2020 • Lecturer at the University of Washington • Cute pup parent6 Agenda • Part I: Development Process • Implementing in the Open • Organization of Work • Part II: Calendrical Types • Part III: Clocks [time.zone] • IANA database challenges • Part VI: Conclusion7 Part I: Development Process8 Development Process • Implemented in our microsoft/STL open-source GitHub repo with the help of our amazing Simple Calendrical Types #include#include using namespace std::chrono; int main() { year y{2021}; std::cout << y << "\n"; month m{October}; auto result = m + months{3}; 0 码力 | 55 页 | 8.67 MB | 5 月前3C++20 STL Features: 1 Year of Development on GitHub
17 Comparing Integers8 Usual Arithmetic Conversions #includeusing namespace std; int main() { cout << boolalpha; short s = -1; unsigned int ui = 1729; cout << (s < • GH-621 implemented by Neargye #include #include using namespace std; int main() { cout << boolalpha; short s = -1; unsigned int ui = 1729; cout << cmp_less(s #include #include #include using namespace std; int main() { static constexpr array skipped_extensions{".dll"sv, ".exe"sv, ".obj"sv}; static_ass 0 码力 | 45 页 | 702.09 KB | 5 月前3THE FIRST EXPLORATION OF PROJECT SPARROW
hkli2013@126.com Jun 18, 2023 An indie developer from China The main translator of the book «Gray Hat Hacking The Ethical Hacker's Handbook, Fourth Edition» Getting started II. Practicing Sparrow https://github.com/AmbiML/sparrow-cantrip-full/blob/main/docs/GettingStarted.md 1.1.1 Testing on LAPAC71H II. Practicing Sparrow repo procedure: Sparrow https://github.com/pop-os/system76-scheduler Auto-configure CFS and process priorities for improved desktop responsiveness. https://www.phoronix.com/scan.php?page=ne0 码力 | 68 页 | 13.14 MB | 1 年前3C++高性能并行编程与优化 - 课件 - 07 深入浅出访存优化
次浮点读写 ≈ 128 次浮点加 法 常见操作所花费的时间 • 图中加法 (add) 和乘法 (mul) 都指的整数。 • 区别是浮点的乘法和加法基本是一样速度。 • L1/2/3 read 和 Main RAM read 的时间指的是 读一个缓存行( 64 字节)所花费的时间。 • 根据计算: 125/64*4≈8 • 即从主内存读取一次 float 花费 8 个 cycle , 符合小彭老师的经验公式。 on memory locality for optimal performance. Data needs to be organized that allows the CPU’s to process the data, without having to wait. If the data is not structured in a cache friendly way, the CPU0 码力 | 147 页 | 18.88 MB | 1 年前3No Silver Bullet – Essence and Accident in Software Engineering
minds are deprived of some of its most powerful conceptual tools • This lack not only impedes the process of design within one mind, it severely hinders communication among mindsPast Breakthroughs Solved Enthusiasm jumps when there is a running system, even a simple one • One always has, at ever stage in the process, a working systemConclusionEssential Complexity vs. Accidental Complexity • Essential Complexity should first be made to run • Bit-by-bit it is fleshed out • One always has, at every stage in the process, a working system • Enthusiasm jumps when there is a running system, even a simple one0 码力 | 35 页 | 1.43 MB | 5 月前3C++高性能并行编程与优化 - 课件 - 11 现代 CMake 进阶指南
PROJECT_SOURCE_DIR :当前项目源码路径(存放 main.cpp 的地方) • PROJECT_BINARY_DIR :当前项目输出路径(存放 main.exe 的地方) • CMAKE_SOURCE_DIR :根项目源码路径(存放 main.cpp 的地方) • CMAKE_BINARY_DIR :根项目输出路径(存放 main.exe 的地方) • PROJECT_IS_TOP_LEVEL 构建工程的产生器。它将产生构建文件 (e.g. "Unix Makefiles", "Visual Studio 2019", etc.) 一个标准的 CMakeLists.txt 模板 第 3 章:链接库文件 main.cpp 调用 mylib.cpp 里的 say_hello 函数 改进: mylib 作为一个静态库 改进: mylib 作为一个动态库 改进: mylib 作为一个对象库 https://www exe 文件同一目录 下。 手动拷贝 dll 好麻烦,能不能让 CMake 把 dll 自动生成在 exe 同一 目录? • 归根到底还是因为 CMake 把定义在顶层模块里的 main 放在 build/main.exe 。 • 而 mylib 因为是定义在 mylib 这个子模块里的,因此被放到了 build/mylib/mylib.dll 。 解决 1 :设置 mylib 对象的 xx_OUTPUT_DIRECTORY0 码力 | 166 页 | 6.54 MB | 1 年前3C++高性能并行编程与优化 - 课件 - Zeno 中的现代 C++ 最佳实践
中的表现 main 函数第一个执行? • 众所周知, main 函数是 C/C++ 程序中 第一个执行的函数,是程序的入口点。 • 但,他真的是第一个执行的吗? 全局变量初始化的妙用 • 我们可以定义一个 int 类型全局变量 helper ,然后他的右边其实是可以写一个表达 式的,这个表达式实际上会在 main 函数之 前执行! • 全局变量的初始化会在 main 之前执行,这实 DLL 来说则是 DLL 加载时执行表达式 。 逗号表达式的妙用 • 那么这里是因为比较巧合, printf 的返回类型 正好是 int 类型,所以可以用作初始化的表达 式。如果你想放在 main 之前执行的不是 printf 而是别的比较复杂的表达式呢? • 可以用逗号表达式的特性,总是会返回后一个 值,例如 (x, y) 始终会返回 y ,哪怕 x 是 void 也没关系。因此只需要这样写就行: 该类的构造函数一定在 main 之前执行 • 2. 该类的解构函数一定在 main 之后执行 • 该技巧可用于在程序退出时删除某些文件之类 。 • 这就是小彭老师的静态初始化 (static-init) 大法 。 静态初始化用于批量注册函数 • 我们可以定义一个全局的函数表(右图中的 functab ),然后利用小彭老师的静态初始化 大法,把这些函数在 main 之前就插入到全局0 码力 | 54 页 | 3.94 MB | 1 年前3C++高性能并行编程与优化 - 课件 - 01 学 C++ 从 CMake 学起
https://github.com/zenustech/zeno ) 什么是编译器 • 编译器,是一个根据源代码生成机器码的程序。 • > g++ main.cpp -o a.out • 该命令会调用编译器程序 g++ ,让他读取 main.cpp 中的字符串(称为源码),并根据 C+ + 标准生成相应的机器指令码,输出到 a.out 这个文件中,(称为可执行文件)。 • > ./a.out 。 • > g++ -c hello.cpp -o hello.o • > g++ -c main.cpp -o main.o • 其中使用 -c 选项指定生成临时的对象文件 main.o ,之后再根据一系列对象文件进行链接 ,得到最终的 a.out : • > g++ hello.o main.o -o a.out 为什么需要构建系统( Makefile ) • 文件越来越多时,一个个调用 和直接用一个脚本写出完整的构建过程相比, make 指明依赖关系的好处: 1. 当更新了 hello.cpp 时只会重新编译 hello.o ,而不需要把 main.o 也重新编译一遍。 2. 能够自动并行地发起对 hello.cpp 和 main.cpp 的编译,加快编译速度( make -j )。 3. 用通配符批量生成构建规则,避免针对每个 .cpp 和 .o 重复写 g++ 命令( %.o:0 码力 | 32 页 | 11.40 MB | 1 年前3
共 30 条
- 1
- 2
- 3