Workarounds for applying thrust algorithms to tuples instead of primitives

Given a collection X of n-tuples stored in device memory as the array, for example (x1 , x2, x3) , (x4, x5, x6) … where each braces identifies an individual tuple in a collection of 3-tuples. I’d like to perform the two following operations on the collection:

  1. Remove repeated tuples from the collection X
  2. Append unique tuples to X from another collection Y := (y1, y2, y3) , (y4 , y5, y6) …

I’m aware that thrust has merge, remove and unique functions but I’m also aware that these algorithms are designed for primitive types. Are there known workarounds?

I think thrust may be able to operate on custom data types/objects that provide all necessary operator overloads for the algorithms you need to run. In your case that might be the == and != operators and possibly comparison operators like < to maintain ordering.

This stackoverflow answer seems to suggest that custom types can work in thrust code:
https://stackoverflow.com/questions/31655844/thrust-vector-with-custom-data-type/31656078

This answer would suggest to try thrust’s tuple type before anything else
https://stackoverflow.com/questions/40742242/does-cuda-c-not-have-tuples-in-device-code/40742357