SysFS features, along with other algo support.

This commit is contained in:
Wolf authored and Kristy-Leigh Minehan committed 2016-12-04 00:20:43 +01:00
1 parent b0a887e5c5
commit 683865c5df
19 files changed
+3197 -1936

No files matched your search

+4 -2
View File
@@ -44,6 +44,7 @@ sgminer_SOURCES += driver-opencl.c driver-opencl.h
sgminer_SOURCES += ocl.c ocl.h
sgminer_SOURCES += findnonce.c findnonce.h
sgminer_SOURCES += adl.c adl.h adl_functions.h
sgminer_SOURCES += sysfs-gpu-controls.c sysfs-gpu-controls.h
sgminer_SOURCES += pool.c pool.h
sgminer_SOURCES += algorithm.c algorithm.h
sgminer_SOURCES += config_parser.c config_parser.h
@@ -76,11 +77,12 @@ sgminer_SOURCES += algorithm/lyra2re.c algorithm/lyra2re.h algorithm/lyra2.c alg
sgminer_SOURCES += algorithm/lyra2rev2.c algorithm/lyra2rev2.h
sgminer_SOURCES += algorithm/pluck.c algorithm/pluck.h
sgminer_SOURCES += algorithm/credits.c algorithm/credits.h
sgminer_SOURCES += algorithm/yescrypt.h algorithm/yescrypt.c algorithm/yescrypt_core.h algorithm/yescrypt-opt.c algorithm/yescryptcommon.c algorithm/sysendian.h
sgminer_SOURCES += algorithm/yescrypt.h algorithm/yescrypt.c algorithm/yescrypt_core.h algorithm/yescrypt-opt.c algorithm/yescryptcommon.c algorithm/sysendian.h
sgminer_SOURCES += algorithm/blake256.c algorithm/blake256.h
sgminer_SOURCES += algorithm/blakecoin.c algorithm/blakecoin.h
sgminer_SOURCES += algorithm/ethash.c algorithm/ethgencache.c algorithm/ethash.h algorithm/eth-sha3.c algorithm/eth-sha3.h
sgminer_SOURCES += algorithm/cryptonight.c algorithm/cryptonight.h algorithm/cn-aes-tbls.h
sgminer_SOURCES += algorithm/equihash.c algorithm/equihash.h
sgminer_SOURCES += gbt-util.c gbt-util.h
bin_SCRIPTS = $(top_srcdir)/kernel/*.cl
+785 -768
View File
File diff suppressed because it is too large. Load diff
+11 -10
View File
@@ -7,19 +7,20 @@ extern bool opt_reorder;
extern int opt_hysteresis;
extern int opt_targettemp;
extern int opt_overheattemp;
void init_adl(int nDevs);
float gpu_temp(int gpu);
int gpu_engineclock(int gpu);
int gpu_memclock(int gpu);
float gpu_vddc(int gpu);
int gpu_activity(int gpu);
int gpu_fanspeed(int gpu);
int gpu_fanpercent(int gpu);
extern int set_powertune(int gpu, int iPercentage);
bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc,
float adl_gpu_temp(int gpu);
int adl_gpu_engineclock(int gpu);
int adl_gpu_memclock(int gpu);
float adl_gpu_vddc(int gpu);
int adl_gpu_activity(int gpu);
int adl_gpu_fanspeed(int gpu);
int adl_gpu_fanpercent(int gpu);
extern int adl_set_powertune(int gpu, int iPercentage);
bool adl_gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc,
int *activity, int *fanspeed, int *fanpercent, int *powertune);
void change_gpusettings(int gpu);
void gpu_autotune(int gpu, enum dev_enable *denable);
void adl_gpu_autotune(int gpu, enum dev_enable *denable);
void clear_adl(int nDevs);
#else /* HAVE_ADL */
+127 -86
View File
@@ -40,7 +40,8 @@
#include "algorithm/blake256.h"
#include "algorithm/blakecoin.h"
#include "algorithm/ethash.h"
#include "algorithm/cryptonight.h"
#include "algorithm/equihash.h"
#include "kernel/equihash-param.h"
#include "compat.h"
@@ -74,7 +75,7 @@ const char *algorithm_type_str[] = {
"Blake",
"Vanilla",
"Ethash",
"cryptonight"
"Equihash"
};
void sha256(const unsigned char *message, unsigned int len, unsigned char *digest)
@@ -120,6 +121,13 @@ static void append_scrypt_compiler_options(struct _build_kernel_data *data, stru
extern uint32_t EthereumEpochNumber;
static void append_ethash_compiler_options(struct _build_kernel_data *data, struct cgpu_info *cgpu, struct _algorithm_t *algorithm)
{
//char buf[255];
//sprintf(buf, " -D DAG_SIZE=%lluUL ", EthGetDAGSize(EthereumEpochNumber) / 128);
//strcat(data->compiler_options, buf);
}
static void append_neoscrypt_compiler_options(struct _build_kernel_data *data, struct cgpu_info *cgpu, struct _algorithm_t *algorithm)
{
char buf[255];
@@ -967,9 +975,9 @@ static cl_int queue_ethash_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u
cl_uint HighNonce, Isolate = 0xFFFFFFFFUL;
cl_ulong DAGSize = EthGetDAGSize(blk->work->EpochNumber);
size_t DAGItems = (size_t) (DAGSize / 64);
le_target = *(cl_ulong *)(blk->work->device_target + 24);
// DO NOT flip80.
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 32, blk->work->data, 0, NULL, NULL);
if (clState->EpochNumber != blk->work->EpochNumber)
@@ -977,28 +985,28 @@ static cl_int queue_ethash_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u
clState->EpochNumber = blk->work->EpochNumber;
cl_ulong CacheSize = EthGetCacheSize(blk->work->EpochNumber);
cl_event DAGGenEvent;
applog(LOG_DEBUG, "DAG being regenerated.");
if (clState->EthCache)
clReleaseMemObject(clState->EthCache);
if (clState->DAG)
clReleaseMemObject(clState->DAG);
clState->DAG = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, DAGSize, NULL, &status);
clState->DAG = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, DAGSize, NULL, &status);
if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d: Creating the DAG buffer.", status);
return(status);
}
clState->EthCache = clCreateBuffer(clState->context, CL_MEM_READ_ONLY, CacheSize, NULL, &status);
int idx = blk->work->EpochNumber % 2;
cg_ilock(&EthCacheLock[idx]);
bool update = (EthCache[idx] == NULL || *(uint32_t*) EthCache[idx] != blk->work->EpochNumber);
if (update)
{
cg_ulock(&EthCacheLock[idx]);
cg_ulock(&EthCacheLock[idx]);
EthCache[idx] = realloc(EthCache[idx], sizeof(uint8_t) * CacheSize + 64);
*(uint32_t*) EthCache[idx] = blk->work->EpochNumber;
EthGenerateCache(EthCache[idx] + 64, blk->work->seedhash, CacheSize);
@@ -1013,47 +1021,47 @@ static cl_int queue_ethash_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u
cg_wunlock(&EthCacheLock[idx]);
else
cg_runlock(&EthCacheLock[idx]);
if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d: Creating the cache buffer and/or writing to it.", status);
return(status);
}
// enqueue DAG gen kernel
kernel = &clState->GenerateDAG;
cl_uint zero = 0;
cl_uint CacheSize64 = CacheSize / 64;
CL_SET_ARG(zero);
CL_SET_ARG(clState->EthCache);
CL_SET_ARG(clState->DAG);
CL_SET_ARG(CacheSize64);
CL_SET_ARG(Isolate);
status |= clEnqueueNDRangeKernel(clState->commandQueue, clState->GenerateDAG, 1, NULL, &DAGItems, NULL, 0, NULL, &DAGGenEvent);
status |= clWaitForEvents(1, &DAGGenEvent);
clReleaseEvent(DAGGenEvent);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d: Setting args for the DAG kernel and/or executing it.", status);
return(status);
}
}
mutex_lock(&eth_nonce_lock);
HighNonce = eth_nonce++;
blk->work->Nonce = (cl_ulong) HighNonce << 32;
mutex_unlock(&eth_nonce_lock);
num = 0;
kernel = &clState->kernel;
// Not nodes now (64 bytes), but DAG entries (128 bytes)
cl_uint ItemsArg = DAGItems >> 1;
CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(clState->CLbuffer0);
CL_SET_ARG(clState->DAG);
@@ -1061,71 +1069,81 @@ static cl_int queue_ethash_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u
CL_SET_ARG(blk->work->Nonce);
CL_SET_ARG(le_target);
CL_SET_ARG(Isolate);
return(status);
}
static cl_int queue_cryptonight_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_unused cl_uint threads)
static void append_equihash_compiler_options(struct _build_kernel_data *data, struct cgpu_info *cgpu, struct _algorithm_t *algorithm)
{
strcat(data->compiler_options, "");
}
static cl_int queue_equihash_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_unused cl_uint threads)
{
cl_kernel *kernel = &clState->kernel;
unsigned int num = 0;
cl_int status = 0, tgt32 = (blk->work->XMRTarget);
cl_ulong le_target = ((cl_ulong)(blk->work->XMRTarget));
cl_int status = 0;
size_t work_items = threads;
size_t worksize = clState->wsize;
struct pool *pool = blk->work->pool;
//le_target = *(cl_ulong *)(blk->work->device_target + 24);
memcpy(clState->cldata, blk->work->data, 76);
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 76, clState->cldata , 0, NULL, NULL);
CL_SET_ARG(clState->CLbuffer0);
CL_SET_ARG(clState->Scratchpads);
CL_SET_ARG(clState->States);
num = 0;
kernel = clState->extra_kernels;
CL_SET_ARG(clState->Scratchpads);
CL_SET_ARG(clState->States);
num = 0;
CL_NEXTKERNEL_SET_ARG(clState->Scratchpads);
CL_SET_ARG(clState->States);
CL_SET_ARG(clState->BranchBuffer[0]);
CL_SET_ARG(clState->BranchBuffer[1]);
CL_SET_ARG(clState->BranchBuffer[2]);
CL_SET_ARG(clState->BranchBuffer[3]);
num = 0;
CL_NEXTKERNEL_SET_ARG(clState->States);
CL_SET_ARG(clState->BranchBuffer[0]);
CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(tgt32);
// last to be set in driver-opencl.c
num = 0;
CL_NEXTKERNEL_SET_ARG(clState->States);
CL_SET_ARG(clState->BranchBuffer[1]);
CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(tgt32);
num = 0;
CL_NEXTKERNEL_SET_ARG(clState->States);
CL_SET_ARG(clState->BranchBuffer[2]);
CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(tgt32);
num = 0;
CL_NEXTKERNEL_SET_ARG(clState->States);
CL_SET_ARG(clState->BranchBuffer[3]);
CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(tgt32);
return(status);
//do this for stratum only, don't want to mess with GBT implementation...
if (blk->work->getwork_mode == GETWORK_MODE_STRATUM) {
//get next nonce to check
cg_wlock(&pool->data_lock);
blk->work->nonce2 = pool->nonce2++;
cg_wunlock(&pool->data_lock);
//set new nonce in equihash_data
*(uint64_t*)(blk->work->equihash_data+108+(strlen(blk->work->nonce1) / 2)) = blk->work->nonce2;
/* char *n = bin2hex(blk->work->equihash_data+108, 32);
applog(LOG_DEBUG, "[THR%d] nonce: %s", blk->work->thr->id, n);
free(n);*/
}
uint64_t mid_hash[8];
equihash_calc_mid_hash(mid_hash, blk->work->equihash_data);
status = clEnqueueWriteBuffer(clState->commandQueue, clState->MidstateBuf, CL_TRUE, 0, sizeof(mid_hash), mid_hash, 0, NULL, NULL);
uint32_t dbg[2] = {0};
status |= clEnqueueWriteBuffer(clState->commandQueue, clState->padbuffer8, CL_TRUE, 0, sizeof(dbg), &dbg, 0, NULL, NULL);
cl_mem buf_ht[2] = {clState->CLbuffer0, clState->buffer1};
cl_mem rowCounters[2] = {clState->buffer2, clState->buffer3};
for (int round = 0; round < PARAM_K; round++) {
size_t global_ws = NR_ROWS / ROWS_PER_UINT;
size_t local_ws = 256;
unsigned int num = 0;
cl_kernel *kernel = &clState->extra_kernels[0];
// Now on every round!!!!
CL_SET_ARG(buf_ht[round % 2]);
CL_SET_ARG(rowCounters[round % 2]);
status |= clEnqueueNDRangeKernel(clState->commandQueue, *kernel, 1, NULL, &global_ws, &local_ws, 0, NULL, NULL);
num = 0;
kernel = &clState->extra_kernels[1 + round];
if (!round) {
CL_SET_ARG(clState->MidstateBuf);
CL_SET_ARG(buf_ht[round % 2]);
CL_SET_ARG(rowCounters[round % 2]);
work_items = threads;
}
else {
CL_SET_ARG(buf_ht[(round - 1) % 2]);
CL_SET_ARG(buf_ht[round % 2]);
CL_SET_ARG(rowCounters[(round - 1) % 2]);
CL_SET_ARG(rowCounters[round % 2]);
work_items = NR_ROWS;
}
CL_SET_ARG(clState->padbuffer8);
if (round == PARAM_K - 1)
CL_SET_ARG(clState->outputBuffer);
status |= clEnqueueNDRangeKernel(clState->commandQueue, *kernel, 1, NULL, &work_items, &worksize, 0, NULL, NULL);
}
work_items = NR_ROWS;
status |= clEnqueueNDRangeKernel(clState->commandQueue, clState->kernel, 1, NULL, &work_items, &worksize, 0, NULL, NULL);
return status;
}
static algorithm_settings_t algos[] = {
// kernels starting from this will have difficulty calculated by using litecoin algorithm
#define A_SCRYPT(a) \
@@ -1218,11 +1236,11 @@ static algorithm_settings_t algos[] = {
{ "blake256r14", ALGO_BLAKE, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x00000000UL, 0, 128, 0, blake256_regenhash, precalc_hash_blake256, queue_blake_kernel, gen_hash, NULL },
{ "vanilla", ALGO_VANILLA, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x000000ffUL, 0, 128, 0, blakecoin_regenhash, precalc_hash_blakecoin, queue_blake_kernel, gen_hash, NULL },
{ "ethash", ALGO_ETHASH, "", (1ULL << 32), (1ULL << 32), 1, 0, 0, 0xFF, 0xFFFF000000000000ULL, 0, 0, 128, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, ethash_regenhash, NULL, queue_ethash_kernel, gen_hash, NULL },
{ "ethash-genoil", ALGO_ETHASH, "", (1ULL << 32), (1ULL << 32), 1, 0, 0, 0xFF, 0xFFFF000000000000ULL, 0, 0, 128, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, ethash_regenhash, NULL, queue_ethash_kernel, gen_hash, NULL },
{ "cryptonight", ALGO_CRYPTONIGHT, "", (1ULL << 32), (1ULL << 32), (1ULL << 32), 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 6, 0, 0, cryptonight_regenhash, NULL, queue_cryptonight_kernel, gen_hash, NULL },
// Terminator (do not remove)
{ "ethash", ALGO_ETHASH, "", (1ULL << 32), (1ULL << 32), 1, 0, 0, 0xFF, 0xFFFF000000000000ULL, 0x00000000UL, 0, 128, 0, ethash_regenhash, NULL, queue_ethash_kernel, gen_hash, append_ethash_compiler_options },
{ "equihash", ALGO_EQUIHASH, "", 1, (1ULL << 28), (1ULL << 28), 0, 0, 0x20000, 0xFFFF000000000000ULL, 0x00000000UL, 0, 128, 0, equihash_regenhash, NULL, queue_equihash_kernel, gen_hash, append_equihash_compiler_options },
// Terminator (do not remove)
{ NULL, ALGO_UNK, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL }
};
@@ -1267,10 +1285,12 @@ void copy_algorithm_settings(algorithm_t* dest, const char* algo)
}
}
static const char *lookup_algorithm_alias(const char *lookup_alias, uint8_t *nfactor)
static const char *lookup_algorithm_alias(const char *lookup_alias, uint8_t *nfactor, uint8_t *kfactor)
{
#define ALGO_ALIAS_NF(alias, name, nf) \
if (strcasecmp(alias, lookup_alias) == 0) { *nfactor = nf; return name; }
#define ALGO_ALIAS_NFK(alias, name, nf, kf) \
if (strcasecmp(alias, lookup_alias) == 0) { *kfactor = kf, *nfactor = nf; return name; }
#define ALGO_ALIAS(alias, name) \
if (strcasecmp(alias, lookup_alias) == 0) return name;
@@ -1298,9 +1318,11 @@ static const char *lookup_algorithm_alias(const char *lookup_alias, uint8_t *nfa
ALGO_ALIAS("lyra2v2", "lyra2rev2");
ALGO_ALIAS("blakecoin", "blake256r8");
ALGO_ALIAS("blake", "blake256r14");
ALGO_ALIAS_NFK("zcash", "equihash", 200, 9);
#undef ALGO_ALIAS
#undef ALGO_ALIAS_NF
#undef ALGO_ALIAS_NFK
return NULL;
}
@@ -1311,21 +1333,35 @@ void set_algorithm(algorithm_t* algo, const char* newname_alias)
//load previous algorithm nfactor in case nfactor was applied before algorithm... or default to 10
uint8_t old_nfactor = ((algo->nfactor) ? algo->nfactor : 0);
//load previous algorithm kfactor in case kfactor was applied before algorithm... or default to 9
uint8_t old_kfactor = ((algo->kfactor) ? algo->kfactor : 0);
//load previous kernel file name if was applied before algorithm...
const char *kernelfile = algo->kernelfile;
uint8_t nfactor = 10;
uint8_t kfactor = 9;
if (!(newname = lookup_algorithm_alias(newname_alias, &nfactor)))
if (!(newname = lookup_algorithm_alias(newname_alias, &nfactor, &kfactor))) {
newname = newname_alias;
}
copy_algorithm_settings(algo, newname);
// use old nfactor if it was previously set and is different than the one set by alias
if ((old_nfactor > 0) && (old_nfactor != nfactor))
if ((old_nfactor > 0) && (old_nfactor != nfactor)) {
nfactor = old_nfactor;
}
set_algorithm_nfactor(algo, nfactor);
// use old kfactor if it was previously set and is different than the one set by alias
if ((old_kfactor > 0) && (old_kfactor != kfactor)) {
kfactor = old_kfactor;
}
set_algorithm_kfactor(algo, kfactor);
//reapply kernelfile if was set
if (!empty_string(kernelfile)) {
algo->kernelfile = kernelfile;
@@ -1357,7 +1393,12 @@ void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor)
}
}
void set_algorithm_kfactor(algorithm_t* algo, const uint8_t kfactor)
{
algo->kfactor = kfactor;
}
bool cmp_algorithm(const algorithm_t* algo1, const algorithm_t* algo2)
{
return (!safe_cmp(algo1->name, algo2->name) && !safe_cmp(algo1->kernelfile, algo2->kernelfile) && (algo1->nfactor == algo2->nfactor));
return (!safe_cmp(algo1->name, algo2->name) && !safe_cmp(algo1->kernelfile, algo2->kernelfile) && (algo1->nfactor == algo2->nfactor) && (algo1->kfactor == algo2->kfactor));
}
+6 -1
View File
@@ -38,11 +38,12 @@ typedef enum {
ALGO_BLAKE,
ALGO_VANILLA,
ALGO_ETHASH,
ALGO_CRYPTONIGHT
ALGO_EQUIHASH
} algorithm_type_t;
extern const char *algorithm_type_str[];
extern void sha256(const unsigned char *message, unsigned int len, unsigned char *digest);
extern void gen_hash(const unsigned char *data, unsigned int len, unsigned char *hash);
struct __clState;
@@ -60,6 +61,7 @@ typedef struct _algorithm_t {
const char *kernelfile; /* alternate kernel file */
uint32_t n; /* N (CPU/Memory tradeoff parameter) */
uint8_t nfactor; /* Factor of N above (n = 2^nfactor) */
uint8_t kfactor; /* Factor of N above (n = 2^nfactor) */
double diff_multiplier1;
double diff_multiplier2;
double share_diff_multiplier;
@@ -107,6 +109,9 @@ void set_algorithm(algorithm_t* algo, const char* name);
/* Set to specific N factor. */
void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor);
/* Set to specific K factor. */
void set_algorithm_kfactor(algorithm_t* algo, const uint8_t kfactor);
/* Compare two algorithm parameters */
bool cmp_algorithm(const algorithm_t* algo1, const algorithm_t* algo2);
+2 -2
View File
@@ -786,10 +786,10 @@ struct api_data *print_data(struct api_data *root, char *buf, bool isjson, bool
case API_UTILITY:
case API_FREQ:
case API_MHS:
sprintf(buf, "%.4f", *((double *)(root->data)));
sprintf(buf, "%.4g", *((double *)(root->data)));
break;
case API_KHS:
sprintf(buf, "%.0f", *((double *)(root->data)));
sprintf(buf, "%.4g", *((double *)(root->data)));
break;
case API_VOLTS:
case API_AVG:
+38 -55
View File
@@ -235,8 +235,6 @@ char *set_default_thread_concurrency(const char *arg)
return NULL;
}
#ifdef HAVE_ADL
char *set_default_gpu_engine(const char *arg)
{
default_profile.gpu_engine = arg;
@@ -273,8 +271,6 @@ char *set_default_thread_concurrency(const char *arg)
return NULL;
}
#endif
char *set_default_profile(char *arg)
{
default_profile.name = arg;
@@ -366,51 +362,47 @@ char *set_profile_thread_concurrency(const char *arg)
return NULL;
}
#ifdef HAVE_ADL
char *set_profile_gpu_engine(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_engine = arg;
return NULL;
}
char *set_profile_gpu_engine(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_engine = arg;
return NULL;
}
char *set_profile_gpu_memclock(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_memclock = arg;
return NULL;
}
char *set_profile_gpu_memclock(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_memclock = arg;
return NULL;
}
char *set_profile_gpu_threads(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_threads = arg;
return NULL;
}
char *set_profile_gpu_threads(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_threads = arg;
return NULL;
}
char *set_profile_gpu_fan(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_fan = arg;
return NULL;
}
char *set_profile_gpu_fan(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_fan = arg;
return NULL;
}
char *set_profile_gpu_powertune(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_powertune = arg;
return NULL;
}
char *set_profile_gpu_powertune(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_powertune = arg;
return NULL;
}
char *set_profile_gpu_vddc(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_vddc = arg;
return NULL;
}
#endif
char *set_profile_gpu_vddc(const char *arg)
{
struct profile *profile = get_current_profile();
profile->gpu_vddc = arg;
return NULL;
}
char *set_profile_nfactor(const char *arg)
{
@@ -911,7 +903,6 @@ void load_default_profile()
if(!empty_string(profile->thread_concurrency))
default_profile.thread_concurrency = profile->thread_concurrency;
#ifdef HAVE_ADL
if(!empty_string(profile->gpu_engine))
default_profile.gpu_engine = profile->gpu_engine;
@@ -929,7 +920,7 @@ void load_default_profile()
if(!empty_string(profile->gpu_vddc))
default_profile.gpu_vddc = profile->gpu_vddc;
#endif
if(!empty_string(profile->shaders))
default_profile.shaders = profile->shaders;
@@ -967,7 +958,6 @@ void apply_defaults()
if (!empty_string(default_profile.thread_concurrency))
set_thread_concurrency(default_profile.thread_concurrency);
#ifdef HAVE_ADL
if (!empty_string(default_profile.gpu_engine))
set_gpu_engine(default_profile.gpu_engine);
@@ -985,8 +975,7 @@ void apply_defaults()
if (!empty_string(default_profile.gpu_vddc))
set_gpu_vddc((char *)default_profile.gpu_vddc);
#endif
if (!empty_string(default_profile.shaders))
set_shaders((char *)default_profile.shaders);
@@ -1145,7 +1134,6 @@ void apply_pool_profile(struct pool *pool)
}
applog(LOG_DEBUG, "Pool %i Thread Concurrency set to \"%s\"", pool->pool_no, pool->thread_concurrency);
#ifdef HAVE_ADL
if(pool_cmp(pool->gpu_engine, default_profile.gpu_engine))
{
if(!empty_string(profile->gpu_engine))
@@ -1199,7 +1187,6 @@ void apply_pool_profile(struct pool *pool)
pool->gpu_vddc = default_profile.gpu_vddc;
}
applog(LOG_DEBUG, "Pool %i GPU Vddc set to \"%s\"", pool->pool_no, pool->gpu_vddc);
#endif
if(pool_cmp(pool->shaders, default_profile.shaders))
{
@@ -1418,7 +1405,6 @@ static json_t *build_pool_json()
if (!build_pool_json_add(obj, "worksize", pool->worksize, profile->worksize, default_profile.worksize, pool->pool_no))
return NULL;
#ifdef HAVE_ADL
// gpu_engine
if (!build_pool_json_add(obj, "gpu-engine", pool->gpu_engine, profile->gpu_engine, default_profile.gpu_engine, pool->pool_no))
return NULL;
@@ -1442,7 +1428,6 @@ static json_t *build_pool_json()
// gpu-vddc
if (!build_pool_json_add(obj, "gpu-vddc", pool->gpu_vddc, profile->gpu_vddc, default_profile.gpu_vddc, pool->pool_no))
return NULL;
#endif
// all done, add pool to array...
if (json_array_append_new(pool_array, obj) == -1)
@@ -1728,7 +1713,6 @@ void write_config(const char *filename)
//write gpu settings that aren't part of profiles -- only write if gpus are available
if(nDevs)
{
#ifdef HAVE_ADL
//temp-cutoff
for(i = 0;i < nDevs; i++)
obj = json_sprintf("%s%s%d", ((i > 0)?json_string_value(obj):""), ((i > 0)?",":""), gpus[i].cutofftemp);
@@ -1756,7 +1740,6 @@ void write_config(const char *filename)
obj = json_sprintf("%s%s%d", ((i > 0)?json_string_value(obj):""), ((i > 0)?",":""), (int)gpus[i].gpu_memdiff);
json_add(config, "gpu-memdiff", obj);
#endif
}
//add other misc options
+2 -2
View File
@@ -1,8 +1,8 @@
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
m4_define([v_maj], [5])
m4_define([v_min], [4])
m4_define([v_mic], [0])
m4_define([v_min], [5])
m4_define([v_mic], [2])
m4_define([v_rev], [gm])
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
m4_ifdef([v_rev], [m4_define([v_ver], [v_maj.v_min.v_mic-v_rev])], [m4_define([v_ver], [v_maj.v_min.v_mic])])
+96 -148
View File
@@ -35,6 +35,9 @@
#include "adl.h"
#include "util.h"
#include "algorithm/equihash.h"
#include "kernel/equihash-param.h"
/* TODO: cleanup externals ********************/
#ifdef HAVE_CURSES
@@ -56,12 +59,6 @@ extern void decay_time(double *f, double fadd);
/**********************************************/
#ifdef HAVE_ADL
extern float gpu_temp(int gpu);
extern int gpu_fanspeed(int gpu);
extern int gpu_fanpercent(int gpu);
#endif
char *set_vector(char *arg)
{
int i, val = 0, device = 0;
@@ -215,7 +212,6 @@ char *set_thread_concurrency(const char *arg)
return NULL;
}
#ifdef HAVE_ADL
/* This function allows us to map an adl device to an opencl device for when
* simple enumeration has failed to match them. */
char *set_gpu_map(char *arg)
@@ -487,21 +483,21 @@ char *set_temp_overheat(char *arg)
if (val < 0 || val > 200)
return "Invalid value passed to set temp overheat";
to = &gpus[device++].adl.overtemp;
*to = val;
gpus[device].adl.overtemp = val;
gpus[device++].sysfs_info.OverHeatTemp = val;
while ((nextptr = strtok(NULL, ",")) != NULL) {
val = atoi(nextptr);
if (val < 0 || val > 200)
return "Invalid value passed to set temp overheat";
to = &gpus[device++].adl.overtemp;
*to = val;
gpus[device].adl.overtemp = val;
gpus[device++].sysfs_info.OverHeatTemp = val;
}
if (device == 1) {
for (i = device; i < MAX_GPUDEVICES; i++) {
to = &gpus[i].adl.overtemp;
*to = val;
gpus[i].adl.overtemp = val;
gpus[i].sysfs_info.OverHeatTemp = val;
}
}
@@ -520,7 +516,9 @@ char *set_temp_target(char *arg)
if (val < 0 || val > 200)
return "Invalid value passed to set temp target";
tt = &gpus[device++].adl.targettemp;
tt = &gpus[device].adl.targettemp;
*tt = val;
tt = &gpus[device++].sysfs_info.TargetTemp;
*tt = val;
while ((nextptr = strtok(NULL, ",")) != NULL) {
@@ -528,19 +526,23 @@ char *set_temp_target(char *arg)
if (val < 0 || val > 200)
return "Invalid value passed to set temp target";
tt = &gpus[device++].adl.targettemp;
tt = &gpus[device].adl.targettemp;
*tt = val;
tt = &gpus[device++].sysfs_info.TargetTemp;
*tt = val;
}
if (device == 1) {
for (i = device; i < MAX_GPUDEVICES; i++) {
tt = &gpus[i].adl.targettemp;
*tt = val;
tt = &gpus[i].sysfs_info.TargetTemp;
*tt = val;
}
}
return NULL;
}
#endif
char *set_intensity(const char *_arg)
{
@@ -754,8 +756,8 @@ retry: // TODO: refactor
gpu, displayed_rolling, displayed_total, mhash_base ? "M" : "K",
cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
cgpu->utility, cgpu->intensity, cgpu->xintensity, cgpu->rawintensity);
#ifdef HAVE_ADL
if (gpus[gpu].has_adl) {
if (gpus[gpu].has_adl || gpus[gpu].has_sysfs_hwcontrols) {
int engineclock = 0, memclock = 0, activity = 0, fanspeed = 0, fanpercent = 0, powertune = 0;
float temp = 0, vddc = 0;
@@ -787,7 +789,6 @@ retry: // TODO: refactor
_wlog(logline);
}
}
#endif
wlog("Last initialised: %s\n", cgpu->init);
rd_lock(&mining_thr_lock);
@@ -1211,9 +1212,11 @@ static void opencl_detect(void)
cgpu->algorithm = default_profile.algorithm;
add_cgpu(cgpu);
}
if (!opt_noadl)
if(!init_sysfs_hwcontrols(nDevs) && !opt_noadl)
{
init_adl(nDevs);
}
}
static void reinit_opencl_device(struct cgpu_info *gpu)
@@ -1221,10 +1224,10 @@ static void reinit_opencl_device(struct cgpu_info *gpu)
tq_push(control_thr[gpur_thr_id].q, gpu);
}
#ifdef HAVE_ADL
static void get_opencl_statline_before(char *buf, size_t bufsiz, struct cgpu_info *gpu)
{
if (gpu->has_adl) {
if (gpu->has_adl || gpu->has_sysfs_hwcontrols)
{
int gpuid = gpu->device_id;
float gt = gpu_temp(gpuid);
int gf = gpu_fanspeed(gpuid);
@@ -1246,7 +1249,6 @@ static void get_opencl_statline_before(char *buf, size_t bufsiz, struct cgpu_inf
else
gpu->drv->get_statline_before = &blank_get_statline_before;
}
#endif
static void get_opencl_statline(char *buf, size_t bufsiz, struct cgpu_info *gpu)
{
@@ -1332,7 +1334,7 @@ static bool opencl_thread_init(struct thr_info *thr)
cl_int status = 0;
thrdata = (struct opencl_thread_data *)calloc(1, sizeof(*thrdata));
thr->cgpu_data = thrdata;
int buffersize = BUFFERSIZE;
int buffersize = (gpu->algorithm.type == ALGO_EQUIHASH) ? sizeof(sols_t) : BUFFERSIZE; //MAX(BUFFERSIZE, sizeof(sols_t));
if (!thrdata) {
applog(LOG_ERR, "Failed to calloc in opencl_thread_init");
@@ -1353,7 +1355,7 @@ static bool opencl_thread_init(struct thr_info *thr)
if (unlikely(status != CL_SUCCESS)) {
free(thrdata->res);
free(thrdata);
applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed.");
applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed (opencl_thread_init) (status = %d).", status);
return false;
}
@@ -1369,11 +1371,13 @@ static bool opencl_prepare_work(struct thr_info __maybe_unused *thr, struct work
work->blk.work = work;
if (work->pool->algorithm.precalc_hash) work->pool->algorithm.precalc_hash(&work->blk, 0, (uint32_t *)(work->data));
thr->pool_no = work->pool->pool_no;
return true;
}
extern int opt_dynamic_interval;
uint32_t verify_sol(struct work *, sols_t *, int);
static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
int64_t __maybe_unused max_nonce)
@@ -1411,136 +1415,81 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
memcpy(&(gpu->tv_gpustart), &tv_gpuend, sizeof(struct timeval));
gpu->intervals = 0;
}
set_threads_hashes(clState->vwidth, clState->compute_shaders, &hashes, globalThreads, localThreads[0],
&gpu->intensity, &gpu->xintensity, &gpu->rawintensity, &gpu->algorithm);
if (hashes > gpu->max_hashes)
gpu->max_hashes = hashes;
if (gpu->algorithm.type == ALGO_EQUIHASH) {
int64_t ret = 0;
size_t length = sizeof(sols_t);
uint64_t t0 = time(NULL);
uint8_t prev_hash[32];
size_t txns;
bool stale = false;
if (work->getwork_mode != GETWORK_MODE_STRATUM) {
cg_rlock(&work->pool->gbt_lock);
txns = work->pool->gbt_txns;
memcpy(prev_hash, work->pool->previousblockhash, 32);
cg_runlock(&work->pool->gbt_lock);
}
thrdata->res = realloc(thrdata->res, length);
sols_t *sols = (sols_t*) thrdata->res;
work->thr = thr;
do {
status = thrdata->queue_kernel_parameters(clState, &work->blk, globalThreads[0]);
status |= clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0, length, thrdata->res, 0, NULL, NULL);
if (status == CL_SUCCESS) {
if (sols->nr > MAX_SOLS) {
applog(LOG_DEBUG, "equihash: %d (probably invalid) solutions were dropped!", sols->nr - MAX_SOLS);
sols->nr = MAX_SOLS;
}
for (int sol_i = 0; sol_i < sols->nr; sol_i++)
ret += verify_sol(work, sols, sol_i);
}
else {
applog(LOG_ERR, "Error %d: Reading result buffer for ALGO_EQUIHASH failed. (clEnqueueReadBuffer)", status);
return -1;
}
work->blk.nonce++;
if (work->getwork_mode != GETWORK_MODE_STRATUM) {
*(uint64_t*)(work->equihash_data + 108) += 1; // increase nonce
cg_rlock(&work->pool->gbt_lock);
stale = (work->pool->gbt_txns != txns) || (memcmp(prev_hash, work->pool->previousblockhash, 32) != 0);
cg_runlock(&work->pool->gbt_lock);
}
} while ((time(NULL) - t0) <= 3 && !stale);
return ret;
}
status = thrdata->queue_kernel_parameters(clState, &work->blk, globalThreads[0]);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error: clSetKernelArg of all params failed.");
return -1;
}
if(gpu->algorithm.type == ALGO_CRYPTONIGHT)
{
mutex_lock(&work->pool->XMRGlobalNonceLock);
work->blk.nonce = work->pool->XMRGlobalNonce;
work->pool->XMRGlobalNonce += gpu->max_hashes;
mutex_unlock(&work->pool->XMRGlobalNonceLock);
}
if (clState->goffset)
p_global_work_offset = (size_t *)&work->blk.nonce;
if(gpu->algorithm.type == ALGO_CRYPTONIGHT)
{
size_t GlobalThreads = *globalThreads, Nonce[2] = { (size_t)work->blk.nonce, 1}, gthreads[2] = { *globalThreads, 8 }, lthreads[2] = { *localThreads, 8 };
size_t BranchBufCount[4] = { 0, 0, 0, 0 };
for(int i = 0; i < 4; ++i)
{
cl_uint zero = 0;
status = clEnqueueWriteBuffer(clState->commandQueue, clState->BranchBuffer[i], CL_FALSE, sizeof(cl_uint) * GlobalThreads, sizeof(cl_uint), &zero, 0, NULL, NULL);
status = clEnqueueNDRangeKernel(clState->commandQueue, clState->kernel, 1, p_global_work_offset,
globalThreads, localThreads, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error %d: Enqueueing kernel onto command queue. (clEnqueueNDRangeKernel)", status);
return -1;
}
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d while resetting branch buffer counter %d.\n", status, i);
return(-1);
}
}
clFinish(clState->commandQueue);
// Main CN P0
status = clEnqueueNDRangeKernel(clState->commandQueue, clState->kernel, 2, Nonce, gthreads, lthreads, 0, NULL, NULL);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d while attempting to enqueue kernel 0.", status);
return(-1);
}
// Main CN P1
status = clEnqueueNDRangeKernel(clState->commandQueue, clState->extra_kernels[0], 1, p_global_work_offset, globalThreads, localThreads, 0, NULL, NULL);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d while attempting to enqueue kernel 1.", status);
return(-1);
}
// Main CN P2
status = clEnqueueNDRangeKernel(clState->commandQueue, clState->extra_kernels[1], 2, Nonce, gthreads, lthreads, 0, NULL, NULL);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d while attempting to enqueue kernel 2.", status);
return(-1);
}
// Read BranchBuf counters
for(int i = 0; i < 4; ++i)
{
status = clEnqueueReadBuffer(clState->commandQueue, clState->BranchBuffer[i], CL_FALSE, sizeof(cl_uint) * GlobalThreads, sizeof(cl_uint), BranchBufCount + i, 0, NULL, NULL);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d while attempting to read branch buffer counter %d.", status, i);
return(-1);
}
}
clFinish(clState->commandQueue);
for(int i = 0; i < 4; ++i)
{
if(BranchBufCount[i])
{
cl_ulong tmp = BranchBufCount[i];
// Threads
status = clSetKernelArg(clState->extra_kernels[i + 2], 4, sizeof(cl_ulong), &tmp);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d while attempting to set argument 4 for kernel %d.", status, i + 2);
return(-1);
}
// Make it a multiple of the local worksize (some drivers will otherwise shit a brick)
BranchBufCount[i] += (clState->wsize - (BranchBufCount[i] & (clState->wsize - 1)));
status = clEnqueueNDRangeKernel(clState->commandQueue, clState->extra_kernels[i + 2], 1, p_global_work_offset, BranchBufCount + i, localThreads, 0, NULL, NULL);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d while attempting to enqueue kernel %d.", status, i + 2);
return(-1);
}
}
}
}
else
{
status = clEnqueueNDRangeKernel(clState->commandQueue, clState->kernel, 1, p_global_work_offset,
globalThreads, localThreads, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error %d: Enqueueing kernel onto command queue. (clEnqueueNDRangeKernel)", status);
return -1;
}
for (i = 0; i < clState->n_extra_kernels; i++) {
status = clEnqueueNDRangeKernel(clState->commandQueue, clState->extra_kernels[i], 1, p_global_work_offset,
globalThreads, localThreads, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error %d: Enqueueing kernel onto command queue. (clEnqueueNDRangeKernel)", status);
return -1;
}
}
for (i = 0; i < clState->n_extra_kernels; i++) {
status = clEnqueueNDRangeKernel(clState->commandQueue, clState->extra_kernels[i], 1, p_global_work_offset,
globalThreads, localThreads, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error %d: Enqueueing kernel onto command queue. (clEnqueueNDRangeKernel)", status);
return -1;
}
}
status = clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
@@ -1564,7 +1513,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
buffersize, blank_res, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS)) {
applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed.");
applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed (opencl_scanhash).");
return -1;
}
applog(LOG_DEBUG, "GPU %d found something?", gpu->device_id);
@@ -1601,8 +1550,6 @@ static void opencl_thread_shutdown(struct thr_info *thr)
clReleaseMemObject(clState->buffer3);
if (clState->padbuffer8)
clReleaseMemObject(clState->padbuffer8);
if(clState->States) clReleaseMemObject(clState->States);
if(clState->Scratchpads) clReleaseMemObject(clState->Scratchpads);
clReleaseKernel(clState->kernel);
for (i = 0; i < clState->n_extra_kernels; i++)
clReleaseKernel(clState->extra_kernels[i]);
@@ -1613,8 +1560,9 @@ static void opencl_thread_shutdown(struct thr_info *thr)
free(clState->extra_kernels);
free(clState);
}
free(((struct opencl_thread_data *)thr->cgpu_data)->res);
free(thr->cgpu_data);
// Causes invalid free crashes in some cases.
//free(((struct opencl_thread_data *)thr->cgpu_data)->res);
//free(thr->cgpu_data);
thr->cgpu_data = NULL;
}
+4 -4
View File
@@ -77,17 +77,17 @@ __constant static const sph_u32 c_u256[16] = {
const sph_u32 idx2 = sigma[r][x+1]; \
v[a] += (m[idx1] ^ c_u256[idx2]) + v[b]; \
v[d] ^= v[a]; \
v[d] = rotate(v[d], 16U); \
v[d] = SPH_ROTR32(v[d], 16); \
v[c] += v[d]; \
v[b] ^= v[c]; \
v[b] = rotate(v[b], 20U); \
v[b] = SPH_ROTR32(v[b], 12); \
\
v[a] += (m[idx2] ^ c_u256[idx1]) + v[b]; \
v[d] ^= v[a]; \
v[d] = rotate(v[d], 24U); \
v[d] = SPH_ROTR32(v[d], 8); \
v[c] += v[d]; \
v[b] ^= v[c]; \
v[b] = rotate(v[b], 25U); \
v[b] = SPH_ROTR32(v[b], 7); \
}
+5
View File
@@ -1,6 +1,10 @@
#define MAX_OUTPUTS 0xFFu
#define barrier(x) mem_fence(x)
#define OPENCL_PLATFORM_UNKNOWN 0
#define OPENCL_PLATFORM_NVIDIA 1
#define OPENCL_PLATFORM_AMD 2
#define ETHASH_DATASET_PARENTS 256
#define NODE_WORDS (64/4)
#define ACCESSES 64
@@ -248,6 +252,7 @@ __kernel void search(
((ulong4 *)state)[2] = share->ulong4s[0];
}
#pragma unroll
for (uint i = 13; i < 25; ++i)
state[i] = (uint2)(0U, 0U);
state[12] = as_uint2(0x0000000000000001UL);
+1091 -145
View File
File diff suppressed because it is too large. Load diff
+98 -50
View File
@@ -30,13 +30,9 @@
* @author Thomas Pornin <thomas.pornin@cryptolog.com>
*/
#if !defined SPH_JH_64 && SPH_64_TRUE
#define SPH_JH_64 1
#define SPH_LITTLE_ENDIAN 1
#define SPH_C32(x) x
#define SPH_C64(x) x
typedef uint sph_u32;
typedef ulong sph_u64;
#endif
/*
* The internal bitslice representation may use either big-endian or
@@ -103,50 +99,91 @@ typedef ulong sph_u64;
x3 ^= x4; \
} while (0)
static const __constant ulong C[] =
{
0x67F815DFA2DED572UL, 0x571523B70A15847BUL, 0xF6875A4D90D6AB81UL, 0x402BD1C3C54F9F4EUL,
0x9CFA455CE03A98EAUL, 0x9A99B26699D2C503UL, 0x8A53BBF2B4960266UL, 0x31A2DB881A1456B5UL,
0xDB0E199A5C5AA303UL, 0x1044C1870AB23F40UL, 0x1D959E848019051CUL, 0xDCCDE75EADEB336FUL,
0x416BBF029213BA10UL, 0xD027BBF7156578DCUL, 0x5078AA3739812C0AUL, 0xD3910041D2BF1A3FUL,
0x907ECCF60D5A2D42UL, 0xCE97C0929C9F62DDUL, 0xAC442BC70BA75C18UL, 0x23FCC663D665DFD1UL,
0x1AB8E09E036C6E97UL, 0xA8EC6C447E450521UL, 0xFA618E5DBB03F1EEUL, 0x97818394B29796FDUL,
0x2F3003DB37858E4AUL, 0x956A9FFB2D8D672AUL, 0x6C69B8F88173FE8AUL, 0x14427FC04672C78AUL,
0xC45EC7BD8F15F4C5UL, 0x80BB118FA76F4475UL, 0xBC88E4AEB775DE52UL, 0xF4A3A6981E00B882UL,
0x1563A3A9338FF48EUL, 0x89F9B7D524565FAAUL, 0xFDE05A7C20EDF1B6UL, 0x362C42065AE9CA36UL,
0x3D98FE4E433529CEUL, 0xA74B9A7374F93A53UL, 0x86814E6F591FF5D0UL, 0x9F5AD8AF81AD9D0EUL,
0x6A6234EE670605A7UL, 0x2717B96EBE280B8BUL, 0x3F1080C626077447UL, 0x7B487EC66F7EA0E0UL,
0xC0A4F84AA50A550DUL, 0x9EF18E979FE7E391UL, 0xD48D605081727686UL, 0x62B0E5F3415A9E7EUL,
0x7A205440EC1F9FFCUL, 0x84C9F4CE001AE4E3UL, 0xD895FA9DF594D74FUL, 0xA554C324117E2E55UL,
0x286EFEBD2872DF5BUL, 0xB2C4A50FE27FF578UL, 0x2ED349EEEF7C8905UL, 0x7F5928EB85937E44UL,
0x4A3124B337695F70UL, 0x65E4D61DF128865EUL, 0xE720B95104771BC7UL, 0x8A87D423E843FE74UL,
0xF2947692A3E8297DUL, 0xC1D9309B097ACBDDUL, 0xE01BDC5BFB301B1DUL, 0xBF829CF24F4924DAUL,
0xFFBF70B431BAE7A4UL, 0x48BCF8DE0544320DUL, 0x39D3BB5332FCAE3BUL, 0xA08B29E0C1C39F45UL,
0x0F09AEF7FD05C9E5UL, 0x34F1904212347094UL, 0x95ED44E301B771A2UL, 0x4A982F4F368E3BE9UL,
0x15F66CA0631D4088UL, 0xFFAF52874B44C147UL, 0x30C60AE2F14ABB7EUL, 0xE68C6ECCC5B67046UL,
0x00CA4FBD56A4D5A4UL, 0xAE183EC84B849DDAUL, 0xADD1643045CE5773UL, 0x67255C1468CEA6E8UL,
0x16E10ECBF28CDAA3UL, 0x9A99949A5806E933UL, 0x7B846FC220B2601FUL, 0x1885D1A07FACCED1UL,
0xD319DD8DA15B5932UL, 0x46B4A5AAC01C9A50UL, 0xBA6B04E467633D9FUL, 0x7EEE560BAB19CAF6UL,
0x742128A9EA79B11FUL, 0xEE51363B35F7BDE9UL, 0x76D350755AAC571DUL, 0x01707DA3FEC2463AUL,
0x42D8A498AFC135F7UL, 0x79676B9E20ECED78UL, 0xA8DB3AEA15638341UL, 0x832C83324D3BC3FAUL,
0xF347271C1F3B40A7UL, 0x9A762DB734F04059UL, 0xFD4F21D26C4E3EE7UL, 0xEF5957DC398DFDB8UL,
0xDAEB492B490C9B8DUL, 0x0D70F36849D7A25BUL, 0x84558D7AD0AE3B7DUL, 0x658EF8E4F0E9A5F5UL,
0x533B1036F4A2B8A0UL, 0x5AEC3E759E07A80CUL, 0x4F88E85692946891UL, 0x4CBCBAF8555CB05BUL,
0x7B9487F3993BBBE3UL, 0x5D1C6B72D6F4DA75UL, 0x6DB334DC28ACAE64UL, 0x71DB28B850A5346CUL,
0x2A518D10F2E261F8UL, 0xFC75DD593364DBE3UL, 0xA23FCE43F1BCAC1CUL, 0xB043E8023CD1BB67UL,
0x75A12988CA5B0A33UL, 0x5C5316B44D19347FUL, 0x1E4D790EC3943B92UL, 0x3FAFEEB6D7757479UL,
0x21391ABEF7D4A8EAUL, 0x5127234C097EF45CUL, 0xD23C32BA5324A326UL, 0xADD5A66D4A17A344UL,
0x08C9F2AFA63E1DB5UL, 0x563C6B91983D5983UL, 0x4D608672A17CF84CUL, 0xF6C76E08CC3EE246UL,
0x5E76BCB1B333982FUL, 0x2AE6C4EFA566D62BUL, 0x36D4C1BEE8B6F406UL, 0x6321EFBC1582EE74UL,
0x69C953F40D4EC1FDUL, 0x26585806C45A7DA7UL, 0x16FAE0061614C17EUL, 0x3F9D63283DAF907EUL,
0x0CD29B00E3F2C9D2UL, 0x300CD4B730CEAA5FUL, 0x9832E0F216512A74UL, 0x9AF8CEE3D830EB0DUL,
0x9279F1B57B9EC54BUL, 0xD36886046EE651FFUL, 0x316796E6574D239BUL, 0x05750A17F3A6E6CCUL,
0xCE6C3213D98176B1UL, 0x62A205F88452173CUL, 0x47154778B3CB2BF4UL, 0x486A9323825446FFUL,
0x65655E4E0758DF38UL, 0x8E5086FC897CFCF2UL, 0x86CA0BD0442E7031UL, 0x4E477830A20940F0UL,
0x8338F7D139EEA065UL, 0xBD3A2CE437E95EF7UL, 0x6FF8130126B29721UL, 0xE7DE9FEFD1ED44A3UL,
0xD992257615DFA08BUL, 0xBE42DC12F6F7853CUL, 0x7EB027AB7CECA7D8UL, 0xDEA83EAADA7D8D53UL,
0xD86902BD93CE25AAUL, 0xF908731AFD43F65AUL, 0xA5194A17DAEF5FC0UL, 0x6A21FD4C33664D97UL,
0x701541DB3198B435UL, 0x9B54CDEDBB0F1EEAUL, 0x72409751A163D09AUL, 0xE26F4791BF9D75F6UL
__constant static const sph_u64 C[] = {
C64e(0x72d5dea2df15f867), C64e(0x7b84150ab7231557),
C64e(0x81abd6904d5a87f6), C64e(0x4e9f4fc5c3d12b40),
C64e(0xea983ae05c45fa9c), C64e(0x03c5d29966b2999a),
C64e(0x660296b4f2bb538a), C64e(0xb556141a88dba231),
C64e(0x03a35a5c9a190edb), C64e(0x403fb20a87c14410),
C64e(0x1c051980849e951d), C64e(0x6f33ebad5ee7cddc),
C64e(0x10ba139202bf6b41), C64e(0xdc786515f7bb27d0),
C64e(0x0a2c813937aa7850), C64e(0x3f1abfd2410091d3),
C64e(0x422d5a0df6cc7e90), C64e(0xdd629f9c92c097ce),
C64e(0x185ca70bc72b44ac), C64e(0xd1df65d663c6fc23),
C64e(0x976e6c039ee0b81a), C64e(0x2105457e446ceca8),
C64e(0xeef103bb5d8e61fa), C64e(0xfd9697b294838197),
C64e(0x4a8e8537db03302f), C64e(0x2a678d2dfb9f6a95),
C64e(0x8afe7381f8b8696c), C64e(0x8ac77246c07f4214),
C64e(0xc5f4158fbdc75ec4), C64e(0x75446fa78f11bb80),
C64e(0x52de75b7aee488bc), C64e(0x82b8001e98a6a3f4),
C64e(0x8ef48f33a9a36315), C64e(0xaa5f5624d5b7f989),
C64e(0xb6f1ed207c5ae0fd), C64e(0x36cae95a06422c36),
C64e(0xce2935434efe983d), C64e(0x533af974739a4ba7),
C64e(0xd0f51f596f4e8186), C64e(0x0e9dad81afd85a9f),
C64e(0xa7050667ee34626a), C64e(0x8b0b28be6eb91727),
C64e(0x47740726c680103f), C64e(0xe0a07e6fc67e487b),
C64e(0x0d550aa54af8a4c0), C64e(0x91e3e79f978ef19e),
C64e(0x8676728150608dd4), C64e(0x7e9e5a41f3e5b062),
C64e(0xfc9f1fec4054207a), C64e(0xe3e41a00cef4c984),
C64e(0x4fd794f59dfa95d8), C64e(0x552e7e1124c354a5),
C64e(0x5bdf7228bdfe6e28), C64e(0x78f57fe20fa5c4b2),
C64e(0x05897cefee49d32e), C64e(0x447e9385eb28597f),
C64e(0x705f6937b324314a), C64e(0x5e8628f11dd6e465),
C64e(0xc71b770451b920e7), C64e(0x74fe43e823d4878a),
C64e(0x7d29e8a3927694f2), C64e(0xddcb7a099b30d9c1),
C64e(0x1d1b30fb5bdc1be0), C64e(0xda24494ff29c82bf),
C64e(0xa4e7ba31b470bfff), C64e(0x0d324405def8bc48),
C64e(0x3baefc3253bbd339), C64e(0x459fc3c1e0298ba0),
C64e(0xe5c905fdf7ae090f), C64e(0x947034124290f134),
C64e(0xa271b701e344ed95), C64e(0xe93b8e364f2f984a),
C64e(0x88401d63a06cf615), C64e(0x47c1444b8752afff),
C64e(0x7ebb4af1e20ac630), C64e(0x4670b6c5cc6e8ce6),
C64e(0xa4d5a456bd4fca00), C64e(0xda9d844bc83e18ae),
C64e(0x7357ce453064d1ad), C64e(0xe8a6ce68145c2567),
C64e(0xa3da8cf2cb0ee116), C64e(0x33e906589a94999a),
C64e(0x1f60b220c26f847b), C64e(0xd1ceac7fa0d18518),
C64e(0x32595ba18ddd19d3), C64e(0x509a1cc0aaa5b446),
C64e(0x9f3d6367e4046bba), C64e(0xf6ca19ab0b56ee7e),
C64e(0x1fb179eaa9282174), C64e(0xe9bdf7353b3651ee),
C64e(0x1d57ac5a7550d376), C64e(0x3a46c2fea37d7001),
C64e(0xf735c1af98a4d842), C64e(0x78edec209e6b6779),
C64e(0x41836315ea3adba8), C64e(0xfac33b4d32832c83),
C64e(0xa7403b1f1c2747f3), C64e(0x5940f034b72d769a),
C64e(0xe73e4e6cd2214ffd), C64e(0xb8fd8d39dc5759ef),
C64e(0x8d9b0c492b49ebda), C64e(0x5ba2d74968f3700d),
C64e(0x7d3baed07a8d5584), C64e(0xf5a5e9f0e4f88e65),
C64e(0xa0b8a2f436103b53), C64e(0x0ca8079e753eec5a),
C64e(0x9168949256e8884f), C64e(0x5bb05c55f8babc4c),
C64e(0xe3bb3b99f387947b), C64e(0x75daf4d6726b1c5d),
C64e(0x64aeac28dc34b36d), C64e(0x6c34a550b828db71),
C64e(0xf861e2f2108d512a), C64e(0xe3db643359dd75fc),
C64e(0x1cacbcf143ce3fa2), C64e(0x67bbd13c02e843b0),
C64e(0x330a5bca8829a175), C64e(0x7f34194db416535c),
C64e(0x923b94c30e794d1e), C64e(0x797475d7b6eeaf3f),
C64e(0xeaa8d4f7be1a3921), C64e(0x5cf47e094c232751),
C64e(0x26a32453ba323cd2), C64e(0x44a3174a6da6d5ad),
C64e(0xb51d3ea6aff2c908), C64e(0x83593d98916b3c56),
C64e(0x4cf87ca17286604d), C64e(0x46e23ecc086ec7f6),
C64e(0x2f9833b3b1bc765e), C64e(0x2bd666a5efc4e62a),
C64e(0x06f4b6e8bec1d436), C64e(0x74ee8215bcef2163),
C64e(0xfdc14e0df453c969), C64e(0xa77d5ac406585826),
C64e(0x7ec1141606e0fa16), C64e(0x7e90af3d28639d3f),
C64e(0xd2c9f2e3009bd20c), C64e(0x5faace30b7d40c30),
C64e(0x742a5116f2e03298), C64e(0x0deb30d8e3cef89a),
C64e(0x4bc59e7bb5f17992), C64e(0xff51e66e048668d3),
C64e(0x9b234d57e6966731), C64e(0xcce6a6f3170a7505),
C64e(0xb17681d913326cce), C64e(0x3c175284f805a262),
C64e(0xf42bcbb378471547), C64e(0xff46548223936a48),
C64e(0x38df58074e5e6565), C64e(0xf2fc7c89fc86508e),
C64e(0x31702e44d00bca86), C64e(0xf04009a23078474e),
C64e(0x65a0ee39d1f73883), C64e(0xf75ee937e42c3abd),
C64e(0x2197b2260113f86f), C64e(0xa344edd1ef9fdee7),
C64e(0x8ba0df15762592d9), C64e(0x3c85f7f612dc42be),
C64e(0xd8a7ec7cab27b07e), C64e(0x538d7ddaaa3ea8de),
C64e(0xaa25ce93bd0269d8), C64e(0x5af643fd1a7308f9),
C64e(0xc05fefda174a19a5), C64e(0x974d66334cfd216a),
C64e(0x35b49831db411570), C64e(0xea1e0fbbedcd549b),
C64e(0x9ad063a151974072), C64e(0xf6759dbf91476fe2)
};
#define Ceven_hi(r) (C[((r) << 2) + 0])
@@ -185,6 +222,17 @@ static const __constant ulong C[] =
x ## l = t; \
} while (0)
__constant static const sph_u64 JH_IV512[] = {
C64e(0x6fd14b963e00aa17), C64e(0x636a2e057a15d543),
C64e(0x8a225e8d0c97ef0b), C64e(0xe9341259f2b3c361),
C64e(0x891da0c1536f801e), C64e(0x2aa9056bea2b6d80),
C64e(0x588eccdb2075baa6), C64e(0xa90f3a76baf83bf7),
C64e(0x0169e60541e34a69), C64e(0x46b58a8e2e6fe65a),
C64e(0x1047a7d0c1843c24), C64e(0x3b6e71b12d5ac199),
C64e(0xcf57f6ec9db1f856), C64e(0xa706887c5716b156),
C64e(0xe3c2fcdfe68517fb), C64e(0x545a4678cc8cdd4b)
};
#define SL(ro) SLu(r + ro, ro)
#define SLu(r, ro) do { \
+1 -1
View File
@@ -29,7 +29,7 @@ extern int opt_log_level;
extern int opt_log_show_date;
#define LOGBUFSIZ 512
#define LOGBUFSIZ 8192
void applog(int prio, const char* fmt, ...);
void applogsiz(int prio, int size, const char* fmt, ...);
+43 -29
View File
@@ -527,6 +527,18 @@ struct sgminer_pool_stats {
uint64_t net_bytes_received;
};
typedef struct _gpu_sysfs_info
{
char *HWMonPath;
uint32_t MinFanSpeed;
uint32_t MaxFanSpeed;
uint32_t TgtFanSpeed;
uint32_t OverHeatTemp;
uint32_t LastFanSpeed;
uint32_t TargetTemp;
float LastTemp;
} gpu_sysfs_info;
struct cgpu_info {
int sgminer_id;
struct device_drv *drv;
@@ -576,10 +588,10 @@ struct cgpu_info {
float temp;
int cutofftemp;
#ifdef HAVE_ADL
bool has_adl;
struct gpu_adl adl;
gpu_sysfs_info sysfs_info;
int gpu_engine;
int min_engine;
int gpu_fan;
@@ -588,7 +600,9 @@ struct cgpu_info {
int gpu_memdiff;
int gpu_powertune;
float gpu_vddc;
#endif
bool has_sysfs_hwcontrols;
double diff1;
double diff_accepted;
double diff_rejected;
@@ -1086,6 +1100,21 @@ extern int swork_id;
extern int opt_tcp_keepalive;
extern bool opt_incognito;
extern float (*gpu_temp)(int);
extern int (*gpu_engineclock)(int);
extern int (*gpu_memclock)(int);
extern float (*gpu_vddc)(int);
extern int (*gpu_activity)(int);
extern int (*gpu_fanspeed)(int);
extern int (*gpu_fanpercent)(int);
extern int (*set_powertune)(int, int);
extern int (*set_fanspeed)(int, int);
extern int (*set_vddc)(int, float);
extern int (*set_engineclock)(int, int);
extern int (*set_memoryclock)(int, int);
extern bool (*gpu_stats)(int, float *, int *, int *, float *, int *, int *, int *, int *);
extern void (*gpu_autotune) (int, enum dev_enable *);
// Xn Algorithm options
extern int opt_keccak_unroll;
extern bool opt_blake_compact;
@@ -1144,14 +1173,6 @@ extern void kill_work(void);
extern void reinit_device(struct cgpu_info *cgpu);
#ifdef HAVE_ADL
extern bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc, int *activity, int *fanspeed, int *fanpercent, int *powertune);
extern int set_fanspeed(int gpu, int iFanSpeed);
extern int set_vddc(int gpu, float fVddc);
extern int set_engineclock(int gpu, int iEngineClock);
extern int set_memoryclock(int gpu, int iMemoryClock);
#endif
extern void api(int thr_id);
extern struct pool *current_pool(void);
@@ -1272,7 +1293,7 @@ struct stratum_work {
char *nbit;
char *ntime;
bool clean;
size_t cb_len;
size_t header_len;
int merkles;
@@ -1302,14 +1323,8 @@ struct pool {
uint32_t EpochNumber;
uint8_t Target[32];
uint8_t EthWork[32];
uint8_t NetDiff[32];
//XMR stuff
char XMRAuthID[64];
uint32_t XMRTarget;
uint8_t XMRBlob[76];
pthread_mutex_t XMRGlobalNonceLock;
uint32_t XMRGlobalNonce;
double diff_accepted;
double diff_rejected;
double diff_stale;
@@ -1430,6 +1445,9 @@ struct pool {
size_t gbt_txns;
size_t coinbase_len;
/* equihash GBT */
unsigned char reserved[32];
/* Shared by both stratum & GBT */
unsigned char *coinbase;
size_t nonce2_offset;
@@ -1454,26 +1472,22 @@ struct work {
unsigned char seedhash[32];
unsigned char hash[32];
unsigned char mixhash[32];
unsigned char device_target[32];
double device_diff;
double share_diff;
double network_diff;
uint32_t EpochNumber;
uint64_t Nonce;
/* cryptonight stuff */
uint32_t XMRTarget;
uint8_t XMRBlob[76];
uint32_t XMRNonce;
unsigned char equihash_data[1487];
int rolls;
int drv_rolllimit; /* How much the driver can roll ntime */
dev_blk_ctx blk;
struct thr_info *thr;
int thr_id;
struct pool *pool;
+108 -97
View File
@@ -38,6 +38,7 @@
#include "algorithm/pluck.h"
#include "algorithm/yescrypt.h"
#include "algorithm/lyra2rev2.h"
#include "kernel/equihash-param.h"
/* FIXME: only here for global config vars, replace with configuration.h
* or similar as soon as config is in a struct instead of littered all
@@ -45,6 +46,11 @@
*/
#include "miner.h"
#define CL_SET_ARG_N(n, var) do { status |= clSetKernelArg(*kernel, n, sizeof(var), (void *)&var); } while (0)
#define CL_SET_ARG(var) CL_SET_ARG_N(num++, var)
int opt_platform_id = -1;
bool get_opencl_platform(int preferred_platform_id, cl_platform_id *platform) {
@@ -180,37 +186,6 @@ static cl_int create_opencl_command_queue(cl_command_queue *command_queue, cl_co
return status;
}
// Borrowed from driver-opencl.c
static void set_threads_hashes(unsigned int vectors, unsigned int compute_shaders, size_t *globalThreads,
unsigned int minthreads, __maybe_unused int *intensity, __maybe_unused int *xintensity,
__maybe_unused int *rawintensity, algorithm_t *algorithm)
{
unsigned int threads = 0;
while (threads < minthreads) {
if (*rawintensity > 0) {
threads = *rawintensity;
}
else if (*xintensity > 0) {
threads = compute_shaders * ((algorithm->xintensity_shift) ? (1 << (algorithm->xintensity_shift + *xintensity)) : *xintensity);
}
else {
threads = 1 << (algorithm->intensity_shift + *intensity);
}
if (threads < minthreads) {
if (likely(*intensity < MAX_INTENSITY)) {
(*intensity)++;
}
else {
threads = minthreads;
}
}
}
*globalThreads = threads;
}
_clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *algorithm)
{
cl_int status = 0;
@@ -264,19 +239,16 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
applog(LOG_INFO, "\t%i\t%s", i, pbuff[i]);
}
applog(LOG_INFO, "Selected %d: %s", gpu, pbuff[gpu]);
strncpy(name, pbuff[gpu], nameSize);
status = create_opencl_context(&clState->context, &platform);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Creating Context. (clCreateContextFromType)", status);
return NULL;
}
applog(LOG_DEBUG, "Inside initCl.");
status = create_opencl_command_queue(&clState->commandQueue, &clState->context, &devices[gpu], cgpu->algorithm.cq_properties);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Creating Command Queue. (clCreateCommandQueue)", status);
@@ -756,7 +728,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
return NULL;
}
// If it doesn't work, oh well, build it again next run
// If it doesn't work, oh well, build it again next run
save_opencl_kernel(build_data, clState->program);
}
@@ -765,39 +737,115 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
filename, algorithm->nfactor, algorithm->n);
/* get a kernel object handle for a kernel with the given name */
clState->kernel = clCreateKernel(clState->program, "search", &status);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Creating Kernel from program. (clCreateKernel)", status);
if (algorithm->type == ALGO_EQUIHASH) {
clState->kernel = clCreateKernel(clState->program, "kernel_sols", &status);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Creating Kernel \"kernel_sols\" from program. (clCreateKernel)", status);
return NULL;
}
char *kernel_names[] = {"kernel_init_ht",
"kernel_round0", "kernel_round1", "kernel_round2",
"kernel_round3", "kernel_round4", "kernel_round5",
"kernel_round6", "kernel_round7", "kernel_round8"};
clState->n_extra_kernels = 1 + 9;
clState->extra_kernels = (cl_kernel *)malloc(sizeof(cl_kernel) * clState->n_extra_kernels);
for (int i = 0; i < clState->n_extra_kernels; i++) {
clState->extra_kernels[i] = clCreateKernel(clState->program, kernel_names[i], &status);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Creating Kernel \"%s\" from program. (clCreateKernel)", status, kernel_names[i]);
return NULL;
}
}
char buffer[32];
clState->CLbuffer0 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, HT_SIZE, NULL, &status);
snprintf(buffer, sizeof(buffer), "CLbuffer0");
if (status != CL_SUCCESS)
goto out;
clState->buffer1 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, HT_SIZE, NULL, &status);
snprintf(buffer, sizeof(buffer), "buffer1");
if (status != CL_SUCCESS)
goto out;
clState->buffer2 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, NR_ROWS, NULL, &status);
snprintf(buffer, sizeof(buffer), "buffer2");
if (status != CL_SUCCESS)
goto out;
clState->buffer3 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, NR_ROWS, NULL, &status);
snprintf(buffer, sizeof(buffer), "buffer3");
if (status != CL_SUCCESS)
goto out;
clState->padbuffer8 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, 2 * sizeof(uint32_t), NULL, &status);
snprintf(buffer, sizeof(buffer), "padbuffer8");
if (status != CL_SUCCESS)
goto out;
clState->MidstateBuf = clCreateBuffer(clState->context, CL_MEM_READ_ONLY, 140, NULL, &status); // TODO: decrease buffer size to 64 bytes
snprintf(buffer, sizeof(buffer), "MidstateBuf");
if (status != CL_SUCCESS)
goto out;
clState->outputBuffer = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, MAX(sizeof(sols_t), BUFFERSIZE), NULL, &status);
snprintf(buffer, sizeof(buffer), "outputBuffer");
if (status != CL_SUCCESS)
goto out;
unsigned int num = 0;
cl_kernel *kernel = &clState->kernel;
CL_SET_ARG(clState->CLbuffer0);
CL_SET_ARG(clState->buffer1);
CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(clState->buffer2);
CL_SET_ARG(clState->buffer3);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Setting Kernel arguments for ALGO_EQUIHASH failed. (clSetKernelArg)", status);
return NULL;
}
clState->devid = cgpu->device_id;
return clState;
out:
applog(LOG_ERR, "Error %d: Creating Buffer \"%s\" failed. (clCreateBuffer)", status, buffer);
return NULL;
}
else {
clState->kernel = clCreateKernel(clState->program, "search", &status);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Creating Kernel from program. (clCreateKernel)", status);
return NULL;
}
// Load kernels
applog(LOG_NOTICE, "Initialising kernel %s with params N=%d, K=%d",
filename, algorithm->nfactor, algorithm->kfactor);
clState->n_extra_kernels = algorithm->n_extra_kernels;
if (clState->n_extra_kernels > 0) {
unsigned int i;
char kernel_name[9]; // max: search99 + 0x0
clState->extra_kernels = (cl_kernel *)malloc(sizeof(cl_kernel)* clState->n_extra_kernels);
for (i = 0; i < clState->n_extra_kernels; i++) {
snprintf(kernel_name, 9, "%s%d", "search", i + 1);
clState->extra_kernels[i] = clCreateKernel(clState->program, kernel_name, &status);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Creating ExtraKernel #%d from program. (clCreateKernel)", status, i);
return NULL;
}
}
}
}
if(algorithm->type == ALGO_ETHASH)
{
clState->GenerateDAG = clCreateKernel(clState->program, "GenerateDAG", &status);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d while creating DAG generation kernel.", status);
return(NULL);
}
}
clState->n_extra_kernels = algorithm->n_extra_kernels;
if (clState->n_extra_kernels > 0) {
unsigned int i;
char kernel_name[9]; // max: search99 + 0x0
clState->extra_kernels = (cl_kernel *)malloc(sizeof(cl_kernel)* clState->n_extra_kernels);
for (i = 0; i < clState->n_extra_kernels; i++) {
snprintf(kernel_name, 9, "%s%d", "search", i + 1);
clState->extra_kernels[i] = clCreateKernel(clState->program, kernel_name, &status);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Creating ExtraKernel #%d from program. (clCreateKernel)", status, i);
return NULL;
}
}
}
size_t bufsize;
size_t buf1size;
@@ -925,56 +973,19 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
return NULL;
}
}
if(algorithm->type == ALGO_ETHASH)
{
readbufsize = 32UL;
clState->DAG = clState->EthCache = NULL;
}
if(algorithm->type == ALGO_CRYPTONIGHT)
{
size_t GlobalThreads;
readbufsize = 76UL;
set_threads_hashes(1, clState->compute_shaders, &GlobalThreads, 1, &cgpu->intensity, &cgpu->xintensity, &cgpu->rawintensity, &cgpu->algorithm);
for(int i = 0; i < 4; ++i)
{
clState->BranchBuffer[i] = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, sizeof(cl_uint) * (GlobalThreads + 2), NULL, &status);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d when creating branch buffer %d.\n", status, i);
return NULL;
}
}
clState->States = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, 200 * GlobalThreads, NULL, &status);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d when creating Cryptonight state buffer.\n", status);
return NULL;
}
clState->Scratchpads = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, (1 << 21) * GlobalThreads, NULL, &status);
if(status != CL_SUCCESS)
{
applog(LOG_ERR, "Error %d when creating Cryptonight scratchpads buffer.\n", status);
return NULL;
}
}
applog(LOG_DEBUG, "Using read buffer sized %lu", (unsigned long)readbufsize);
clState->CLbuffer0 = clCreateBuffer(clState->context, CL_MEM_READ_ONLY, readbufsize, NULL, &status);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: clCreateBuffer (CLbuffer0)", status);
return NULL;
}
clState->devid = cgpu->device_id;
applog(LOG_DEBUG, "Using output buffer sized %lu", BUFFERSIZE);
+1 -3
View File
@@ -27,12 +27,10 @@ typedef struct __clState {
cl_uint EpochNumber;
cl_mem MidstateBuf;
cl_mem padbuffer8;
cl_mem BranchBuffer[4];
cl_mem Scratchpads;
cl_mem States;
cl_mem buffer1;
cl_mem buffer2;
cl_mem buffer3;
cl_mem index_buf[9];
unsigned char cldata[168];
bool goffset;
cl_uint vwidth;
+456 -316
View File
File diff suppressed because it is too large. Load diff
+319 -217
View File
@@ -1263,6 +1263,10 @@ static enum send_ret __stratum_send(struct pool *pool, char *s, ssize_t len)
SOCKETTYPE sock = pool->sock;
ssize_t ssent = 0;
if (opt_protocol) {
applog(LOG_DEBUG, "SEND: %s", s);
}
strcat(s, "\n");
len++;
@@ -1304,9 +1308,6 @@ bool stratum_send(struct pool *pool, char *s, ssize_t len)
{
enum send_ret ret = SEND_INACTIVE;
if (opt_protocol)
applog(LOG_DEBUG, "SEND: %s", s);
mutex_lock(&pool->stratum_lock);
if (pool->stratum_active)
ret = __stratum_send(pool, s, len);
@@ -1504,8 +1505,166 @@ static char *json_array_string(json_t *val, unsigned int entry)
static char *blank_merkel = "0000000000000000000000000000000000000000000000000000000000000000";
static bool parse_notify_equihash(struct pool *pool, json_t *val)
{
char *job_id, *prev_hash, *reserved, *bbversion, *nbit, *ntime, *header, *merkle;
size_t cb1_len, cb2_len, alloc_len;
unsigned char *cb1, *cb2;
bool clean, invalid, ret = false;
int merkles, i;
json_t *arr = NULL;
job_id = json_array_string(val, 0);
merkles = 1;
bbversion = json_array_string(val, 1);
prev_hash = json_array_string(val, 2);
merkle = json_array_string(val, 3);
reserved = json_array_string(val, 4);
ntime = json_array_string(val, 5);
nbit = json_array_string(val, 6);
clean = json_is_true(json_array_get(val, 7));
if (!job_id || !prev_hash || !merkle || !reserved || !bbversion || !nbit || !ntime) {
goto out;
}
applog(LOG_DEBUG, "Valid Notify");
cg_wlock(&pool->data_lock);
free(pool->swork.job_id);
free(pool->swork.prev_hash);
free(pool->swork.bbversion);
free(pool->swork.nbit);
free(pool->swork.ntime);
pool->swork.job_id = job_id;
pool->swork.prev_hash = prev_hash;
cb1_len = 0;
cb2_len = 0;
pool->swork.bbversion = bbversion;
pool->swork.nbit = nbit;
pool->swork.ntime = ntime;
pool->swork.clean = clean;
if (pool->next_diff > 0) {
pool->swork.diff = pool->next_diff;
}
if (clean) {
pool->nonce2 = 0;
}
pool->merkle_offset = strlen(pool->swork.bbversion) + strlen(pool->swork.prev_hash);
pool->swork.header_len = (pool->merkle_offset / 2) +
/* merkle_hash */ 32 +
/* reserved */ 32 +
(strlen(pool->swork.ntime) / 2) +
(strlen(pool->swork.nbit) / 2) +
/* partial nonce */ 20;
pool->merkle_offset /= 2;
pool->swork.header_len = pool->swork.header_len * 2 + 1;
applog(LOG_DEBUG, "%s: pool->swork.header_len = %d", __func__, pool->swork.header_len);
align_len(&pool->swork.header_len);
if ((header = (char *)malloc(pool->swork.header_len)) == NULL) {
quithere(1, "%s: Failed to malloc header.", __func__);
}
snprintf(header, pool->swork.header_len,
"%s%s%s%s%s%s%s",
pool->swork.bbversion,
pool->swork.prev_hash,
merkle,
reserved,
pool->swork.ntime,
pool->swork.nbit,
"0000000000000000000000000000000000000000" /* partial empty nonce just to pad */
);
if (unlikely(!hex2bin(pool->header_bin, header, 128))) {
applog(LOG_WARNING, "%s: Failed to convert header to header_bin, got %s", __func__, header);
cg_wunlock(&pool->data_lock);
pool_failed(pool);
goto out;
}
/* A notify message is the closest stratum gets to a getwork */
pool->getwork_requested++;
total_getworks++;
cg_wunlock(&pool->data_lock);
ret = true;
if (pool == current_pool()) {
opt_work_update = true;
}
if (opt_protocol) {
applog(LOG_DEBUG, "job_id: %s", job_id);
applog(LOG_DEBUG, "version: %s", bbversion);
applog(LOG_DEBUG, "prev_hash: %s", prev_hash);
applog(LOG_DEBUG, "merkle: %s", merkle);
applog(LOG_DEBUG, "reserved: %s", reserved);
applog(LOG_DEBUG, "nbit: %s", nbit);
applog(LOG_DEBUG, "ntime: %s", ntime);
applog(LOG_DEBUG, "clean: %s", clean ? "yes" : "no");
}
out:
/* Annoying but we must not leak memory */
//only free these if we failed
if (!ret) {
if (job_id != NULL) {
free(job_id);
}
if (prev_hash != NULL) {
free(prev_hash);
}
if (reserved != NULL) {
free(reserved);
}
if (merkle != NULL) {
free(merkle);
}
if (bbversion != NULL) {
free(bbversion);
}
if (nbit != NULL) {
free(nbit);
}
if (ntime != NULL) {
free(ntime);
}
}
if (header != NULL) {
free(header);
}
return ret;
}
static bool parse_notify(struct pool *pool, json_t *val)
{
if (pool->algorithm.type == ALGO_EQUIHASH) {
return parse_notify_equihash(pool, val);
}
char *job_id, *prev_hash, *coinbase1, *coinbase2, *bbversion, *nbit,
*ntime, *header;
size_t cb1_len, cb2_len, alloc_len;
@@ -1724,6 +1883,7 @@ static bool parse_notify_ethash(struct pool *pool, json_t *val)
ret &= parse_diff_ethash(Target, TgtStr);
if (!ret || (NetDiffStr != NULL && !parse_diff_ethash(NetDiff, NetDiffStr))) {
ret = false;
goto out;
}
@@ -1746,9 +1906,8 @@ static bool parse_notify_ethash(struct pool *pool, json_t *val)
pool->diff1 = 0;
if (NetDiffStr != NULL) {
uint8_t tmp[32];
swab256(tmp, NetDiff);
pool->diff1 = eth2pow256 / le256todouble(tmp);
swab256(pool->NetDiff, NetDiff);
pool->diff1 = eth2pow256 / le256todouble(pool->NetDiff);
}
pool->getwork_requested++;
@@ -1781,83 +1940,6 @@ out:
return ret;
}
bool parse_notify_cn(struct pool *pool, json_t *val)
{
char *job_id = NULL;
bool clean;
uint32_t XMRTarget;
uint8_t XMRBlob[76];
int ret = true;
/*json_t *arr = json_array_get(val, 0);
if (!arr || !json_is_array(arr)) {
applog(LOG_DEBUG, "parse_notify_ethash: Array was bad.");
ret = false;
goto out;
}*/
applog(LOG_DEBUG, "parse_notify_cn()");
json_t *blob, *jid, *target;
blob = json_object_get(val, "blob");
jid = json_object_get(val, "job_id");
target = json_object_get(val, "target");
if(!blob || !jid || !target)
{
applog(LOG_DEBUG, "parse_notify_cn: bad params.");
ret = false;
goto out;
}
const char *blobval = json_string_value(blob);
if (!hex2bin(XMRBlob, blobval, 76)) {
ret = false;
goto out;
}
job_id = json_string_value(jid);
XMRTarget = bswap_32(strtoul(json_string_value(target), NULL, 16));
cg_wlock(&pool->data_lock);
if (pool->swork.job_id != NULL) {
free(pool->swork.job_id);
}
pool->swork.job_id = strdup(job_id);
pool->swork.clean = true;
memcpy(pool->XMRBlob, XMRBlob, 76);
pool->XMRTarget = XMRTarget;
pool->swork.diff = (double)0xffffffff / XMRTarget;
pool->getwork_requested++;
cg_wunlock(&pool->data_lock);
mutex_lock(&pool->XMRGlobalNonceLock);
pool->XMRGlobalNonce = 0;
mutex_unlock(&pool->XMRGlobalNonceLock);
if (opt_protocol) {
applog(LOG_DEBUG, "job_id: %s", job_id);
applog(LOG_DEBUG, "Blob: %s", blobval);
applog(LOG_DEBUG, "Target: %08x", XMRTarget);
applog(LOG_DEBUG, "Share diff: %.2f", pool->swork.diff);
}
/* A notify message is the closest stratum gets to a getwork */
total_getworks++;
if (pool == current_pool())
opt_work_update = true;
out:
/* Annoying but we must not leak memory */
if (job_id != NULL)
free(job_id);
return ret;
}
static bool parse_diff(struct pool *pool, json_t *val)
{
double old_diff, diff;
@@ -1897,8 +1979,67 @@ static bool parse_diff(struct pool *pool, json_t *val)
return true;
}
static bool parse_target(struct pool *pool, json_t *val)
{
uint8_t oldtarget[32], target[32], *str;
if ((str = json_array_string(val, 0)) == NULL) {
applog(LOG_DEBUG, "parse_target: Missing an array value.");
return false;
}
hex2bin(target, str, 32);
cg_wlock(&pool->data_lock);
memcpy(oldtarget, pool->Target, 32);
swab256(pool->Target, target);
cg_wunlock(&pool->data_lock);
if (memcmp(oldtarget, target, 32) != 0) {
applog(pool == current_pool() ? LOG_NOTICE : LOG_DEBUG, "%s target changed to %s", get_pool_name(pool), str);
}
if (str != NULL) {
free(str);
}
return true;
}
static bool parse_extranonce_equihash(struct pool *pool, json_t *val)
{
char *n1str;
if (!(n1str = json_array_string(val, 1))) {
return false;
}
cg_wlock(&pool->data_lock);
free(pool->nonce1);
pool->nonce1 = n1str;
pool->n1_len = strlen(n1str) / 2; //size in bytes of nonce1 in the header
free(pool->nonce1bin);
if (unlikely(!(pool->nonce1bin = (unsigned char *)calloc(pool->n1_len, 1)))) {
quithere(1, "%s: Failed to calloc pool->nonce1bin", __func__);
}
hex2bin(pool->nonce1bin, pool->nonce1, pool->n1_len);
pool->n2size = 64 - pool->n1_len; //size in bytes of nonce2 in the header
pool->nonce2 = 0; //reset nonce 2 to 0
cg_wunlock(&pool->data_lock);
applog(LOG_NOTICE, "%s extranonce set to %s", get_pool_name(pool), n1str);
return true;
}
static bool parse_extranonce(struct pool *pool, json_t *val)
{
if (pool->algorithm.type == ALGO_EQUIHASH) {
return parse_extranonce_equihash(pool, val);
}
char *nonce1;
int n2size;
@@ -2017,9 +2158,7 @@ bool parse_method(struct pool *pool, char *s)
json_error_t err;
bool ret = false;
char *buf;
if (!s) {
return ret;
}
@@ -2028,71 +2167,52 @@ bool parse_method(struct pool *pool, char *s)
applog(LOG_INFO, "JSON decode failed(%d): %s", err.line, err.text);
return ret;
}
if (!(method = json_object_get(val, "method"))) {
goto done;
}
params = json_object_get(val, "params");
// Ethash Stratum sends no error
params = json_object_get(val, "params");
// Ethash Stratum sends no error
if(pool->algorithm.type != ALGO_ETHASH)
{
err_val = json_object_get(val, "error");
err_val = json_object_get(val, "error");
if (err_val && !json_is_null(err_val)) {
char *ss;
if (err_val) {
ss = json_dumps(err_val, JSON_INDENT(3));
}
else {
ss = strdup("(unknown reason)");
}
applog(LOG_INFO, "JSON-RPC method decode failed: %s", ss);
free(ss);
goto done;
}
}
if (err_val && !json_is_null(err_val)) {
char *ss;
if (err_val) {
ss = json_dumps(err_val, JSON_INDENT(3));
}
else {
ss = strdup("(unknown reason)");
}
applog(LOG_INFO, "JSON-RPC method decode failed: %s", ss);
free(ss);
goto done;
}
}
buf = (char *)json_string_value(method);
if (!buf) {
goto done;
}
applog(LOG_DEBUG, "We made it to parse_method()!");
if (!strncasecmp(buf, "mining.notify", 13))
{
if(pool->algorithm.type == ALGO_ETHASH)
{
if (parse_notify_ethash(pool, params)) pool->stratum_notify = ret = true;
else pool->stratum_notify = ret = false;
goto done;
}
else
{
if(parse_notify(pool, params)) pool->stratum_notify = ret = true;
else pool->stratum_notify = ret = false;
goto done;
}
}
//cryptonight uses the "job" method instead of mining.notify
if (pool->algorithm.type == ALGO_CRYPTONIGHT) {
if (!strncasecmp(buf, "job", 3)) {
if (parse_notify_cn(pool, params)) {
pool->stratum_notify = ret = true;
}
else {
pool->stratum_notify = ret = false;
}
goto done;
applog(LOG_DEBUG, "We made it to parse_method()!");
if (!strncasecmp(buf, "mining.notify", 13)) {
if (pool->algorithm.type == ALGO_ETHASH) {
ret = parse_notify_ethash(pool, params);
}
else {
ret = parse_notify(pool, params);
}
pool->stratum_notify = ret;
goto done;
}
if (!strncasecmp(buf, "mining.set_difficulty", 21) && parse_diff(pool, params)) {
@@ -2120,8 +2240,13 @@ applog(LOG_DEBUG, "We made it to parse_method()!");
goto done;
}
if (!strncasecmp(buf, "mining.set_target", 17) && parse_target(pool, params)) {
ret = true;
goto done;
}
done:
//json_decref(val);
json_decref(val);
return ret;
}
@@ -2201,22 +2326,13 @@ out:
bool auth_stratum(struct pool *pool)
{
json_t *val = NULL, *res_val, *err_val, *res_id, *res_job;
json_t *val = NULL, *res_val, *err_val;
char s[RBUFSIZE], *sret = NULL;
json_error_t err;
bool ret = false;
if (pool->algorithm.type == ALGO_CRYPTONIGHT) {
sprintf(s, "{\"method\": \"login\", \"params\": {\"login\": \"%s\", \"pass\": \"%s\", \"agent\": \"%s/%s\"}, \"id\": 1}",
pool->rpc_user, pool->rpc_pass, PACKAGE, VERSION);
swork_id++;
}
else {
sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}",
swork_id++, pool->rpc_user, pool->rpc_pass);
}
sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}",
swork_id++, pool->rpc_user, pool->rpc_pass);
if (!stratum_send(pool, s, strlen(s))) {
return ret;
@@ -2256,34 +2372,14 @@ bool auth_stratum(struct pool *pool)
goto out;
}
//check if the result contains an id... if so then we need to process as first job
if (pool->algorithm.type == ALGO_CRYPTONIGHT) {
if ((res_id = json_object_get(res_val, "id"))) {
cg_wlock(&pool->data_lock);
strcpy(pool->XMRAuthID, json_string_value(res_id));
applog(LOG_DEBUG, "XMR AuthID: %s", pool->XMRAuthID);
cg_wunlock(&pool->data_lock);
//get the job object and send to parse notify
if ((res_job = json_object_get(res_val, "job"))) {
if (parse_notify_cn(pool, res_job)) {
pool->stratum_notify = true;
}
else {
goto out;
}
}
}
}
ret = true;
applog(LOG_INFO, "Stratum authorisation success for %s", get_pool_name(pool));
pool->probed = true;
successful_connect = true;
out:
//json_decref(val);
json_decref(val);
return ret;
}
@@ -2729,26 +2825,7 @@ resend:
sockd = false;
goto out;
}
//Cryptonight doesn't subscribe...
if(pool->algorithm.type == ALGO_CRYPTONIGHT)
{
if (!pool->stratum_url) {
pool->stratum_url = pool->sockaddr_url;
}
pool->stratum_active = true;
pool->next_diff = 0;
pool->swork.diff = 1;
pool->sessionid = NULL;
pool->nonce1 = NULL;
pool->n1_len = 0;
json_decref(val);
return true;
}
sockd = true;
if (recvd) {
@@ -2756,10 +2833,17 @@ resend:
clear_sock(pool);
sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++);
} else {
if (pool->sessionid)
if (pool->sessionid) {
sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"CGMINER_VERSION"\", \"%s\"]}", swork_id++, pool->sessionid);
else
sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"CGMINER_VERSION"\"]}", swork_id++);
}
else {
if (pool->algorithm.type == ALGO_EQUIHASH) {
sprintf(s, "{\"id\":%d, \"method\":\"mining.subscribe\", \"params\":[\""PACKAGE"/"CGMINER_VERSION"\", null, \"%s\", \"%s\"]}", swork_id++, pool->sockaddr_url, pool->stratum_port);
}
else {
sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"CGMINER_VERSION"\"]}", swork_id++);
}
}
}
if (__stratum_send(pool, s, strlen(s)) != SEND_OK) {
@@ -2804,31 +2888,41 @@ resend:
goto out;
}
if(pool->algorithm.type == ALGO_ETHASH)
{
if(!pool->stratum_url) pool->stratum_url = pool->sockaddr_url;
pool->stratum_active = true;
pool->next_diff = 0;
pool->swork.diff = 1;
pool->sessionid = NULL;
pool->nonce1 = NULL;
pool->n1_len = 0;
json_decref(val);
return true;
}
if(pool->algorithm.type == ALGO_ETHASH)
{
if(!pool->stratum_url) pool->stratum_url = pool->sockaddr_url;
pool->stratum_active = true;
pool->next_diff = 0;
pool->swork.diff = 1;
pool->sessionid = NULL;
pool->nonce1 = NULL;
pool->n1_len = 0;
json_decref(val);
return true;
}
else if (pool->algorithm.type == ALGO_EQUIHASH) {
if (!(ret = parse_extranonce(pool, res_val))) {
applog(LOG_DEBUG, "%s: Failed to get parse extranonce.", __func__);
}
goto out;
}
sessionid = get_sessionid(res_val);
if (!sessionid)
if (!sessionid) {
applog(LOG_DEBUG, "Failed to get sessionid in initiate_stratum");
}
nonce1 = json_array_string(res_val, 1);
if (!nonce1) {
applog(LOG_INFO, "Failed to get nonce1 in initiate_stratum");
free(sessionid);
goto out;
}
n2size = json_integer_value(json_array_get(res_val, 2));
if (n2size < 1)
{
@@ -2841,21 +2935,29 @@ resend:
cg_wlock(&pool->data_lock);
free(pool->nonce1);
free(pool->sessionid);
pool->sessionid = sessionid;
pool->nonce1 = nonce1;
pool->n1_len = strlen(nonce1) / 2;
free(pool->nonce1bin);
pool->nonce1bin = (unsigned char *)calloc(pool->n1_len, 1);
if (unlikely(!pool->nonce1bin))
if (unlikely(!pool->nonce1bin)) {
quithere(1, "Failed to calloc pool->nonce1bin");
}
hex2bin(pool->nonce1bin, pool->nonce1, pool->n1_len);
pool->n2size = n2size;
cg_wunlock(&pool->data_lock);
if (sessionid)
if (sessionid) {
applog(LOG_DEBUG, "%s stratum session id: %s", get_pool_name(pool), pool->sessionid);
}
ret = true;
out:
if (ret) {
if (!pool->stratum_url)