My questions are:
1: How does Thrust determine what arguments to send to a functor and in which order to send them? Is it in the order of the input iterator data? I have not found any information on this. I have seen examples of e.g. thrust transform usage with zip/tuple iterators, which then has two data types, for instance as in this question: CUDA thrust zip_iterator tuple transform_reduce, but never with basically more than 2 arguments to operator(). UPDATE: I guess i can just use a struct object with the wanted data here, and use a 1-argument operator() with a device vector iterator of the struct object..
2: Is there a max number of arguments allowed to pass to the functor operator() for use in a thrust function?
3: In special cases where you want to pass the CUDA kernel thread ID to the functor operator(), in addition to other arguments, how can this be done? Is the pseudocode in the unfinished example below even possible? If so, could you help me with a solution? (Preferably a generic solution if you want n arguments to a thrust functor operator()):
#include <thrust/device_vector.h>
struct functor
{
__device__ operator()(unsigned int thread_id, int arg2, double arg3, float arg4) // n arguments of different types in general, this is just an example
{
// Do some operations here..
}
};
int main()
{
// How to zip multiple device vector iterators here such
// that one can match the given functor argument list for operator()?
// and thus use the functor.
return 0;
}
std::tuple<std::string, int, int>. It's possible to pass that tuple to a function with signaturevoid foo(std::string const& str, int x, int y). Seestd::apply- Timo