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

Enabling/disabling GPUs from CLI #2432

Merged
merged 1 commit into from Jun 9, 2019
Merged
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
27 changes: 27 additions & 0 deletions xmrstak/backend/amd/autoAdjust.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ class autoAdjust
std::string conf;
for(auto& ctx : devVec)
{
std::string enabledGpus = params::inst().amdGpus;
bool enabled = true;
if (!enabledGpus.empty())
{
enabled = false;
std::stringstream ss(enabledGpus);

int i = -1;
while (ss >> i)
{
if (i == ctx.deviceIdx)
{
enabled = true;
break;
}

while (ss.peek() == ',' || ss.peek() == ' ')
ss.ignore();
}
}

size_t minFreeMem = 128u * byteToMiB;
/* 1000 is a magic selected limit, the reason is that more than 2GiB memory
* sowing down the memory performance because of TLB cache misses
Expand Down Expand Up @@ -196,6 +217,9 @@ class autoAdjust
}
if(intensity != 0)
{
if (!enabled)
conf += "/* Disabled\n";

for(uint32_t thd = 0; thd < numThreads; ++thd)
{
conf += " // gpu: " + ctx.name + std::string(" compute units: ") + std::to_string(ctx.computeUnits) + "\n";
Expand All @@ -209,6 +233,9 @@ class autoAdjust
std::to_string(numUnroll) + ", \"comp_mode\" : true, \"interleave\" : " + std::to_string(ctx.interleave) + "\n" +
" },\n";
}

if (!enabled)
conf += "*/\n";
}
else
{
Expand Down
27 changes: 27 additions & 0 deletions xmrstak/backend/nvidia/autoAdjust.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,32 @@ class autoAdjust
std::string conf;
for(auto& ctx : nvidCtxVec)
{
std::string enabledGpus = params::inst().nvidiaGpus;
bool enabled = true;
if (!enabledGpus.empty())
{
enabled = false;
std::stringstream ss(enabledGpus);

int i = -1;
while (ss >> i)
{
if (i == ctx.device_id)
{
enabled = true;
break;
}

while (ss.peek() == ',' || ss.peek() == ' ')
ss.ignore();
}
}

if(ctx.device_threads * ctx.device_blocks > 0)
{
if (!enabled)
conf += "/* Disabled\n";

conf += std::string(" // gpu: ") + ctx.name + " architecture: " + std::to_string(ctx.device_arch[0] * 10 + ctx.device_arch[1]) + "\n";
conf += std::string(" // memory: ") + std::to_string(ctx.free_device_memory / byte2mib) + "/" + std::to_string(ctx.total_device_memory / byte2mib) + " MiB\n";
conf += std::string(" // smx: ") + std::to_string(ctx.device_mpcount) + "\n";
Expand All @@ -92,6 +116,9 @@ class autoAdjust
" \"affine_to_cpu\" : false, \"sync_mode\" : 3,\n" +
" \"mem_mode\" : 1,\n" +
" },\n";

if (!enabled)
conf += "*/\n";
}
}

Expand Down
24 changes: 24 additions & 0 deletions xmrstak/cli/cli-miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ void help()
#endif
#ifndef CONF_NO_OPENCL
cout << " --noAMD disable the AMD miner backend" << endl;
cout << " --amdGpus GPUS indices of AMD GPUs to use. Example: 0,2,3" << endl;
cout << " --noAMDCache disable the AMD(OpenCL) cache for precompiled binaries" << endl;
cout << " --openCLVendor VENDOR use OpenCL driver of VENDOR and devices [AMD,NVIDIA]" << endl;
cout << " default: AMD" << endl;
Expand All @@ -88,6 +89,7 @@ void help()
#endif
#ifndef CONF_NO_CUDA
cout << " --noNVIDIA disable the NVIDIA miner backend" << endl;
cout << " --nvidiaGpus GPUS indices of NVIDIA GPUs to use. Example: 0,2,3" << endl;
cout << " --nvidia FILE NVIDIA backend miner config file" << endl;
#endif
cout << " --log FILE miner output file" << endl;
Expand Down Expand Up @@ -472,6 +474,17 @@ int main(int argc, char* argv[])
{
params::inst().useAMD = false;
}
else if (opName.compare("--amdGpus") == 0)
{
++i;
if (i >= argc)
{
printer::inst()->print_msg(L0, "No argument for parameter '--amdGpus' given");
win_exit();
return 1;
}
params::inst().amdGpus = argv[i];
}
else if(opName.compare("--openCLVendor") == 0)
{
++i;
Expand All @@ -498,6 +511,17 @@ int main(int argc, char* argv[])
{
params::inst().useNVIDIA = false;
}
else if (opName.compare("--nvidiaGpus") == 0)
{
++i;
if (i >= argc)
{
printer::inst()->print_msg(L0, "No argument for parameter '--nvidiaGpus' given");
win_exit();
return 1;
}
params::inst().nvidiaGpus = argv[i];
}
else if(opName.compare("--cpu") == 0)
{
++i;
Expand Down
2 changes: 2 additions & 0 deletions xmrstak/params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct params
bool AMDCache;
bool useNVIDIA;
bool useCPU;
std::string amdGpus;
std::string nvidiaGpus;
// user selected OpenCL vendor
std::string openCLVendor;

Expand Down