Bolt  1.1
C++ template library with support for OpenCL
Functions
CL-sort

Functions

template<typename RandomAccessIterator >
void bolt::cl::sort (bolt::cl::control &ctl, RandomAccessIterator first, RandomAccessIterator last, const std::string &cl_code="")
 This version of sort returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements. The routine arranges the elements in an ascending order. RandomAccessIterator's value_type must provide operator < overload.
 
template<typename RandomAccessIterator >
void bolt::cl::sort (RandomAccessIterator first, RandomAccessIterator last, const std::string &cl_code="")
 
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::cl::sort (bolt::cl::control &ctl, RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp, const std::string &cl_code="")
 sort returns the sorted result of all the elements in the inputIterator between the the first and last elements using the specified binary_op. You can arrange the elements in an ascending order, where the binary_op is the less<>() operator. This version of sort takes a bolt::cl::control structure as a first argument and compares objects using functor object defined by StrictWeakOrdering.
 
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::cl::sort (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp, const std::string &cl_code="")
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 >
void bolt::cl::sort_by_key (bolt::cl::control &ctl, RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first, const std::string &cl_code="")
 This version of sort_by_key returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements key elements and corresponding values. The routine arranges the elements in an ascending order.
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 >
void bolt::cl::sort_by_key (RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first, const std::string &cl_code="")
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::cl::sort_by_key (bolt::cl::control &ctl, RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first, StrictWeakOrdering comp, const std::string &cl_code="")
 This version of sort_by_key returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements key elements and corresponding values. The routine arranges the elements in an ascending order.
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::cl::sort_by_key (RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first, StrictWeakOrdering comp, const std::string &cl_code="")
 

Detailed Description

Function Documentation

template<typename RandomAccessIterator >
void bolt::cl::sort ( bolt::cl::control ctl,
RandomAccessIterator  first,
RandomAccessIterator  last,
const std::string &  cl_code = "" 
)

This version of sort returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements. The routine arranges the elements in an ascending order. RandomAccessIterator's value_type must provide operator < overload.

The sort operation is analogus to the std::sort function. See http://www.sgi.com/tech/stl/sort.html

Template Parameters
RandomAccessIteratorIs a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html,
RandomAccessIterator is mutable,
RandomAccessIterator's value_type is convertible to StrictWeakOrdering's
RandomAccessIterator's value_type is LessThanComparable http://www.sgi.com/tech/stl/LessThanComparable.html; i.e., the value _type must provide operator < overloaded.
Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
firstThe first position in the sequence to be sorted.
lastThe last position in the sequence to be sorted.
cl_codeOptional OpenCL(TM) code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code traits. This can be used for any extra cl code that is to be passed when compiling the OpenCl Kernel.
Returns
The sorted data that is available in place.

The following code example shows the use of sort to sort the elements in the ascending order, specifying a specific command-queue.

#include <bolt/cl/sort.h>
int a[8] = {2, 9, 3, 7, 5, 6, 3, 8};
// for arranging the elements in descending order, use bolt::cl::greater<int>()
bolt::cl::sort( a, a+8 );
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::cl::sort ( bolt::cl::control ctl,
RandomAccessIterator  first,
RandomAccessIterator  last,
StrictWeakOrdering  comp,
const std::string &  cl_code = "" 
)

sort returns the sorted result of all the elements in the inputIterator between the the first and last elements using the specified binary_op. You can arrange the elements in an ascending order, where the binary_op is the less<>() operator. This version of sort takes a bolt::cl::control structure as a first argument and compares objects using functor object defined by StrictWeakOrdering.

The sort operation is analogus to the std::sort function. See http://www.sgi.com/tech/stl/sort.html.

Template Parameters
RandomAccessIteratorIs a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html,
RandomAccessIterator is mutable,
RandomAccessIterator's value_type is convertible to StrictWeakOrdering's
RandomAccessIterator's value_type is LessThanComparable http://www.sgi.com/tech/stl/LessThanComparable.html i.e the value _type should provide operator < overloaded.
StrictWeakOrderingIs a model of http://www.sgi.com/tech/stl/StrictWeakOrdering.html.
Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
firstThe first position in the sequence to be sorted.
lastThe last position in the sequence to be sorted.
compThe comparison operation used to compare two values.
cl_codeOptional OpenCL(TM) code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code traits. This can be used for any extra cl code that is to be passed when compiling the OpenCl Kernel.
Returns
The sorted data that is available in place.

The following code example shows the use of sort to sort the elements in the descending order.

#include <bolt/cl/sort.h>
int a[8] = {2, 9, 3, 7, 5, 6, 3, 8};
bolt::cl::sort(a, a+8, bolt::cl::greater<int>());
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 >
void bolt::cl::sort_by_key ( bolt::cl::control ctl,
RandomAccessIterator1  keys_first,
RandomAccessIterator1  keys_last,
RandomAccessIterator2  values_first,
const std::string &  cl_code = "" 
)

This version of sort_by_key returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements key elements and corresponding values. The routine arranges the elements in an ascending order.

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
keys_firstThe first position in the sequence to be sorted.
keys_lastThe last position in the sequence to be sorted.
values_firstThe first position in the value sequence.
cl_codeOptional OpenCL(TM) code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code traits. This can be used for any extra cl code that is to be passed when compiling the OpenCl Kernel.
Returns
The sorted key,value pair that is available in place.
Template Parameters
RandomAccessIterator1Is a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html
RandomAccessIterator2Is a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html

The following code example shows the use of sort_by_key to sort the key,value pair in the ascending order.

int keys[8] = {2, 9, 3, 7, 5, 6, 3, 8};
int values[8] = {100, 200, 16, 50, 15, 8, 3, 5};
bolt::cl::sort_by_key(keys, keys+8,values);
//Output
//keys[8] = {2,3,3,5,6,7,8,9}
//values[8] = {100,16,3,15,8,50,5,200}
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::cl::sort_by_key ( bolt::cl::control ctl,
RandomAccessIterator1  keys_first,
RandomAccessIterator1  keys_last,
RandomAccessIterator2  values_first,
StrictWeakOrdering  comp,
const std::string &  cl_code = "" 
)

This version of sort_by_key returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements key elements and corresponding values. The routine arranges the elements in an ascending order.

This routine uses function object comp to compare the key objects.

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
keys_firstThe first position in the sequence to be sorted.
keys_lastThe last position in the sequence to be sorted.
values_firstThe first position in the value sequence.
compThe comparison operation used to compare two values.
cl_codeOptional OpenCL(TM) code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code traits. This can be used for any extra cl code that is to be passed when compiling the OpenCl Kernel.
Returns
The sorted key,value pair that is available in place.
Template Parameters
RandomAccessIterator1Is a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html
RandomAccessIterator2Is a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html
StrictWeakOrderingIs a model of http://www.sgi.com/tech/stl/StrictWeakOrdering.html.

The following code example shows the use of sort_by_key to sort the key,value pair in the ascending order.

int keys[8] = {2, 9, 3, 7, 5, 6, 3, 8};
int values[8] = {100, 200, 16, 50, 15, 8, 3, 5};
// for arranging the elements in descending order, use bolt::cl::greater<int>()
bolt::cl::sort_by_key(keys, keys+8,values,bolt::cl::less<int>());
//Output
//keys[8] = {9,8,7,6,5,3,3,2}
//values[8] = {200,5,50,8,15,3,16,100}