Browse Source

opencl: Default to single thread with Mesa OpenCL

Luke Dashjr 13 years ago
parent
commit
4b59876501
3 changed files with 10 additions and 1 deletions
  1. 3 0
      driver-opencl.c
  2. 1 1
      miner.c
  3. 6 0
      ocl.c

+ 3 - 0
driver-opencl.c

@@ -1433,6 +1433,9 @@ static void opencl_detect()
 	if (!nDevs)
 		return;
 
+	if (opt_g_threads == -1)
+		opt_g_threads = 2;
+
 	for (i = 0; i < nDevs; ++i) {
 		struct cgpu_info *cgpu;
 

+ 1 - 1
miner.c

@@ -138,7 +138,7 @@ unsigned long long global_hashrate;
 #ifdef HAVE_OPENCL
 int opt_dynamic_interval = 7;
 int nDevs;
-int opt_g_threads = 2;
+int opt_g_threads = -1;
 int gpu_threads;
 #endif
 #ifdef USE_SCRYPT

+ 6 - 0
ocl.c

@@ -251,6 +251,8 @@ char *file_contents(const char *filename, int *length)
 	return (char*)buffer;
 }
 
+extern int opt_g_threads;
+
 int clDevicesNum(void) {
 	cl_int status;
 	char pbuff[256];
@@ -259,6 +261,7 @@ int clDevicesNum(void) {
 	cl_platform_id *platforms;
 	cl_platform_id platform = NULL;
 	unsigned int most_devices = 0, i, mdplatform = 0;
+	bool mdmesa = false;
 
 	status = clGetPlatformIDs(0, NULL, &numPlatforms);
 	/* If this fails, assume no GPUs. */
@@ -307,6 +310,7 @@ int clDevicesNum(void) {
 		if (numDevices > most_devices) {
 			most_devices = numDevices;
 			mdplatform = i;
+			mdmesa = strstr(pbuff, "MESA");
 		}
 		if (numDevices) {
 			unsigned int j;
@@ -324,6 +328,8 @@ int clDevicesNum(void) {
 
 	if (opt_platform_id < 0)
 		opt_platform_id = mdplatform;;
+	if (mdmesa && opt_g_threads == -1)
+		opt_g_threads = 1;
 
 	return most_devices;
 }