You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cp_guide.md 5.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. # GPU 高性能并行计算算法优化竞赛
  2. ## 🎯 竞赛概述
  3. 本竞赛旨在评估参赛者在GPU并行计算领域的算法优化能力。参赛者可选择实现三个核心算法的高性能版本:
  4. - **ReduceSum**: 高精度归约求和
  5. - **SortPair**: 键值对稳定排序
  6. - **TopkPair**: 键值对TopK选择
  7. ## 🚀 快速开始
  8. ### 编译和测试
  9. #### 1. 全量编译和运行
  10. ```bash
  11. # 编译并运行所有算法测试(默认行为)
  12. ./build_and_run.sh
  13. # 仅编译所有算法,不运行测试
  14. ./build_and_run.sh --build-only
  15. # 编译并运行单个算法测试
  16. ./build_and_run.sh --run_reduce # ReduceSum算法
  17. ./build_and_run.sh --run_sort # SortPair算法
  18. ./build_and_run.sh --run_topk # TopkPair算法
  19. ```
  20. #### 2. 单独编译和运行
  21. ```bash
  22. # 编译并运行ReduceSum算法(默认行为)
  23. ./build_and_run_reduce_sum.sh
  24. # 仅编译ReduceSum算法,不运行测试
  25. ./build_and_run_reduce_sum.sh --build-only
  26. # 编译并运行SortPair正确性测试
  27. ./build_and_run_sort_pair.sh --run correctness
  28. # 编译并运行TopkPair性能测试
  29. ./build_and_run_topk_pair.sh --run performance
  30. ```
  31. #### 3. 手动运行测试
  32. ```bash
  33. ./build/test_reducesum [correctness|performance|all]
  34. ./build/test_sortpair [correctness|performance|all]
  35. ./build/test_topkpair [correctness|performance|all]
  36. ```
  37. ## 📝 参赛指南
  38. ### 实现位置
  39. 参赛者需要在以下文件中替换Thrust实现:
  40. - `src/reduce_sum_algorithm.maca` - 替换Thrust归约求和
  41. - `src/sort_pair_algorithm.maca` - 替换Thrust稳定排序
  42. - `src/topk_pair_algorithm.maca` - 替换Thrust TopK选择
  43. ### 算法要求
  44. 见competition_parallel_algorithms.md
  45. ## 📊 性能评测
  46. ### 测试流程
  47. 1. **Warmup**: 5次预热运行
  48. 2. **Benchmark**: 10次正式测试取平均
  49. 3. **数据规模**: 1M, 128M, 512M, 1G elements
  50. 4. **评估指标**: 吞吐量(G/s)
  51. ### 性能指标计算
  52. #### ReduceSum
  53. - **数据类型**: float → float
  54. - **吞吐量**: elements / time(s) / 1e9 (G/s)
  55. #### SortPair
  56. - **数据类型**: <float, uint32_t>
  57. - **吞吐量**: elements / time(s) / 1e9 (G/s)
  58. #### TopkPair
  59. - **数据类型**: <float, uint32_t>
  60. - **吞吐量**: elements / time(s) / 1e9 (G/s)
  61. ### 性能结果文件
  62. 每个算法会生成详细的YAML性能分析文件:
  63. - `reduce_sum_performance.yaml` - ReduceSum性能数据
  64. - `sort_pair_performance.yaml` - SortPair性能数据
  65. - `topk_pair_performance.yaml` - TopkPair性能数据
  66. 这些文件包含:
  67. - 算法信息和数据类型
  68. - 计算公式说明
  69. - 各数据规模的详细性能数据
  70. - 升序/降序分别统计(适用时)
  71. ## 📁 项目结构
  72. ```
  73. ├── build_and_run.sh # 统一编译和运行脚本(默认编译+运行所有算法)
  74. ├── build_common.sh # 公共编译配置和函数
  75. ├── build_and_run_reduce_sum.sh # ReduceSum独立编译和运行脚本
  76. ├── build_and_run_sort_pair.sh # SortPair独立编译和运行脚本
  77. ├── build_and_run_topk_pair.sh # TopkPair独立编译和运行脚本
  78. ├── competition_parallel_algorithms.md # 详细题目说明
  79. ├── src/ # 算法实现和工具文件
  80. │ ├── reduce_sum_algorithm.maca # 1. ReduceSum测试程序
  81. │ ├── sort_pair_algorithm.maca # 2. SortPair测试程序
  82. │ ├── topk_pair_algorithm.maca # 3. TopkPair测试程序
  83. │ ├── test_utils.h # 测试工具和CPU参考实现
  84. │ ├── yaml_reporter.h # YAML性能报告生成器
  85. │ └── performance_utils.h # 性能测试工具
  86. ├── final_results/reduce_sum_results.yaml #ReduceSum性能数据
  87. ├── final_results/sort_pair_results.yaml #替换Thrust稳定排序
  88. └── final_results/topk_pair_results.yaml #TopkPair性能数据
  89. ```
  90. ## 🔧 开发工具
  91. ### 编译选项
  92. ```bash
  93. # 默认编译命令
  94. mxcc -O3 -std=c++17 --extended-lambda -Isrc
  95. ### 自动化测试
  96. ```bash
  97. # 查看所有选项
  98. ./build.sh --help
  99. # 运行所有测试并生成YAML报告
  100. ./build.sh --run_all
  101. ### 环境变量配置
  102. | 变量 | 默认值 | 说明 |
  103. |--------|--------|------|
  104. | `COMPILER` | `mxcc` | CUDA编译器路径 |
  105. | `COMPILER_FLAGS` | `-O3 -std=c++17 --extended-lambda` | 编译标志 |
  106. | `INCLUDE_DIR` | `src` | 头文件目录 |
  107. | `BUILD_DIR` | `build` | 构建输出目录 |
  108. ### 调试模式
  109. ## 📋 提交清单
  110. 在提交前请确保:
  111. - [ ] 所有算法通过正确性测试
  112. - [ ] 性能测试可以正常运行
  113. - [ ] 代码注释清晰,说明优化策略
  114. - [ ] 无内存泄漏或运行时错误
  115. - [ ] 生成完整测试报告
  116. - [ ] 在函数实现注释中说明创新点
  117. # 提交时包含以下文件
  118. # - final_results/reduce_sum_results.yaml
  119. # - final_results/sort_pair_results.yaml
  120. # - final_results/topk_pair_results.yaml
  121. ```
  122. ## 🤝 技术支持
  123. 如有技术问题,请:
  124. 1. 查看详细错误信息和GPU状态
  125. 2. 确认环境配置正确
  126. 3. 检查内存使用是否超限
  127. 4. 验证算法逻辑和数据类型
  128. ---
  129. **祝您在竞赛中取得优异成绩!** 🏆