Add parallel sort example (#220) - #606
Merged
Merged
Conversation
Owner
|
你好,看了您的例子,感觉整体很不错,非常符合 CGraph 的特性和思想。 个人提出一点建议哈:
我个人提供两个优化思路,建议参考其一: 第一个思路:
第二个思路:
最终还可以比较一下,并行排序和 std::sort 的真实性能差距。直接用 UTimeCounter("xxx") 即可,不需要自己计算时间了。 |
Owner
|
对了,记得在 CONTRIBUTORS.md 文档中,添加自己的信息哈。感谢 |
Contributor
Author
|
感谢您的详细建议!我已经更新了示例: 1.合并节点已改为四路归并,不再整体重排。 2.增加了串行 std::sort 基准对比,并输出加速比。 3.精简了日志,聚焦性能对比。 4.已在 CONTRIBUTORS.md 中添加了自己的信息。 数据随机生成已放在第一个节点的 init 方法中;计时的部分我目前采用 std::chrono 计算 pipeline->process() 和 std::sort 本身的耗时,后续如需要会改用 UTimeCounter。 目前示例在 100 万随机整数上显示约 1.3 倍加速(并行 vs 串行)。如果还有需要调整的地方,请随时指出。 |
Owner
|
感谢您的贡献,已经合入。 如果有兴趣,非常希望可以添加个人微信,随时交流。 我的vx 见项目readme。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a new example
E06-ParallelSortthat demonstrates how to use CGraph's pipeline to sort a large array in parallel.The example:
SortGNodes to sort each part concurrently.Fixes #220