Skip to content

Commit

Permalink
Option to use oneDPL sorting with macro SPHINXSYS_USE_ONEDPL_SORTING
Browse files Browse the repository at this point in the history
  • Loading branch information
nR3D committed Jul 13, 2024
1 parent bcb7192 commit 8981ddd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/shared/particles/particle_sorting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include "base_particles.h"
#include "cell_linked_list.h"

#ifdef SPHINXSYS_USE_ONEDPL_SORTING
#include <oneapi/dpl/execution>
#include <oneapi/dpl/algorithm>
#endif

namespace SPH
{
Expand Down Expand Up @@ -95,17 +97,19 @@ void ParticleSorting::sortingParticleData(DeviceInt *begin, DeviceInt size, exec
if (!index_sorting_device_variables_)
index_sorting_device_variables_ = allocateDeviceData<DeviceInt>(size);

#ifndef SPHINXSYS_USE_ONEDPL_SORTING
device_radix_sorting.sort_by_key(begin, index_sorting_device_variables_, size, execution::executionQueue.getQueue(), 512, 4).wait();

/*execution::executionQueue.getQueue().parallel_for(execution::executionQueue.getUniformNdRange(size),
#else
execution::executionQueue.getQueue().parallel_for(execution::executionQueue.getUniformNdRange(size),
[=, index_sorting = index_sorting_device_variables_](sycl::nd_item<1> it) {
DeviceInt i = it.get_global_id(0);
if(i < size)
index_sorting[i] = i;
}).wait();

oneapi::dpl::sort_by_key(oneapi::dpl::execution::make_device_policy(execution::executionQueue.getQueue()),
begin, begin + size, index_sorting_device_variables_);*/
begin, begin + size, index_sorting_device_variables_);
#endif

move_sortable_particle_device_data_(index_sorting_device_variables_, size);

Expand Down

0 comments on commit 8981ddd

Please sign in to comment.