0

I want to do parallel reduction, but inside my kernel with data in shared memory. Is this possible with thrust library ? Something like

int sum = thrust::reduce(myIntArray, myIntArray+numberOfItems, (int) 0, thrust::max_element<int>());

But this doesn't work inside kernel. Is it possible? Thank you.

codetwiddler
  • 452
  • 3
  • 10
Hlavson
  • 309
  • 1
  • 7
  • 14
  • possible duplicate of [Thrust inside user written kernels](http://stackoverflow.com/questions/5510715/thrust-inside-user-written-kernels) – talonmies Apr 16 '12 at 15:06

1 Answers1

1

No, thrust::reduce() is a host function that results in the execution of CUDA kernels if the data is on the GPU.

You would have to dig into the thrust source and find the __device__ functions it uses for reduction. Those would be callable from your kernel. If the logic for reduction is contained in other __global__ kernels, you'll have to piece it together manually in order to use it.

Devin Lane
  • 964
  • 1
  • 7
  • 14