Dynamic intensity for GPUs should be calculated on a per device basis. Clean up the code to only calculate it if required as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
diff --git a/driver-opencl.c b/driver-opencl.c
index 9dbaef1..2d6f975 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -1350,34 +1350,32 @@ static uint64_t opencl_scanhash(struct thr_info *thr, struct work *work,
_clState *clState = clStates[thr_id];
const cl_kernel *kernel = &clState->kernel;
- double gpu_ms_average = 7;
cl_int status;
-
size_t globalThreads[1];
size_t localThreads[1] = { clState->wsize };
unsigned int threads;
unsigned int hashes;
-
- struct timeval tv_gpustart, tv_gpuend, diff;
- suseconds_t gpu_us;
-
- gettimeofday(&tv_gpustart, NULL);
- timeval_subtract(&diff, &tv_gpustart, &tv_gpuend);
+ gettimeofday(&gpu->tv_gpustart, NULL);
/* This finish flushes the readbuffer set with CL_FALSE later */
clFinish(clState->commandQueue);
- gettimeofday(&tv_gpuend, NULL);
- timeval_subtract(&diff, &tv_gpuend, &tv_gpustart);
- gpu_us = diff.tv_sec * 1000000 + diff.tv_usec;
- decay_time(&gpu_ms_average, gpu_us / 1000);
+ gettimeofday(&gpu->tv_gpuend, NULL);
+
if (gpu->dynamic) {
+ struct timeval diff;
+ suseconds_t gpu_ms;
+
+ timersub(&gpu->tv_gpuend, &gpu->tv_gpustart, &diff);
+ gpu_ms = diff.tv_sec * 1000 + diff.tv_usec / 1000;
+ gpu->gpu_ms_average = (gpu->gpu_ms_average + gpu_ms * 0.63) / 1.63;
+
/* Try to not let the GPU be out for longer than 6ms, but
* increase intensity when the system is idle, unless
* dynamic is disabled. */
- if (gpu_ms_average > opt_dynamic_interval) {
+ if (gpu->gpu_ms_average > opt_dynamic_interval) {
if (gpu->intensity > MIN_INTENSITY)
--gpu->intensity;
- } else if (gpu_ms_average < ((opt_dynamic_interval / 2) ? : 1)) {
+ } else if (gpu->gpu_ms_average < ((opt_dynamic_interval / 2) ? : 1)) {
if (gpu->intensity < MAX_INTENSITY)
++gpu->intensity;
}
diff --git a/miner.h b/miner.h
index 9eb1b6d..78d3b80 100644
--- a/miner.h
+++ b/miner.h
@@ -342,6 +342,10 @@ struct cgpu_info {
cl_uint vwidth;
size_t work_size;
enum cl_kernels kernel;
+
+ struct timeval tv_gpustart;;
+ struct timeval tv_gpuend;
+ double gpu_ms_average;
#endif
float temp;