Browse Source

More options added

Added the following options to profiles/pools:
device (set devices on/off per profile), lookup-gap, shaders, worksize,
gpu-powertune, gpu-vddc
djm34
ystarnaud 11 years ago committed by Noel Maersk
parent
commit
d9b4798e8e
  1. 2
      adl.c
  2. 1
      adl.h
  3. 522
      config_parser.c
  4. 24
      config_parser.h
  5. 23
      miner.h
  6. 314
      sgminer.c

2
adl.c

@ -1208,7 +1208,7 @@ int set_fanspeed(int gpu, int iFanSpeed)
} }
#ifdef HAVE_CURSES #ifdef HAVE_CURSES
static int set_powertune(int gpu, int iPercentage) int set_powertune(int gpu, int iPercentage)
{ {
struct gpu_adl *ga; struct gpu_adl *ga;
int dummy, ret = 1; int dummy, ret = 1;

1
adl.h

@ -15,6 +15,7 @@ float gpu_vddc(int gpu);
int gpu_activity(int gpu); int gpu_activity(int gpu);
int gpu_fanspeed(int gpu); int gpu_fanspeed(int gpu);
int gpu_fanpercent(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, bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc,
int *activity, int *fanspeed, int *fanpercent, int *powertune); int *activity, int *fanspeed, int *fanpercent, int *powertune);
void change_gpusettings(int gpu); void change_gpusettings(int gpu);

522
config_parser.c

@ -121,6 +121,18 @@ static struct profile *get_profile(char *name)
} }
/******* Default profile functions used during config parsing *****/ /******* Default profile functions used during config parsing *****/
char *set_default_devices(const char *arg)
{
default_profile.devices = arg;
return NULL;
}
char *set_default_lookup_gap(const char *arg)
{
default_profile.lookup_gap = arg;
return NULL;
}
char *set_default_intensity(const char *arg) char *set_default_intensity(const char *arg)
{ {
default_profile.intensity = arg; default_profile.intensity = arg;
@ -171,6 +183,18 @@ char *set_default_thread_concurrency(const char *arg)
return NULL; return NULL;
} }
char *set_default_gpu_powertune(const char *arg)
{
default_profile.gpu_powertune = arg;
return NULL;
}
char *set_default_gpu_vddc(const char *arg)
{
default_profile.gpu_vddc = arg;
return NULL;
}
#endif #endif
char *set_default_profile(char *arg) char *set_default_profile(char *arg)
@ -179,8 +203,20 @@ char *set_default_profile(char *arg)
return NULL; return NULL;
} }
char *set_default_shaders(const char *arg)
{
default_profile.shaders = arg;
return NULL;
}
char *set_default_worksize(const char *arg)
{
default_profile.worksize = arg;
return NULL;
}
/****** Profile functions used in during config parsing ********/ /****** Profile functions used in during config parsing ********/
char *set_profile_name(char *arg) char *set_profile_name(const char *arg)
{ {
struct profile *profile = get_current_profile(); struct profile *profile = get_current_profile();
@ -200,6 +236,20 @@ char *set_profile_algorithm(const char *arg)
return NULL; return NULL;
} }
char *set_profile_devices(const char *arg)
{
struct profile *profile = get_current_profile();
profile->devices = arg;
return NULL;
}
char *set_profile_lookup_gap(const char *arg)
{
struct profile *profile = get_current_profile();
profile->lookup_gap = arg;
return NULL;
}
char *set_profile_intensity(const char *arg) char *set_profile_intensity(const char *arg)
{ {
struct profile *profile = get_current_profile(); struct profile *profile = get_current_profile();
@ -258,6 +308,20 @@ char *set_profile_thread_concurrency(const char *arg)
return NULL; 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 #endif
char *set_profile_nfactor(const char *arg) char *set_profile_nfactor(const char *arg)
@ -270,6 +334,20 @@ char *set_profile_nfactor(const char *arg)
return NULL; return NULL;
} }
char *set_profile_shaders(const char *arg)
{
struct profile *profile = get_current_profile();
profile->shaders = arg;
return NULL;
}
char *set_profile_worksize(const char *arg)
{
struct profile *profile = get_current_profile();
profile->worksize = arg;
return NULL;
}
/*************************************** /***************************************
* Helper Functions * Helper Functions
****************************************/ ****************************************/
@ -562,6 +640,8 @@ void load_default_profile()
if((profile = get_profile(default_profile.name))) if((profile = get_profile(default_profile.name)))
{ {
default_profile.algorithm = profile->algorithm; default_profile.algorithm = profile->algorithm;
default_profile.devices = profile->devices;
default_profile.lookup_gap = profile->lookup_gap;
default_profile.intensity = profile->intensity; default_profile.intensity = profile->intensity;
default_profile.xintensity = profile->xintensity; default_profile.xintensity = profile->xintensity;
default_profile.rawintensity = profile->rawintensity; default_profile.rawintensity = profile->rawintensity;
@ -571,7 +651,11 @@ void load_default_profile()
default_profile.gpu_memclock = profile->gpu_memclock; default_profile.gpu_memclock = profile->gpu_memclock;
default_profile.gpu_threads = profile->gpu_threads; default_profile.gpu_threads = profile->gpu_threads;
default_profile.gpu_fan = profile->gpu_fan; default_profile.gpu_fan = profile->gpu_fan;
default_profile.gpu_powertune = profile->gpu_powertune;
default_profile.gpu_vddc = profile->gpu_vddc;
#endif #endif
default_profile.shaders = profile->shaders;
default_profile.worksize = profile->worksize;
} }
} }
} }
@ -581,31 +665,49 @@ void apply_defaults()
{ {
set_algorithm(opt_algorithm, default_profile.algorithm.name); set_algorithm(opt_algorithm, default_profile.algorithm.name);
if(!empty_string(default_profile.devices))
set_devices((char *)default_profile.devices);
if(!empty_string(default_profile.intensity)) if(!empty_string(default_profile.intensity))
set_intensity(default_profile.intensity); set_intensity(default_profile.intensity);
if(!empty_string(default_profile.xintensity)) if(!empty_string(default_profile.xintensity))
set_xintensity(default_profile.xintensity); set_xintensity(default_profile.xintensity);
if(!empty_string(default_profile.rawintensity)) if(!empty_string(default_profile.rawintensity))
set_rawintensity(default_profile.rawintensity); set_rawintensity(default_profile.rawintensity);
if(!empty_string(default_profile.thread_concurrency)) if(!empty_string(default_profile.lookup_gap))
set_thread_concurrency(default_profile.thread_concurrency); set_lookup_gap((char *)default_profile.lookup_gap);
if(!empty_string(default_profile.thread_concurrency))
set_thread_concurrency(default_profile.thread_concurrency);
#ifdef HAVE_ADL #ifdef HAVE_ADL
if(!empty_string(default_profile.gpu_engine)) if(!empty_string(default_profile.gpu_engine))
set_gpu_engine(default_profile.gpu_engine); set_gpu_engine(default_profile.gpu_engine);
if(!empty_string(default_profile.gpu_memclock)) if(!empty_string(default_profile.gpu_memclock))
set_gpu_memclock(default_profile.gpu_memclock); set_gpu_memclock(default_profile.gpu_memclock);
if(!empty_string(default_profile.gpu_threads)) if(!empty_string(default_profile.gpu_threads))
set_gpu_threads(default_profile.gpu_threads); set_gpu_threads(default_profile.gpu_threads);
if(!empty_string(default_profile.gpu_fan)) if(!empty_string(default_profile.gpu_fan))
set_gpu_fan(default_profile.gpu_fan); set_gpu_fan(default_profile.gpu_fan);
if(!empty_string(default_profile.gpu_powertune))
set_gpu_powertune((char *)default_profile.gpu_powertune);
if(!empty_string(default_profile.gpu_vddc))
set_gpu_vddc((char *)default_profile.gpu_vddc);
#endif #endif
if(!empty_string(default_profile.shaders))
set_shaders((char *)default_profile.shaders);
if(!empty_string(default_profile.worksize))
set_worksize((char *)default_profile.worksize);
} }
//apply profile settings to pools //apply profile settings to pools
@ -627,6 +729,18 @@ void apply_pool_profiles()
pools[i]->algorithm = profile->algorithm; pools[i]->algorithm = profile->algorithm;
applog(LOG_DEBUG, "Pool %i Algorithm set to \"%s\"", pools[i]->pool_no, pools[i]->algorithm.name); applog(LOG_DEBUG, "Pool %i Algorithm set to \"%s\"", pools[i]->pool_no, pools[i]->algorithm.name);
if(!empty_string(profile->devices))
{
pools[i]->devices = profile->devices;
applog(LOG_DEBUG, "Pool %i devices set to \"%s\"", pools[i]->pool_no, pools[i]->devices);
}
if(!empty_string(profile->lookup_gap))
{
pools[i]->lookup_gap = profile->lookup_gap;
applog(LOG_DEBUG, "Pool %i lookup gap set to \"%s\"", pools[i]->pool_no, pools[i]->lookup_gap);
}
if(!empty_string(profile->intensity)) if(!empty_string(profile->intensity))
{ {
pools[i]->intensity = profile->intensity; pools[i]->intensity = profile->intensity;
@ -675,7 +789,31 @@ void apply_pool_profiles()
pools[i]->gpu_fan = profile->gpu_fan; pools[i]->gpu_fan = profile->gpu_fan;
applog(LOG_DEBUG, "Pool %i GPU Fan set to \"%s\"", pools[i]->pool_no, pools[i]->gpu_fan); applog(LOG_DEBUG, "Pool %i GPU Fan set to \"%s\"", pools[i]->pool_no, pools[i]->gpu_fan);
} }
if(!empty_string(profile->gpu_powertune))
{
pools[i]->gpu_powertune = profile->gpu_powertune;
applog(LOG_DEBUG, "Pool %i GPU Powertune set to \"%s\"", pools[i]->pool_no, pools[i]->gpu_powertune);
}
if(!empty_string(profile->gpu_vddc))
{
pools[i]->gpu_vddc = profile->gpu_vddc;
applog(LOG_DEBUG, "Pool %i GPU Vddc set to \"%s\"", pools[i]->pool_no, pools[i]->gpu_vddc);
}
#endif #endif
if(!empty_string(profile->shaders))
{
pools[i]->shaders = profile->shaders;
applog(LOG_DEBUG, "Pool %i Shaders set to \"%s\"", pools[i]->pool_no, pools[i]->shaders);
}
if(!empty_string(profile->worksize))
{
pools[i]->worksize = profile->worksize;
applog(LOG_DEBUG, "Pool %i Worksize set to \"%s\"", pools[i]->pool_no, pools[i]->worksize);
}
} }
else else
applog(LOG_DEBUG, "Profile load failed for pool %i: profile %s not found.", pools[i]->pool_no, pools[i]->profile); applog(LOG_DEBUG, "Profile load failed for pool %i: profile %s not found.", pools[i]->pool_no, pools[i]->profile);
@ -823,6 +961,32 @@ json_t *build_pool_json()
} }
//if pool and profile value doesn't match below, add it //if pool and profile value doesn't match below, add it
//devices
if(!empty_string(pool->devices))
{
if(strcmp(pool->devices, profile->devices))
{
if(json_object_set(obj, "devices", json_string(pool->devices)) == -1)
{
set_last_json_error("json_object_set() failed on pool(%d):device", pool->pool_no);
return NULL;
}
}
}
//lookup-gap
if(!empty_string(pool->lookup_gap))
{
if(strcmp(pool->lookup_gap, profile->lookup_gap))
{
if(json_object_set(obj, "lookup-gap", json_string(pool->lookup_gap)) == -1)
{
set_last_json_error("json_object_set() failed on pool(%d):lookup-gap", pool->pool_no);
return NULL;
}
}
}
//intensity //intensity
if(!empty_string(pool->intensity)) if(!empty_string(pool->intensity))
{ {
@ -862,28 +1026,53 @@ json_t *build_pool_json()
} }
} }
//shaders
if(!empty_string(pool->shaders))
{
if(strcmp(pool->shaders, profile->shaders) != 0)
{
if(json_object_set(obj, "shaders", json_string(pool->shaders)) == -1)
{
set_last_json_error("json_object_set() failed on pool(%d):shaders", pool->pool_no);
return NULL;
}
}
}
//thread_concurrency //thread_concurrency
if(!empty_string(pool->thread_concurrency)) if(!empty_string(pool->thread_concurrency))
{ {
if(strcmp(pool->thread_concurrency, profile->thread_concurrency) != 0) if(strcmp(pool->thread_concurrency, profile->thread_concurrency) != 0)
{ {
if(json_object_set(obj, "thread_concurrency", json_string(pool->thread_concurrency)) == -1) if(json_object_set(obj, "thread-concurrency", json_string(pool->thread_concurrency)) == -1)
{ {
set_last_json_error("json_object_set() failed on pool(%d):thread_concurrency", pool->pool_no); set_last_json_error("json_object_set() failed on pool(%d):thread-concurrency", pool->pool_no);
return NULL; return NULL;
} }
} }
} }
//worksize
if(!empty_string(pool->worksize))
{
if(strcmp(pool->worksize, profile->worksize) != 0)
{
if(json_object_set(obj, "worksize", json_string(pool->worksize)) == -1)
{
set_last_json_error("json_object_set() failed on pool(%d):worksize", pool->pool_no);
return NULL;
}
}
}
#ifdef HAVE_ADL #ifdef HAVE_ADL
//gpu_engine //gpu_engine
if(!empty_string(pool->gpu_engine)) if(!empty_string(pool->gpu_engine))
{ {
if(strcmp(pool->gpu_engine, profile->gpu_engine) != 0) if(strcmp(pool->gpu_engine, profile->gpu_engine) != 0)
{ {
if(json_object_set(obj, "gpu_engine", json_string(pool->gpu_engine)) == -1) if(json_object_set(obj, "gpu-engine", json_string(pool->gpu_engine)) == -1)
{ {
set_last_json_error("json_object_set() failed on pool(%d):gpu_engine", pool->pool_no); set_last_json_error("json_object_set() failed on pool(%d):gpu-engine", pool->pool_no);
return NULL; return NULL;
} }
} }
@ -894,9 +1083,9 @@ json_t *build_pool_json()
{ {
if(strcmp(pool->gpu_memclock, profile->gpu_memclock) != 0) if(strcmp(pool->gpu_memclock, profile->gpu_memclock) != 0)
{ {
if(json_object_set(obj, "gpu_memclock", json_string(pool->gpu_memclock)) == -1) if(json_object_set(obj, "gpu-memclock", json_string(pool->gpu_memclock)) == -1)
{ {
set_last_json_error("json_object_set() failed on pool(%d):gpu_memclock", pool->pool_no); set_last_json_error("json_object_set() failed on pool(%d):gpu-memclock", pool->pool_no);
return NULL; return NULL;
} }
} }
@ -907,9 +1096,9 @@ json_t *build_pool_json()
{ {
if(strcmp(pool->gpu_threads, profile->gpu_threads) != 0) if(strcmp(pool->gpu_threads, profile->gpu_threads) != 0)
{ {
if(json_object_set(obj, "gpu_threads", json_string(pool->gpu_threads)) == -1) if(json_object_set(obj, "gpu-threads", json_string(pool->gpu_threads)) == -1)
{ {
set_last_json_error("json_object_set() failed on pool(%d):gpu_threads", pool->pool_no); set_last_json_error("json_object_set() failed on pool(%d):gpu-threads", pool->pool_no);
return NULL; return NULL;
} }
} }
@ -920,9 +1109,35 @@ json_t *build_pool_json()
{ {
if(strcmp(pool->gpu_fan, profile->gpu_fan) != 0) if(strcmp(pool->gpu_fan, profile->gpu_fan) != 0)
{ {
if(json_object_set(obj, "gpu_fan", json_string(pool->gpu_fan)) == -1) if(json_object_set(obj, "gpu-fan", json_string(pool->gpu_fan)) == -1)
{
set_last_json_error("json_object_set() failed on pool(%d):gpu-fan", pool->pool_no);
return NULL;
}
}
}
//gpu-powertune
if(!empty_string(pool->gpu_powertune))
{
if(strcmp(pool->gpu_powertune, profile->gpu_powertune) != 0)
{
if(json_object_set(obj, "gpu-powertune", json_string(pool->gpu_powertune)) == -1)
{ {
set_last_json_error("json_object_set() failed on pool(%d):gpu_fan", pool->pool_no); set_last_json_error("json_object_set() failed on pool(%d):gpu-powertune", pool->pool_no);
return NULL;
}
}
}
//gpu-vddc
if(!empty_string(pool->gpu_vddc))
{
if(strcmp(pool->gpu_vddc, profile->gpu_vddc) != 0)
{
if(json_object_set(obj, "gpu-vddc", json_string(pool->gpu_vddc)) == -1)
{
set_last_json_error("json_object_set() failed on pool(%d):gpu-vddc", pool->pool_no);
return NULL; return NULL;
} }
} }
@ -976,8 +1191,8 @@ json_t *build_profile_json()
} }
} }
//if algorithm is different than profile, add it //if algorithm is different than profile, add it - if default profile is the current profile, always add
if(!cmp_algorithm(&default_profile.algorithm, &profile->algorithm)) if(!cmp_algorithm(&default_profile.algorithm, &profile->algorithm) || !strcasecmp(default_profile.name, profile->name))
{ {
//save algorithm name //save algorithm name
if(json_object_set(obj, "algorithm", json_string(profile->algorithm.name)) == -1) if(json_object_set(obj, "algorithm", json_string(profile->algorithm.name)) == -1)
@ -990,10 +1205,39 @@ json_t *build_profile_json()
} }
//if pool and profile value doesn't match below, add it //if pool and profile value doesn't match below, add it
//devices
if(!empty_string(profile->devices))
{
//always add if default profile is this profile
if(strcmp(default_profile.devices, profile->devices) != 0 || !strcasecmp(default_profile.name, profile->name))
{
if(json_object_set(obj, "devices", json_string(profile->devices)) == -1)
{
set_last_json_error("json_object_set() failed on profile(%d):device", profile->profile_no);
return NULL;
}
}
}
//lookup-gap
if(!empty_string(profile->lookup_gap))
{
//always add if default profile is this profile
if(strcmp(default_profile.lookup_gap, profile->lookup_gap) != 0 || !strcasecmp(default_profile.name, profile->name))
{
if(json_object_set(obj, "lookup-gap", json_string(profile->lookup_gap)) == -1)
{
set_last_json_error("json_object_set() failed on profile(%d):lookup-gap", profile->profile_no);
return NULL;
}
}
}
//intensity //intensity
if(!empty_string(profile->intensity)) if(!empty_string(profile->intensity))
{ {
if(strcmp(default_profile.intensity, profile->intensity) != 0) //always add if default profile is this profile
if(strcmp(default_profile.intensity, profile->intensity) != 0 || !strcasecmp(default_profile.name, profile->name))
{ {
if(json_object_set(obj, "intensity", json_string(profile->intensity)) == -1) if(json_object_set(obj, "intensity", json_string(profile->intensity)) == -1)
{ {
@ -1006,7 +1250,7 @@ json_t *build_profile_json()
//xintensity //xintensity
if(!empty_string(profile->xintensity)) if(!empty_string(profile->xintensity))
{ {
if(strcmp(default_profile.xintensity, profile->xintensity) != 0) if(strcmp(default_profile.xintensity, profile->xintensity) != 0 || !strcasecmp(default_profile.name, profile->name))
{ {
if(json_object_set(obj, "xintensity", json_string(profile->xintensity)) == -1) if(json_object_set(obj, "xintensity", json_string(profile->xintensity)) == -1)
{ {
@ -1019,7 +1263,7 @@ json_t *build_profile_json()
//rawintensity //rawintensity
if(!empty_string(profile->rawintensity)) if(!empty_string(profile->rawintensity))
{ {
if(strcmp(default_profile.rawintensity, profile->rawintensity) != 0) if(strcmp(default_profile.rawintensity, profile->rawintensity) != 0 || !strcasecmp(default_profile.name, profile->name))
{ {
if(json_object_set(obj, "rawintensity", json_string(profile->rawintensity)) == -1) if(json_object_set(obj, "rawintensity", json_string(profile->rawintensity)) == -1)
{ {
@ -1029,12 +1273,25 @@ json_t *build_profile_json()
} }
} }
//shaders
if(!empty_string(profile->shaders))
{
if(strcmp(default_profile.shaders, profile->shaders) != 0 || !strcasecmp(default_profile.name, profile->name))
{
if(json_object_set(obj, "shaders", json_string(profile->shaders)) == -1)
{
set_last_json_error("json_object_set() failed on profile(%d):shaders", profile->profile_no);
return NULL;
}
}
}
//thread_concurrency //thread_concurrency
if(!empty_string(profile->thread_concurrency)) if(!empty_string(profile->thread_concurrency))
{ {
if(strcmp(default_profile.thread_concurrency, profile->thread_concurrency) != 0) if(strcmp(default_profile.thread_concurrency, profile->thread_concurrency) != 0 || !strcasecmp(default_profile.name, profile->name))
{ {
if(json_object_set(obj, "thread_concurrency", json_string(profile->thread_concurrency)) == -1) if(json_object_set(obj, "thread-concurrency", json_string(profile->thread_concurrency)) == -1)
{ {
set_last_json_error("json_object_set() failed on profile(%d):thread_concurrency", profile->profile_no); set_last_json_error("json_object_set() failed on profile(%d):thread_concurrency", profile->profile_no);
return NULL; return NULL;
@ -1042,15 +1299,28 @@ json_t *build_profile_json()
} }
} }
//worksize
if(!empty_string(profile->worksize))
{
if(strcmp(default_profile.worksize, profile->worksize) != 0 || !strcasecmp(default_profile.name, profile->name))
{
if(json_object_set(obj, "worksize", json_string(profile->worksize)) == -1)
{
set_last_json_error("json_object_set() failed on profile(%d):worksize", profile->profile_no);
return NULL;
}
}
}
#ifdef HAVE_ADL #ifdef HAVE_ADL
//gpu_engine //gpu_engine
if(!empty_string(profile->gpu_engine)) if(!empty_string(profile->gpu_engine))
{ {
if(strcmp(default_profile.gpu_engine, profile->gpu_engine) != 0) if(strcmp(default_profile.gpu_engine, profile->gpu_engine) != 0 || !strcasecmp(default_profile.name, profile->name))
{ {
if(json_object_set(obj, "gpu_engine", json_string(profile->gpu_engine)) == -1) if(json_object_set(obj, "gpu-engine", json_string(profile->gpu_engine)) == -1)
{ {
set_last_json_error("json_object_set() failed on profile(%d):gpu_engine", profile->profile_no); set_last_json_error("json_object_set() failed on profile(%d):gpu-engine", profile->profile_no);
return NULL; return NULL;
} }
} }
@ -1059,11 +1329,11 @@ json_t *build_profile_json()
//gpu_memclock //gpu_memclock
if(!empty_string(profile->gpu_memclock)) if(!empty_string(profile->gpu_memclock))
{ {
if(strcmp(default_profile.gpu_memclock, profile->gpu_memclock) != 0) if(strcmp(default_profile.gpu_memclock, profile->gpu_memclock) != 0 || !strcasecmp(default_profile.name, profile->name))
{ {
if(json_object_set(obj, "gpu_memclock", json_string(profile->gpu_memclock)) == -1) if(json_object_set(obj, "gpu-memclock", json_string(profile->gpu_memclock)) == -1)
{ {
set_last_json_error("json_object_set() failed on profile(%d):gpu_memclock", profile->profile_no); set_last_json_error("json_object_set() failed on profile(%d):gpu-memclock", profile->profile_no);
return NULL; return NULL;
} }
} }
@ -1072,11 +1342,11 @@ json_t *build_profile_json()
//gpu_threads //gpu_threads
if(!empty_string(profile->gpu_threads)) if(!empty_string(profile->gpu_threads))
{ {
if(strcmp(default_profile.gpu_threads, profile->gpu_threads) != 0) if(strcmp(default_profile.gpu_threads, profile->gpu_threads) != 0 || !strcasecmp(default_profile.name, profile->name))
{ {
if(json_object_set(obj, "gpu_threads", json_string(profile->gpu_threads)) == -1) if(json_object_set(obj, "gpu-threads", json_string(profile->gpu_threads)) == -1)
{ {
set_last_json_error("json_object_set() failed on profile(%d):gpu_threads", profile->profile_no); set_last_json_error("json_object_set() failed on profile(%d):gpu-threads", profile->profile_no);
return NULL; return NULL;
} }
} }
@ -1085,11 +1355,37 @@ json_t *build_profile_json()
//gpu_fan //gpu_fan
if(!empty_string(profile->gpu_fan)) if(!empty_string(profile->gpu_fan))
{ {
if(strcmp(default_profile.gpu_fan, profile->gpu_fan) != 0) if(strcmp(default_profile.gpu_fan, profile->gpu_fan) != 0 || !strcasecmp(default_profile.name, profile->name))
{ {
if(json_object_set(obj, "gpu_fan", json_string(profile->gpu_fan)) == -1) if(json_object_set(obj, "gpu-fan", json_string(profile->gpu_fan)) == -1)
{ {
set_last_json_error("json_object_set() failed on profile(%d):gpu_fan", profile->profile_no); set_last_json_error("json_object_set() failed on profile(%d):gpu-fan", profile->profile_no);
return NULL;
}
}
}
//gpu-powertune
if(!empty_string(profile->gpu_powertune))
{
if(strcmp(default_profile.gpu_powertune, profile->gpu_powertune) != 0 || !strcasecmp(default_profile.name, profile->name))
{
if(json_object_set(obj, "gpu-powertune", json_string(profile->gpu_powertune)) == -1)
{
set_last_json_error("json_object_set() failed on profile(%d):gpu-powertune", profile->profile_no);
return NULL;
}
}
}
//gpu-vddc
if(!empty_string(profile->gpu_vddc))
{
if(strcmp(default_profile.gpu_vddc, profile->gpu_vddc) != 0 || !strcasecmp(default_profile.name, profile->name))
{
if(json_object_set(obj, "gpu-vddc", json_string(profile->gpu_vddc)) == -1)
{
set_last_json_error("json_object_set() failed on profile(%d):gpu-vddc", profile->profile_no);
return NULL; return NULL;
} }
} }
@ -1192,7 +1488,7 @@ void write_config(const char *filename)
//if using a specific profile as default, set it //if using a specific profile as default, set it
if(!empty_string(default_profile.name)) if(!empty_string(default_profile.name))
{ {
if(json_object_set(config, "default_profile", json_string(default_profile.name)) == -1) if(json_object_set(config, "default-profile", json_string(default_profile.name)) == -1)
{ {
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on default_profile"); applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on default_profile");
return; return;
@ -1209,6 +1505,26 @@ void write_config(const char *filename)
} }
//TODO: add other options like nfactor etc... //TODO: add other options like nfactor etc...
//devices
if(!empty_string(default_profile.devices))
{
if(json_object_set(config, "devices", json_string(default_profile.devices)) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on devices");
return;
}
}
//lookup-gap
if(!empty_string(default_profile.lookup_gap))
{
if(json_object_set(config, "lookup-gap", json_string(default_profile.lookup_gap)) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on lookup-gap");
return;
}
}
//intensity //intensity
if(!empty_string(default_profile.intensity)) if(!empty_string(default_profile.intensity))
{ {
@ -1239,23 +1555,43 @@ void write_config(const char *filename)
} }
} }
//shaders
if(!empty_string(default_profile.shaders))
{
if(json_object_set(config, "shaders", json_string(default_profile.shaders)) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on shaders");
return;
}
}
//thread_concurrency //thread_concurrency
if(!empty_string(default_profile.thread_concurrency)) if(!empty_string(default_profile.thread_concurrency))
{ {
if(json_object_set(config, "thread_concurrency", json_string(default_profile.thread_concurrency)) == -1) if(json_object_set(config, "thread-concurrency", json_string(default_profile.thread_concurrency)) == -1)
{ {
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on thread_concurrency"); applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on thread_concurrency");
return; return;
} }
} }
//worksize
if(!empty_string(default_profile.worksize))
{
if(json_object_set(config, "worksize", json_string(default_profile.worksize)) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on worksize");
return;
}
}
#ifdef HAVE_ADL #ifdef HAVE_ADL
//gpu_engine //gpu_engine
if(!empty_string(default_profile.gpu_engine)) if(!empty_string(default_profile.gpu_engine))
{ {
if(json_object_set(config, "gpu_engine", json_string(default_profile.gpu_engine)) == -1) if(json_object_set(config, "gpu-engine", json_string(default_profile.gpu_engine)) == -1)
{ {
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu_engine"); applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-engine");
return; return;
} }
} }
@ -1263,9 +1599,9 @@ void write_config(const char *filename)
//gpu_memclock //gpu_memclock
if(!empty_string(default_profile.gpu_memclock)) if(!empty_string(default_profile.gpu_memclock))
{ {
if(json_object_set(config, "gpu_memclock", json_string(default_profile.gpu_memclock)) == -1) if(json_object_set(config, "gpu-memclock", json_string(default_profile.gpu_memclock)) == -1)
{ {
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu_memclock"); applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-memclock");
return; return;
} }
} }
@ -1273,9 +1609,9 @@ void write_config(const char *filename)
//gpu_threads //gpu_threads
if(!empty_string(default_profile.gpu_threads)) if(!empty_string(default_profile.gpu_threads))
{ {
if(json_object_set(config, "gpu_threads", json_string(default_profile.gpu_threads)) == -1) if(json_object_set(config, "gpu-threads", json_string(default_profile.gpu_threads)) == -1)
{ {
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu_threads"); applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-threads");
return; return;
} }
} }
@ -1283,9 +1619,29 @@ void write_config(const char *filename)
//gpu_fan //gpu_fan
if(!empty_string(default_profile.gpu_fan)) if(!empty_string(default_profile.gpu_fan))
{ {
if(json_object_set(config, "gpu_fan", json_string(default_profile.gpu_fan)) == -1) if(json_object_set(config, "gpu-fan", json_string(default_profile.gpu_fan)) == -1)
{ {
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu_fan"); applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-fan");
return;
}
}
//gpu-powertune
if(!empty_string(default_profile.gpu_powertune))
{
if(json_object_set(config, "gpu-powertune", json_string(default_profile.gpu_powertune)) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-powertune");
return;
}
}
//gpu-vddc
if(!empty_string(default_profile.gpu_vddc))
{
if(json_object_set(config, "gpu-vddc", json_string(default_profile.gpu_vddc)) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-vddc");
return; return;
} }
} }
@ -1293,7 +1649,7 @@ void write_config(const char *filename)
} }
//devices //devices
if(opt_devs_enabled) /*if(opt_devs_enabled)
{ {
bool extra_devs = false; bool extra_devs = false;
obj = json_string(""); obj = json_string("");
@ -1321,7 +1677,7 @@ void write_config(const char *filename)
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on devices"); applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on devices");
return; return;
} }
} }*/
//remove-disabled //remove-disabled
if(opt_removedisabled) if(opt_removedisabled)
@ -1378,40 +1734,6 @@ void write_config(const char *filename)
return; return;
} }
} }
#endif
//lookup-gap
for(i = 0;i < nDevs; i++)
obj = json_sprintf("%s%s%d", ((i > 0)?json_string_value(obj):""), ((i > 0)?",":""), (int)gpus[i].opt_lg);
if(json_object_set(config, "lookup-gap", obj) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on lookup-gap");
return;
}
//TODO: move the below into profiles/algorithm switching
//worksize
for(i = 0;i < nDevs; i++)
obj = json_sprintf("%s%s%d", ((i > 0)?json_string_value(obj):""), ((i > 0)?",":""), (int)gpus[i].work_size);
if(json_object_set(config, "worksize", obj) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on worksize");
return;
}
//shaders
for(i = 0;i < nDevs; i++)
obj = json_sprintf("%s%s%d", ((i > 0)?json_string_value(obj):""), ((i > 0)?",":""), (int)gpus[i].shaders);
if(json_object_set(config, "shaders", obj) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on shaders");
return;
}
#ifdef HAVE_ADL
//gpu-memdiff //gpu-memdiff
for(i = 0;i < nDevs; i++) for(i = 0;i < nDevs; i++)
@ -1422,26 +1744,6 @@ void write_config(const char *filename)
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-memdiff"); applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-memdiff");
return; return;
} }
//gpu-powertune
for(i = 0;i < nDevs; i++)
obj = json_sprintf("%s%s%d", ((i > 0)?json_string_value(obj):""), ((i > 0)?",":""), gpus[i].gpu_powertune);
if(json_object_set(config, "gpu-powertune", obj) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-powertune");
return;
}
//gpu-vdcc
for(i = 0;i < nDevs; i++)
obj = json_sprintf("%s%s%1.3f", ((i > 0)?json_string_value(obj):""), ((i > 0)?",":""), gpus[i].gpu_vddc);
if(json_object_set(config, "gpu-vddc", obj) == -1)
{
applog(LOG_ERR, "Error: config_parser::write_config():\n json_object_set() failed on gpu-vddc");
return;
}
#endif #endif
} }

24
config_parser.h

@ -12,7 +12,7 @@
#endif #endif
//helper function to get a gpu option value //helper function to get a gpu option value
#define gpu_opt #ifndef gpu_opt
#define gpu_opt(i,optname) gpus[i].optname #define gpu_opt(i,optname) gpus[i].optname
#endif #endif
@ -22,14 +22,20 @@ struct profile {
char *name; char *name;
algorithm_t algorithm; algorithm_t algorithm;
const char *devices;
const char *intensity; const char *intensity;
const char *xintensity; const char *xintensity;
const char *rawintensity; const char *rawintensity;
const char *thread_concurrency; const char *lookup_gap;
const char *gpu_engine; const char *gpu_engine;
const char *gpu_memclock; const char *gpu_memclock;
const char *gpu_threads; const char *gpu_threads;
const char *gpu_fan; const char *gpu_fan;
const char *gpu_powertune;
const char *gpu_vddc;
const char *shaders;
const char *thread_concurrency;
const char *worksize;
}; };
/* globals needed outside */ /* globals needed outside */
@ -44,6 +50,8 @@ extern int json_array_index;
extern struct profile default_profile; extern struct profile default_profile;
/* option parser functions */ /* option parser functions */
extern char *set_default_devices(const char *arg);
extern char *set_default_lookup_gap(const char *arg);
extern char *set_default_intensity(const char *arg); extern char *set_default_intensity(const char *arg);
extern char *set_default_xintensity(const char *arg); extern char *set_default_xintensity(const char *arg);
extern char *set_default_rawintensity(const char *arg); extern char *set_default_rawintensity(const char *arg);
@ -53,11 +61,17 @@ extern char *set_default_thread_concurrency(const char *arg);
extern char *set_default_gpu_memclock(const char *arg); extern char *set_default_gpu_memclock(const char *arg);
extern char *set_default_gpu_threads(const char *arg); extern char *set_default_gpu_threads(const char *arg);
extern char *set_default_gpu_fan(const char *arg); extern char *set_default_gpu_fan(const char *arg);
extern char *set_default_gpu_powertune(const char *arg);
extern char *set_default_gpu_vddc(const char *arg);
#endif #endif
extern char *set_default_profile(char *arg); extern char *set_default_profile(char *arg);
extern char *set_default_shaders(const char *arg);
extern char *set_default_worksize(const char *arg);
extern char *set_profile_name(char *arg); extern char *set_profile_name(const char *arg);
extern char *set_profile_algorithm(const char *arg); extern char *set_profile_algorithm(const char *arg);
extern char *set_profile_devices(const char *arg);
extern char *set_profile_lookup_gap(const char *arg);
extern char *set_profile_intensity(const char *arg); extern char *set_profile_intensity(const char *arg);
extern char *set_profile_xintensity(const char *arg); extern char *set_profile_xintensity(const char *arg);
extern char *set_profile_rawintensity(const char *arg); extern char *set_profile_rawintensity(const char *arg);
@ -67,8 +81,12 @@ extern char *set_profile_thread_concurrency(const char *arg);
extern char *set_profile_gpu_memclock(const char *arg); extern char *set_profile_gpu_memclock(const char *arg);
extern char *set_profile_gpu_threads(const char *arg); extern char *set_profile_gpu_threads(const char *arg);
extern char *set_profile_gpu_fan(const char *arg); extern char *set_profile_gpu_fan(const char *arg);
extern char *set_profile_gpu_powertune(const char *arg);
extern char *set_profile_gpu_vddc(const char *arg);
#endif #endif
extern char *set_profile_nfactor(const char *arg); extern char *set_profile_nfactor(const char *arg);
extern char *set_profile_shaders(const char *arg);
extern char *set_profile_worksize(const char *arg);
/* config parser functions */ /* config parser functions */
extern char *parse_config(json_t *val, const char *key, const char *parentkey, bool fileconf, int parent_iteration); extern char *parse_config(json_t *val, const char *key, const char *parentkey, bool fileconf, int parent_iteration);

23
miner.h

@ -1039,6 +1039,7 @@ extern void api(int thr_id);
extern struct pool *current_pool(void); extern struct pool *current_pool(void);
extern int enabled_pools; extern int enabled_pools;
extern void get_intrange(char *arg, int *val1, int *val2); extern void get_intrange(char *arg, int *val1, int *val2);
extern char *set_devices(char *arg);
extern bool detect_stratum(struct pool *pool, char *url); extern bool detect_stratum(struct pool *pool, char *url);
extern void print_summary(void); extern void print_summary(void);
extern void adjust_quota_gcd(void); extern void adjust_quota_gcd(void);
@ -1216,14 +1217,20 @@ struct pool {
char *profile; char *profile;
algorithm_t algorithm; algorithm_t algorithm;
const char *intensity; const char *devices;
const char *xintensity; const char *intensity;
const char *rawintensity; const char *xintensity;
const char *thread_concurrency; const char *rawintensity;
const char *gpu_engine; const char *lookup_gap;
const char *gpu_memclock; const char *gpu_engine;
const char *gpu_threads; const char *gpu_memclock;
const char *gpu_fan; const char *gpu_threads;
const char *gpu_fan;
const char *gpu_powertune;
const char *gpu_vddc;
const char *shaders;
const char *thread_concurrency;
const char *worksize;
pthread_mutex_t pool_lock; pthread_mutex_t pool_lock;
cglock_t data_lock; cglock_t data_lock;

314
sgminer.c

@ -121,6 +121,7 @@ int total_devices;
static int most_devices; static int most_devices;
struct cgpu_info **devices; struct cgpu_info **devices;
int mining_threads; int mining_threads;
static int sgminer_id_count = 0;
#ifdef HAVE_CURSES #ifdef HAVE_CURSES
bool use_curses = true; bool use_curses = true;
@ -408,6 +409,8 @@ struct cgpu_info *get_devices(int id)
return cgpu; return cgpu;
} }
void enable_device(struct cgpu_info *cgpu);
static void sharelog(const char*disposition, const struct work*work) static void sharelog(const char*disposition, const struct work*work)
{ {
char *target, *hash, *data; char *target, *hash, *data;
@ -629,18 +632,30 @@ void get_intrange(char *arg, int *val1, int *val2)
*val2 = *val1; *val2 = *val1;
} }
static char *set_devices(char *arg) char *set_devices(char *arg)
{ {
int i, val1 = 0, val2 = 0; int i, val1 = 0, val2 = 0;
char *nextptr; char *nextptr;
if (*arg) { if (*arg)
if (*arg == '?') { {
opt_display_devs = true; if (*arg == '?')
return NULL; {
} opt_display_devs = true;
} else return NULL;
return "Invalid device parameters"; }
//all devices enabled
else if(*arg == '*')
{
applog(LOG_DEBUG, "set_devices(%s)", arg);
opt_devs_enabled = 0;
return NULL;
}
}
else
return "Invalid device parameters";
applog(LOG_DEBUG, "set_devices(%s)", arg);
nextptr = strtok(arg, ","); nextptr = strtok(arg, ",");
if (nextptr == NULL) if (nextptr == NULL)
@ -760,6 +775,20 @@ static char *set_pool_algorithm(const char *arg)
return NULL; return NULL;
} }
static char *set_pool_devices(const char *arg)
{
struct pool *pool = get_current_pool();
pool->devices = arg;
return NULL;
}
static char *set_pool_lookup_gap(const char *arg)
{
struct pool *pool = get_current_pool();
pool->lookup_gap = arg;
return NULL;
}
static char *set_pool_intensity(const char *arg) static char *set_pool_intensity(const char *arg)
{ {
struct pool *pool = get_current_pool(); struct pool *pool = get_current_pool();
@ -816,6 +845,20 @@ static char *set_pool_gpu_fan(const char *arg)
pool->gpu_fan = arg; pool->gpu_fan = arg;
return NULL; return NULL;
} }
static char *set_pool_gpu_powertune(const char *arg)
{
struct pool *pool = get_current_pool();
pool->gpu_powertune = arg;
return NULL;
}
static char *set_pool_gpu_vddc(const char *arg)
{
struct pool *pool = get_current_pool();
pool->gpu_vddc = arg;
return NULL;
}
#endif #endif
static char *set_pool_nfactor(const char *arg) static char *set_pool_nfactor(const char *arg)
@ -856,6 +899,20 @@ static char *set_poolname_deprecated(char *arg)
return NULL; return NULL;
} }
static char *set_pool_shaders(const char *arg)
{
struct pool *pool = get_current_pool();
pool->shaders = arg;
return NULL;
}
static char *set_pool_worksize(const char *arg)
{
struct pool *pool = get_current_pool();
pool->worksize = arg;
return NULL;
}
static void enable_pool(struct pool *pool) static void enable_pool(struct pool *pool)
{ {
if (pool->state != POOL_ENABLED) if (pool->state != POOL_ENABLED)
@ -1258,7 +1315,7 @@ struct opt_table opt_config_table[] = {
set_pool_description, NULL, NULL, set_pool_description, NULL, NULL,
"Pool description"), "Pool description"),
OPT_WITH_ARG("--device|-d", OPT_WITH_ARG("--device|-d",
set_devices, NULL, NULL, set_default_devices, NULL, NULL,
"Select device to use, one value, range and/or comma separated (e.g. 0-2,4) default: all"), "Select device to use, one value, range and/or comma separated (e.g. 0-2,4) default: all"),
OPT_WITHOUT_ARG("--disable-rejecting", OPT_WITHOUT_ARG("--disable-rejecting",
opt_set_bool, &opt_disable_pool, opt_set_bool, &opt_disable_pool,
@ -1310,17 +1367,17 @@ struct opt_table opt_config_table[] = {
set_gpu_memdiff, NULL, NULL, set_gpu_memdiff, NULL, NULL,
"Set a fixed difference in clock speed between the GPU and memory in auto-gpu mode"), "Set a fixed difference in clock speed between the GPU and memory in auto-gpu mode"),
OPT_WITH_ARG("--gpu-powertune", OPT_WITH_ARG("--gpu-powertune",
set_gpu_powertune, NULL, NULL, set_default_gpu_powertune, NULL, NULL,
"Set the GPU powertune percentage - one value for all or separate by commas for per card"), "Set the GPU powertune percentage - one value for all or separate by commas for per card"),
OPT_WITHOUT_ARG("--gpu-reorder", OPT_WITHOUT_ARG("--gpu-reorder",
opt_set_bool, &opt_reorder, opt_set_bool, &opt_reorder,
"Attempt to reorder GPU devices according to PCI Bus ID"), "Attempt to reorder GPU devices according to PCI Bus ID"),
OPT_WITH_ARG("--gpu-vddc", OPT_WITH_ARG("--gpu-vddc",
set_gpu_vddc, NULL, NULL, set_default_gpu_vddc, NULL, NULL,
"Set the GPU voltage in Volts - one value for all or separate by commas for per card"), "Set the GPU voltage in Volts - one value for all or separate by commas for per card"),
#endif #endif
OPT_WITH_ARG("--lookup-gap", OPT_WITH_ARG("--lookup-gap",
set_lookup_gap, NULL, NULL, set_default_lookup_gap, NULL, NULL,
"Set GPU lookup gap for scrypt mining, comma separated"), "Set GPU lookup gap for scrypt mining, comma separated"),
OPT_WITH_ARG("--hamsi-expand-big", OPT_WITH_ARG("--hamsi-expand-big",
set_int_1_to_10, opt_show_intval, &opt_hamsi_expand_big, set_int_1_to_10, opt_show_intval, &opt_hamsi_expand_big,
@ -1408,6 +1465,12 @@ struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--pool-algorithm", OPT_WITH_ARG("--pool-algorithm",
set_pool_algorithm, NULL, NULL, set_pool_algorithm, NULL, NULL,
"Set algorithm for pool"), "Set algorithm for pool"),
OPT_WITH_ARG("--pool-device",
set_pool_devices, NULL, NULL,
"Select devices to use with pool, one value, range and/or comma separated (e.g. 0-2,4) default: all"),
OPT_WITH_ARG("--pool-lookup-gap",
set_pool_lookup_gap, NULL, NULL,
"Set Pool GPU lookup gap for scrypt mining, comma separated"),
#ifdef HAVE_ADL #ifdef HAVE_ADL
OPT_WITH_ARG("--pool-gpu-engine", OPT_WITH_ARG("--pool-gpu-engine",
set_pool_gpu_engine, NULL, NULL, set_pool_gpu_engine, NULL, NULL,
@ -1418,9 +1481,15 @@ struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--pool-gpu-memclock", OPT_WITH_ARG("--pool-gpu-memclock",
set_pool_gpu_memclock, NULL, NULL, set_pool_gpu_memclock, NULL, NULL,
"Set the Pool GPU memory (over)clock in Mhz - one value for all or separate by commas for per card"), "Set the Pool GPU memory (over)clock in Mhz - one value for all or separate by commas for per card"),
OPT_WITH_ARG("--pool-gpu-powertune",
set_pool_gpu_powertune, NULL, NULL,
"Set the Pool GPU powertune percentage - one value for all or separate by commas for per card"),
OPT_WITH_ARG("--pool-gpu-threads", OPT_WITH_ARG("--pool-gpu-threads",
set_pool_gpu_threads, NULL, NULL, set_pool_gpu_threads, NULL, NULL,
"Number of threads per GPU for pool"), "Number of threads per GPU for pool"),
OPT_WITH_ARG("--pool-gpu-vddc",
set_pool_gpu_vddc, NULL, NULL,
"Set the Pool GPU voltage in Volts - one value for all or separate by commas for per card"),
#endif #endif
OPT_WITH_ARG("--pool-intensity", OPT_WITH_ARG("--pool-intensity",
set_pool_intensity, NULL, NULL, set_pool_intensity, NULL, NULL,
@ -1434,9 +1503,15 @@ struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--pool-rawintensity", OPT_WITH_ARG("--pool-rawintensity",
set_pool_rawintensity, NULL, NULL, set_pool_rawintensity, NULL, NULL,
"Raw intensity of GPU scanning (pool-specific)"), "Raw intensity of GPU scanning (pool-specific)"),
OPT_WITH_ARG("--pool-shaders",
set_pool_shaders, NULL, NULL,
"Pool GPU shaders per card for tuning scrypt, comma separated"),
OPT_WITH_ARG("--pool-thread-concurrency", OPT_WITH_ARG("--pool-thread-concurrency",
set_pool_thread_concurrency, NULL, NULL, set_pool_thread_concurrency, NULL, NULL,
"Set thread concurrency for pool"), "Set thread concurrency for pool"),
OPT_WITH_ARG("--pool-worksize",
set_pool_worksize, NULL, NULL,
"Override detected optimal worksize for pool - one value or comma separated list"),
OPT_WITH_ARG("--pool-xintensity", OPT_WITH_ARG("--pool-xintensity",
set_pool_xintensity, NULL, NULL, set_pool_xintensity, NULL, NULL,
"Shader based intensity of GPU scanning (pool-specific)"), "Shader based intensity of GPU scanning (pool-specific)"),
@ -1448,6 +1523,12 @@ struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--profile-algorithm", OPT_WITH_ARG("--profile-algorithm",
set_profile_algorithm, NULL, NULL, set_profile_algorithm, NULL, NULL,
"Set algorithm for profile"), "Set algorithm for profile"),
OPT_WITH_ARG("--profile-device",
set_profile_devices, NULL, NULL,
"Select devices to use with profile, one value, range and/or comma separated (e.g. 0-2,4) default: all"),
OPT_WITH_ARG("--profile-lookup-gap",
set_profile_lookup_gap, NULL, NULL,
"Set Profile GPU lookup gap for scrypt mining, comma separated"),
#ifdef HAVE_ADL #ifdef HAVE_ADL
OPT_WITH_ARG("--profile-gpu-engine", OPT_WITH_ARG("--profile-gpu-engine",
set_profile_gpu_engine, NULL, NULL, set_profile_gpu_engine, NULL, NULL,
@ -1458,9 +1539,15 @@ struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--profile-gpu-memclock", OPT_WITH_ARG("--profile-gpu-memclock",
set_profile_gpu_memclock, NULL, NULL, set_profile_gpu_memclock, NULL, NULL,
"Set the Profile GPU memory (over)clock in Mhz - one value for all or separate by commas for per card"), "Set the Profile GPU memory (over)clock in Mhz - one value for all or separate by commas for per card"),
OPT_WITH_ARG("--profile-gpu-powertune",
set_profile_gpu_powertune, NULL, NULL,
"Set the Profile GPU powertune percentage - one value for all or separate by commas for per card"),
OPT_WITH_ARG("--profile-gpu-threads", OPT_WITH_ARG("--profile-gpu-threads",
set_profile_gpu_threads, NULL, NULL, set_profile_gpu_threads, NULL, NULL,
"Number of threads per GPU for profile"), "Number of threads per GPU for profile"),
OPT_WITH_ARG("--profile-gpu-vddc",
set_profile_gpu_vddc, NULL, NULL,
"Set the Profile GPU voltage in Volts - one value for all or separate by commas for per card"),
#endif #endif
OPT_WITH_ARG("--profile-intensity", OPT_WITH_ARG("--profile-intensity",
set_profile_intensity, NULL, NULL, set_profile_intensity, NULL, NULL,
@ -1474,9 +1561,15 @@ struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--profile-rawintensity", OPT_WITH_ARG("--profile-rawintensity",
set_profile_rawintensity, NULL, NULL, set_profile_rawintensity, NULL, NULL,
"Raw intensity of GPU scanning (profile-specific)"), "Raw intensity of GPU scanning (profile-specific)"),
OPT_WITH_ARG("--profile-shaders",
set_profile_shaders, NULL, NULL,
"Profile GPU shaders per card for tuning scrypt, comma separated"),
OPT_WITH_ARG("--profile-thread-concurrency", OPT_WITH_ARG("--profile-thread-concurrency",
set_profile_thread_concurrency, NULL, NULL, set_profile_thread_concurrency, NULL, NULL,
"Set thread concurrency for profile"), "Set thread concurrency for profile"),
OPT_WITH_ARG("--profile-worksize",
set_profile_worksize, NULL, NULL,
"Override detected optimal worksize for profile - one value or comma separated list"),
OPT_WITH_ARG("--profile-xintensity", OPT_WITH_ARG("--profile-xintensity",
set_profile_xintensity, NULL, NULL, set_profile_xintensity, NULL, NULL,
"Shader based intensity of GPU scanning (profile-specific)"), "Shader based intensity of GPU scanning (profile-specific)"),
@ -1521,7 +1614,7 @@ struct opt_table opt_config_table[] = {
set_schedtime, NULL, &schedstop, set_schedtime, NULL, &schedstop,
"Set a time of day in HH:MM to stop mining (will quit without a start time)"), "Set a time of day in HH:MM to stop mining (will quit without a start time)"),
OPT_WITH_ARG("--shaders", OPT_WITH_ARG("--shaders",
set_shaders, NULL, NULL, set_default_shaders, NULL, NULL,
"GPU shaders per card for tuning scrypt, comma separated"), "GPU shaders per card for tuning scrypt, comma separated"),
OPT_WITH_ARG("--sharelog", OPT_WITH_ARG("--sharelog",
set_sharelog, NULL, NULL, set_sharelog, NULL, NULL,
@ -1594,7 +1687,7 @@ struct opt_table opt_config_table[] = {
opt_set_bool, &opt_log_output, opt_set_bool, &opt_log_output,
"Log verbose output to stderr as well as status output"), "Log verbose output to stderr as well as status output"),
OPT_WITH_ARG("--worksize|-w", OPT_WITH_ARG("--worksize|-w",
set_worksize, NULL, NULL, set_default_worksize, NULL, NULL,
"Override detected optimal worksize - one value or comma separated list"), "Override detected optimal worksize - one value or comma separated list"),
OPT_WITH_ARG("--userpass|-O", OPT_WITH_ARG("--userpass|-O",
set_userpass, NULL, NULL, set_userpass, NULL, NULL,
@ -5794,79 +5887,144 @@ static void *restart_mining_threads_thread(void *userdata);
static void get_work_prepare_thread(struct thr_info *mythr, struct work *work) static void get_work_prepare_thread(struct thr_info *mythr, struct work *work)
{ {
int i; int i;
int active_threads; //number of actual active threads
int start_threads; //number of threads at start before devices enabled change
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
mutex_lock(&algo_switch_lock); mutex_lock(&algo_switch_lock);
if (cmp_algorithm(&work->pool->algorithm, &mythr->cgpu->algorithm) && (algo_switch_n == 0)) { if (cmp_algorithm(&work->pool->algorithm, &mythr->cgpu->algorithm) && (algo_switch_n == 0))
{
mutex_unlock(&algo_switch_lock); mutex_unlock(&algo_switch_lock);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
return; return;
} }
algo_switch_n++; algo_switch_n++;
//get the number of active threads to know when to switch... if we only check total threads, we may wait for ever on a disabled GPU
active_threads = 0;
for(i = 0; i < mining_threads; i++)
{
struct thr_info *thr = mining_thr[i];
if(thr->cgpu->deven != DEV_DISABLED)
active_threads ++;
}
// If all threads are waiting now // If all threads are waiting now
if (algo_switch_n >= mining_threads) { if (algo_switch_n >= active_threads)
{
start_threads = mining_threads; //use start_threads below
bool soft_restart = !work->pool->gpu_threads; bool soft_restart = !work->pool->gpu_threads;
rd_lock(&mining_thr_lock); rd_lock(&mining_thr_lock);
// Shutdown all threads first (necessary) // Shutdown all threads first (necessary)
if (soft_restart) { if (soft_restart) {
for (i = 0; i < mining_threads; i++) { for (i = 0; i < start_threads; i++) {
struct thr_info *thr = mining_thr[i]; struct thr_info *thr = mining_thr[i];
thr->cgpu->drv->thread_shutdown(thr); thr->cgpu->drv->thread_shutdown(thr);
} }
} }
// Reset stats (e.g. for working_diff to be set properly in hash_sole_work) // Reset stats (e.g. for working_diff to be set properly in hash_sole_work)
zero_stats(); zero_stats();
// Apply other pool-specific settings
// TODO: when config parser is improved, add else statements and set // Apply other pool-specific settings or revert to defaults
// to default intensity
//reset devices flags
opt_devs_enabled = 0;
for (i = 0; i < MAX_DEVICES; i++)
devices_enabled[i] = false;
//assign pool devices if any
if(!empty_string(work->pool->devices))
set_devices((char *)work->pool->devices);
//assign default devices if any
else if(!empty_string(default_profile.devices))
set_devices((char *)default_profile.devices);
//lookup gap
if(!empty_string(work->pool->lookup_gap))
set_lookup_gap((char *)work->pool->lookup_gap);
else if(!empty_string(default_profile.lookup_gap))
set_lookup_gap((char *)default_profile.lookup_gap);
//intensity
if(!empty_string(work->pool->intensity)) if(!empty_string(work->pool->intensity))
set_intensity(work->pool->intensity); set_intensity(work->pool->intensity);
else if(!empty_string(default_profile.intensity)) else if(!empty_string(default_profile.intensity))
set_intensity(default_profile.intensity); set_intensity(default_profile.intensity);
//xintensity
if (!empty_string(work->pool->xintensity)) if (!empty_string(work->pool->xintensity))
set_xintensity(work->pool->xintensity); set_xintensity(work->pool->xintensity);
else if(!empty_string(default_profile.xintensity)) else if(!empty_string(default_profile.xintensity))
set_xintensity(default_profile.xintensity); set_xintensity(default_profile.xintensity);
//raw intensity
if (!empty_string(work->pool->rawintensity)) if (!empty_string(work->pool->rawintensity))
set_rawintensity(work->pool->rawintensity); set_rawintensity(work->pool->rawintensity);
else if(!empty_string(default_profile.rawintensity)) else if(!empty_string(default_profile.rawintensity))
set_rawintensity(default_profile.rawintensity); set_rawintensity(default_profile.rawintensity);
if (!empty_string(work->pool->thread_concurrency)) //shaders
set_thread_concurrency(work->pool->thread_concurrency); if (!empty_string(work->pool->shaders))
else if(!empty_string(default_profile.thread_concurrency)) set_shaders((char *)work->pool->shaders);
set_thread_concurrency(default_profile.thread_concurrency); else if(!empty_string(default_profile.shaders))
set_shaders((char *)default_profile.shaders);
//worksize
if (!empty_string(work->pool->worksize))
set_worksize((char *)work->pool->worksize);
else if(!empty_string(default_profile.worksize))
set_worksize((char *)default_profile.worksize);
#ifdef HAVE_ADL #ifdef HAVE_ADL
if(!empty_string(work->pool->gpu_engine)) //GPU clock
{ if(!empty_string(work->pool->gpu_engine))
set_gpu_engine(work->pool->gpu_engine); set_gpu_engine(work->pool->gpu_engine);
for (i = 0; i < nDevs; i++) else if(!empty_string(default_profile.gpu_engine))
set_engineclock(i, gpus[i].min_engine); set_gpu_engine(default_profile.gpu_engine);
}
//GPU memory clock
if(!empty_string(work->pool->gpu_memclock)) if(!empty_string(work->pool->gpu_memclock))
{
set_gpu_memclock(work->pool->gpu_memclock); set_gpu_memclock(work->pool->gpu_memclock);
for (i = 0; i < nDevs; i++) else if(!empty_string(default_profile.gpu_memclock))
set_memoryclock(i, gpus[i].gpu_memclock); set_gpu_memclock(default_profile.gpu_memclock);
}
//GPU fans
if(!empty_string(work->pool->gpu_fan)) if(!empty_string(work->pool->gpu_fan))
{
set_gpu_fan(work->pool->gpu_fan); set_gpu_fan(work->pool->gpu_fan);
for (i = 0; i < nDevs; i++) else if(!empty_string(default_profile.gpu_fan))
if (gpus[i].min_fan == gpus[i].gpu_fan) set_gpu_fan(default_profile.gpu_fan);
set_fanspeed(i, gpus[i].gpu_fan);
} //GPU powertune
if(!empty_string(work->pool->gpu_powertune))
set_gpu_powertune((char *)work->pool->gpu_powertune);
else if(!empty_string(default_profile.gpu_powertune))
set_gpu_powertune((char *)default_profile.gpu_powertune);
//GPU vddc
if(!empty_string(work->pool->gpu_vddc))
set_gpu_vddc((char *)work->pool->gpu_vddc);
else if(!empty_string(default_profile.gpu_vddc))
set_gpu_vddc((char *)default_profile.gpu_vddc);
//apply gpu settings
for (i = 0; i < nDevs; i++)
{
set_engineclock(i, gpus[i].min_engine);
set_memoryclock(i, gpus[i].gpu_memclock);
set_fanspeed(i, gpus[i].gpu_fan);
set_powertune(i, gpus[i].gpu_powertune);
set_vddc(i, gpus[i].gpu_vddc);
}
#endif #endif
// Change algorithm for each thread (thread_prepare calls initCl) // Change algorithm for each thread (thread_prepare calls initCl)
for (i = 0; i < mining_threads; i++) { for (i = 0; i < start_threads; i++)
{
struct thr_info *thr = mining_thr[i]; struct thr_info *thr = mining_thr[i];
thr->cgpu->algorithm = work->pool->algorithm; thr->cgpu->algorithm = work->pool->algorithm;
if (soft_restart) { if (soft_restart) {
@ -5878,22 +6036,66 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work)
thr->cgpu->drv->working_diff = 1; thr->cgpu->drv->working_diff = 1;
} }
rd_unlock(&mining_thr_lock); rd_unlock(&mining_thr_lock);
// Finish switching pools // Finish switching pools
algo_switch_n = 0; algo_switch_n = 0;
mutex_unlock(&algo_switch_lock); mutex_unlock(&algo_switch_lock);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
// Hard restart (when gpu_threads is changed) // Hard restart (when gpu_threads is changed)
if (!soft_restart) { if (!soft_restart)
{
//enable/disable devices based on profile/pool/defaults
sgminer_id_count = 0; //reset sgminer_ids
mining_threads = 0; //mining threads gets added inside each enable_device() so reset
if(opt_devs_enabled)
{
for (i = 0; i < MAX_DEVICES; i++)
{
//device should be enabled
if(devices_enabled[i] && i < total_devices)
{
applog(LOG_DEBUG, "Enabling device %d", i);
enable_device(devices[i]);
}
else if(i < total_devices)
{
applog(LOG_DEBUG, "Disabling device %d", i);
//if option is set to not remove disabled, enable device
if(!opt_removedisabled)
enable_device(devices[i]);
//mark as disabled
devices[i]->deven = DEV_DISABLED;
}
}
}
//enable all devices
else
{
for (i = 0; i < total_devices; ++i)
enable_device(devices[i]);
}
//devices reset - assign gpu-threads as needed
unsigned int n_threads = 0; unsigned int n_threads = 0;
pthread_t restart_thr; pthread_t restart_thr;
#ifdef HAVE_ADL #ifdef HAVE_ADL
set_gpu_threads(work->pool->gpu_threads); if(!empty_string(work->pool->gpu_threads))
set_gpu_threads(work->pool->gpu_threads);
else if(!empty_string(default_profile.gpu_threads))
set_gpu_threads(default_profile.gpu_threads);
for (i = 0; i < total_devices; ++i) for (i = 0; i < total_devices; ++i)
n_threads += devices[i]->threads; n_threads += devices[i]->threads;
#else #else
n_threads = mining_threads; n_threads = mining_threads;
#endif #endif
/*use start_threads to close original threads... mining_threads was recounted above and would cause crashes
when trying to close a thread index that doesn't exist.*/
mining_threads = start_threads;
if (unlikely(pthread_create(&restart_thr, NULL, restart_mining_threads_thread, (void *) (intptr_t) n_threads))) if (unlikely(pthread_create(&restart_thr, NULL, restart_mining_threads_thread, (void *) (intptr_t) n_threads)))
quit(1, "restart_mining_threads create thread failed"); quit(1, "restart_mining_threads create thread failed");
sleep(60); sleep(60);
@ -7192,8 +7394,6 @@ void enable_curses(void) {
} }
#endif #endif
static int sgminer_id_count = 0;
/* Various noop functions for drivers that don't support or need their /* Various noop functions for drivers that don't support or need their
* variants. */ * variants. */
static void noop_reinit_device(struct cgpu_info __maybe_unused *cgpu) static void noop_reinit_device(struct cgpu_info __maybe_unused *cgpu)
@ -7373,16 +7573,18 @@ static void restart_mining_threads(unsigned int new_n_threads)
if (mining_thr) { if (mining_thr) {
rd_lock(&mining_thr_lock); rd_lock(&mining_thr_lock);
for (i = 0; i < mining_threads; i++) { for (i = 0; i < mining_threads; i++) {
mining_thr[i]->cgpu->shutdown = true; applog(LOG_DEBUG, "Shutting down thread %d", i);
mining_thr[i]->cgpu->shutdown = true;
} }
rd_unlock(&mining_thr_lock); rd_unlock(&mining_thr_lock);
// kill_mining will rd lock mining_thr_lock // kill_mining will rd lock mining_thr_lock
kill_mining(); kill_mining();
rd_lock(&mining_thr_lock); rd_lock(&mining_thr_lock);
for (i = 0; i < mining_threads; i++) { for (i = 0; i < mining_threads; i++)
thr = mining_thr[i]; {
thr->cgpu->drv->thread_shutdown(thr); thr = mining_thr[i];
thr->cgpu->shutdown = false; thr->cgpu->drv->thread_shutdown(thr);
thr->cgpu->shutdown = false;
} }
rd_unlock(&mining_thr_lock); rd_unlock(&mining_thr_lock);
} }
@ -7610,9 +7812,9 @@ int main(int argc, char *argv[])
wlogprint("Cannot open or create file\n"); wlogprint("Cannot open or create file\n");
quit(1,""); quit(1,"");
}*/ }*/
write_config("./testconf_test.conf"); //write_config("./testconf_test.conf");
//fclose(fcfg); //fclose(fcfg);
quit(1,"file saved."); //quit(1,"file saved.");
if (opt_benchmark) { if (opt_benchmark) {

Loading…
Cancel
Save