diff options
author | fireice-uk <fireice-uk@users.noreply.github.com> | 2017-11-16 15:25:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-16 15:25:08 +0000 |
commit | 036ffa887272b0c27197f78a6082b903ace1a344 (patch) | |
tree | 2b5dc47b60d3b1d001a0bf4830b7bf47d253190c /xmrstak/backend/amd | |
parent | 1dc874c542a23c36dd65ea0f5b9cb65e3c3a572a (diff) | |
parent | cabd46f39fdadad7345f9603ccdcf1daf49e1a9c (diff) | |
download | xmr-stak-036ffa887272b0c27197f78a6082b903ace1a344.zip xmr-stak-036ffa887272b0c27197f78a6082b903ace1a344.tar.gz |
Merge pull request #126 from psychocrypt/topic-removeSpaceIndentionWithTabs
remove space indention with tabs
Diffstat (limited to 'xmrstak/backend/amd')
-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 |
4 files changed, 72 insertions, 71 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(); |