Browse Source

opencl: Reintroduce independent intensity setting internally

Luke Dashjr 11 years ago
parent
commit
5014232892
2 changed files with 10 additions and 0 deletions
  1. 6 0
      driver-opencl.c
  2. 4 0
      driver-opencl.h

+ 6 - 0
driver-opencl.c

@@ -308,6 +308,7 @@ void opencl_early_init()
 		struct opencl_device_data * const data = &dataarray[i];
 		struct opencl_device_data * const data = &dataarray[i];
 		*data = (struct opencl_device_data){
 		*data = (struct opencl_device_data){
 			.dynamic = true,
 			.dynamic = true,
+			.intensity = intensity_not_set,
 		};
 		};
 		gpus[i] = (struct cgpu_info){
 		gpus[i] = (struct cgpu_info){
 			.device_data = data,
 			.device_data = data,
@@ -685,6 +686,7 @@ bool opencl_set_intensity_from_str(struct cgpu_info * const cgpu, const char *_v
 {
 {
 	struct opencl_device_data * const data = cgpu->device_data;
 	struct opencl_device_data * const data = cgpu->device_data;
 	unsigned long oclthreads = 0;
 	unsigned long oclthreads = 0;
+	float intensity = intensity_not_set;
 	bool dynamic = false;
 	bool dynamic = false;
 	
 	
 	if (!strncasecmp(_val, "d", 1))
 	if (!strncasecmp(_val, "d", 1))
@@ -716,6 +718,7 @@ bool opencl_set_intensity_from_str(struct cgpu_info * const cgpu, const char *_v
 		if (v < MIN_INTENSITY || v > MAX_GPU_INTENSITY)
 		if (v < MIN_INTENSITY || v > MAX_GPU_INTENSITY)
 			return false;
 			return false;
 		oclthreads = intensity_to_oclthreads(v, !opt_scrypt);
 		oclthreads = intensity_to_oclthreads(v, !opt_scrypt);
+		intensity = v;
 	}
 	}
 	
 	
 	// Make actual assignments after we know the values are valid
 	// Make actual assignments after we know the values are valid
@@ -723,6 +726,7 @@ bool opencl_set_intensity_from_str(struct cgpu_info * const cgpu, const char *_v
 	if (data->oclthreads)
 	if (data->oclthreads)
 	{
 	{
 		data->oclthreads = oclthreads;
 		data->oclthreads = oclthreads;
+		data->intensity = intensity;
 		pause_dynamic_threads(cgpu->device_id);
 		pause_dynamic_threads(cgpu->device_id);
 	}
 	}
 	else
 	else
@@ -1725,6 +1729,8 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
 			if (data->oclthreads > max_oclthreads)
 			if (data->oclthreads > max_oclthreads)
 				data->oclthreads = max_oclthreads;
 				data->oclthreads = max_oclthreads;
 		}
 		}
+		if (data->intensity != intensity_not_set)
+			data->intensity = oclthreads_to_intensity(data->oclthreads, !opt_scrypt);
 		memcpy(&(data->tv_gpustart), &tv_gpuend, sizeof(struct timeval));
 		memcpy(&(data->tv_gpustart), &tv_gpuend, sizeof(struct timeval));
 		data->intervals = 0;
 		data->intervals = 0;
 	}
 	}

+ 4 - 0
driver-opencl.h

@@ -1,6 +1,7 @@
 #ifndef BFG_DRIVER_OPENCL
 #ifndef BFG_DRIVER_OPENCL
 #define BFG_DRIVER_OPENCL
 #define BFG_DRIVER_OPENCL
 
 
+#include <float.h>
 #include <stdbool.h>
 #include <stdbool.h>
 
 
 #include "CL/cl.h"
 #include "CL/cl.h"
@@ -32,11 +33,14 @@ enum opencl_binary_usage {
 	OBU_NONE     = 4,
 	OBU_NONE     = 4,
 };
 };
 
 
+static const float intensity_not_set = FLT_MAX;
+
 struct opencl_device_data {
 struct opencl_device_data {
 	bool mapped;
 	bool mapped;
 	int virtual_gpu;
 	int virtual_gpu;
 	int virtual_adl;
 	int virtual_adl;
 	unsigned long oclthreads;
 	unsigned long oclthreads;
+	float intensity;
 	char *_init_intensity;
 	char *_init_intensity;
 	bool dynamic;
 	bool dynamic;