Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable task-based parallel on windows #50

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ endif()

if(MSVC)
add_compile_definitions(_USE_MATH_DEFINES)
add_compile_options(/openmp:llvm)
# add_compile_options(/openmp:llvm)
endif()

##############
Expand Down
13 changes: 13 additions & 0 deletions include/small_gicp/util/sort_omp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

#include <algorithm>

#ifdef _MSC_VER
#pragma message("warning: Task-based OpenMP parallelism is not well supported on windows.")
#pragma message("warning: Thus, OpenMP-based downsampling is only partially parallelized on windows.")
#endif

namespace small_gicp {

template <typename RandomAccessIterator, typename Compare>
Expand All @@ -28,11 +33,15 @@ void merge_sort_omp_impl(RandomAccessIterator first, RandomAccessIterator last,

template <typename RandomAccessIterator, typename Compare>
void merge_sort_omp(RandomAccessIterator first, RandomAccessIterator last, const Compare& comp, int num_threads) {
#ifndef _MSC_VER
#pragma omp parallel num_threads(num_threads)
{
#pragma omp single nowait
{ merge_sort_omp_impl(first, last, comp); }
}
#else
std::stable_sort(first, last, comp);
#endif
}

template <typename RandomAccessIterator, typename Compare>
Expand Down Expand Up @@ -65,11 +74,15 @@ void quick_sort_omp_impl(RandomAccessIterator first, RandomAccessIterator last,

template <typename RandomAccessIterator, typename Compare>
void quick_sort_omp(RandomAccessIterator first, RandomAccessIterator last, const Compare& comp, int num_threads) {
#ifndef _MSC_VER
#pragma omp parallel num_threads(num_threads)
{
#pragma omp single nowait
{ quick_sort_omp_impl(first, last, comp); }
}
#else
std::sort(first, last, comp);
#endif
}

} // namespace small_gicp
Loading