Skip to content

Commit 3eb35dd

Browse files
committed
MSVC++ limited to OpenMP 2.0 support: parallel for must use signed integer indices.
1 parent 9fd4ddf commit 3eb35dd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/pyco_tree/pico_tree/_pyco_tree/kd_tree.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class KdTree : public pico_tree::KdTree<Space_, Metric_> {
2222

2323
using Base = pico_tree::KdTree<Space_, Metric_>;
2424
using Space = Space_;
25+
// TODO Remove when MSVC++ has default support for OpenMP 3.0+.
26+
using SSize = std::ptrdiff_t;
2527

2628
public:
2729
using Base::Dim;
@@ -47,7 +49,7 @@ class KdTree : public pico_tree::KdTree<Space_, Metric_> {
4749
auto output = static_cast<NeighborType*>(nns.mutable_data());
4850

4951
#pragma omp parallel for schedule(dynamic, kChunkSize)
50-
for (SizeType i = 0; i < query.size(); ++i) {
52+
for (SSize i = 0; i < static_cast<SSize>(query.size()); ++i) {
5153
Base::SearchKnn(query[i], output + i * k, output + (i + 1) * k);
5254
}
5355
}
@@ -69,7 +71,7 @@ class KdTree : public pico_tree::KdTree<Space_, Metric_> {
6971
auto output = static_cast<NeighborType*>(nns.mutable_data());
7072

7173
#pragma omp parallel for schedule(dynamic, kChunkSize)
72-
for (SizeType i = 0; i < query.size(); ++i) {
74+
for (SSize i = 0; i < static_cast<SSize>(query.size()); ++i) {
7375
Base::SearchKnn(query[i], e, output + i * k, output + (i + 1) * k);
7476
}
7577
}
@@ -95,7 +97,7 @@ class KdTree : public pico_tree::KdTree<Space_, Metric_> {
9597

9698
#pragma omp parallel for schedule(dynamic, kChunkSize)
9799
// TODO Reduce the vector resize overhead
98-
for (SizeType i = 0; i < query.size(); ++i) {
100+
for (SSize i = 0; i < static_cast<SSize>(query.size()); ++i) {
99101
Base::SearchRadius(query[i], radius, nns_data[i], sort);
100102
}
101103
}
@@ -125,7 +127,7 @@ class KdTree : public pico_tree::KdTree<Space_, Metric_> {
125127

126128
#pragma omp parallel for schedule(dynamic, kChunkSize)
127129
// TODO Reduce the vector resize overhead
128-
for (SizeType i = 0; i < query_min.size(); ++i) {
130+
for (SSize i = 0; i < static_cast<SSize>(query_min.size()); ++i) {
129131
Base::SearchBox(query_min[i], query_max[i], box_data[i]);
130132
}
131133
}

0 commit comments

Comments
 (0)