Skip to content

Instantly share code, notes, and snippets.

@ddemidov
Created February 17, 2014 21:03
Show Gist options
  • Save ddemidov/9059056 to your computer and use it in GitHub Desktop.
Save ddemidov/9059056 to your computer and use it in GitHub Desktop.
#include <vexcl/vexcl.hpp>
typedef int val_type;
typedef vex::cl_vector_of<val_type, 2>::type Tuple;
struct less {
typedef bool result_type;
VEX_FUNCTION(device, bool(Tuple, Tuple),
"return (prm1.x == prm2.x) ? (prm1.y < prm2.y) : (prm1.x < prm2.x);"
);
result_type operator()(Tuple a, Tuple b) const {
return (a.s[0] == b.s[0]) ? (a.s[1] < b.s[1]) : (a.s[0] < b.s[0]);
}
less() {}
};
int main() {
vex::Context ctx(vex::Filter::Env);
vex::vector<Tuple> x(ctx, 1024);
x = vex::Random<Tuple>()(vex::element_index(), std::rand());
vex::sort(x, less());
std::cout << x << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment