Skip to content

Commit

Permalink
Addressed code review results (2nd round)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihavnoid committed Jul 25, 2018
1 parent c2ab6a9 commit eba11a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ T relative_difference(const T a, const T b) {
return fabs(fa - fb) / std::min(fa, fb);
}

#endif

#ifdef USE_OPENCL_SELFCHECK
void Network::compare_net_outputs(Netresult& data,
Netresult& ref) {
// We accept an error up to 20%, but output values
Expand Down Expand Up @@ -540,7 +543,7 @@ void Network::compare_net_outputs(Netresult& data,
LOCK(m_selfcheck_mutex, selfcheck_lock);
if (selfcheck_fail) {
m_selfcheck_fails.push_back(true);
if (std::count(m_selfcheck_fails.begin(), m_selfcheck_fails.end(), true) >= max_failures) {
if (std::count(begin(m_selfcheck_fails), end(m_selfcheck_fails), true) >= max_failures) {
printf("Error in OpenCL calculation: Update your GPU drivers or reduce the amount of games "
"played simultaneously.\n");
throw std::runtime_error("OpenCL self-check mismatch.");
Expand Down Expand Up @@ -681,6 +684,7 @@ Network::Netresult Network::get_output_internal(
m_forward->forward(input_data, policy_data, value_data);
}
#else
m_forward->forward(input_data, policy_data, value_data);
(void) selfcheck;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ class Network {
std::vector<float>::iterator black,
std::vector<float>::iterator white,
const int symmetry);
void compare_net_outputs(Netresult& data, Netresult& ref);
bool probe_cache(const GameState* const state, Network::Netresult& result);
std::unique_ptr<ForwardPipe> m_forward;
#ifdef USE_OPENCL_SELFCHECK
void compare_net_outputs(Netresult& data, Netresult& ref);
std::unique_ptr<ForwardPipe> m_forward_cpu;

// records the result of most recent selfchecks
Expand Down

0 comments on commit eba11a4

Please sign in to comment.