diff options
Diffstat (limited to 'xmrstak')
27 files changed, 239 insertions, 237 deletions
diff --git a/xmrstak/backend/amd/amd_gpu/gpu.cpp b/xmrstak/backend/amd/amd_gpu/gpu.cpp index 22ce5d0..791ceb2 100644 --- a/xmrstak/backend/amd/amd_gpu/gpu.cpp +++ b/xmrstak/backend/amd/amd_gpu/gpu.cpp @@ -386,42 +386,42 @@ size_t InitOpenCLGpu(cl_context opencl_ctx, GpuContext* ctx, const char* source_ } const cl_platform_info attributeTypes[5] = { - CL_PLATFORM_NAME, - CL_PLATFORM_VENDOR, - CL_PLATFORM_VERSION, - CL_PLATFORM_PROFILE, - CL_PLATFORM_EXTENSIONS + CL_PLATFORM_NAME, + CL_PLATFORM_VENDOR, + CL_PLATFORM_VERSION, + CL_PLATFORM_PROFILE, + CL_PLATFORM_EXTENSIONS }; const char* const attributeNames[] = { - "CL_PLATFORM_NAME", - "CL_PLATFORM_VENDOR", - "CL_PLATFORM_VERSION", - "CL_PLATFORM_PROFILE", - "CL_PLATFORM_EXTENSIONS" + "CL_PLATFORM_NAME", + "CL_PLATFORM_VENDOR", + "CL_PLATFORM_VERSION", + "CL_PLATFORM_PROFILE", + "CL_PLATFORM_EXTENSIONS" }; #define NELEMS(x) (sizeof(x) / sizeof((x)[0])) void PrintDeviceInfo(cl_device_id device) { - char queryBuffer[1024]; - int queryInt; - cl_int clError; - clError = clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(queryBuffer), &queryBuffer, NULL); - printf(" CL_DEVICE_NAME: %s\n", queryBuffer); - queryBuffer[0] = '\0'; - clError = clGetDeviceInfo(device, CL_DEVICE_VENDOR, sizeof(queryBuffer), &queryBuffer, NULL); - printf(" CL_DEVICE_VENDOR: %s\n", queryBuffer); - queryBuffer[0] = '\0'; - clError = clGetDeviceInfo(device, CL_DRIVER_VERSION, sizeof(queryBuffer), &queryBuffer, NULL); - printf(" CL_DRIVER_VERSION: %s\n", queryBuffer); - queryBuffer[0] = '\0'; - clError = clGetDeviceInfo(device, CL_DEVICE_VERSION, sizeof(queryBuffer), &queryBuffer, NULL); - printf(" CL_DEVICE_VERSION: %s\n", queryBuffer); - queryBuffer[0] = '\0'; - clError = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(int), &queryInt, NULL); - printf(" CL_DEVICE_MAX_COMPUTE_UNITS: %d\n", queryInt); + char queryBuffer[1024]; + int queryInt; + cl_int clError; + clError = clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(queryBuffer), &queryBuffer, NULL); + printf(" CL_DEVICE_NAME: %s\n", queryBuffer); + queryBuffer[0] = '\0'; + clError = clGetDeviceInfo(device, CL_DEVICE_VENDOR, sizeof(queryBuffer), &queryBuffer, NULL); + printf(" CL_DEVICE_VENDOR: %s\n", queryBuffer); + queryBuffer[0] = '\0'; + clError = clGetDeviceInfo(device, CL_DRIVER_VERSION, sizeof(queryBuffer), &queryBuffer, NULL); + printf(" CL_DRIVER_VERSION: %s\n", queryBuffer); + queryBuffer[0] = '\0'; + clError = clGetDeviceInfo(device, CL_DEVICE_VERSION, sizeof(queryBuffer), &queryBuffer, NULL); + printf(" CL_DEVICE_VERSION: %s\n", queryBuffer); + queryBuffer[0] = '\0'; + clError = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(int), &queryInt, NULL); + printf(" CL_DEVICE_MAX_COMPUTE_UNITS: %d\n", queryInt); } uint32_t getNumPlatforms() @@ -449,8 +449,8 @@ std::vector<GpuContext> getAMDDevices(int index) uint32_t numPlatforms = getNumPlatforms(); - platforms = (cl_platform_id *) malloc(sizeof(cl_platform_id) * numPlatforms); - clStatus = clGetPlatformIDs(numPlatforms, platforms, NULL); + platforms = (cl_platform_id *) malloc(sizeof(cl_platform_id) * numPlatforms); + clStatus = clGetPlatformIDs(numPlatforms, platforms, NULL); clStatus = clGetDeviceIDs( platforms[index], CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); device_list = (cl_device_id *) malloc(sizeof(cl_device_id)*num_devices); @@ -478,7 +478,7 @@ std::vector<GpuContext> getAMDDevices(int index) ctxVec.push_back(ctx); } } - + free(device_list); free(platforms); @@ -500,7 +500,7 @@ int getAMDPlatformIdx() cl_int clStatus; platforms = (cl_platform_id *) malloc(sizeof(cl_platform_id) * numPlatforms); - clStatus = clGetPlatformIDs(numPlatforms, platforms, NULL); + clStatus = clGetPlatformIDs(numPlatforms, platforms, NULL); int platformIndex = -1; @@ -554,7 +554,7 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx) uint32_t numPlatforms = getNumPlatforms(); platforms = (cl_platform_id *) malloc(sizeof(cl_platform_id) * numPlatforms); - clStatus = clGetPlatformIDs(numPlatforms, platforms, NULL); + clStatus = clGetPlatformIDs(numPlatforms, platforms, NULL); size_t infoSize; clGetPlatformInfo(platforms[platform_idx], CL_PLATFORM_VENDOR, 0, NULL, &infoSize); @@ -565,7 +565,7 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx) { printer::inst()->print_msg(L1,"WARNING: using non AMD device: %s", platformName.c_str()); } - + free(platforms); /*MSVC skimping on devel costs by shoehorning C99 to be a subset of C++? Noooo... can't be.*/ @@ -674,7 +674,7 @@ size_t XMRSetJob(GpuContext* ctx, uint8_t* input, size_t input_len, uint64_t tar input[input_len] = 0x01; memset(input + input_len + 1, 0, 88 - input_len - 1); - + size_t numThreads = ctx->rawIntensity; if((ret = clEnqueueWriteBuffer(ctx->CommandQueues, ctx->InputBuffer, CL_TRUE, 0, 88, input, 0, NULL, NULL)) != CL_SUCCESS) diff --git a/xmrstak/backend/amd/autoAdjust.hpp b/xmrstak/backend/amd/autoAdjust.hpp index 41dd11a..0b91212 100644 --- a/xmrstak/backend/amd/autoAdjust.hpp +++ b/xmrstak/backend/amd/autoAdjust.hpp @@ -34,18 +34,18 @@ class autoAdjust { public: - autoAdjust() - { - - } - - /** print the adjusted values if needed - * - * Routine exit the application and print the adjusted values if needed else - * nothing is happened. - */ - bool printConfig() - { + autoAdjust() + { + + } + + /** print the adjusted values if needed + * + * Routine exit the application and print the adjusted values if needed else + * nothing is happened. + */ + bool printConfig() + { int platformIndex = getAMDPlatformIdx(); if(platformIndex == -1) @@ -65,14 +65,14 @@ public: return false; } - generateThreadConfig(platformIndex); + generateThreadConfig(platformIndex); return true; - } + } private: - void generateThreadConfig(const int platformIndex) - { + void generateThreadConfig(const int platformIndex) + { // load the template of the backend config into a char variable const char *tpl = #include "./config.tpl" @@ -94,9 +94,9 @@ private: } std::string conf; - int i = 0; - for(auto& ctx : devVec) - { + int i = 0; + for(auto& ctx : devVec) + { /* 1000 is a magic selected limit, the reason is that more than 2GiB memory * sowing down the memory performance because of TLB cache misses */ @@ -121,20 +121,20 @@ private: conf += std::string(" // gpu: ") + ctx.name + " memory:" + std::to_string(availableMem / byteToMiB) + "\n"; conf += std::string(" // compute units: ") + std::to_string(ctx.computeUnits) + "\n"; // set 8 threads per block (this is a good value for the most gpus) - conf += std::string(" { \"index\" : ") + std::to_string(ctx.deviceIdx) + ",\n" + - " \"intensity\" : " + std::to_string(intensity) + ", \"worksize\" : " + std::to_string(8) + ",\n" + - " \"affine_to_cpu\" : false, \n" - " },\n"; - ++i; - } + conf += std::string(" { \"index\" : ") + std::to_string(ctx.deviceIdx) + ",\n" + + " \"intensity\" : " + std::to_string(intensity) + ", \"worksize\" : " + std::to_string(8) + ",\n" + + " \"affine_to_cpu\" : false, \n" + " },\n"; + ++i; + } configTpl.replace("PLATFORMINDEX",std::to_string(platformIndex)); configTpl.replace("GPUCONFIG",conf); configTpl.write(params::inst().configFileAMD); printer::inst()->print_msg(L0, "AMD: GPU configuration stored in file '%s'", params::inst().configFileAMD.c_str()); - } + } - std::vector<GpuContext> devVec; + std::vector<GpuContext> devVec; }; } // namespace amd diff --git a/xmrstak/backend/amd/minethd.cpp b/xmrstak/backend/amd/minethd.cpp index de0b6e8..c1399e0 100644 --- a/xmrstak/backend/amd/minethd.cpp +++ b/xmrstak/backend/amd/minethd.cpp @@ -61,7 +61,7 @@ minethd::minethd(miner_work& pWork, size_t iNo, GpuContext* ctx, const jconf::th std::unique_lock<std::mutex> lck(thd_aff_set); std::future<void> order_guard = order_fix.get_future(); - + oWorkThd = std::thread(&minethd::work_main, this); order_guard.wait(); @@ -126,7 +126,7 @@ std::vector<iBackend*>* minethd::thread_starter(uint32_t threadOffset, miner_wor printer::inst()->print_msg(L1, "WARNING: AMD device not found"); return pvThreads; } - + size_t i, n = jconf::inst()->GetThreadCount(); pvThreads->reserve(n); @@ -172,7 +172,7 @@ void minethd::consume_work() memcpy(&oWork, &globalStates::inst().oGlobalWork, sizeof(miner_work)); iJobNo++; globalStates::inst().iConsumeCnt++; - + } void minethd::work_main() @@ -184,20 +184,21 @@ void minethd::work_main() std::unique_lock<std::mutex> lck(thd_aff_set); lck.release(); std::this_thread::yield(); - + uint64_t iCount = 0; cryptonight_ctx* cpu_ctx; cpu_ctx = cpu::minethd::minethd_alloc_ctx(); cn_hash_fun hash_fun = cpu::minethd::func_selector(::jconf::inst()->HaveHardwareAes(), true /*bNoPrefetch*/, ::jconf::inst()->IsCurrencyMonero()); globalStates::inst().iConsumeCnt++; - + while (bQuit == 0) { if (oWork.bStall) { - /* We are stalled here because the executor didn't find a job for us yet, - either because of network latency, or a socket problem. Since we are - raison d'etre of this software it us sensible to just wait until we have something*/ + /* We are stalled here because the executor didn't find a job for us yet, + * either because of network latency, or a socket problem. Since we are + * raison d'etre of this software it us sensible to just wait until we have something + */ while (globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) std::this_thread::sleep_for(std::chrono::milliseconds(100)); diff --git a/xmrstak/backend/amd/minethd.hpp b/xmrstak/backend/amd/minethd.hpp index c808192..29ddb74 100644 --- a/xmrstak/backend/amd/minethd.hpp +++ b/xmrstak/backend/amd/minethd.hpp @@ -26,9 +26,9 @@ public: private: typedef void (*cn_hash_fun)(const void*, size_t, void*, cryptonight_ctx*); - + minethd(miner_work& pWork, size_t iNo, GpuContext* ctx, const jconf::thd_cfg cfg); - + void work_main(); void consume_work(); diff --git a/xmrstak/backend/backendConnector.cpp b/xmrstak/backend/backendConnector.cpp index 28ba1ac..d735cb3 100644 --- a/xmrstak/backend/backendConnector.cpp +++ b/xmrstak/backend/backendConnector.cpp @@ -57,7 +57,7 @@ bool BackendConnector::self_test() std::vector<iBackend*>* BackendConnector::thread_starter(miner_work& pWork) { - globalStates::inst().iGlobalJobNo = 0; + globalStates::inst().iGlobalJobNo = 0; globalStates::inst().iConsumeCnt = 0; @@ -94,7 +94,7 @@ std::vector<iBackend*>* BackendConnector::thread_starter(miner_work& pWork) printer::inst()->print_msg(L0, "WARNING: backend CPU disabled."); } #endif - + globalStates::inst().iThreadCount = pvThreads->size(); return pvThreads; } diff --git a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp index c73dbd8..8b2207d 100644 --- a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp +++ b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp @@ -186,7 +186,7 @@ size_t cryptonight_init(size_t use_fast_mem, size_t use_mlock, alloc_msg* msg) return 0; } - + bRebootDesirable = TRUE; return 1; #else diff --git a/xmrstak/backend/cpu/crypto/soft_aes.hpp b/xmrstak/backend/cpu/crypto/soft_aes.hpp index d36f1fb..d3f4637 100644 --- a/xmrstak/backend/cpu/crypto/soft_aes.hpp +++ b/xmrstak/backend/cpu/crypto/soft_aes.hpp @@ -35,43 +35,43 @@ #include <inttypes.h> #define saes_data(w) {\ - w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\ - w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\ - w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\ - w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\ - w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\ - w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\ - w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\ - w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\ - w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\ - w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\ - w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\ - w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\ - w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\ - w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\ - w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\ - w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\ - w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\ - w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\ - w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\ - w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\ - w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\ - w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\ - w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\ - w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\ - w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\ - w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\ - w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\ - w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\ - w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\ - w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\ - w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\ - w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) } + w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\ + w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\ + w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\ + w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\ + w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\ + w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\ + w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\ + w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\ + w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\ + w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\ + w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\ + w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\ + w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\ + w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\ + w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\ + w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\ + w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\ + w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\ + w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\ + w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\ + w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\ + w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\ + w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\ + w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\ + w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\ + w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\ + w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\ + w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\ + w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\ + w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\ + w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\ + w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) } #define SAES_WPOLY 0x011b #define saes_b2w(b0, b1, b2, b3) (((uint32_t)(b3) << 24) | \ - ((uint32_t)(b2) << 16) | ((uint32_t)(b1) << 8) | (b0)) + ((uint32_t)(b2) << 16) | ((uint32_t)(b1) << 8) | (b0)) #define saes_f2(x) ((x<<1) ^ (((x>>7) & 1) * SAES_WPOLY)) #define saes_f3(x) (saes_f2(x) ^ x) diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index 03071c4..cbb01f9 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -234,7 +234,7 @@ bool minethd::self_test() if(!bResult) printer::inst()->print_msg(L0, - "Cryptonight hash self-test failed. This might be caused by bad compiler optimizations."); + "Cryptonight hash self-test failed. This might be caused by bad compiler optimizations."); return bResult; } @@ -254,7 +254,7 @@ std::vector<iBackend*> minethd::thread_starter(uint32_t threadOffset, miner_work { win_exit(); } - + //Launch the requested number of single and double threads, to distribute //load evenly we need to alternate single and double threads @@ -280,7 +280,7 @@ std::vector<iBackend*> minethd::thread_starter(uint32_t threadOffset, miner_work minethd* thd = new minethd(pWork, i + threadOffset, cfg.bDoubleMode, cfg.bNoPrefetch, cfg.iCpuAff); pvThreads.push_back(thd); } - + return pvThreads; } @@ -359,14 +359,15 @@ void minethd::work_main() piNonce = (uint32_t*)(oWork.bWorkBlob + 39); globalStates::inst().inst().iConsumeCnt++; result.iThreadId = iThreadNo; - + while (bQuit == 0) { if (oWork.bStall) { - /* We are stalled here because the executor didn't find a job for us yet, - either because of network latency, or a socket problem. Since we are - raison d'etre of this software it us sensible to just wait until we have something*/ + /* We are stalled here because the executor didn't find a job for us yet, + * either because of network latency, or a socket problem. Since we are + * raison d'etre of this software it us sensible to just wait until we have something + */ while (globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) std::this_thread::sleep_for(std::chrono::milliseconds(100)); diff --git a/xmrstak/backend/globalStates.hpp b/xmrstak/backend/globalStates.hpp index 9fdda2a..442be69 100644 --- a/xmrstak/backend/globalStates.hpp +++ b/xmrstak/backend/globalStates.hpp @@ -15,7 +15,7 @@ struct pool_data { uint32_t iSavedNonce; size_t pool_id; - + pool_data() : iSavedNonce(0), pool_id(invalid_pool_id) { } diff --git a/xmrstak/backend/nvidia/autoAdjust.hpp b/xmrstak/backend/nvidia/autoAdjust.hpp index d36a46a..c6a7dca 100644 --- a/xmrstak/backend/nvidia/autoAdjust.hpp +++ b/xmrstak/backend/nvidia/autoAdjust.hpp @@ -24,58 +24,57 @@ class autoAdjust { public: - autoAdjust() - { - - } - - /** print the adjusted values if needed - * - * Routine exit the application and print the adjusted values if needed else - * nothing is happened. - */ - bool printConfig() - { + autoAdjust() + { + + } + + /** print the adjusted values if needed + * + * Routine exit the application and print the adjusted values if needed else + * nothing is happened. + */ + bool printConfig() + { int deviceCount = 0; - if(cuda_get_devicecount(&deviceCount) == 0) - return false; - // evaluate config parameter for if auto adjustment is needed - // evaluate config parameter for if auto adjustment is needed - for(int i = 0; i < deviceCount; i++) - { - - nvid_ctx ctx; - - ctx.device_id = i; - // -1 trigger auto adjustment - ctx.device_blocks = -1; - ctx.device_threads = -1; - - // set all evice option those marked as auto (-1) to a valid value + if(cuda_get_devicecount(&deviceCount) == 0) + return false; + // evaluate config parameter for if auto adjustment is needed + for(int i = 0; i < deviceCount; i++) + { + + nvid_ctx ctx; + + ctx.device_id = i; + // -1 trigger auto adjustment + ctx.device_blocks = -1; + ctx.device_threads = -1; + + // set all evice option those marked as auto (-1) to a valid value #ifndef _WIN32 - ctx.device_bfactor = 0; - ctx.device_bsleep = 0; + ctx.device_bfactor = 0; + ctx.device_bsleep = 0; #else - // windows pass, try to avoid that windows kills the miner if the gpu is blocked for 2 seconds - ctx.device_bfactor = 6; - ctx.device_bsleep = 25; + // windows pass, try to avoid that windows kills the miner if the gpu is blocked for 2 seconds + ctx.device_bfactor = 6; + ctx.device_bsleep = 25; #endif - if(cuda_get_deviceinfo(&ctx) == 0) - nvidCtxVec.push_back(ctx); - else - printer::inst()->print_msg(L0, "WARNING: NVIDIA setup failed for GPU %d.\n", i); + if(cuda_get_deviceinfo(&ctx) == 0) + nvidCtxVec.push_back(ctx); + else + printer::inst()->print_msg(L0, "WARNING: NVIDIA setup failed for GPU %d.\n", i); - } + } - generateThreadConfig(); - return true; + generateThreadConfig(); + return true; - } + } private: - - void generateThreadConfig() - { + + void generateThreadConfig() + { // load the template of the backend config into a char variable const char *tpl = #include "./config.tpl" @@ -86,8 +85,8 @@ private: constexpr size_t byte2mib = 1024u * 1024u; std::string conf; - for(auto& ctx : nvidCtxVec) - { + for(auto& ctx : nvidCtxVec) + { if(ctx.device_threads * ctx.device_blocks > 0) { conf += std::string(" // gpu: ") + ctx.name + " architecture: " + std::to_string(ctx.device_arch[0] * 10 + ctx.device_arch[1]) + "\n"; @@ -99,14 +98,14 @@ private: " \"affine_to_cpu\" : false,\n" + " },\n"; } - } + } configTpl.replace("GPUCONFIG",conf); configTpl.write(params::inst().configFileNVIDIA); printer::inst()->print_msg(L0, "NVIDIA: GPU configuration stored in file '%s'", params::inst().configFileNVIDIA.c_str()); - } + } - std::vector<nvid_ctx> nvidCtxVec; + std::vector<nvid_ctx> nvidCtxVec; }; } // namespace nvidia diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp index 9dbd83e..9eab1c0 100644 --- a/xmrstak/backend/nvidia/minethd.cpp +++ b/xmrstak/backend/nvidia/minethd.cpp @@ -59,11 +59,11 @@ namespace nvidia { #ifdef WIN32 - HINSTANCE lib_handle; + HINSTANCE lib_handle; #else - void *lib_handle; + void *lib_handle; #endif - + minethd::minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg) { this->backendType = iBackend::NVIDIA; @@ -81,7 +81,7 @@ minethd::minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg) std::unique_lock<std::mutex> lck(thd_aff_set); std::future<void> order_guard = order_fix.get_future(); - + oWorkThd = std::thread(&minethd::work_main, this); order_guard.wait(); @@ -113,7 +113,7 @@ bool minethd::self_test() //if(!bResult) // printer::inst()->print_msg(L0, - // "Cryptonight hash self-test failed. This might be caused by bad compiler optimizations."); + // "Cryptonight hash self-test failed. This might be caused by bad compiler optimizations."); return bResult; } @@ -211,7 +211,7 @@ void minethd::work_main() std::unique_lock<std::mutex> lck(thd_aff_set); lck.release(); std::this_thread::yield(); - + uint64_t iCount = 0; cryptonight_ctx* cpu_ctx; cpu_ctx = cpu::minethd::minethd_alloc_ctx(); @@ -227,14 +227,15 @@ void minethd::work_main() } bool mineMonero = strcmp_i(::jconf::inst()->GetCurrency(), "monero"); - + while (bQuit == 0) { if (oWork.bStall) { - /* We are stalled here because the executor didn't find a job for us yet, - either because of network latency, or a socket problem. Since we are - raison d'etre of this software it us sensible to just wait until we have something*/ + /* We are stalled here because the executor didn't find a job for us yet, + * either because of network latency, or a socket problem. Since we are + * raison d'etre of this software it us sensible to just wait until we have something + */ while (globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) std::this_thread::sleep_for(std::chrono::milliseconds(100)); diff --git a/xmrstak/backend/nvidia/minethd.hpp b/xmrstak/backend/nvidia/minethd.hpp index ffcdab1..d13c868 100644 --- a/xmrstak/backend/nvidia/minethd.hpp +++ b/xmrstak/backend/nvidia/minethd.hpp @@ -30,7 +30,7 @@ public: private: typedef void (*cn_hash_fun)(const void*, size_t, void*, cryptonight_ctx*); - + minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg); void work_main(); diff --git a/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp b/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp index 0cfdaac..1b63379 100644 --- a/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp +++ b/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp @@ -12,7 +12,7 @@ typedef struct { int device_threads; int device_bfactor; int device_bsleep; - + uint32_t *d_input; uint32_t inputlen; uint32_t *d_result_count; diff --git a/xmrstak/backend/plugin.hpp b/xmrstak/backend/plugin.hpp index b08ab89..89cdf97 100644 --- a/xmrstak/backend/plugin.hpp +++ b/xmrstak/backend/plugin.hpp @@ -95,16 +95,16 @@ struct plugin starterBackend_t fn_starterBackend; #ifdef WIN32 - HINSTANCE libBackend; + HINSTANCE libBackend; #else - void *libBackend; + void *libBackend; #endif /* \todo add unload to destructor and change usage of plugin that libs keeped open until the miner endss #ifdef WIN32 - FreeLibrary(libBackend); + FreeLibrary(libBackend); #else - dlclose(libBackend); + dlclose(libBackend); #endif * */ }; diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index f0f3c3a..90da834 100644 --- a/xmrstak/cli/cli-miner.cpp +++ b/xmrstak/cli/cli-miner.cpp @@ -59,7 +59,7 @@ void help() { using namespace std; using namespace xmrstak; - + cout<<"Usage: "<<params::inst().binaryName<<" [OPTION]..."<<endl; cout<<" "<<endl; cout<<" -h, --help show this help"<<endl; @@ -113,7 +113,7 @@ inline const char* bool_to_str(bool v) std::string get_multipool_entry(bool& final) { std::cout<<std::endl<<"- Next Pool:"<<std::endl<<std::endl; - + std::string pool; if(xmrstak::params::inst().currency == "monero") std::cout<<"- Pool address: e.g. pool.usxmrpool.com:3333"<<std::endl; @@ -147,7 +147,7 @@ std::string get_multipool_entry(bool& final) } final = !read_yes_no("- Do you want to add another pool? (y/n)"); - + return "\t{\"pool_address\" : \"" + pool +"\", \"wallet_address\" : \"" + userName + "\", \"pool_password\" : \"" + passwd + "\", \"use_nicehash\" : " + bool_to_str(nicehash) + ", \"use_tls\" : " + bool_to_str(tls) + ", \"tls_fingerprint\" : \"\", \"pool_weight\" : " + std::to_string(pool_weight) + " },\n"; @@ -217,13 +217,13 @@ void do_guided_config(bool userSetPasswd) bool tls = read_yes_no("- Does this pool port support TLS/SSL? Use no if unknown. (y/N)"); #endif bool nicehash = read_yes_no("- Do you want to use nicehash on this pool? (y/n)"); - + bool multipool; if(!userSetPool) multipool = read_yes_no("- Do you want to use multiple pools? (y/n)"); else multipool = false; - + int64_t pool_weight; if(multipool) { @@ -238,10 +238,10 @@ void do_guided_config(bool userSetPasswd) std::cin.ignore(INT_MAX, '\n'); std::cout << "Invalid weight. Try 1, 10, 100, etc:" << std::endl; } - } - else + } + else pool_weight = 1; - + std::string pool_table; pool_table += "\t{\"pool_address\" : \"" + pool +"\", \"wallet_address\" : \"" + userName + "\", \"pool_password\" : \"" + passwd + "\", \"use_nicehash\" : " + bool_to_str(nicehash) + ", \"use_tls\" : " + bool_to_str(tls) + @@ -256,7 +256,7 @@ void do_guided_config(bool userSetPasswd) } while(!final); } - + configTpl.replace("POOLCONF", pool_table); configTpl.replace("CURRENCY", currency); configTpl.write(params::inst().configFile); diff --git a/xmrstak/http/httpd.cpp b/xmrstak/http/httpd.cpp index 8debfa7..dba7d7c 100644 --- a/xmrstak/http/httpd.cpp +++ b/xmrstak/http/httpd.cpp @@ -49,13 +49,13 @@ httpd::httpd() } int httpd::req_handler(void * cls, - MHD_Connection* connection, - const char* url, - const char* method, - const char* version, - const char* upload_data, - size_t* upload_data_size, - void ** ptr) + MHD_Connection* connection, + const char* url, + const char* method, + const char* version, + const char* upload_data, + size_t* upload_data_size, + void ** ptr) { struct MHD_Response * rsp; @@ -86,7 +86,7 @@ int httpd::req_handler(void * cls, return ret; } } - + *ptr = nullptr; std::string str; if(strcasecmp(url, "/style.css") == 0) diff --git a/xmrstak/http/httpd.hpp b/xmrstak/http/httpd.hpp index 3836968..fe534f0 100644 --- a/xmrstak/http/httpd.hpp +++ b/xmrstak/http/httpd.hpp @@ -21,13 +21,13 @@ private: static httpd* oInst; static int req_handler(void * cls, - MHD_Connection* connection, - const char* url, - const char* method, - const char* version, - const char* upload_data, - size_t* upload_data_size, - void ** ptr); + MHD_Connection* connection, + const char* url, + const char* method, + const char* version, + const char* upload_data, + size_t* upload_data_size, + void ** ptr); MHD_Daemon *d; }; diff --git a/xmrstak/http/webdesign.cpp b/xmrstak/http/webdesign.cpp index 963c080..c31d6c6 100644 --- a/xmrstak/http/webdesign.cpp +++ b/xmrstak/http/webdesign.cpp @@ -106,7 +106,7 @@ extern const char sHtmlCssFile [] = "padding: 0.5em 0em;" "font-weight: bold;" "}" - + ".motd-body {" "overflow: hidden;" "}"; diff --git a/xmrstak/jconf.cpp b/xmrstak/jconf.cpp index a617f96..462f564 100644 --- a/xmrstak/jconf.cpp +++ b/xmrstak/jconf.cpp @@ -148,7 +148,7 @@ bool jconf::GetPoolConfig(size_t id, pool_cfg& cfg) cfg.tls = jtls->GetBool(); cfg.tls_fingerprint = jtlsfp->GetString(); cfg.raw_weight = jwt->GetUint64(); - + size_t dlt = wt_max - wt_min; if(dlt != 0) { @@ -412,13 +412,13 @@ bool jconf::parse_config(const char* sFilename) printer::inst()->print_msg(L0, "Invalid config file. pool_list must not be empty."); return false; } - + std::vector<size_t> pool_weights; pool_weights.reserve(pool_cnt); - + const char* aPoolValues[] = { "pool_address", "wallet_address", "pool_password", "use_nicehash", "use_tls", "tls_fingerprint", "pool_weight" }; Type poolValTypes[] = { kStringType, kStringType, kStringType, kTrueType, kTrueType, kStringType, kNumberType }; - + constexpr size_t pvcnt = sizeof(aPoolValues)/sizeof(aPoolValues[0]); for(uint32_t i=0; i < pool_cnt; i++) { diff --git a/xmrstak/jconf.hpp b/xmrstak/jconf.hpp index 131263e..df1bf79 100644 --- a/xmrstak/jconf.hpp +++ b/xmrstak/jconf.hpp @@ -19,7 +19,7 @@ public: }; bool parse_config(const char* sFilename = xmrstak::params::inst().configFile.c_str()); - + struct pool_cfg { const char* sPoolAddr; const char* sWalletAddr; @@ -30,10 +30,10 @@ public: size_t raw_weight; double weight; }; - + size_t wt_max; size_t wt_min; - + uint64_t GetPoolCount(); bool GetPoolConfig(size_t id, pool_cfg& cfg); @@ -46,7 +46,7 @@ public: }; bool TlsSecureAlgos(); - + const std::string GetCurrency(); bool IsCurrencyMonero(); diff --git a/xmrstak/misc/configEditor.hpp b/xmrstak/misc/configEditor.hpp index 3960384..a840bc4 100644 --- a/xmrstak/misc/configEditor.hpp +++ b/xmrstak/misc/configEditor.hpp @@ -16,7 +16,7 @@ struct configEditor configEditor() { - + } static bool file_exist( const std::string filename) @@ -35,7 +35,7 @@ struct configEditor std::ifstream fstream(filename); m_fileContent = std::string( (std::istreambuf_iterator<char>(fstream)), - std::istreambuf_iterator<char>() + std::istreambuf_iterator<char>() ); return fstream.good(); } @@ -51,7 +51,7 @@ struct configEditor { m_fileContent = std::regex_replace(m_fileContent, std::regex(search), substring); } - + }; } // namepsace xmrstak diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp index 43e3d6b..dea1dab 100644 --- a/xmrstak/misc/executor.cpp +++ b/xmrstak/misc/executor.cpp @@ -267,7 +267,7 @@ void executor::log_socket_error(jpsock* pool, std::string&& sError) pool_name.reserve(128); pool_name.append("[").append(pool->get_pool_addr()).append("] "); sError.insert(0, pool_name); - + vSocketLog.emplace_back(std::move(sError)); printer::inst()->print_msg(L1, "SOCKET ERROR - %s", vSocketLog.back().msg.c_str()); @@ -321,7 +321,7 @@ jpsock* executor::pick_pool_by_id(size_t pool_id) void executor::on_sock_ready(size_t pool_id) { jpsock* pool = pick_pool_by_id(pool_id); - + if(pool->is_dev_pool()) printer::inst()->print_msg(L1, "Dev pool connected. Logging in..."); else @@ -342,7 +342,7 @@ void executor::on_sock_error(size_t pool_id, std::string&& sError, bool silent) jpsock* pool = pick_pool_by_id(pool_id); pool->disconnect(); - + if(pool_id == current_pool_id) current_pool_id = invalid_pool_id; @@ -505,7 +505,7 @@ void executor::ex_main() if(!cfg.tls) tls = false; pools.emplace_back(i+1, cfg.sPoolAddr, cfg.sWalletAddr, cfg.sPasswd, cfg.weight, false, cfg.tls, cfg.tls_fingerprint, cfg.nicehash); } - + if(jconf::inst()->IsCurrencyMonero()) { if(tls) @@ -753,7 +753,7 @@ void executor::hashrate_report(std::string& out) if((i & 0x1) == 1) //We had odd number of threads out.append("|\n"); - + if(nthd != 1) out.append("-----------------------------------------------------\n"); else diff --git a/xmrstak/misc/executor.hpp b/xmrstak/misc/executor.hpp index c90e864..c2caa39 100644 --- a/xmrstak/misc/executor.hpp +++ b/xmrstak/misc/executor.hpp @@ -53,7 +53,7 @@ private: }; inline void set_timestamp() { dev_timestamp = get_timestamp(); }; - + // In miliseconds, has to divide a second (1000ms) into an integer number constexpr static size_t iTickTime = 500; @@ -97,7 +97,7 @@ private: constexpr static size_t motd_max_length = 512; bool motd_filter_console(std::string& motd); bool motd_filter_web(std::string& motd); - + void hashrate_report(std::string& out); void result_report(std::string& out); void connection_report(std::string& out); diff --git a/xmrstak/misc/thdq.hpp b/xmrstak/misc/thdq.hpp index 248c807..7a4a5cf 100644 --- a/xmrstak/misc/thdq.hpp +++ b/xmrstak/misc/thdq.hpp @@ -1,10 +1,10 @@ #pragma once
-
+ #include <queue>
#include <thread>
#include <mutex>
#include <condition_variable>
-
+ template <typename T>
class thdq
{
@@ -17,7 +17,7 @@ public: queue_.pop();
return item;
}
-
+ void pop(T& item)
{
std::unique_lock<std::mutex> mlock(mutex_);
@@ -25,7 +25,7 @@ public: item = queue_.front();
queue_.pop();
}
-
+ void push(const T& item)
{
std::unique_lock<std::mutex> mlock(mutex_);
@@ -33,7 +33,7 @@ public: mlock.unlock();
cond_.notify_one();
}
-
+ void push(T&& item)
{
std::unique_lock<std::mutex> mlock(mutex_);
@@ -41,7 +41,7 @@ public: mlock.unlock();
cond_.notify_one();
}
-
+ private:
std::queue<T> queue_;
std::mutex mutex_;
diff --git a/xmrstak/net/jpsock.cpp b/xmrstak/net/jpsock.cpp index 5769448..36c901e 100644 --- a/xmrstak/net/jpsock.cpp +++ b/xmrstak/net/jpsock.cpp @@ -93,8 +93,8 @@ struct jpsock::opq_json_val }; jpsock::jpsock(size_t id, const char* sAddr, const char* sLogin, const char* sPassword, double pool_weight, bool dev_pool, bool tls, const char* tls_fp, bool nicehash) : - net_addr(sAddr), usr_login(sLogin), usr_pass(sPassword), tls_fp(tls_fp), pool_id(id), pool_weight(pool_weight), pool(dev_pool), nicehash(nicehash), - connect_time(0), connect_attempts(0), disconnect_time(0), quiet_close(false) + net_addr(sAddr), usr_login(sLogin), usr_pass(sPassword), tls_fp(tls_fp), pool_id(id), pool_weight(pool_weight), pool(dev_pool), nicehash(nicehash), + connect_time(0), connect_attempts(0), disconnect_time(0), quiet_close(false) { sock_init(); @@ -443,7 +443,7 @@ bool jpsock::connect(std::string& sConnectError) sSocketError.clear(); iJobDiff = 0; connect_attempts++; - + if(sck->set_hostname(net_addr.c_str())) { bRunning = true; @@ -607,13 +607,13 @@ bool jpsock::cmd_submit(const char* sJobId, uint32_t iNonce, const uint8_t* bRes if(ext_backend) snprintf(sBackend, sizeof(sBackend), ",\"backend\":\"%s\"", xmrstak::iBackend::getName(bend->backendType)); - + if(ext_hashcount) snprintf(sHashcount, sizeof(sHashcount), ",\"hashcount\":%llu", int_port(bend->iHashCount.load(std::memory_order_relaxed))); if(ext_algo) snprintf(sAlgo, sizeof(sAlgo), ",\"algo\":\"%s\"", algo_full_cn ? "cryptonight" : "cryptonight-lite"); - + bin2hex((unsigned char*)&iNonce, 4, sNonce); sNonce[8] = '\0'; @@ -648,7 +648,7 @@ bool jpsock::get_pool_motd(std::string& strin) { if(!ext_motd) return false; - + std::unique_lock<std::mutex>(motd_mutex); if(pool_motd.size() > 0) { diff --git a/xmrstak/net/msgstruct.hpp b/xmrstak/net/msgstruct.hpp index 9065fe3..a15f806 100644 --- a/xmrstak/net/msgstruct.hpp +++ b/xmrstak/net/msgstruct.hpp @@ -170,6 +170,6 @@ struct ex_event //Get steady_clock timestamp - misc helper function inline size_t get_timestamp() { - using namespace std::chrono; - return time_point_cast<seconds>(steady_clock::now()).time_since_epoch().count(); + using namespace std::chrono; + return time_point_cast<seconds>(steady_clock::now()).time_since_epoch().count(); }; diff --git a/xmrstak/params.hpp b/xmrstak/params.hpp index 1551378..2aedc38 100644 --- a/xmrstak/params.hpp +++ b/xmrstak/params.hpp @@ -46,7 +46,7 @@ struct params configFileCPU("cpu.txt"), configFileNVIDIA("nvidia.txt") {} - + }; } // namepsace xmrstak |