1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-30 08:24:26 +00:00

Dynamic intensity for GPUs should be calculated on a per device basis. Clean up the code to only calculate it if required as well.

This commit is contained in:
Con Kolivas 2012-06-25 13:31:52 +10:00
parent 17ba2dca63
commit eaf1505381
2 changed files with 16 additions and 14 deletions

View File

@ -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;
}

View File

@ -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;