Support CSV output for triad only running mode

Fixes #54
This commit is contained in:
Tom Deakin 2018-10-04 14:36:59 +01:00
parent 96216628bf
commit a1f7b94820
2 changed files with 49 additions and 21 deletions

View File

@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file.
### Added ### Added
- OpenACC flags to build for Volta. - OpenACC flags to build for Volta.
- Kokkos list CLI argument shows some information about which device will be used. - Kokkos list CLI argument shows some information about which device will be used.
- OpenMP GNU compiler now uses native target flag - OpenMP GNU compiler now uses native target flag.
- Support CSV output for Triad only running mode.
### Changed ### Changed
- Update SYCL implementation to SYCL 1.2.1 interface. - Update SYCL implementation to SYCL 1.2.1 interface.

View File

@ -286,25 +286,30 @@ void run()
template <typename T> template <typename T>
void run_triad() void run_triad()
{ {
std::cout << "Running triad " << num_times << " times" << std::endl;
std::cout << "Number of elements: " << ARRAY_SIZE << std::endl;
if (sizeof(T) == sizeof(float)) if (!output_as_csv)
std::cout << "Precision: float" << std::endl; {
else std::cout << "Running triad " << num_times << " times" << std::endl;
std::cout << "Precision: double" << std::endl; std::cout << "Number of elements: " << ARRAY_SIZE << std::endl;
if (sizeof(T) == sizeof(float))
std::cout << "Precision: float" << std::endl;
else
std::cout << "Precision: double" << std::endl;
std::streamsize ss = std::cout.precision();
std::cout << std::setprecision(1) << std::fixed
<< "Array size: " << ARRAY_SIZE*sizeof(T)*1.0E-3 << " KB"
<< " (=" << ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB)" << std::endl;
std::cout << "Total size: " << 3.0*ARRAY_SIZE*sizeof(T)*1.0E-3 << " KB"
<< " (=" << 3.0*ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB)" << std::endl;
std::cout.precision(ss);
}
// Create host vectors // Create host vectors
std::vector<T> a(ARRAY_SIZE); std::vector<T> a(ARRAY_SIZE);
std::vector<T> b(ARRAY_SIZE); std::vector<T> b(ARRAY_SIZE);
std::vector<T> c(ARRAY_SIZE); std::vector<T> c(ARRAY_SIZE);
std::streamsize ss = std::cout.precision();
std::cout << std::setprecision(1) << std::fixed
<< "Array size: " << ARRAY_SIZE*sizeof(T)*1.0E-3 << " KB"
<< " (=" << ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB)" << std::endl;
std::cout << "Total size: " << 3.0*ARRAY_SIZE*sizeof(T)*1.0E-3 << " KB"
<< " (=" << 3.0*ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB)" << std::endl;
std::cout.precision(ss);
Stream<T> *stream; Stream<T> *stream;
@ -365,13 +370,35 @@ void run_triad()
// Display timing results // Display timing results
double total_bytes = 3 * sizeof(T) * ARRAY_SIZE * num_times; double total_bytes = 3 * sizeof(T) * ARRAY_SIZE * num_times;
double bandwidth = 1.0E-9 * (total_bytes / runtime); double bandwidth = 1.0E-9 * (total_bytes / runtime);
std::cout if (output_as_csv)
<< "--------------------------------" {
<< std::endl << std::fixed std::cout
<< "Runtime (seconds): " << std::left << std::setprecision(5) << "function" << csv_separator
<< runtime << std::endl << "num_times" << csv_separator
<< "Bandwidth (GB/s): " << std::left << std::setprecision(3) << "n_elements" << csv_separator
<< bandwidth << std::endl; << "sizeof" << csv_separator
<< "gbytes_per_sec" << csv_separator
<< "runtime"
<< std::endl;
std::cout
<< "Triad" << csv_separator
<< num_times << csv_separator
<< ARRAY_SIZE << csv_separator
<< sizeof(T) << csv_separator
<< bandwidth << csv_separator
<< runtime
<< std::endl;
}
else
{
std::cout
<< "--------------------------------"
<< std::endl << std::fixed
<< "Runtime (seconds): " << std::left << std::setprecision(5)
<< runtime << std::endl
<< "Bandwidth (GB/s): " << std::left << std::setprecision(3)
<< bandwidth << std::endl;
}
delete stream; delete stream;
} }