Skip to content

Commit

Permalink
Merge pull request #11 from bogdanadnan/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
bogdanadnan authored Jan 25, 2019
2 parents 69bc370 + cd9c9b0 commit 5de8b3e
Show file tree
Hide file tree
Showing 15 changed files with 243 additions and 76 deletions.
98 changes: 73 additions & 25 deletions app/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,21 @@ arguments::arguments(int argc, char **argv) {
{"force-gpu-optimization", required_argument, NULL, 'f'},
{"update-interval", required_argument, NULL, 'u'},
{"report-interval", required_argument, NULL, 'r'},
{"hash-report-interval", required_argument, NULL, 'j'},
{"block-type", required_argument, NULL, 'b'},
{"intensity-start", required_argument, NULL, 'y'},
{"intensity-stop", required_argument, NULL, 'z'},
{"intensity-step", required_argument, NULL, 'q'},
{"autotune-step-time", required_argument, NULL, 's'},
{"chs-threshold", required_argument, NULL, 'e'},
{"ghs-threshold", required_argument, NULL, 'i'},
{"show-pool-requests", no_argument, NULL, 'k'},
{0, 0, 0, 0}
};

int option_index = 0;

c = getopt_long (argc, argv, "hvm:a:p:w:n:c:g:x:d:o:f:u:r:b:y:z:q:t:s:",
c = getopt_long (argc, argv, "hvm:a:p:w:n:c:g:x:d:o:f:u:r:b:y:z:q:t:s:e:i:j:k",
options, &option_index);

switch (c)
Expand All @@ -73,6 +75,9 @@ arguments::arguments(int argc, char **argv) {
case 'v':
__verbose_flag = 1;
break;
case 'k':
__show_pool_requests = true;
break;
case 'm':
if(strcmp(optarg, "-h") == 0 || strcmp(optarg, "--help") == 0) {
__help_flag = 1;
Expand Down Expand Up @@ -226,18 +231,23 @@ arguments::arguments(int argc, char **argv) {
__help_flag = 1;
}
else {
if (strcmp(optarg, "OPENCL") == 0)
__gpu_optimization = "OPENCL";
else if (strcmp(optarg, "CUDA") == 0)
__gpu_optimization = "CUDA";
else if (strcmp(optarg, "AMDGCN") == 0)
__gpu_optimization = "AMDGCN";
else {
sprintf(buff, "%s: invalid arguments",
argv[0]);
__error_message = buff;
__error_flag = true;
}
vector<string> gpu_hashers = __parse_multiarg(optarg);
for(vector<string>::iterator st = gpu_hashers.begin(); st != gpu_hashers.end(); st++) {
string opt = *st;
if (opt == "OPENCL")
__gpu_optimization.push_back("OPENCL");
else if (opt == "CUDA")
__gpu_optimization.push_back("CUDA");
else if (opt == "AMDGCN")
__gpu_optimization.push_back("AMDGCN");
else {
sprintf(buff, "%s: invalid arguments",
argv[0]);
__error_message = buff;
__error_flag = true;
break;
}
}
}
break;
case 'u':
Expand All @@ -256,6 +266,14 @@ arguments::arguments(int argc, char **argv) {
__report_interval = 1000000 * atoi(optarg);
}
break;
case 'j':
if(strcmp(optarg, "-h") == 0 || strcmp(optarg, "--help") == 0) {
__help_flag = 1;
}
else {
__hash_report_interval = 60000000 * atoi(optarg);
}
break;
case 'y':
if(strcmp(optarg, "-h") == 0 || strcmp(optarg, "--help") == 0) {
__help_flag = 1;
Expand Down Expand Up @@ -397,6 +415,11 @@ bool arguments::valid(string &error) {
error = "Reporting interval must be at least 1 sec.";
return false;
}

if (__hash_report_interval < 60000000) {
error = "Reporting interval must be at least 1 min.";
return false;
}
}
else if(__autotune_flag == 1) {
if (__argon2profile.empty()) {
Expand Down Expand Up @@ -428,6 +451,11 @@ bool arguments::valid(string &error) {
error = "GPU autotune step time must be at least 10 seconds.";
return false;
}

if(__gpu_optimization.size() > 1) {
error = "In autotune mode you can only use one gpu hasher type (AMDGCN|CUDA|OPENCL).";
return false;
}
}
else {
error = "Only miner or autotune mode are supported for the moment";
Expand Down Expand Up @@ -497,18 +525,22 @@ string arguments::cpu_optimization() {
return __cpu_optimization;
}

string arguments::gpu_optimization() {
vector<string> arguments::gpu_optimization() {
return __gpu_optimization;
}

int arguments::update_interval() {
int64_t arguments::update_interval() {
return __update_interval;
}

int arguments::report_interval() {
int64_t arguments::report_interval() {
return __report_interval;
}

int64_t arguments::hash_report_interval() {
return __hash_report_interval;
}

string arguments::argon2_profile() {
return __argon2profile;
}
Expand All @@ -525,7 +557,7 @@ double arguments::gpu_intensity_step() {
return __gpu_intensity_step;
}

int arguments::autotune_step_time() {
int64_t arguments::autotune_step_time() {
return __autotune_step_time;
}

Expand All @@ -537,6 +569,10 @@ int arguments::ghs_threshold() {
return __ghs_threshold;
}

bool arguments::show_pool_requests() {
return __show_pool_requests;
}

string arguments::get_help() {
return
"\nArionum CPU/GPU Miner v." ArioMiner_VERSION_MAJOR "." ArioMiner_VERSION_MINOR "." ArioMiner_VERSION_REVISION "\n"
Expand Down Expand Up @@ -572,17 +608,23 @@ string arguments::get_help() {
" --gpu-intensity-cblocks: miner specific option, mining intensity on GPU\n"
" value from 0 (disabled) to 100 (full load)\n"
" this is optional, defaults to 100 (*)\n"
" you can add more entries separated by comma for each GPU\n"
" you can add more entries separated by comma for each GPU;\n"
" in this case you need to add entries for all cards displayed,\n"
" even if card is disabled by gpu-filter - use 0 for those\n"
" --gpu-intensity-gblocks: miner specific option, mining intensity on GPU\n"
" value from 0 (disabled) to 100 (full load)\n"
" this is optional, defaults to 100 (*)\n"
" you can add more entries separated by comma for each GPU\n"
" you can add more entries separated by comma for each GPU;\n"
" in this case you need to add entries for all cards displayed,\n"
" even if card is disabled by gpu-filter - use 0 for those\n"
" --gpu-threads: miner specific option, how many host threads per GPU\n"
" this is unused for the moment, defaults to 4 (*)\n"
" you can add more entries separated by comma for each GPU\n"
" --gpu-filter: miner specific option, filter string for device selection\n"
" it will select only devices that have in description the specified string\n"
" this is optional, defaults to \"\"; you can add more entries separated by comma\n"
" this is optional, defaults to \"\"; you can add more entries separated by comma;\n"
" if using multiple gpu hashers you can select specific filters for each like this:\n"
" --gpu-filter CUDA:[1],CUDA:[2],OPENCL:AMD where [1], [2] and AMD are filters for cards\n"
" --force-cpu-optimization: miner specific option, what type of CPU optimization to use\n"
#if defined(__x86_64__) || defined(_WIN64)
" values: REF, SSE2, SSSE3, AVX, AVX2, AVX512F\n"
Expand All @@ -592,9 +634,9 @@ string arguments::get_help() {
" values: REF\n"
#endif
" this is optional, defaults to autodetect, change only if autodetected one crashes\n"
" --force-gpu-optimization: what type of GPU optimization to use\n"
" values: OPENCL, CUDA, AMDGCN\n"
" this is optional, defaults to autodetect, change only if autodetected one crashes\n"
" --force-gpu-optimization: what type of GPU optimization/hasher to use; values: OPENCL, CUDA, AMDGCN\n"
" this is optional, defaults to autodetect\n"
" you can add more entries separated by comma\n"
" --chs-threshold: miner specific option, cblocks avg hashrate value under which\n"
" miner will exit (default is disabled)\n"
" --ghs-threshold: miner specific option, gblocks avg hashrate value under which\n"
Expand All @@ -605,8 +647,11 @@ string arguments::get_help() {
" --update-interval: how often should we update mining settings from pool, in seconds\n"
" increasing it will lower the load on pool but will increase rejection rate\n"
" this is optional, defaults to 2 sec and can't be set lower than that\n"
" --hash-report-interval: how often should we send hashrate to pool, in minutes\n"
" this is optional, defaults to 10 min and can't be set lower than 1 min\n"
" --report-interval: how often should we display mining reports, in seconds\n"
" this is optional, defaults to 10 sec\n"
" --show-pool-requests: miner specific option, show full requests sent to pool, debug purpose only\n"
" --intensity-start: autotune specific option, start intensity for autotuning (default 1)\n"
" --intensity-stop: autotune specific option, stop intensity for autotuning (default 100)\n"
" --intensity-step: autotune specific option, intensity steps for autotuning (default 1)\n"
Expand All @@ -630,19 +675,23 @@ void arguments::__init() {
__proxy_port = 8088;
__update_interval = 2000000;
__report_interval = 10000000;
__hash_report_interval = 600000000;

__gpu_intensity_start = 1;
__gpu_intensity_stop = 100;
__gpu_intensity_step = 1;
__autotune_step_time = 20;

__cpu_optimization = "";
__gpu_optimization = "";
__gpu_optimization.clear();
__argon2profile = "";

__chs_threshold = -1;
__ghs_threshold = -1;

__show_pool_requests = false;

__cards_count = 0;
__error_flag = false;
}

Expand Down Expand Up @@ -680,4 +729,3 @@ vector<string> arguments::__parse_multiarg(const string &arg) {

return tokens;
}

26 changes: 18 additions & 8 deletions app/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,27 @@ class DLLEXPORT arguments {
double gpu_intensity_start();
double gpu_intensity_stop();
double gpu_intensity_step();
int autotune_step_time();
int64_t autotune_step_time();

int update_interval();
int report_interval();
int64_t update_interval();
int64_t report_interval();
int64_t hash_report_interval();

string cpu_optimization();
string gpu_optimization();
vector<string> gpu_optimization();

int chs_threshold();
int ghs_threshold();

bool show_pool_requests();

string get_help();

static string get_app_folder();

int get_cards_count() { return __cards_count; }
void set_cards_count(int count) { __cards_count = count; }

private:
void __init();
vector<string> __parse_multiarg(const string &arg);
Expand All @@ -68,22 +74,26 @@ class DLLEXPORT arguments {
vector<string> __gpu_filter;
vector<int> __gpu_threads;
int __proxy_port;
int __update_interval;
int __report_interval;
int64_t __update_interval;
int64_t __report_interval;
int64_t __hash_report_interval;

double __gpu_intensity_start;
double __gpu_intensity_stop;
double __gpu_intensity_step;
int __autotune_step_time;
int64_t __autotune_step_time;

string __argon2profile;

string __cpu_optimization;
string __gpu_optimization;
vector<string> __gpu_optimization;

int __chs_threshold;
int __ghs_threshold;

bool __show_pool_requests;

int __cards_count;
static string __argv_0;
};

Expand Down
8 changes: 6 additions & 2 deletions autotune/autotune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ autotune::~autotune() { }
void autotune::run() {
vector<hasher*> all_hashers = hasher::get_hashers();
hasher *selected_hasher = NULL;
string gpu_optimization;
if(__args.gpu_optimization().size() > 0)
gpu_optimization = __args.gpu_optimization()[0];

for (vector<hasher*>::iterator it = all_hashers.begin(); it != all_hashers.end(); ++it) {
if ((*it)->get_type() == "GPU") {
if ((*it)->initialize()) {
if (selected_hasher == NULL || selected_hasher->get_priority() < (*it)->get_priority()) {
selected_hasher = *it;
}
if ((*it)->get_subtype() == __args.gpu_optimization()) {
if ((*it)->get_subtype() == gpu_optimization) {
selected_hasher = *it;
break;
}
Expand All @@ -34,7 +38,7 @@ void autotune::run() {
if (selected_hasher != NULL) {
selected_hasher->configure(__args);
selected_hasher->set_input("test_public_key", "test_blk", "test_difficulty", __args.argon2_profile(), "mine");
LOG("Compute unit: " + selected_hasher->get_type());
LOG("Compute unit: " + selected_hasher->get_type() + " - " + selected_hasher->get_subtype());
LOG(selected_hasher->get_info());
}

Expand Down
2 changes: 1 addition & 1 deletion common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

using namespace std;

#define LOG(msg) cout<<msg<<endl
#define LOG(msg) cout<<msg<<endl<<flush

DLLEXPORT uint64_t microseconds();
DLLEXPORT vector<string> get_files(string folder);
Expand Down
3 changes: 2 additions & 1 deletion hash/cpu/cpu_hasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

cpu_hasher::cpu_hasher() : hasher() {
_type = "CPU";
_subtype = "CPU";
__optimization = "REF";
__available_processing_thr = 1;
__available_memory_thr = 1;
Expand Down Expand Up @@ -182,7 +183,7 @@ void cpu_hasher::__run() {
if(mem == NULL) {
LOG("Error allocating memory");
__running = false;
continue;
exit(0);
}
hash_factory.set_seed_memory((uint8_t *)mem);
free(buffer);
Expand Down
Loading

0 comments on commit 5de8b3e

Please sign in to comment.