 Working with Asynchrony Generically: A Tour of C++ ExecutorsPart 1: 1. Goals for the Executors proposal 2. Some simple examples, intro to senders 3. The lifecycle of an async operation 4. Under the hood of a concurrent operation 5. Implementing a simple algorithm Vision: “An asynchronous analogue of the STL” 2. Some simple examples, intro to senders 3. The lifecycle of an async operation with sender/receiver 4. Under the hood of a composite concurrent operation the // stop_when() algorithm requests stop of its stop // source. struct cancel_keyclick { void operator()() const noexcept { auto* current = pending_completion_.exchange(nullptr); if (current0 码力 | 121 页 | 7.73 MB | 6 月前3 Working with Asynchrony Generically: A Tour of C++ ExecutorsPart 1: 1. Goals for the Executors proposal 2. Some simple examples, intro to senders 3. The lifecycle of an async operation 4. Under the hood of a concurrent operation 5. Implementing a simple algorithm Vision: “An asynchronous analogue of the STL” 2. Some simple examples, intro to senders 3. The lifecycle of an async operation with sender/receiver 4. Under the hood of a composite concurrent operation the // stop_when() algorithm requests stop of its stop // source. struct cancel_keyclick { void operator()() const noexcept { auto* current = pending_completion_.exchange(nullptr); if (current0 码力 | 121 页 | 7.73 MB | 6 月前3
 C++23: An Overview of Almost All New and Updated Features3 Marc Grégoire  Belgium  Software architect / project manager for Nikon Metrology  marc.gregoire@nuonsoft.com  Microsoft VC++ MVP Since 2007  Author of Professional C++, 2nd, 3rd, 4th, and C++23 Core Language  Explicit Object Parameters  if consteval  Multidimensional Subscript Operator  Attributes on Lambda-Expressions  Literal Suffix for size_t  auto(x): decay-copy in The Language C++23 Core Language  Explicit Object Parameters  if consteval  Multidimensional Subscript Operator  Attributes on Lambda-Expressions  Literal Suffix for size_t  auto(x): decay-copy in The Language0 码力 | 105 页 | 759.96 KB | 6 月前3 C++23: An Overview of Almost All New and Updated Features3 Marc Grégoire  Belgium  Software architect / project manager for Nikon Metrology  marc.gregoire@nuonsoft.com  Microsoft VC++ MVP Since 2007  Author of Professional C++, 2nd, 3rd, 4th, and C++23 Core Language  Explicit Object Parameters  if consteval  Multidimensional Subscript Operator  Attributes on Lambda-Expressions  Literal Suffix for size_t  auto(x): decay-copy in The Language C++23 Core Language  Explicit Object Parameters  if consteval  Multidimensional Subscript Operator  Attributes on Lambda-Expressions  Literal Suffix for size_t  auto(x): decay-copy in The Language0 码力 | 105 页 | 759.96 KB | 6 月前3
 Автоматизация управления ClickHouse-кластерами в Kubernetesсисадмина. ClickHouse operator? Что это? Программа, управляющая кластером ClickHouse в Kubernetes. Кодифицированные шаблоны. Кодифицированные best practices. ClickHouse operator? Зачем это? • Позволяет именно ClickHouse кластеризуется. • Позволяет легко автоматизировать типовые задачи. ClickHouse operator? Кому это надо? • Тем, кто находится в начале пути. • Тем, у кого есть типовая инсталляция. • много типовых задач, т.е. требуется автоматизация. ClickHouse operator – управление кластером как ОДНИМ РЕСУРСОМ ClickHouse Operator ClickHouseInstallation YAML file Лицензия: Apache 2.0, Распространяется0 码力 | 44 页 | 2.24 MB | 1 年前3 Автоматизация управления ClickHouse-кластерами в Kubernetesсисадмина. ClickHouse operator? Что это? Программа, управляющая кластером ClickHouse в Kubernetes. Кодифицированные шаблоны. Кодифицированные best practices. ClickHouse operator? Зачем это? • Позволяет именно ClickHouse кластеризуется. • Позволяет легко автоматизировать типовые задачи. ClickHouse operator? Кому это надо? • Тем, кто находится в начале пути. • Тем, у кого есть типовая инсталляция. • много типовых задач, т.е. требуется автоматизация. ClickHouse operator – управление кластером как ОДНИМ РЕСУРСОМ ClickHouse Operator ClickHouseInstallation YAML file Лицензия: Apache 2.0, Распространяется0 码力 | 44 页 | 2.24 MB | 1 年前3
 C++20: An (Almost) Complete Overviewatomic waiting, latches, and barriers  std::atomic_ref  Designated Initializers  Spaceship Operator <=>  Range-based for Loop Initializer  Non-Type Template Parameters  [[likely]] and [[unlikely]] std::string aString; }; Data d { .aString = "Hello" };48 Spaceship Operator <=>  Official name: three-way comparison operator  Three-way: comparing 2 objects and then comparing result with 0 Similar to C-style strcmp() returning neg. value, 0, or pos. value49 Spaceship Operator <=>  Common case:  auto X::operator<=>(const Y&) const = default;  Compiler generates all 6 comparison operators0 码力 | 85 页 | 512.18 KB | 6 月前3 C++20: An (Almost) Complete Overviewatomic waiting, latches, and barriers  std::atomic_ref  Designated Initializers  Spaceship Operator <=>  Range-based for Loop Initializer  Non-Type Template Parameters  [[likely]] and [[unlikely]] std::string aString; }; Data d { .aString = "Hello" };48 Spaceship Operator <=>  Official name: three-way comparison operator  Three-way: comparing 2 objects and then comparing result with 0 Similar to C-style strcmp() returning neg. value, 0, or pos. value49 Spaceship Operator <=>  Common case:  auto X::operator<=>(const Y&) const = default;  Compiler generates all 6 comparison operators0 码力 | 85 页 | 512.18 KB | 6 月前3
 C++高性能并行编程与优化 -  课件 - 13 C++ STL 容器全解之 vectornoexcept; vector 容器: operator[] • 要访问 vector 里的元素,只需用 [] 运算符 : • 例如 a[0] 访问第 0 个元素(人类的第一 个) • 例如 a[1] 访问第 1 个元素(人类的第二 个) • int &operator[](size_t i) noexcept; • int const &operator[](size_t i) const vector 容器: operator[] • 值得注意的是, [] 运算符在索引超出数组大 小时并不会直接报错,这是为了性能的考虑。 • 如果你不小心用 [] 访问了越界的索引,可能 会覆盖掉别的变量导致程序行为异常,或是访 问到操作系统未映射的区域导致奔溃。 • int &operator[](size_t i) noexcept; • int const &operator[](size_t const; vector 容器: operator[] 和 at • [] 和 at 除了可以读取元素,还可以写入。 • 这是因为他们返回的是元素的引用 int& 。 • 例如给第 i 个元素赋值 val : • a[i] = val; • 读取第 i 个元素并打印: • cout << a[i] << endl; • int &operator[](size_t i) noexcept;0 码力 | 90 页 | 4.93 MB | 1 年前3 C++高性能并行编程与优化 -  课件 - 13 C++ STL 容器全解之 vectornoexcept; vector 容器: operator[] • 要访问 vector 里的元素,只需用 [] 运算符 : • 例如 a[0] 访问第 0 个元素(人类的第一 个) • 例如 a[1] 访问第 1 个元素(人类的第二 个) • int &operator[](size_t i) noexcept; • int const &operator[](size_t i) const vector 容器: operator[] • 值得注意的是, [] 运算符在索引超出数组大 小时并不会直接报错,这是为了性能的考虑。 • 如果你不小心用 [] 访问了越界的索引,可能 会覆盖掉别的变量导致程序行为异常,或是访 问到操作系统未映射的区域导致奔溃。 • int &operator[](size_t i) noexcept; • int const &operator[](size_t const; vector 容器: operator[] 和 at • [] 和 at 除了可以读取元素,还可以写入。 • 这是因为他们返回的是元素的引用 int& 。 • 例如给第 i 个元素赋值 val : • a[i] = val; • 读取第 i 个元素并打印: • cout << a[i] << endl; • int &operator[](size_t i) noexcept;0 码力 | 90 页 | 4.93 MB | 1 年前3
 C++高性能并行编程与优化 -  课件 - 15 C++ 系列课:字符与字符串还得套一层壳 string(“hello”) 才能变成安全封装的类型,才能用他 的成员函数。 • 因此, C++14 引入了一项缓解“键盘压力”的新特性: • 写 “ hello”_s 就相当于写 operator“”_s(“hello”, 5) ,就相当于 string(“hello”, 5) 了。 • 为什么还需要指定长度 5 ?其实不指定也可以,就是 “ hello\0world” 会退化 这个特殊的名字空间里包含了所有的 operator“” 函数。 小彭老师锐评:何谓“键盘压力” • 高情商:键盘压力,指的是程序员敲击键盘时产生的心理压力。 • 低情商:键盘压力,指的是 rust 键盘侠对 cpp 标准委员会的压力。 • rust 键盘侠曰:我们有 233_i32 , cpp 做得到吗? • cpp 标准委员会:谢邀,人在 cpp14 ,已经在 operator“”_i32 了。 • allocator 不必占据额外的空间。 • 问题:既然 allocator 往往都是个空类( std::allocator C++高性能并行编程与优化 -  课件 - 15 C++ 系列课:字符与字符串还得套一层壳 string(“hello”) 才能变成安全封装的类型,才能用他 的成员函数。 • 因此, C++14 引入了一项缓解“键盘压力”的新特性: • 写 “ hello”_s 就相当于写 operator“”_s(“hello”, 5) ,就相当于 string(“hello”, 5) 了。 • 为什么还需要指定长度 5 ?其实不指定也可以,就是 “ hello\0world” 会退化 这个特殊的名字空间里包含了所有的 operator“” 函数。 小彭老师锐评:何谓“键盘压力” • 高情商:键盘压力,指的是程序员敲击键盘时产生的心理压力。 • 低情商:键盘压力,指的是 rust 键盘侠对 cpp 标准委员会的压力。 • rust 键盘侠曰:我们有 233_i32 , cpp 做得到吗? • cpp 标准委员会:谢邀,人在 cpp14 ,已经在 operator“”_i32 了。 • allocator 不必占据额外的空间。 • 问题:既然 allocator 往往都是个空类( std::allocator- 默认就是空类,只有几个 成员函数负责调用 operator new 和 operator delete ),为什么还要把 allocator 对 象存到 string 对象里,最后还要搞什么空基类优化防止他浪费空间,多此一举? • 因为最近开始流行“有状态分配器”了,侯杰老师显然不知道这一点,在他的 0 码力 | 162 页 | 40.20 MB | 1 年前3
 C++高性能并行编程与优化 -  课件 - 10 从稀疏数据结构到量化数据类型个 bit 用 map 来存储 读取:如果不存在,则读到 0 写入:如果不存在,则创建该表项 用 unordered_map 来存储 map 基于红黑树,会按照键值排序,需要键值具有 operator< 重载,复杂度 O(logn) C++11 新增的 unordered_map 基于哈希表,不保证顺序但更高效,需要键值能被哈希,复杂度 O(1) 用 unordered_map 按 16x16 • 不过效率比我们手写的低很多…… 不推荐使用 std::vector C++高性能并行编程与优化 -  课件 - 10 从稀疏数据结构到量化数据类型个 bit 用 map 来存储 读取:如果不存在,则读到 0 写入:如果不存在,则创建该表项 用 unordered_map 来存储 map 基于红黑树,会按照键值排序,需要键值具有 operator< 重载,复杂度 O(logn) C++11 新增的 unordered_map 基于哈希表,不保证顺序但更高效,需要键值能被哈希,复杂度 O(1) 用 unordered_map 按 16x16 • 不过效率比我们手写的低很多…… 不推荐使用 std::vector- • 不建议使用 vector - 的原因:他返回的不是真正的引用,而是一个重载了 operator= 和 operator bool 的 std::_Bit_reference 对象,而且效率很低。 • 如果配合用 decltype 和 auto 的话,他们不会正确推导出 bool ,影响我们正常使用模板元编 0 码力 | 102 页 | 9.50 MB | 1 年前3
 C++高性能并行编程与优化 -  课件 - 17 由浅入深学习 map 容器实际上是 val = m.__getitem__(key) 。 • C++ 的 [] 就不论读取还是写入都是同一个运算符重载,他只是返回引用,无法区分你是读是写: • value_type &operator[](key_type key); // [] 返回引用,你 = val 写入的是这个引用, [] 是不知道的 • [] 被调用的时候根本不知道他外面是想写入还是读取。找不到键值时,为了能兼容写入的情况, auto &[k, v] = *it; 而 it 的 operator* 会返回该迭代器所指向元素(的引用) 。 • 所以 [k, v] 就会被 structural-binding 分别绑定到当前遍历到的元素的 K 和 V 上了。 • 然后从程序员的黑盒视角看来,就是对于所有 map 中的 K-V 对执行了一遍循环体。 迭代器 operator++ 的移动方向 • 迭代器的 ++ 是中根遍历0 码力 | 90 页 | 8.76 MB | 1 年前3 C++高性能并行编程与优化 -  课件 - 17 由浅入深学习 map 容器实际上是 val = m.__getitem__(key) 。 • C++ 的 [] 就不论读取还是写入都是同一个运算符重载,他只是返回引用,无法区分你是读是写: • value_type &operator[](key_type key); // [] 返回引用,你 = val 写入的是这个引用, [] 是不知道的 • [] 被调用的时候根本不知道他外面是想写入还是读取。找不到键值时,为了能兼容写入的情况, auto &[k, v] = *it; 而 it 的 operator* 会返回该迭代器所指向元素(的引用) 。 • 所以 [k, v] 就会被 structural-binding 分别绑定到当前遍历到的元素的 K 和 V 上了。 • 然后从程序员的黑盒视角看来,就是对于所有 map 中的 K-V 对执行了一遍循环体。 迭代器 operator++ 的移动方向 • 迭代器的 ++ 是中根遍历0 码力 | 90 页 | 8.76 MB | 1 年前3
 Bringing Existing Code to CUDA Using constexpr and std::pmrconst& b_; auto operator()(index i) const { return a_[i] + b_[i]; } }; struct add_span { gsl::span Bringing Existing Code to CUDA Using constexpr and std::pmrconst& b_; auto operator()(index i) const { return a_[i] + b_[i]; } }; struct add_span { gsl::span- a_; gsl::span - b_; auto operator()(index i) const 0 码力 | 51 页 | 3.68 MB | 6 月前3
 C++20's << "\n"; } Output: 2021-10-28 Nov/Thu[4] 2020/Feb/last 29 2021/Feb/last 2814 Some examples: operator/ with new chrono literals #include C++20's << "\n"; } Output: 2021-10-28 Nov/Thu[4] 2020/Feb/last 29 2021/Feb/last 2814 Some examples: operator/ with new chrono literals #include- #include - using namespace std::chrono; all? Couldn’t we just use unsigned int for each? Consider our year_month_day example using operator/: year_month_day ymd1{October/28d/ 2021y}; year_month_day ymd2{2021y/October/ 28d}; 0 码力 | 55 页 | 8.67 MB | 6 月前3
共 21 条
- 1
- 2
- 3













