-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move eval into its own file for easier development (#123)
- Loading branch information
Showing
2 changed files
with
68 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <chrono> | ||
#include <iostream> | ||
|
||
#include "reference.cuh" | ||
#include "train.cuh" | ||
|
||
#define WARMUP_RUNS 10 | ||
#define TIMED_RUNS 100 | ||
|
||
|
||
float measure_runtime() { | ||
std::cout << "warming up..." << std::endl; | ||
|
||
for (int i = 0; i < WARMUP_RUNS; i++) { | ||
auto data = generate_input(); | ||
custom_kernel(data); | ||
} | ||
cudaDeviceSynchronize(); | ||
|
||
using double_duration = std::chrono::duration<double>; | ||
double total_duration = 0.0; | ||
|
||
for (int i = 0; i < TIMED_RUNS; i++) { | ||
auto data = generate_input(); | ||
|
||
auto start = std::chrono::high_resolution_clock::now(); | ||
auto submission_output = custom_kernel(data); | ||
cudaDeviceSynchronize(); | ||
auto end = std::chrono::high_resolution_clock::now(); | ||
|
||
total_duration += std::chrono::duration_cast<double_duration>(end - start).count(); | ||
|
||
auto reference_output = ref_kernel(data); | ||
if (!check_implementation(submission_output, reference_output)) { | ||
std::cout << "check_implementation failed" << std::endl; | ||
return 1; | ||
} | ||
|
||
} | ||
|
||
|
||
double average_duration = total_duration / TIMED_RUNS; | ||
std::cout << "submitted kernel runtime: " << average_duration << " seconds" << std::endl; | ||
return average_duration; | ||
} | ||
|
||
int main() { | ||
auto data = generate_input(); | ||
auto reference_output = ref_kernel(data); | ||
auto submission_output = custom_kernel(data); | ||
|
||
if (!check_implementation(submission_output, reference_output)) { | ||
std::cout << "check_implementation failed" << std::endl; | ||
return 1; | ||
} | ||
|
||
float s = measure_runtime(); | ||
if (s < 0) { | ||
return 1; | ||
} | ||
|
||
std::cout << "score: " << s << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters