diff options
author | fireice-uk <fireice-uk@users.noreply.github.com> | 2018-04-02 21:14:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-02 21:14:14 +0100 |
commit | 6feffe2228282814abe716d241292ca2648a4e2a (patch) | |
tree | 277cc583c0f5df77e781dec0ba5019daf08e75d0 /xmrstak/backend/amd/amd_gpu/gpu.cpp | |
parent | a036cd81592e3b3de804ba88bb8f94729ab60b7d (diff) | |
parent | 6880be70a6b29a1c850f4a4603bbc38d0ca6d117 (diff) | |
download | xmr-stak-6feffe2228282814abe716d241292ca2648a4e2a.zip xmr-stak-6feffe2228282814abe716d241292ca2648a4e2a.tar.gz |
Merge pull request #1279 from fireice-uk/dev
release 2.4.0
Diffstat (limited to 'xmrstak/backend/amd/amd_gpu/gpu.cpp')
-rw-r--r-- | xmrstak/backend/amd/amd_gpu/gpu.cpp | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/xmrstak/backend/amd/amd_gpu/gpu.cpp b/xmrstak/backend/amd/amd_gpu/gpu.cpp index 8d0fd32..2973db4 100644 --- a/xmrstak/backend/amd/amd_gpu/gpu.cpp +++ b/xmrstak/backend/amd/amd_gpu/gpu.cpp @@ -16,6 +16,7 @@ #include "xmrstak/backend/cryptonight.hpp" #include "xmrstak/jconf.hpp" #include "xmrstak/picosha2/picosha2.hpp" +#include "xmrstak/params.hpp" #include <stdio.h> #include <string.h> @@ -393,9 +394,10 @@ size_t InitOpenCLGpu(cl_context opencl_ctx, GpuContext* ctx, const char* source_ std::string cache_file = get_home() + "/.openclcache/" + hash_hex_str + ".openclbin"; std::ifstream clBinFile(cache_file, std::ofstream::in | std::ofstream::binary); - if(!clBinFile.good()) + if(xmrstak::params::inst().AMDCache == false || !clBinFile.good()) { - printer::inst()->print_msg(L1,"OpenCL device %u - Precompiled code %s not found. Compiling ...",ctx->deviceIdx, cache_file.c_str()); + if(xmrstak::params::inst().AMDCache) + printer::inst()->print_msg(L1,"OpenCL device %u - Precompiled code %s not found. Compiling ...",ctx->deviceIdx, cache_file.c_str()); ctx->Program = clCreateProgramWithSource(opencl_ctx, 1, (const char**)&source_code, NULL, &ret); if(ret != CL_SUCCESS) { @@ -467,29 +469,31 @@ size_t InitOpenCLGpu(cl_context opencl_ctx, GpuContext* ctx, const char* source_ std::vector<char*> all_programs(num_devices); std::vector<std::vector<char>> program_storage; - int p_id = 0; - size_t mem_size = 0; - // create memory structure to query all OpenCL program binaries - for(auto & p : all_programs) + if(xmrstak::params::inst().AMDCache) { - program_storage.emplace_back(std::vector<char>(binary_sizes[p_id])); - all_programs[p_id] = program_storage[p_id].data(); - mem_size += binary_sizes[p_id]; - p_id++; - } + int p_id = 0; + size_t mem_size = 0; + // create memory structure to query all OpenCL program binaries + for(auto & p : all_programs) + { + program_storage.emplace_back(std::vector<char>(binary_sizes[p_id])); + all_programs[p_id] = program_storage[p_id].data(); + mem_size += binary_sizes[p_id]; + p_id++; + } - if( ret = clGetProgramInfo(ctx->Program, CL_PROGRAM_BINARIES, num_devices * sizeof(char*), all_programs.data(),NULL) != CL_SUCCESS) - { - printer::inst()->print_msg(L1,"Error %s when calling clGetProgramInfo.", err_to_str(ret)); - return ERR_OCL_API; - } + if((ret = clGetProgramInfo(ctx->Program, CL_PROGRAM_BINARIES, num_devices * sizeof(char*), all_programs.data(),NULL)) != CL_SUCCESS) + { + printer::inst()->print_msg(L1,"Error %s when calling clGetProgramInfo.", err_to_str(ret)); + return ERR_OCL_API; + } - std::ofstream file_stream; - std::cout<<get_home() + "/.openclcache/" + hash_hex_str + ".openclbin"<<std::endl; - file_stream.open(cache_file, std::ofstream::out | std::ofstream::binary); - file_stream.write(all_programs[dev_id], binary_sizes[dev_id]); - file_stream.close(); - printer::inst()->print_msg(L1, "OpenCL device %u - Precompiled code stored in file %s",ctx->deviceIdx, cache_file.c_str()); + std::ofstream file_stream; + file_stream.open(cache_file, std::ofstream::out | std::ofstream::binary); + file_stream.write(all_programs[dev_id], binary_sizes[dev_id]); + file_stream.close(); + printer::inst()->print_msg(L1, "OpenCL device %u - Precompiled code stored in file %s",ctx->deviceIdx, cache_file.c_str()); + } } else { @@ -936,7 +940,7 @@ size_t XMRSetJob(GpuContext* ctx, uint8_t* input, size_t input_len, uint64_t tar /// @todo only activate if currency is monero int cn_kernel_offset = 0; - if(miner_algo == cryptonight_monero && version >= 7) + if(miner_algo == cryptonight_monero || miner_algo == cryptonight_aeon) { cn_kernel_offset = 6; } @@ -962,7 +966,7 @@ size_t XMRSetJob(GpuContext* ctx, uint8_t* input, size_t input_len, uint64_t tar return(ERR_OCL_API); } - if(miner_algo == cryptonight_monero && version >= 7) + if(miner_algo == cryptonight_monero || miner_algo == cryptonight_aeon ) { // Input if ((ret = clSetKernelArg(ctx->Kernels[1 + cn_kernel_offset], 3, sizeof(cl_mem), &ctx->InputBuffer)) != CL_SUCCESS) @@ -1130,7 +1134,7 @@ size_t XMRRunJob(GpuContext* ctx, cl_uint* HashOutput, xmrstak_algo miner_algo, size_t tmpNonce = ctx->Nonce; /// @todo only activate if currency is monero int cn_kernel_offset = 0; - if(miner_algo == cryptonight_monero && version >= 7) + if(miner_algo == cryptonight_monero || miner_algo == cryptonight_aeon) { cn_kernel_offset = 6; } |