Skip to content

Commit 7aeae40

Browse files
Kalrothveox
authored andcommitted
EXPERIMENTAL: A new way of setting intensity; introducing xintensity!
All of this is credited to ArGee of RGMiner, he did the initial ground work for this setting. This new setting allows for a much finer grained intensity setting and also opens up for dual gpu threads on devices not previously able to. Note: make sure to use lower thread-concurrency values when you increase cpu threads. Intensity is currently used to spawn GPU threads as a simple 2^value setting. I:13 = 8192 threads I:15 = 32768 threads I:17 = 131072 threads I:18 = 262144 threads I:19 = 524288 threads I:20 = 1048576 threads Notice how the higher settings increase thread count tremendously. Now enter the xintensity setting (Yes, I am a genius with my naming convention!). It is simply a shader multiplier, obviously based on the amount of shaders you got on a card, this should allow the same value to scale with different card models. 6970 with 1536 shaders: xI:64 = 98304 threads R9 280X with 2048 shaders: xI:64 = 131072 threads R9 290 with 2560 shaders: xI:64 = 180224 threads R9 290X with 2816 shaders: xI:64 = 163840 threads 6970 with 1536 shaders: xI:300 = 460800 threads R9 280X with 2048 shaders: xI:300 = 614400 threads R9 290 with 2560 shaders: xI:300 = 768000 threads R9 290X with 2816 shaders: xI:300 = 844800 threads It's now much easier to control thread intensity and it potentially allows for a uniform way of setting the intensity on your system. I'm very interested in constructive feedback, as I do not have access to a lot of different card models. This change has been tested on 6970, R9 290, R9 290X - all with equal or a little better speeds than regular intensity setting after a little tuning, but your mileage may vary. Don't fret it, if this doesn't work for you, the regular intensity setting is still available. Conflicts: driver-opencl.c sgminer.c
1 parent d7e469b commit 7aeae40

File tree

6 files changed

+68
-6
lines changed

6 files changed

+68
-6
lines changed

driver-opencl.c

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ char *set_intensity(char *arg)
563563
return "Invalid value passed to set intensity";
564564
tt = &gpus[device].intensity;
565565
*tt = val;
566+
gpus[device].xintensity = 0; // Disable shader based intensity
566567
}
567568

568569
device++;
@@ -578,19 +579,57 @@ char *set_intensity(char *arg)
578579

579580
tt = &gpus[device].intensity;
580581
*tt = val;
582+
gpus[device].xintensity = 0; // Disable shader based intensity
581583
}
582584
device++;
583585
}
584586
if (device == 1) {
585587
for (i = device; i < MAX_GPUDEVICES; i++) {
586588
gpus[i].dynamic = gpus[0].dynamic;
587589
gpus[i].intensity = gpus[0].intensity;
590+
gpus[i].xintensity = 0; // Disable shader based intensity
588591
}
589592
}
590593

591594
return NULL;
592595
}
593596

597+
char *set_xintensity(char *arg)
598+
{
599+
int i, device = 0, val = 0;
600+
char *nextptr;
601+
602+
nextptr = strtok(arg, ",");
603+
if (nextptr == NULL)
604+
return "Invalid parameters for shader based intensity";
605+
val = atoi(nextptr);
606+
if (val < 1 || val > 9999)
607+
return "Invalid value passed to set shader intensity";
608+
609+
gpus[device].dynamic = false; // Disable dynamic intensity
610+
gpus[device].intensity = 0; // Disable regular intensity
611+
gpus[device].xintensity = val;
612+
device++;
613+
614+
while ((nextptr = strtok(NULL, ",")) != NULL) {
615+
val = atoi(nextptr);
616+
if (val < 1 || val > 9999)
617+
return "Invalid value passed to set shader based intensity";
618+
gpus[device].dynamic = false; // Disable dynamic intensity
619+
gpus[device].intensity = 0; // Disable regular intensity
620+
gpus[device].xintensity = val;
621+
device++;
622+
}
623+
if (device == 1)
624+
for (i = device; i < MAX_GPUDEVICES; i++) {
625+
gpus[i].dynamic = gpus[0].dynamic; // Disable dynamic intensity
626+
gpus[i].intensity = gpus[0].intensity; // Disable regular intensity
627+
gpus[i].xintensity = gpus[0].xintensity;
628+
}
629+
630+
return NULL;
631+
}
632+
594633
void print_ndevs(int *ndevs)
595634
{
596635
opt_log_output = true;
@@ -878,13 +917,16 @@ static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u
878917
return status;
879918
}
880919

881-
static void set_threads_hashes(unsigned int vectors,int64_t *hashes, size_t *globalThreads,
882-
unsigned int minthreads, __maybe_unused int *intensity)
920+
static void set_threads_hashes(unsigned int vectors, unsigned int compute_shaders, int64_t *hashes, size_t *globalThreads,
921+
unsigned int minthreads, __maybe_unused int *intensity, __maybe_unused int *xintensity)
883922
{
884923
unsigned int threads = 0;
885-
886924
while (threads < minthreads) {
887-
threads = 1 << *intensity;
925+
if (*xintensity > 0) {
926+
threads = compute_shaders * *xintensity;
927+
} else {
928+
threads = 1 << *intensity;
929+
}
888930
if (threads < minthreads) {
889931
if (likely(*intensity < MAX_INTENSITY))
890932
(*intensity)++;
@@ -1077,7 +1119,10 @@ static void get_opencl_statline_before(char *buf, size_t bufsiz, struct cgpu_inf
10771119

10781120
static void get_opencl_statline(char *buf, size_t bufsiz, struct cgpu_info *gpu)
10791121
{
1080-
tailsprintf(buf, bufsiz, " I:%2d", gpu->intensity);
1122+
if (gpu->xintensity > 0)
1123+
tailsprintf(buf, bufsiz, " xI:%3d", gpu->threads, gpu->xintensity);
1124+
else
1125+
tailsprintf(buf, bufsiz, " I:%2d", gpu->threads, gpu->intensity);
10811126
}
10821127

10831128
struct opencl_thread_data {
@@ -1243,7 +1288,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
12431288
gpu->intervals = 0;
12441289
}
12451290

1246-
set_threads_hashes(clState->vwidth, &hashes, globalThreads, localThreads[0], &gpu->intensity);
1291+
set_threads_hashes(clState->vwidth, clState->compute_shaders, &hashes, globalThreads, localThreads[0], &gpu->intensity, &gpu->xintensity);
12471292
if (hashes > gpu->max_hashes)
12481293
gpu->max_hashes = hashes;
12491294

driver-opencl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extern char *set_gpu_vddc(char *arg);
1717
extern char *set_temp_overheat(char *arg);
1818
extern char *set_temp_target(char *arg);
1919
extern char *set_intensity(char *arg);
20+
extern char *set_xintensity(char *arg);
2021
extern char *set_vector(char *arg);
2122
extern char *set_worksize(char *arg);
2223
extern char *set_shaders(char *arg);

miner.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ struct cgpu_info {
464464
int virtual_gpu;
465465
int virtual_adl;
466466
int intensity;
467+
int xintensity;
467468
bool dynamic;
468469

469470
cl_uint vwidth;

ocl.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,17 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
369369
return NULL;
370370
}
371371
applog(LOG_DEBUG, "Max work group size reported %d", (int)(clState->max_work_size));
372+
373+
size_t compute_units = 0;
374+
status = clGetDeviceInfo(devices[gpu], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(size_t), (void *)&compute_units, NULL);
375+
if (status != CL_SUCCESS) {
376+
applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_MAX_COMPUTE_UNITS", status);
377+
return NULL;
378+
}
379+
// AMD architechture got 64 compute shaders per compute unit.
380+
// Source: http://www.amd.com/us/Documents/GCN_Architecture_whitepaper.pdf
381+
clState->compute_shaders = compute_units * 64;
382+
applog(LOG_DEBUG, "Max shaders calculated %d", (int)(clState->compute_shaders));
372383

373384
status = clGetDeviceInfo(devices[gpu], CL_DEVICE_MAX_MEM_ALLOC_SIZE , sizeof(cl_ulong), (void *)&cgpu->max_alloc, NULL);
374385
if (status != CL_SUCCESS) {

ocl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ typedef struct {
2929
cl_uint vwidth;
3030
size_t max_work_size;
3131
size_t wsize;
32+
size_t compute_shaders;
3233
enum cl_kernels chosen_kernel;
3334
} _clState;
3435

sgminer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,9 @@ static struct opt_table opt_config_table[] = {
10831083
"Intensity of GPU scanning (d or " MIN_INTENSITY_STR
10841084
" -> " MAX_INTENSITY_STR
10851085
",default: d to maintain desktop interactivity)"),
1086+
OPT_WITH_ARG("--xintensity|-X",
1087+
set_xintensity, NULL, NULL,
1088+
"Shader based intensity of GPU scanning (0 to 9999), overrides --intensity|-I."),
10861089
OPT_WITH_ARG("--kernel-path|-K",
10871090
opt_set_charp, opt_show_charp, &opt_kernel_path,
10881091
"Specify a path to where kernel files are"),

0 commit comments

Comments
 (0)