-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sorting algorithms take tuples of keys/values
One will also has to explicitly specify the comparison function. Both host and device variants of the comparison functor should take 2*n arguments, where n is number of keys. First n arguments correspond to a left set of keys, and second n arguments correspond to a right set of keys. Here is an example that sorts values by a tuple of two keys: vex::vector<int> keys1(ctx, n); vex::vector<float> keys2(ctx, n); vex::vector<double> vals (ctx, n); struct { VEX_FUNCTION(device, bool(int, float, int, float), "return (prm1 == prm3) ? (prm2 < prm4) : (prm1 < prm3);" ); bool operator()(int a1, float a2, int b1, float b2) const { return std::make_tuple(a1, a2) < std::tuple(b1, b2); } } comp; vex::sort_by_key(std::tie(keys1, keys2), vals);
- Loading branch information
Showing
6 changed files
with
1,233 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.