From e07916954cc7d711a83ba526bf3e52d4c1769002 Mon Sep 17 00:00:00 2001 From: Denis Demidov Date: Wed, 2 Apr 2014 09:45:48 +0400 Subject: [PATCH] Fixed errors and warnings given by VS2010 --- examples/benchmark.cpp | 2 +- tests/sort.cpp | 8 ++++---- vexcl/generator.hpp | 10 +++++----- vexcl/scan.hpp | 14 +++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/benchmark.cpp b/examples/benchmark.cpp index 87b0b50da..28f7f53f4 100644 --- a/examples/benchmark.cpp +++ b/examples/benchmark.cpp @@ -818,7 +818,7 @@ void benchmark_scan( if (options.bm_cpu) { prof.tic_cpu("CPU"); for(size_t i = 0; i < M; i++) { - key_type sum = 0.0; + key_type sum = key_type(); for(size_t j = 0; j < N; ++j) { key_type next = sum + x0[j]; x1[j] = sum; diff --git a/tests/sort.cpp b/tests/sort.cpp index bfacb620e..136e1bbdf 100644 --- a/tests/sort.cpp +++ b/tests/sort.cpp @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE(sort_keys_vals_default) vex::vector keys(ctx, k); vex::vector vals(ctx, v); - std::iota(p.begin(), p.end(), 0); + for(size_t i = 0; i < p.size(); ++i) p[i] = static_cast(i); std::stable_sort(p.begin(), p.end(), [&](int i, int j) { return k[i] < k[j]; }); vex::sort_by_key(keys, vals); @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(sort_keys_vals_custom_op) vex::vector keys(ctx, k); vex::vector vals(ctx, v); - std::iota(p.begin(), p.end(), 0); + for(size_t i = 0; i < p.size(); ++i) p[i] = static_cast(i); struct even_first_t { typedef bool result_type; @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(sort_keys_vals_custom_op) ) } even_first; - std::stable_sort(p.begin(), p.end(), [&](int i, int j) { + std::stable_sort(p.begin(), p.end(), [&](int i, int j) -> bool { int a = k[i]; int b = k[j]; return even_first(a, b); @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(sort_keys_vals_tuple) vex::vector vals2(ctx, v2); std::vector p(n); - std::iota(p.begin(), p.end(), 0); + for(size_t i = 0; i < p.size(); ++i) p[i] = static_cast(i); struct less_t { typedef bool result_type; diff --git a/vexcl/generator.hpp b/vexcl/generator.hpp index 54e50e6cc..417569350 100644 --- a/vexcl/generator.hpp +++ b/vexcl/generator.hpp @@ -80,7 +80,7 @@ class recorder { // Reset preamble and state. preamble.reset(new backend::source_generator); - state = detail::empty_state(); + state = vex::detail::empty_state(); } static std::ostream& get() { @@ -91,7 +91,7 @@ class recorder { return *preamble; } - static detail::kernel_generator_state_ptr get_state() { + static vex::detail::kernel_generator_state_ptr get_state() { return state; } @@ -102,7 +102,7 @@ class recorder { static size_t index; static std::ostream *os; static std::unique_ptr preamble; - static detail::kernel_generator_state_ptr state; + static vex::detail::kernel_generator_state_ptr state; }; template @@ -115,7 +115,7 @@ template std::unique_ptr recorder::preamble; template -detail::kernel_generator_state_ptr recorder::state; +vex::detail::kernel_generator_state_ptr recorder::state; inline size_t var_id() { return recorder<>::var_id(); @@ -129,7 +129,7 @@ inline backend::source_generator& get_preamble() { return recorder<>::get_preamble(); } -inline detail::kernel_generator_state_ptr get_state() { +inline vex::detail::kernel_generator_state_ptr get_state() { return recorder<>::get_state(); } /// \endcond diff --git a/vexcl/scan.hpp b/vexcl/scan.hpp index b09defdd9..01d65e5fb 100644 --- a/vexcl/scan.hpp +++ b/vexcl/scan.hpp @@ -445,18 +445,18 @@ void inclusive_scan( auto &queue = input.queue_list(); - for(size_t d = 0; d < queue.size(); ++d) + for(unsigned d = 0; d < queue.size(); ++d) detail::scan(queue[d], input(d), output(d), init, false, oper.device); std::vector tail(queue.size() - 1); - for(size_t d = 1; d < queue.size(); ++d) + for(unsigned d = 1; d < queue.size(); ++d) if (size_t head = output.part_start(d)) tail[d - 1] = output[head - 1]; std::partial_sum(tail.begin(), tail.end(), tail.begin(), oper); - for(size_t d = 1; d < queue.size(); ++d) + for(unsigned d = 1; d < queue.size(); ++d) if (output.part_start(d)) { vector part(queue[d], output(d)); part = oper.device(part, tail[d - 1]); @@ -492,20 +492,20 @@ void exclusive_scan( std::vector tail(queue.size() - 1); - for(size_t d = 1; d < queue.size(); ++d) + for(unsigned d = 1; d < queue.size(); ++d) if (size_t head = input.part_start(d)) tail[d - 1] = input[head - 1]; - for(size_t d = 0; d < queue.size(); ++d) + for(unsigned d = 0; d < queue.size(); ++d) detail::scan(queue[d], input(d), output(d), init, true, oper.device); - for(size_t d = 1; d < queue.size(); ++d) + for(unsigned d = 1; d < queue.size(); ++d) if (size_t head = output.part_start(d)) tail[d - 1] = oper(tail[d - 1], output[head - 1]); std::partial_sum(tail.begin(), tail.end(), tail.begin(), oper); - for(size_t d = 1; d < queue.size(); ++d) + for(unsigned d = 1; d < queue.size(); ++d) if (output.part_start(d)) { vector part(queue[d], output(d)); part = oper.device(part, tail[d - 1]);