add configuration and compilation instructions; properly indent a function in example01

This commit is contained in:
Dakota St. Laurent
2015-06-12 19:00:45 -04:00
parent 1ea82c8b76
commit fd6b886c67
2 changed files with 29 additions and 14 deletions

View File

@@ -3,16 +3,16 @@
#include <ctime>
void compareResults (double CPUtime, double GPUtime, int trial) {
double time_ratio = (CPUtime / GPUtime);
std::cout << "VERSION " << trial << " -----------" << std::endl;
std::cout << "CPU time: " << CPUtime << std::endl;
std::cout << "GPU time: " << GPUtime << std::endl;
std::cout << "GPU is ";
if (time_ratio > 1)
std::cout << time_ratio << " times faster!" << std::endl;
else
std::cout << (1/time_ratio) << " times slower :(" << std::endl;
void compareResults (double CPUtime, double GPUtime, int trial) {
double time_ratio = (CPUtime / GPUtime);
std::cout << "VERSION " << trial << " -----------" << std::endl;
std::cout << "CPU time: " << CPUtime << std::endl;
std::cout << "GPU time: " << GPUtime << std::endl;
std::cout << "GPU is ";
if (time_ratio > 1)
std::cout << time_ratio << " times faster!" << std::endl;
else
std::cout << (1/time_ratio) << " times slower :(" << std::endl;
}
@@ -39,6 +39,7 @@ double timeAddVectorsCPU(int n, int k) {
return duration;
}
int main() {
// get all platforms (drivers), e.g. NVIDIA
std::vector<cl::Platform> all_platforms;
@@ -66,9 +67,6 @@ int main() {
cl::Context context({default_device});
cl::Program::Sources sources;
std::cout << CL_DEVICE_MAX_WORK_ITEM_SIZES << std::endl;
exit(1);
// calculates for each element; C = A + B
std::string kernel_code=
// is equivalent to the host's "time_add_vectors" function, except the