Working with Asynchrony Generically: A Tour of C++ Executorsincluding some standard ones: an event loop, portable access to the system execution context, nursery for spawned work4 P2300: STD::EXECUTION Proposes: • A set of concepts that represent: • A handle to a compute Example 1: Launching concurrent work6 EXAMPLE: LAUNCHING CONCURRENT WORK namespace ex = std::execution; int compute_intensive(int); int main() { unifex::static_thread_pool pool{8}; ex::scheduler concurrently on a custom execution context libunifex: https://github.com/facebookexperimental/libunifex7 EXAMPLE: LAUNCHING CONCURRENT WORK namespace ex = std::execution; int compute_intensive(int);0 码力 | 121 页 | 7.73 MB | 6 月前3
Bringing Existing Code to CUDA Using constexpr and std::pmrfloat* y) { for (int i = 0; i < n; i++) y[i] = x[i] + y[i]; } 35 |Execution Space Specifiers The __global__ execution space specifier declares a function as being a kernel. Such a function is: is: • Executed on the device, • Callable from the host. The __device__ execution space specifier declares a function that is: • Executed on the device, • Callable from the device only. https://docs __host__ execution space specifier declares a function that is: • Executed on the host, • Callable from the host only. It is equivalent to declare a function with only the __host__ execution space specifier0 码力 | 51 页 | 3.68 MB | 6 月前3
C++20: An (Almost) Complete Overviewthe caller, and suspends the coroutine, subsequently calling the coroutine again continues its execution co_return: returns from a coroutine (just return is not allowed)16 Coroutines What are coroutines Can be used with condition_variable_any std::stop_source Used to request a thread to stop execution Stop requests are visible to all associated stop_sources and stop_tokens std::stop_callback calculate the midpoint of two numbers lerp() to do linear interpolation New unsequenced_policy (execution::unseq): algorithm is allowed to be vectorized84 Agenda Modules Ranges Coroutines 0 码力 | 85 页 | 512.18 KB | 6 月前3
Rust 异步并发框架在移动端的应用 - 陈明煜Syntax sugar wake await Rust 异步机制 Asynchronous Rust Rust 异步机制 Asynchronous Rust Waker Task Future task Queue wake Worker Future.poll() Reactor fd fd listen listen find 现有并发框架 Third Party 多线程模型提供了并行迭代器功能, 适用于处理 CPU 密集型计算任务 rayon 现有框架无法完美适配移动端(一) Core Thread Thread Worker Worker task task Local queue Local queue Tokio 采用了如右图这种 GMP 模式: • 一核可以绑定多线程,每个线程拥有一个 Worker ,每个 Worker 拥有一个任务队列 Mobile spawn_blocking 调度模式 spawn 调度模式 Thread Worker task Local queue Thread Thread task Global queue task New task Global queue New task take & run take & run Worker take & run Steal & run0 码力 | 25 页 | 1.64 MB | 1 年前3
CeresDB Rust 生产实践 任春韶生产实践 – Async lock runtime.spawn(task0) runtime.spawn(task1) runtime.spawn(task2) 生产实践 – Async lock runtime.spawn(task0) runtime.spawn(task1) runtime.spawn(task2) 生产实践 – Async lock 总结: Async spawn(task0) runtime.spawn(task1) runtime.spawn(task2) runtime.spawn(task3) 生产实践 – Mixed workload cpu_runtime.spawn(task0) cpu_runtime.spawn(task1) cpu_runtime.spawn(task2) cpu_runtime.spawn(task3)0 码力 | 22 页 | 6.95 MB | 1 年前3
Await-Tree Async Rust 可观测性的灵丹妙药 - 赵梓淇Lifetime • 无栈协程 Async Rust 回顾 Rust 的无栈协程抽象 — Future Async Rust 回顾 • 通过 poll 驱动的状态机 • 组合嵌套为调度单元: Task • async fn 语法糖 Async Rust 观测与调试的痛点 Async Rust 回顾 • 特性: Future 灵活的可组合性 • 任意定制 Poll 的执行逻辑 (Join 无法追踪调用关系的变化 Async Rust 观测与调试的痛点 Async Rust 回顾 • 特性:用户态调度的无栈协程 • Pending Task 不存在栈空间 • 痛点:观测与调试工具无法还原 Pending Task 的执行状态 • 难以得知 Task 阻塞的位置和原因 • 难以调试 Async Stuck • ? 如何解决? Await-Tree Async Rust 可观测性的灵丹妙药 Tree 的设计原理与实现 • 追踪关键 Future 的生命周期和控制流 • Init, First Poll, Pending, Next Poll, Ready, Cancel • 实时将 Task 的执行状态维护为一棵树 • 显示目前正在阻塞 / 执行的 Await Point • 得名 Await-Tree 基本用例 Await Tree 的设计原理与实现 基本用例 Await0 码力 | 37 页 | 8.60 MB | 1 年前3
C++高性能并行编程与优化 - 课件 - 06 TBB 开启的并行编程之旅https://www.bilibili.com/video/BV1fa411r7zp 的 1:18:48 上一课的案例代码:基于标准库 基于 TBB 的版本:任务组 • 用一个任务组 tbb::task_group 启动多个 任务,一个负责下载,一个负责和用户交 互。并在主线程中等待该任务组里的任务 全部执行完毕。 • 区别在于,一个任务不一定对应一个线程 ,如果任务数量超过 CPU 最大的线程数, 让人咋 用? 第 4 章:任务域与嵌套 https://link.springer.com/chapter/10.1007%2F978-1-4842-4398-5_12 任务域: tbb::task_arena 任务域:指定使用 4 个线程 嵌套 for 循环 嵌套 for 循环:死锁问题 死锁问题的原因 • 因为 TBB 用了工作窃取法来分配任务: 当一个线程 t1 做完自己队列里全部的工 这种技术又称为线程池( thread pool ),避免了 线程需要保存上下文的开销。但是需要我们管理 一个任务队列,而且要是线程安全的队列。 struct Task { int x0, y0; int nx, ny; }; std::queue<Task> q; 1 2 3 4 解决 3 :每个线程一个任务队列,做完本职工作后可以认领其他线程的任务 工作窃取法( work-stealing0 码力 | 116 页 | 15.85 MB | 1 年前3
No Silver Bullet – Essence and Accident in Software Engineering“Therefore it appears that the time has come to address the essential parts of the software task, those concerned with fashioning abstract conceptual structures of great complexity. I suggest: validation can only establish that a program meets its specification, the hardest part of the software task is arriving at a complete and consistent specificationEnvironments and tools • How much more gain Environments and toolsA Modern Take on Accidental Complexity • Yak Shaving - the phenomenon where one task leads to another, which leads to another, until you end up working on something that seems completely0 码力 | 35 页 | 1.43 MB | 5 月前3
nativescript-new-looper-vantoll.pptxapp size Threading ⛓ • NativeScript = single threaded, by default ? • Samples for background execution are now available. • WebWorkers API coming soon Angular ? • Angular 2 final—Now 100% more a0 码力 | 36 页 | 10.78 MB | 1 年前3
A Crash Course in Calendars, Dates, Time, and Time Zoneslocaltime(&tt) }; // Write the time to the console. cout << put_time(t, "%H:%M:%S");22 Clocks Time execution time: // Get start time. auto start { high_resolution_clock::now() }; // Execute code to benchmark0 码力 | 43 页 | 551.60 KB | 6 月前3
共 13 条
- 1
- 2
相关搜索词
WorkingwithAsynchronyGenericallyTourofC++ExecutorsBringingExistingCodetoCUDAUsingconstexprandstdpmr20AnAlmostCompleteOverview陈明煜2023RustChinaConf任春韶ceresdbrust生产实践生产实践赵梓Await-TreeRust高性性能高性能并行编程优化课件06NoSilverBulletEssenceAccidentinSoftwareEngineeringnativescriptnewloopervantollpptxCrashCourseCalendarsDatesTimeZones













