Skip to content

Commit

Permalink
Replace oneDPL with Dispatch on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ruberith committed Sep 18, 2024
1 parent 99fa1fe commit 847c2c2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
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

0 comments on commit 847c2c2

Please sign in to comment.