diff options
Diffstat (limited to 'xmrstak/backend')
-rw-r--r-- | xmrstak/backend/amd/amd_gpu/gpu.cpp | 68 | ||||
-rw-r--r-- | xmrstak/backend/amd/autoAdjust.hpp | 54 | ||||
-rw-r--r-- | xmrstak/backend/amd/minethd.cpp | 17 | ||||
-rw-r--r-- | xmrstak/backend/amd/minethd.hpp | 4 | ||||
-rw-r--r-- | xmrstak/backend/backendConnector.cpp | 4 | ||||
-rw-r--r-- | xmrstak/backend/cpu/crypto/cryptonight_common.cpp | 2 | ||||
-rw-r--r-- | xmrstak/backend/cpu/crypto/soft_aes.hpp | 66 | ||||
-rw-r--r-- | xmrstak/backend/cpu/minethd.cpp | 15 | ||||
-rw-r--r-- | xmrstak/backend/globalStates.hpp | 2 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/autoAdjust.hpp | 95 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/minethd.cpp | 21 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/minethd.hpp | 2 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp | 2 | ||||
-rw-r--r-- | xmrstak/backend/plugin.hpp | 8 |
14 files changed, 181 insertions, 179 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 * */ }; |