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

Replace oneDPL with Dispatch on macOS #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ endif ()

target_include_directories(CompactNSearch PUBLIC include)

if (APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
find_package(oneDPL REQUIRED)
target_link_libraries(CompactNSearch PUBLIC oneDPL)
endif()

install(FILES "include/CompactNSearch" ${HEADER_FILES}
DESTINATION include/)

Expand Down
2 changes: 1 addition & 1 deletion demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ advect()
#ifdef _MSC_VER
concurrency::parallel_for_each(
#elif defined(__APPLE__) && defined(__clang__)
std::for_each(oneapi::dpl::execution::par,
dispatch::parallel_for_each(
#else
__gnu_parallel::for_each(
#endif
Expand Down
19 changes: 17 additions & 2 deletions include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,23 @@ namespace CompactNSearch
#ifdef _MSC_VER
#include <ppl.h>
#elif defined(__APPLE__) && defined(__clang__)
#include <oneapi/dpl/execution>
#include <oneapi/dpl/algorithm>
#include <dispatch/dispatch.h>
#include <iterator>

namespace dispatch
{
template <typename _Iterator, typename _Function>
void parallel_for_each(_Iterator first, _Iterator last, const _Function& _Func)
{
dispatch_apply(
std::distance(first, last),
DISPATCH_APPLY_AUTO,
^(size_t i) {
_Func(*std::next(first, i));
}
);
}
}
#else
#include <parallel/algorithm>
#endif
8 changes: 4 additions & 4 deletions src/CompactNSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ NeighborhoodSearch::update_point_sets()
#ifdef _MSC_VER
concurrency::parallel_for_each(
#elif defined(__APPLE__) && defined(__clang__)
std::for_each(oneapi::dpl::execution::par,
dispatch::parallel_for_each(
#else
__gnu_parallel::for_each(
#endif
Expand Down Expand Up @@ -318,7 +318,7 @@ NeighborhoodSearch::erase_empty_entries(std::vector<unsigned int> const& to_dele
#ifdef _MSC_VER
concurrency::parallel_for_each(
#elif defined(__APPLE__) && defined(__clang__)
std::for_each(oneapi::dpl::execution::par,
dispatch::parallel_for_each(
#else
__gnu_parallel::for_each(
#endif
Expand Down Expand Up @@ -418,7 +418,7 @@ NeighborhoodSearch::query()
#ifdef _MSC_VER
concurrency::parallel_for_each(
#elif defined(__APPLE__) && defined(__clang__)
std::for_each(oneapi::dpl::execution::par,
dispatch::parallel_for_each(
#else
__gnu_parallel::for_each(
#endif
Expand Down Expand Up @@ -480,7 +480,7 @@ NeighborhoodSearch::query()
#ifdef _MSC_VER
concurrency::parallel_for_each(
#elif defined(__APPLE__) && defined(__clang__)
std::for_each(oneapi::dpl::execution::par,
dispatch::parallel_for_each(
#else
__gnu_parallel::for_each(
#endif
Expand Down