[compute] 28/49: Fix perf_max_element benchmark
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Fri Dec 18 17:58:18 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository compute.
commit 11709434ebec9e4324101128fc0ff9140ecbc089
Author: Jakub Szuppe <j.szuppe at gmail.com>
Date: Tue Aug 18 16:13:02 2015 +0200
Fix perf_max_element benchmark
---
perf/perf_bolt_max_element.cpp | 19 ++++++++++++++++---
perf/perf_max_element.cpp | 16 ++++++++--------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/perf/perf_bolt_max_element.cpp b/perf/perf_bolt_max_element.cpp
index e71acf1..238b1ba 100644
--- a/perf/perf_bolt_max_element.cpp
+++ b/perf/perf_bolt_max_element.cpp
@@ -42,15 +42,28 @@ int main(int argc, char *argv[])
// transfer data to the device
bolt::cl::copy(host_vec.begin(), host_vec.end(), device_vec.begin());
- size_t max = 0;
+ bolt::cl::device_vector<int>::iterator max_iter = device_vec.begin();
perf_timer t;
for(size_t trial = 0; trial < PERF_TRIALS; trial++){
t.start();
- max = *bolt::cl::max_element(device_vec.begin(), device_vec.end());
+ max_iter = bolt::cl::max_element(device_vec.begin(), device_vec.end());
t.stop();
}
+
+ int device_max = *max_iter;
std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
- std::cout << "max: " << max << std::endl;
+ std::cout << "max: " << device_max << std::endl;
+
+ // verify max is correct
+ int host_max = *std::max_element(host_vec.begin(), host_vec.end());
+ if(device_max != host_max){
+ std::cout << "ERROR: "
+ << "device_max (" << device_max << ") "
+ << "!= "
+ << "host_max (" << host_max << ")"
+ << std::endl;
+ return -1;
+ }
return 0;
}
diff --git a/perf/perf_max_element.cpp b/perf/perf_max_element.cpp
index cda2131..6635488 100644
--- a/perf/perf_max_element.cpp
+++ b/perf/perf_max_element.cpp
@@ -47,26 +47,26 @@ int main(int argc, char *argv[])
queue
);
- size_t max = 0;
+ boost::compute::vector<int>::iterator max = device_vector.begin();
perf_timer t;
for(size_t trial = 0; trial < PERF_TRIALS; trial++){
t.start();
- max = *boost::compute::max_element(
+ max = boost::compute::max_element(
device_vector.begin(), device_vector.end(), queue
);
queue.finish();
t.stop();
}
+
+ int device_max = max.read(queue);
std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
- std::cout << "max: " << max << std::endl;
+ std::cout << "max: " << device_max << std::endl;
// verify max is correct
- size_t host_max = *std::max_element(host_vector.begin(),
- host_vector.end()
- );
- if(max != host_max){
+ int host_max = *std::max_element(host_vector.begin(), host_vector.end());
+ if(device_max != host_max){
std::cout << "ERROR: "
- << "device_max (" << max << ") "
+ << "device_max (" << device_max << ") "
<< "!= "
<< "host_max (" << host_max << ")"
<< std::endl;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/compute.git
More information about the debian-science-commits
mailing list