Changes to API for HiveOS support.
This commit is contained in:
parent
08007ca59b
commit
2a62844fe8
9 changed files with 41 additions and 29 deletions
|
@ -59,7 +59,7 @@ rapidjson::Value ApiRouter::normalize(double d)
|
||||||
return Value(kNullType);
|
return Value(kNullType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Value(floor(d * 100.0) / 100.0);
|
return Value((int)floor(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,16 +93,11 @@ void ApiRouter::ApiRouter::get(const xmrig::HttpRequest &req, xmrig::HttpReply &
|
||||||
return finalize(reply, doc);
|
return finalize(reply, doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.match("/1/threads")) {
|
|
||||||
getThreads(doc);
|
|
||||||
|
|
||||||
return finalize(reply, doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
doc.SetObject();
|
doc.SetObject();
|
||||||
|
|
||||||
getIdentify(doc);
|
getIdentify(doc);
|
||||||
getMiner(doc);
|
getMiner(doc);
|
||||||
|
getThreads(doc);
|
||||||
getHashrate(doc);
|
getHashrate(doc);
|
||||||
getResults(doc);
|
getResults(doc);
|
||||||
getConnection(doc);
|
getConnection(doc);
|
||||||
|
@ -208,7 +203,6 @@ void ApiRouter::getHashrate(rapidjson::Document &doc) const
|
||||||
|
|
||||||
rapidjson::Value hashrate(rapidjson::kObjectType);
|
rapidjson::Value hashrate(rapidjson::kObjectType);
|
||||||
rapidjson::Value total(rapidjson::kArrayType);
|
rapidjson::Value total(rapidjson::kArrayType);
|
||||||
rapidjson::Value threads(rapidjson::kArrayType);
|
|
||||||
|
|
||||||
const Hashrate *hr = Workers::hashrate();
|
const Hashrate *hr = Workers::hashrate();
|
||||||
|
|
||||||
|
@ -216,21 +210,8 @@ void ApiRouter::getHashrate(rapidjson::Document &doc) const
|
||||||
total.PushBack(normalize(hr->calc(Hashrate::MediumInterval)), allocator);
|
total.PushBack(normalize(hr->calc(Hashrate::MediumInterval)), allocator);
|
||||||
total.PushBack(normalize(hr->calc(Hashrate::LargeInterval)), allocator);
|
total.PushBack(normalize(hr->calc(Hashrate::LargeInterval)), allocator);
|
||||||
|
|
||||||
vector<Handle *> workers = Workers::workers();
|
|
||||||
for (size_t i = 0; i < workers.size(); i++) {
|
|
||||||
for(size_t j = 0; j < workers[i]->hasher()->deviceCount(); j++) {
|
|
||||||
rapidjson::Value thread(rapidjson::kArrayType);
|
|
||||||
thread.PushBack(normalize(hr->calc(i, j, Hashrate::ShortInterval)), allocator);
|
|
||||||
thread.PushBack(normalize(hr->calc(i, j, Hashrate::MediumInterval)), allocator);
|
|
||||||
thread.PushBack(normalize(hr->calc(i, j, Hashrate::LargeInterval)), allocator);
|
|
||||||
|
|
||||||
threads.PushBack(thread, allocator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hashrate.AddMember("total", total, allocator);
|
hashrate.AddMember("total", total, allocator);
|
||||||
hashrate.AddMember("highest", normalize(hr->highest()), allocator);
|
hashrate.AddMember("highest", normalize(hr->highest()), allocator);
|
||||||
hashrate.AddMember("threads", threads, allocator);
|
|
||||||
doc.AddMember("hashrate", hashrate, allocator);
|
doc.AddMember("hashrate", hashrate, allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,9 +262,6 @@ void ApiRouter::getResults(rapidjson::Document &doc) const
|
||||||
|
|
||||||
void ApiRouter::getThreads(rapidjson::Document &doc) const
|
void ApiRouter::getThreads(rapidjson::Document &doc) const
|
||||||
{
|
{
|
||||||
doc.SetObject();
|
|
||||||
auto &allocator = doc.GetAllocator();
|
|
||||||
|
|
||||||
Workers::hashersSummary(doc);
|
Workers::hashersSummary(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
virtual int compute(int threadIdx, uint8_t *input, size_t size, uint8_t *output) = 0;
|
virtual int compute(int threadIdx, uint8_t *input, size_t size, uint8_t *output) = 0;
|
||||||
virtual size_t parallelism(int workerIdx) = 0;
|
virtual size_t parallelism(int workerIdx) = 0;
|
||||||
virtual size_t deviceCount() = 0;
|
virtual size_t deviceCount() = 0;
|
||||||
|
virtual DeviceInfo &device(int workerIdx) = 0;
|
||||||
|
|
||||||
string type();
|
string type();
|
||||||
string subType(bool shortName = false);
|
string subType(bool shortName = false);
|
||||||
|
|
|
@ -224,4 +224,8 @@ size_t CpuHasher::deviceCount() {
|
||||||
return computingThreads();
|
return computingThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceInfo &CpuHasher::device(int workerIdx) {
|
||||||
|
return devices()[0];
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_HASHER(CpuHasher);
|
REGISTER_HASHER(CpuHasher);
|
|
@ -22,6 +22,7 @@ public:
|
||||||
virtual int compute(int threadIdx, uint8_t *input, size_t size, uint8_t *output);
|
virtual int compute(int threadIdx, uint8_t *input, size_t size, uint8_t *output);
|
||||||
virtual size_t parallelism(int workerIdx);
|
virtual size_t parallelism(int workerIdx);
|
||||||
virtual size_t deviceCount();
|
virtual size_t deviceCount();
|
||||||
|
virtual DeviceInfo &device(int workerIdx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string detectFeaturesAndMakeDescription();
|
string detectFeaturesAndMakeDescription();
|
||||||
|
|
|
@ -119,7 +119,8 @@ CudaDeviceInfo *CudaHasher::getDeviceInfo(int device_index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CudaHasher::configure(xmrig::HasherConfig &config) {
|
bool CudaHasher::configure(xmrig::HasherConfig &config) {
|
||||||
int index = config.getGPUCardsCount();
|
int deviceOffset = config.getGPUCardsCount();
|
||||||
|
int index = deviceOffset;
|
||||||
double intensity = 0;
|
double intensity = 0;
|
||||||
|
|
||||||
int total_threads = 0;
|
int total_threads = 0;
|
||||||
|
@ -165,7 +166,7 @@ bool CudaHasher::configure(xmrig::HasherConfig &config) {
|
||||||
|
|
||||||
ss << endl;
|
ss << endl;
|
||||||
|
|
||||||
double device_intensity = config.getGPUIntensity((*d)->deviceIndex);
|
double device_intensity = config.getGPUIntensity(deviceOffset + m_enabledDevices.size());
|
||||||
|
|
||||||
m_description += ss.str();
|
m_description += ss.str();
|
||||||
|
|
||||||
|
@ -335,6 +336,15 @@ size_t CudaHasher::deviceCount() {
|
||||||
return m_enabledDevices.size();
|
return m_enabledDevices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceInfo &CudaHasher::device(int workerIdx) {
|
||||||
|
workerIdx /= 2;
|
||||||
|
|
||||||
|
if(workerIdx < 0 || workerIdx > m_enabledDevices.size())
|
||||||
|
return devices().begin()->second;
|
||||||
|
|
||||||
|
return devices()[m_enabledDevices[workerIdx]->deviceIndex];
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_HASHER(CudaHasher);
|
REGISTER_HASHER(CudaHasher);
|
||||||
|
|
||||||
#endif //WITH_CUDA
|
#endif //WITH_CUDA
|
||||||
|
|
|
@ -99,6 +99,7 @@ public:
|
||||||
virtual int compute(int threadIdx, uint8_t *input, size_t size, uint8_t *output);
|
virtual int compute(int threadIdx, uint8_t *input, size_t size, uint8_t *output);
|
||||||
virtual size_t parallelism(int workerIdx);
|
virtual size_t parallelism(int workerIdx);
|
||||||
virtual size_t deviceCount();
|
virtual size_t deviceCount();
|
||||||
|
virtual DeviceInfo &device(int workerIdx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CudaDeviceInfo *getDeviceInfo(int device_index);
|
CudaDeviceInfo *getDeviceInfo(int device_index);
|
||||||
|
|
|
@ -217,7 +217,8 @@ OpenCLDeviceInfo *OpenCLHasher::getDeviceInfo(cl_platform_id platform, cl_device
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenCLHasher::configure(xmrig::HasherConfig &config) {
|
bool OpenCLHasher::configure(xmrig::HasherConfig &config) {
|
||||||
int index = config.getGPUCardsCount();
|
int deviceOffset = config.getGPUCardsCount();
|
||||||
|
int index = deviceOffset;
|
||||||
double intensity = 0;
|
double intensity = 0;
|
||||||
|
|
||||||
int total_threads = 0;
|
int total_threads = 0;
|
||||||
|
@ -264,7 +265,7 @@ bool OpenCLHasher::configure(xmrig::HasherConfig &config) {
|
||||||
|
|
||||||
ss << endl;
|
ss << endl;
|
||||||
|
|
||||||
double device_intensity = config.getGPUIntensity((*d)->deviceIndex);
|
double device_intensity = config.getGPUIntensity(deviceOffset + m_enabledDevices.size());
|
||||||
|
|
||||||
m_description += ss.str();
|
m_description += ss.str();
|
||||||
|
|
||||||
|
@ -307,7 +308,7 @@ bool OpenCLHasher::configure(xmrig::HasherConfig &config) {
|
||||||
intensity += device_intensity;
|
intensity += device_intensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.addGPUCardsCount(index - config.getGPUCardsCount());
|
config.addGPUCardsCount(index - deviceOffset);
|
||||||
|
|
||||||
if(!cards_selected) {
|
if(!cards_selected) {
|
||||||
m_intensity = 0;
|
m_intensity = 0;
|
||||||
|
@ -883,6 +884,15 @@ size_t OpenCLHasher::deviceCount() {
|
||||||
return m_enabledDevices.size();
|
return m_enabledDevices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceInfo &OpenCLHasher::device(int workerIdx) {
|
||||||
|
workerIdx /= 2;
|
||||||
|
|
||||||
|
if(workerIdx < 0 || workerIdx > m_enabledDevices.size())
|
||||||
|
return devices().begin()->second;
|
||||||
|
|
||||||
|
return devices()[m_enabledDevices[workerIdx]->deviceIndex];
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_HASHER(OpenCLHasher);
|
REGISTER_HASHER(OpenCLHasher);
|
||||||
|
|
||||||
#endif // WITH_OPENCL
|
#endif // WITH_OPENCL
|
||||||
|
|
|
@ -91,6 +91,7 @@ public:
|
||||||
virtual int compute(int threadIdx, uint8_t *input, size_t size, uint8_t *output);
|
virtual int compute(int threadIdx, uint8_t *input, size_t size, uint8_t *output);
|
||||||
virtual size_t parallelism(int workerIdx);
|
virtual size_t parallelism(int workerIdx);
|
||||||
virtual size_t deviceCount();
|
virtual size_t deviceCount();
|
||||||
|
virtual DeviceInfo &device(int workerIdx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OpenCLDeviceInfo *getDeviceInfo(cl_platform_id platform, cl_device_id device);
|
OpenCLDeviceInfo *getDeviceInfo(cl_platform_id platform, cl_device_id device);
|
||||||
|
|
|
@ -228,12 +228,18 @@ void Workers::hashersSummary(rapidjson::Document &doc)
|
||||||
Handle *worker = m_workers[i];
|
Handle *worker = m_workers[i];
|
||||||
for(int j=0; j < worker->hasher()->deviceCount(); j++) {
|
for(int j=0; j < worker->hasher()->deviceCount(); j++) {
|
||||||
rapidjson::Value hasherDoc(rapidjson::kObjectType);
|
rapidjson::Value hasherDoc(rapidjson::kObjectType);
|
||||||
|
int multiplier = worker->hasher()->computingThreads() / worker->hasher()->deviceCount();
|
||||||
|
|
||||||
xmrig::String type = worker->hasher()->type().data();
|
xmrig::String type = worker->hasher()->type().data();
|
||||||
xmrig::String id = (worker->hasher()->subType(true) + to_string(j)).data();
|
xmrig::String id = (worker->hasher()->subType(true) + to_string(j)).data();
|
||||||
|
DeviceInfo &deviceInfo = worker->hasher()->device(j * multiplier);
|
||||||
|
xmrig::String device = deviceInfo.name.data();
|
||||||
|
xmrig::String busId = deviceInfo.bus_id.data();
|
||||||
|
|
||||||
hasherDoc.AddMember("type", type.toJSON(doc), allocator);
|
hasherDoc.AddMember("type", type.toJSON(doc), allocator);
|
||||||
hasherDoc.AddMember("id", id.toJSON(doc), allocator);
|
hasherDoc.AddMember("id", id.toJSON(doc), allocator);
|
||||||
|
hasherDoc.AddMember("device", device.toJSON(doc), allocator);
|
||||||
|
hasherDoc.AddMember("bus_id", busId.toJSON(doc), allocator);
|
||||||
|
|
||||||
rapidjson::Value hashrateEntry(rapidjson::kArrayType);
|
rapidjson::Value hashrateEntry(rapidjson::kArrayType);
|
||||||
hashrateEntry.PushBack(ApiRouter::normalize(m_hashrate->calc(i, j, Hashrate::ShortInterval)), allocator);
|
hashrateEntry.PushBack(ApiRouter::normalize(m_hashrate->calc(i, j, Hashrate::ShortInterval)), allocator);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue