Browse Source

Merge pull request #274 from Elbandi/v5_0

Remove unused enum diff_calc_mode from miner.h, make opt_algorithm a simple algorithm_t structure (not a pointer), use macros in queue_{darkcoin_mod,marucoin_mod,marucoin_mod_old}_kernel().
djm34
Noel Maersk 11 years ago
parent
commit
14d2b940f9
  1. 129
      algorithm.c
  2. 2
      driver-opencl.c
  3. 8
      miner.h
  4. 23
      sgminer.c

129
algorithm.c

@ -52,8 +52,13 @@ void gen_hash(const unsigned char *data, unsigned int len, unsigned char *hash)
} }
#define CL_SET_BLKARG(blkvar) status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->blkvar) #define CL_SET_BLKARG(blkvar) status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->blkvar)
#define CL_SET_ARG(var) status |= clSetKernelArg(*kernel, num++, sizeof(var), (void *)&var)
#define CL_SET_VARG(args, var) status |= clSetKernelArg(*kernel, num++, args * sizeof(uint), (void *)var) #define CL_SET_VARG(args, var) status |= clSetKernelArg(*kernel, num++, args * sizeof(uint), (void *)var)
#define CL_SET_ARG_N(n, var) do { status |= clSetKernelArg(*kernel, n, sizeof(var), (void *)&var); } while (0)
#define CL_SET_ARG_0(var) CL_SET_ARG_N(0, var)
#define CL_SET_ARG(var) CL_SET_ARG_N(num++, var)
#define CL_NEXTKERNEL_SET_ARG_N(n, var) do { kernel++; CL_SET_ARG_N(n, var); } while (0)
#define CL_NEXTKERNEL_SET_ARG_0(var) CL_NEXTKERNEL_SET_ARG_N(0, var)
#define CL_NEXTKERNEL_SET_ARG(var) CL_NEXTKERNEL_SET_ARG_N(num++, var)
static void append_scrypt_compiler_options(struct _build_kernel_data *data, struct cgpu_info *cgpu, struct _algorithm_t *algorithm) static void append_scrypt_compiler_options(struct _build_kernel_data *data, struct cgpu_info *cgpu, struct _algorithm_t *algorithm)
{ {
@ -150,44 +155,26 @@ static cl_int queue_darkcoin_mod_kernel(struct __clState *clState, struct _dev_b
CL_SET_ARG(clState->padbuffer8); CL_SET_ARG(clState->padbuffer8);
// bmw - search1 // bmw - search1
kernel = clState->extra_kernels; kernel = clState->extra_kernels;
num = 0; CL_SET_ARG_0(clState->padbuffer8);
CL_SET_ARG(clState->padbuffer8);
// groestl - search2 // groestl - search2
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// skein - search3 // skein - search3
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// jh - search4 // jh - search4
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// keccak - search5 // keccak - search5
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// luffa - search6 // luffa - search6
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// cubehash - search7 // cubehash - search7
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// shavite - search8 // shavite - search8
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// simd - search9 // simd - search9
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// echo - search10 // echo - search10
kernel++;
num = 0; num = 0;
CL_SET_ARG(clState->padbuffer8); CL_NEXTKERNEL_SET_ARG(clState->padbuffer8);
CL_SET_ARG(clState->outputBuffer); CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(le_target); CL_SET_ARG(le_target);
@ -212,52 +199,30 @@ static cl_int queue_marucoin_mod_kernel(struct __clState *clState, struct _dev_b
CL_SET_ARG(clState->padbuffer8); CL_SET_ARG(clState->padbuffer8);
// bmw - search1 // bmw - search1
kernel = clState->extra_kernels; kernel = clState->extra_kernels;
num = 0; CL_SET_ARG_0(clState->padbuffer8);
CL_SET_ARG(clState->padbuffer8);
// groestl - search2 // groestl - search2
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// skein - search3 // skein - search3
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// jh - search4 // jh - search4
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// keccak - search5 // keccak - search5
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// luffa - search6 // luffa - search6
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// cubehash - search7 // cubehash - search7
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// shavite - search8 // shavite - search8
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// simd - search9 // simd - search9
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// echo - search10 // echo - search10
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// hamsi - search11 // hamsi - search11
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// fugue - search12 // fugue - search12
kernel++;
num = 0; num = 0;
CL_SET_ARG(clState->padbuffer8); CL_NEXTKERNEL_SET_ARG(clState->padbuffer8);
CL_SET_ARG(clState->outputBuffer); CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(le_target); CL_SET_ARG(le_target);
@ -282,44 +247,26 @@ static cl_int queue_marucoin_mod_old_kernel(struct __clState *clState, struct _d
CL_SET_ARG(clState->padbuffer8); CL_SET_ARG(clState->padbuffer8);
// bmw - search1 // bmw - search1
kernel = clState->extra_kernels; kernel = clState->extra_kernels;
num = 0; CL_SET_ARG_0(clState->padbuffer8);
CL_SET_ARG(clState->padbuffer8);
// groestl - search2 // groestl - search2
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// skein - search3 // skein - search3
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// jh - search4 // jh - search4
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// keccak - search5 // keccak - search5
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// luffa - search6 // luffa - search6
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// cubehash - search7 // cubehash - search7
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// shavite - search8 // shavite - search8
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// simd - search9 // simd - search9
kernel++; CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8);
num = 0;
CL_SET_ARG(clState->padbuffer8);
// combined echo, hamsi, fugue - search10 // combined echo, hamsi, fugue - search10
kernel++;
num = 0; num = 0;
CL_SET_ARG(clState->padbuffer8); CL_NEXTKERNEL_SET_ARG(clState->padbuffer8);
CL_SET_ARG(clState->outputBuffer); CL_SET_ARG(clState->outputBuffer);
CL_SET_ARG(le_target); CL_SET_ARG(le_target);

2
driver-opencl.c

@ -1157,7 +1157,7 @@ static void opencl_detect(bool hotplug)
cgpu->threads = 1; cgpu->threads = 1;
#endif #endif
cgpu->virtual_gpu = i; cgpu->virtual_gpu = i;
cgpu->algorithm = *opt_algorithm; cgpu->algorithm = opt_algorithm;
add_cgpu(cgpu); add_cgpu(cgpu);
} }

8
miner.h

@ -990,7 +990,7 @@ extern int opt_queue;
extern int opt_scantime; extern int opt_scantime;
extern int opt_expiry; extern int opt_expiry;
extern algorithm_t *opt_algorithm; extern algorithm_t opt_algorithm;
extern cglock_t control_lock; extern cglock_t control_lock;
extern pthread_mutex_t hash_lock; extern pthread_mutex_t hash_lock;
@ -1463,10 +1463,4 @@ extern struct api_data *api_add_diff(struct api_data *root, char *name, double *
extern struct api_data *api_add_percent(struct api_data *root, char *name, double *data, bool copy_data); extern struct api_data *api_add_percent(struct api_data *root, char *name, double *data, bool copy_data);
extern struct api_data *api_add_avg(struct api_data *root, char *name, float *data, bool copy_data); extern struct api_data *api_add_avg(struct api_data *root, char *name, float *data, bool copy_data);
enum diff_calc_mode {
DM_BITCOIN,
DM_QUARKCOIN,
DM_LITECOIN,
};
#endif /* MINER_H */ #endif /* MINER_H */

23
sgminer.c

@ -98,7 +98,7 @@ int opt_queue = 1;
int opt_scantime = 7; int opt_scantime = 7;
int opt_expiry = 28; int opt_expiry = 28;
algorithm_t *opt_algorithm; algorithm_t opt_algorithm;
unsigned long long global_hashrate; unsigned long long global_hashrate;
unsigned long global_quota_gcd = 1; unsigned long global_quota_gcd = 1;
@ -528,7 +528,7 @@ struct pool *add_pool(void)
pool->name = strdup(buf); pool->name = strdup(buf);
/* Algorithm */ /* Algorithm */
pool->algorithm = *opt_algorithm; pool->algorithm = opt_algorithm;
pools = (struct pool **)realloc(pools, sizeof(struct pool *) * (total_pools + 2)); pools = (struct pool **)realloc(pools, sizeof(struct pool *) * (total_pools + 2));
pools[total_pools++] = pool; pools[total_pools++] = pool;
@ -1117,8 +1117,8 @@ static void load_temp_cutoffs()
static char *set_algo(const char *arg) static char *set_algo(const char *arg)
{ {
if ((json_array_index < 0) || (total_pools == 0)) { if ((json_array_index < 0) || (total_pools == 0)) {
set_algorithm(opt_algorithm, arg); set_algorithm(&opt_algorithm, arg);
applog(LOG_INFO, "Set default algorithm to %s", opt_algorithm->name); applog(LOG_INFO, "Set default algorithm to %s", opt_algorithm.name);
} else { } else {
set_pool_algorithm(arg); set_pool_algorithm(arg);
} }
@ -1129,9 +1129,9 @@ static char *set_algo(const char *arg)
static char *set_nfactor(const char *arg) static char *set_nfactor(const char *arg)
{ {
if ((json_array_index < 0) || (total_pools == 0)) { if ((json_array_index < 0) || (total_pools == 0)) {
set_algorithm_nfactor(opt_algorithm, (const uint8_t) atoi(arg)); set_algorithm_nfactor(&opt_algorithm, (const uint8_t) atoi(arg));
applog(LOG_INFO, "Set algorithm N-factor to %d (N to %d)", applog(LOG_INFO, "Set algorithm N-factor to %d (N to %d)",
opt_algorithm->nfactor, opt_algorithm->n); opt_algorithm.nfactor, opt_algorithm.n);
} else { } else {
set_pool_nfactor(arg); set_pool_nfactor(arg);
} }
@ -4414,7 +4414,7 @@ void write_config(FILE *fcfg)
if (strcmp(pool->description, "") != 0) { if (strcmp(pool->description, "") != 0) {
fprintf(fcfg, ",\n\t\t\"description\" : \"%s\"", json_escape(pool->description)); fprintf(fcfg, ",\n\t\t\"description\" : \"%s\"", json_escape(pool->description));
} }
if (!cmp_algorithm(&pool->algorithm, opt_algorithm)) { if (!cmp_algorithm(&pool->algorithm, &opt_algorithm)) {
fprintf(fcfg, ",\n\t\t\"algorithm\" : \"%s\"", json_escape(pool->algorithm.name)); fprintf(fcfg, ",\n\t\t\"algorithm\" : \"%s\"", json_escape(pool->algorithm.name));
} }
if (pool->prio != i) { if (pool->prio != i) {
@ -4591,8 +4591,8 @@ void write_config(FILE *fcfg)
} }
if (opt_removedisabled) if (opt_removedisabled)
fprintf(fcfg, ",\n\"remove-disabled\" : true"); fprintf(fcfg, ",\n\"remove-disabled\" : true");
if (strcmp(opt_algorithm->name, "scrypt") != 0) if (strcmp(opt_algorithm.name, "scrypt") != 0)
fprintf(fcfg, ",\n\"algorithm\" : \"%s\"", json_escape(opt_algorithm->name)); fprintf(fcfg, ",\n\"algorithm\" : \"%s\"", json_escape(opt_algorithm.name));
if (opt_api_allow) if (opt_api_allow)
fprintf(fcfg, ",\n\"api-allow\" : \"%s\"", json_escape(opt_api_allow)); fprintf(fcfg, ",\n\"api-allow\" : \"%s\"", json_escape(opt_api_allow));
if (strcmp(opt_api_mcast_addr, API_MCAST_ADDR) != 0) if (strcmp(opt_api_mcast_addr, API_MCAST_ADDR) != 0)
@ -7409,7 +7409,7 @@ static bool input_pool(bool live)
desc = curses_input("Description (optional)"); desc = curses_input("Description (optional)");
if (strcmp(desc, "-1") == 0) strcpy(desc, ""); if (strcmp(desc, "-1") == 0) strcpy(desc, "");
algo = curses_input("Algorithm (optional)"); algo = curses_input("Algorithm (optional)");
if (strcmp(algo, "-1") == 0) strcpy(algo, opt_algorithm->name); if (strcmp(algo, "-1") == 0) strcpy(algo, opt_algorithm.name);
pool = add_pool(); pool = add_pool();
@ -7919,8 +7919,7 @@ int main(int argc, char *argv[])
#endif #endif
/* Default algorithm specified in algorithm.c ATM */ /* Default algorithm specified in algorithm.c ATM */
opt_algorithm = (algorithm_t *)alloca(sizeof(algorithm_t)); set_algorithm(&opt_algorithm, "scrypt");
set_algorithm(opt_algorithm, "scrypt");
devcursor = 8; devcursor = 8;
logstart = devcursor + 1; logstart = devcursor + 1;

Loading…
Cancel
Save