MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / tune_sort

Function tune_sort

compute/perf/perf_sort.cpp:50–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49template<class T>
50void tune_sort(const std::vector<T>& data,
51 const size_t trials,
52 compute::command_queue& queue)
53{
54 boost::shared_ptr<compute::detail::parameter_cache>
55 params = compute::detail::parameter_cache::get_global_cache(queue.get_device());
56
57 const std::string cache_key =
58 std::string("__boost_radix_sort_") + compute::type_name<T>();
59
60 const compute::uint_ tpbs[] = { 32, 64, 128, 256, 512, 1024 };
61
62 double min_time = (std::numeric_limits<double>::max)();
63 compute::uint_ best_tpb = 0;
64
65 for(size_t i = 0; i < sizeof(tpbs) / sizeof(*tpbs); i++){
66 params->set(cache_key, "tpb", tpbs[i]);
67
68 try {
69 const double t = perf_sort(data, trials, queue);
70 if(t < min_time){
71 best_tpb = tpbs[i];
72 min_time = t;
73 }
74 }
75 catch(compute::opencl_error&){
76 // invalid work group size for this device, skip
77 }
78 }
79
80 // store optimal parameters
81 params->set(cache_key, "tpb", best_tpb);
82}
83
84int main(int argc, char *argv[])
85{

Callers 1

mainFunction · 0.85

Calls 3

perf_sortFunction · 0.85
get_deviceMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected