[all-commits] [llvm/llvm-project] dc124c: [libc++] Introduce __for_each_segment and use it i...

philnik777 via All-commits all-commits at lists.llvm.org
Wed May 31 18:15:41 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dc124cda7c7808e4cadc8cf6d24c73680878a3d2
      https://github.com/llvm/llvm-project/commit/dc124cda7c7808e4cadc8cf6d24c73680878a3d2
  Author: Nikolas Klauser <nikolasklauser at berlin.de>
  Date:   2023-05-31 (Wed, 31 May 2023)

  Changed paths:
    M libcxx/include/CMakeLists.txt
    M libcxx/include/__algorithm/copy.h
    A libcxx/include/__algorithm/for_each_segment.h
    M libcxx/include/__algorithm/move.h
    M libcxx/include/module.modulemap.in
    M libcxx/test/libcxx/private_headers.verify.cpp
    M libcxx/utils/data/ignore_format.txt
    M libcxx/utils/libcxx/test/params.py

  Log Message:
  -----------
  [libc++] Introduce __for_each_segment and use it in copy/move

This simplifies the code inside copy/move and makes it easier to apply the optimization to other algorithms.

Reviewed By: ldionne, Mordante, #libc

Spies: arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D151265


  Commit: b1dc43aa3a05c2f14725e2e6428544208ccbe161
      https://github.com/llvm/llvm-project/commit/b1dc43aa3a05c2f14725e2e6428544208ccbe161
  Author: Nikolas Klauser <nikolasklauser at berlin.de>
  Date:   2023-05-31 (Wed, 31 May 2023)

  Changed paths:
    M libcxx/benchmarks/CMakeLists.txt
    A libcxx/benchmarks/algorithms/for_each.bench.cpp
    M libcxx/include/__algorithm/for_each.h
    A libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/for_each.pass.cpp
    R libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp
    M libcxx/utils/data/ignore_format.txt

  Log Message:
  -----------
  [libc++] Optimize for_each for segmented iterators

```
---------------------------------------------------
Benchmark                       old             new
---------------------------------------------------
bm_for_each/1               3.00 ns         2.98 ns
bm_for_each/2               4.53 ns         4.57 ns
bm_for_each/3               5.82 ns         5.82 ns
bm_for_each/4               6.94 ns         6.91 ns
bm_for_each/5               7.55 ns         7.75 ns
bm_for_each/6               7.06 ns         7.45 ns
bm_for_each/7               6.69 ns         7.14 ns
bm_for_each/8               6.86 ns         4.06 ns
bm_for_each/16              11.5 ns         5.73 ns
bm_for_each/64              43.7 ns         4.06 ns
bm_for_each/512              356 ns         7.98 ns
bm_for_each/4096            2787 ns         53.6 ns
bm_for_each/32768          20836 ns          438 ns
bm_for_each/262144        195362 ns         4945 ns
bm_for_each/1048576       685482 ns        19822 ns
```

Reviewed By: ldionne, Mordante, #libc

Spies: arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D151274


Compare: https://github.com/llvm/llvm-project/compare/85af42df5dbb...b1dc43aa3a05


More information about the All-commits mailing list