If I have a vector A = [0, 0, 1, 1, 2, 3] and B = [11, 23, 45, 1, 4, 7] and C = [0, 2, 3] how can I fill vector D such that it has all elements from B that are the corresponding indices where the value of A matches the value in C at the same index meaning D = [11, 23, 4, 7]?
I am using Thrust and I have a solution to do that using a device_vector of device_vectors which works when I set my DEVICE TARGET to CPP but when I set my DEVICE TARGET to CUDA it does not work, specifically the initialization of device vector of device vectors did not work. I think it is because I am initializing them with a value and they're all pointing to the same base element, but I am not sure about that, this is where the error I get when I compile the program with CUDA (It worked with CPP)
int max_particles_in_a_cell = 5;
//unique_cell_ids is a vector of size 50.
thrust::device_vector<int> vector_of_particles_in_cell(max_particles_in_a_cell, -1);
thrust::device_vector<thrust::device_vector<int>> vector_of_vector_of_particles_in_cell(unique_cell_ids.size(), vector_of_particles_in_cell);
A will always be sorted, C will always be unique values, values of B are also unique to the corresponding value of A for eg, if value of B at index 0 - 11 will only be at a index corresponding to ) in vector A and that too uniquely. Basically, A is the id of the cell the particle is in, B is the unique particle ID present in the corresponding cell id, and C is the subset of A which holds the cell ids, which we are interested in to know which particle ids (vector B) are there.
I tried using thrust::find but it always returns the first instance it finds, so if I use thrust::find to locate all particles in cell 0 i.e., 11 and 23, it always returns 11 and I need to find a way that it returns 11 and 23