Skip to content
Open
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
17 changes: 13 additions & 4 deletions paddle/phi/kernels/gpu/argsort_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/backends/gpu/gpu_info.h"
#include "paddle/phi/backends/gpu/gpu_launch_config.h"
#include "paddle/phi/common/memory_utils.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/blas/blas.h"
#include "paddle/phi/kernels/funcs/cub.h"
Expand Down Expand Up @@ -283,9 +284,13 @@ void PerSort(const GPUContext& dev_ctx,
bool stable,
bool descending) {
#ifdef PADDLE_WITH_CUDA
const auto& exec_policy = thrust::cuda::par.on(dev_ctx.stream());
phi::memory_utils::ThrustAllocator<cudaStream_t> allocator(dev_ctx.GetPlace(),
dev_ctx.stream());
const auto& exec_policy = thrust::cuda::par(allocator).on(dev_ctx.stream());
#else
const auto& exec_policy = thrust::hip::par.on(dev_ctx.stream());
phi::memory_utils::ThrustAllocator<hipStream_t> allocator(dev_ctx.GetPlace(),
dev_ctx.stream());
const auto& exec_policy = thrust::hip::par(allocator).on(dev_ctx.stream());
#endif
if (stable) {
if (descending) {
Expand Down Expand Up @@ -349,9 +354,13 @@ void ArgsortKernel(const Context& dev_ctx,
T* out_data = dev_ctx.template Alloc<T>(output);
int64_t* ids_data = dev_ctx.template Alloc<int64_t>(indices);
#ifdef PADDLE_WITH_CUDA
const auto& exec_policy = thrust::cuda::par.on(dev_ctx.stream());
phi::memory_utils::ThrustAllocator<cudaStream_t> allocator(
dev_ctx.GetPlace(), dev_ctx.stream());
const auto& exec_policy = thrust::cuda::par(allocator).on(dev_ctx.stream());
#else
const auto& exec_policy = thrust::hip::par.on(dev_ctx.stream());
phi::memory_utils::ThrustAllocator<hipStream_t> allocator(
dev_ctx.GetPlace(), dev_ctx.stream());
const auto& exec_policy = thrust::hip::par(allocator).on(dev_ctx.stream());
#endif
auto cu_stream = dev_ctx.stream();
thrust::sequence(exec_policy, ids_data, ids_data + size);
Expand Down
Loading