Skip to content

Commit 38f89b0

Browse files
author
Raghuveer Devulapalli
authored
Merge pull request #126 from r-devulap/perf-objsort
Use uint32_t instead of size_t for object sort
2 parents 22d6711 + 3961abd commit 38f89b0

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.github/workflows/build-numpy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ jobs:
5151
- name: Install NumPy dependencies
5252
working-directory: ${{ github.workspace }}/numpy
5353
run: |
54-
pip install -r build_requirements.txt
55-
pip install -r test_requirements.txt
54+
pip install -r requirements/build_requirements.txt
55+
pip install -r requirements/test_requirements.txt
5656
5757
- name: Update x86-simd-sort
5858
working-directory: ${{ github.workspace }}/numpy
@@ -116,8 +116,8 @@ jobs:
116116
- name: Install NumPy dependencies
117117
working-directory: ${{ github.workspace }}/numpy
118118
run: |
119-
pip install -r build_requirements.txt
120-
pip install -r test_requirements.txt
119+
pip install -r requirements/build_requirements.txt
120+
pip install -r requirements/test_requirements.txt
121121
122122
- name: Update x86-simd-sort
123123
working-directory: ${{ github.workspace }}/numpy

benchmarks/bench-objsort.hpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct Point3D {
2626
return std::sqrt(x * x + y * y + z * z);
2727
}
2828
else if constexpr (name == "taxicab") {
29-
return abs(x) + abs(y) + abs(z);
29+
return std::abs(x) + std::abs(y) + std::abs(z);
3030
}
3131
else if constexpr (name == "chebyshev") {
3232
return std::max(std::max(x, y), z);
@@ -98,13 +98,15 @@ static void simdobjsort(benchmark::State &state)
9898
->Arg(10e5) \
9999
->Arg(10e6);
100100

101-
BENCHMARK_OBJSORT(simdobjsort, Point3D, double, x)
102-
BENCHMARK_OBJSORT(scalarobjsort, Point3D, double, x)
103-
BENCHMARK_OBJSORT(simdobjsort, Point3D, float, x)
104-
BENCHMARK_OBJSORT(scalarobjsort, Point3D, float, x)
105-
BENCHMARK_OBJSORT(simdobjsort, Point3D, double, taxicab )
106-
BENCHMARK_OBJSORT(scalarobjsort, Point3D, double, taxicab)
107-
BENCHMARK_OBJSORT(simdobjsort, Point3D, double, euclidean)
108-
BENCHMARK_OBJSORT(scalarobjsort, Point3D, double, euclidean)
109-
BENCHMARK_OBJSORT(simdobjsort, Point3D, double, chebyshev)
110-
BENCHMARK_OBJSORT(scalarobjsort, Point3D, double, chebyshev)
101+
#define BENCH_ALL(dtype) \
102+
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, x) \
103+
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, x) \
104+
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, taxicab ) \
105+
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, taxicab) \
106+
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, euclidean) \
107+
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, euclidean) \
108+
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, chebyshev) \
109+
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, chebyshev) \
110+
111+
BENCH_ALL(double)
112+
BENCH_ALL(float)

lib/x86simdsort.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ keyvalue_qsort(T1 *key, T2* val, size_t arrsize, bool hasnan = false);
4343

4444
// sort an object
4545
template <typename T, typename Func>
46-
XSS_EXPORT_SYMBOL void object_qsort(T *arr, size_t arrsize, Func key_func)
46+
XSS_EXPORT_SYMBOL void object_qsort(T *arr, uint32_t arrsize, Func key_func)
4747
{
4848
/* (1) Create a vector a keys */
4949
using return_type_of =
@@ -55,9 +55,9 @@ XSS_EXPORT_SYMBOL void object_qsort(T *arr, size_t arrsize, Func key_func)
5555
}
5656

5757
/* (2) Call arg based on keys using the keyvalue sort */
58-
std::vector<size_t> arg(arrsize);
58+
std::vector<uint32_t> arg(arrsize);
5959
std::iota(arg.begin(), arg.end(), 0);
60-
keyvalue_qsort(keys.data(), arg.data(), arrsize);
60+
x86simdsort::keyvalue_qsort(keys.data(), arg.data(), arrsize);
6161

6262
/* (3) Permute obj array in-place */
6363
std::vector<bool> done(arrsize);

0 commit comments

Comments
 (0)