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

Function tune_accumulate

compute/perf/perf_accumulate.cpp:48–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47template<class T>
48void tune_accumulate(const compute::vector<T>& data,
49 const size_t trials,
50 compute::command_queue& queue)
51{
52 boost::shared_ptr<compute::detail::parameter_cache>
53 params = compute::detail::parameter_cache::get_global_cache(queue.get_device());
54
55 const std::string cache_key =
56 std::string("__boost_reduce_on_gpu_") + compute::type_name<T>();
57
58 const compute::uint_ tpbs[] = { 4, 8, 16, 32, 64, 128, 256, 512, 1024 };
59 const compute::uint_ vpts[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
60
61 double min_time = (std::numeric_limits<double>::max)();
62 compute::uint_ best_tpb = 0;
63 compute::uint_ best_vpt = 0;
64
65 for(size_t i = 0; i < sizeof(tpbs) / sizeof(*tpbs); i++){
66 params->set(cache_key, "tpb", tpbs[i]);
67 for(size_t j = 0; j < sizeof(vpts) / sizeof(*vpts); j++){
68 params->set(cache_key, "vpt", vpts[j]);
69
70 try {
71 const double t = perf_accumulate(data, trials, queue);
72 if(t < min_time){
73 best_tpb = tpbs[i];
74 best_vpt = vpts[j];
75 min_time = t;
76 }
77 }
78 catch(compute::opencl_error&){
79 // invalid parameters for this device, skip
80 }
81 }
82 }
83
84 // store optimal parameters
85 params->set(cache_key, "tpb", best_tpb);
86 params->set(cache_key, "vpt", best_vpt);
87}
88
89int main(int argc, char *argv[])
90{

Callers 1

mainFunction · 0.85

Calls 3

perf_accumulateFunction · 0.85
get_deviceMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected