Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GPU Compute Error tracking to API #150

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/api/ApiRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <math.h>
#include <string.h>
#include <string>
#include <uv.h>

#if _WIN32
Expand Down Expand Up @@ -269,6 +270,13 @@ void ApiRouter::getResults(rapidjson::Document &doc) const
results.AddMember("best", best, allocator);
results.AddMember("error_log", rapidjson::Value(rapidjson::kArrayType), allocator);

rapidjson::Value gpuComputeErrors(rapidjson::kObjectType);
for (auto const& gpuError : m_network.gpuComputeErrors){
std::string s = std::to_string(gpuError.first);
rapidjson::Value index(s.c_str(), s.size(), allocator);
gpuComputeErrors.AddMember(index, gpuError.second, allocator);
}
results.AddMember("gpuComputeErrors", gpuComputeErrors, allocator);
doc.AddMember("results", results, allocator);
}

Expand Down
4 changes: 4 additions & 0 deletions src/api/NetworkState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ void NetworkState::add(const SubmitResult &result, const char *error)
m_latency.push_back(result.elapsed > 0xFFFF ? 0xFFFF : (uint16_t) result.elapsed);
}

void NetworkState::addGPUComputeError(int threadID){
gpuComputeErrors[threadID]++;
}


void NetworkState::setPool(const char *host, int port, const char *ip)
{
Expand Down
4 changes: 3 additions & 1 deletion src/api/NetworkState.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include <array>
#include <vector>

#include <map>

class SubmitResult;

Expand All @@ -41,11 +41,13 @@ class NetworkState
uint32_t avgTime() const;
uint32_t latency() const;
void add(const SubmitResult &result, const char *error);
void addGPUComputeError(int threadID);
void setPool(const char *host, int port, const char *ip);
void stop();

char pool[256];
std::array<uint64_t, 10> topDiff { { } };
std::map<int, int> gpuComputeErrors;
uint32_t diff;
uint64_t accepted;
uint64_t failures;
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/IJobResultListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class IJobResultListener
virtual ~IJobResultListener() {}

virtual void onJobResult(const JobResult &result) = 0;
virtual void onComputeError(int threadID) = 0;
};


Expand Down
5 changes: 5 additions & 0 deletions src/net/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ void Network::onJobResult(const JobResult &result)
m_strategy->submit(result);
}

void Network::onComputeError(int threadID)
{
m_state.addGPUComputeError(threadID);
}


void Network::onPause(IStrategy *strategy)
{
Expand Down
1 change: 1 addition & 0 deletions src/net/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Network : public IJobResultListener, public IStrategyListener
void onActive(IStrategy *strategy, Client *client) override;
void onJob(IStrategy *strategy, Client *client, const Job &job) override;
void onJobResult(const JobResult &result) override;
void onComputeError(int gpuID) override;
void onPause(IStrategy *strategy) override;
void onResultAccepted(IStrategy *strategy, Client *client, const SubmitResult &result, const char *error) override;

Expand Down
1 change: 1 addition & 0 deletions src/workers/Workers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ void Workers::onResult(uv_async_t *handle)
}

if (baton->errors > 0 && !baton->jobs.empty()) {
m_listener->onComputeError(baton->jobs[0].threadId());
LOG_ERR("THREAD #%d COMPUTE ERROR", baton->jobs[0].threadId());
}

Expand Down