Browse Source

Merge branch 'cg_cherry_20120325' into bfgminer

Luke Dashjr 13 years ago
parent
commit
ffb9bd3514
8 changed files with 72 additions and 31 deletions
  1. 16 9
      README
  2. 4 2
      README.RPC
  3. 5 0
      README.scrypt
  4. 1 0
      api.c
  5. 17 6
      miner.c
  6. 1 0
      miner.h
  7. 7 2
      ocl.c
  8. 21 12
      util.c

+ 16 - 9
README

@@ -1,5 +1,4 @@
-
-This is a multi-threaded multi-pool FPGA, GPU and CPU miner with ATI GPU
+This is a multi-threaded multi-pool ASIC, FPGA, GPU and CPU miner with ATI GPU
 monitoring, (over)clocking and fanspeed support for bitcoin and derivative
 monitoring, (over)clocking and fanspeed support for bitcoin and derivative
 coins. Do not use on multiple block chains at the same time!
 coins. Do not use on multiple block chains at the same time!
 
 
@@ -62,6 +61,7 @@ Optional Dependencies:
 
 
 
 
 BFGMiner specific configuration options:
 BFGMiner specific configuration options:
+	--enable-avalon         Compile support for Avalon (default disabled)
 	--enable-cpumining      Build with cpu mining support(default disabled)
 	--enable-cpumining      Build with cpu mining support(default disabled)
 	--disable-opencl        Build without support for OpenCL (default enabled)
 	--disable-opencl        Build without support for OpenCL (default enabled)
 	--disable-adl           Build without ADL monitoring (default enabled)
 	--disable-adl           Build without ADL monitoring (default enabled)
@@ -82,19 +82,23 @@ Install AMD APP sdk, ideal version (see FAQ!) - put it into a system location.
 Download the correct version for either 32 bit or 64 bit from here:
 Download the correct version for either 32 bit or 64 bit from here:
 	http://developer.amd.com/tools/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/downloads/
 	http://developer.amd.com/tools/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/downloads/
 
 
-This will give you a file with a name like AMD-APP-SDK-v2.4-lnx64.tgz
+This will give you a file with a name like:
+ AMD-APP-SDK-v2.4-lnx64.tgz (64-bit)
+or
+ AMD-APP-SDK-v2.4-lnx32.tgz (32-bit)
 
 
 Then:
 Then:
 
 
 sudo -i
 sudo -i
 cd /opt
 cd /opt
-tar xf /path/to/AMD-APP-SDK-v2.4-lnx64.tgz
+tar xf /path/to/AMD-APP-SDK-v2.4-lnx##.tgz
 cd /
 cd /
-tar xf /opt/AMD-APP-SDK-v2.4-lnx64/icd-registration.tgz
-ln -s /opt/AMD-APP-SDK-v2.4-lnx64/include/CL /usr/include
-ln -s /opt/AMD-APP-SDK-v2.4-lnx64/lib/x86_64/* /usr/lib/
+tar xf /opt/AMD-APP-SDK-v2.4-lnx##/icd-registration.tgz
+ln -s /opt/AMD-APP-SDK-v2.4-lnx##/include/CL /usr/include
+ln -s /opt/AMD-APP-SDK-v2.4-lnx##/lib/x86_64/* /usr/lib/
 ldconfig
 ldconfig
 
 
+Where ## is 32 or 64, depending on the bitness of the SDK you downloaded.
 If you are on 32 bit, x86_64 in the 2nd last line should be x86
 If you are on 32 bit, x86_64 in the 2nd last line should be x86
 
 
 Basic *nix build instructions:
 Basic *nix build instructions:
@@ -687,7 +691,8 @@ Sets card 0 cutoff temperature to 95 and card 1 to 105.
 This setting will modify the memory speed whenever the GPU clock speed is
 This setting will modify the memory speed whenever the GPU clock speed is
 modified by --auto-gpu. In this example, it will set the memory speed to be 125
 modified by --auto-gpu. In this example, it will set the memory speed to be 125
 MHz lower than the GPU speed. This is useful for some cards like the 6970 which
 MHz lower than the GPU speed. This is useful for some cards like the 6970 which
-normally don't allow a bigger clock speed difference.
+normally don't allow a bigger clock speed difference. The 6970 is known to only
+allow -125, while the 7970 only allows -150.
 
 
 
 
 CHANGING SETTINGS:
 CHANGING SETTINGS:
@@ -845,7 +850,9 @@ CPU core unnecessarily so downgrade to 11.6. Binding BFGMiner to one CPU core on
 windows can minimise it to 100% (instead of more than one core). Driver version
 windows can minimise it to 100% (instead of more than one core). Driver version
 11.11 on linux and 11.12 on windows appear to have fixed this issue. Note that
 11.11 on linux and 11.12 on windows appear to have fixed this issue. Note that
 later drivers may have an apparent return of high CPU usage. Try
 later drivers may have an apparent return of high CPU usage. Try
-'export GPU_USE_SYNC_OBJECTS=1' on Linux before starting BFGMiner.
+'export GPU_USE_SYNC_OBJECTS=1' on Linux before starting BFGMiner. You can also
+set this variable in windows via a batch file or on the command line before
+starting BFGMiner with 'setx GPU_USE_SYNC_OBJECTS 1'
 
 
 Q: Can you implement feature X?
 Q: Can you implement feature X?
 A: I can, but time is limited, and people who donate are more likely to get
 A: I can, but time is limited, and people who donate are more likely to get

+ 4 - 2
README.RPC

@@ -305,7 +305,8 @@ The list of requests - a (*) means it requires privileged access - and replies a
                               Hash Method=sha256/scrypt,
                               Hash Method=sha256/scrypt,
                               Current Block Time=N.N, <- 0 means none
                               Current Block Time=N.N, <- 0 means none
                               Current Block Hash=XXXX..., <- blank if none
                               Current Block Hash=XXXX..., <- blank if none
-                              LP=true/false| <- LP is in use on at least 1 pool
+                              LP=true/false, <- LP is in use on at least 1 pool
+                              Network Difficulty=NN.NN|
 
 
  debug|setting (*)
  debug|setting (*)
                DEBUG          Debug settings
                DEBUG          Debug settings
@@ -408,7 +409,7 @@ miner.php - an example web page to access the API
 Feature Changelog for external applications using the API:
 Feature Changelog for external applications using the API:
 
 
 
 
-API V1.24b
+API V1.24.1
 
 
 Modified API commands:
 Modified API commands:
  'cpustatus' - add 'ProcID'
  'cpustatus' - add 'ProcID'
@@ -419,6 +420,7 @@ Modified API commands:
  'devdetails' - add 'ProcID'
  'devdetails' - add 'ProcID'
  'devdetail' - add 'Name', 'ID', and 'ProcID'
  'devdetail' - add 'Name', 'ID', and 'ProcID'
  'pools' - add 'Message'
  'pools' - add 'Message'
+ 'coin' - add 'Network Difficulty'
 
 
 Pretty much updated every method returning 'Name' and 'ID' to also return
 Pretty much updated every method returning 'Name' and 'ID' to also return
 'ProcID'. This is a number starting with 0 for 'a', 1 for 'b', etc.
 'ProcID'. This is a number starting with 0 for 'a', 1 for 'b', etc.

+ 5 - 0
README.scrypt

@@ -32,6 +32,11 @@ a value of 40 is enough and increasing this further has little effect.
 export GPU_USE_SYNC_OBJECTS=1
 export GPU_USE_SYNC_OBJECTS=1
 may help CPU usage a little as well.
 may help CPU usage a little as well.
 
 
+On windows the same commands can be passed via a batch file if the following
+lines are in the .bat before starting cgminer:
+setx GPU_MAX_ALLOC_PERCENT 100
+setx GPU_USE_SYNC_OBJECTS 1
+
 --shaders XXX
 --shaders XXX
 
 
 is a new option where you tell BFGMiner how many shaders your GPU has. This
 is a new option where you tell BFGMiner how many shaders your GPU has. This

+ 1 - 0
api.c

@@ -2871,6 +2871,7 @@ static void minecoin(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __may
 	mutex_unlock(&ch_lock);
 	mutex_unlock(&ch_lock);
 
 
 	root = api_add_bool(root, "LP", &have_longpoll, false);
 	root = api_add_bool(root, "LP", &have_longpoll, false);
+	root = api_add_diff(root, "Network Difficulty", &current_diff, true);
 
 
 	root = print_data(root, buf, isjson, false);
 	root = print_data(root, buf, isjson, false);
 	io_add(io_data, buf);
 	io_add(io_data, buf);

+ 17 - 6
miner.c

@@ -270,6 +270,7 @@ static char datestamp[40];
 static char blocktime[32];
 static char blocktime[32];
 struct timeval block_timeval;
 struct timeval block_timeval;
 static char best_share[8] = "0";
 static char best_share[8] = "0";
+double current_diff;
 static char block_diff[8];
 static char block_diff[8];
 uint64_t best_diff = 0;
 uint64_t best_diff = 0;
 
 
@@ -3744,8 +3745,14 @@ bool stale_work(struct work *work, bool share)
 		}
 		}
 
 
 	if (pool->has_stratum && work->job_id) {
 	if (pool->has_stratum && work->job_id) {
-		bool same_job = true;
+		bool same_job;
 
 
+		if (!pool->stratum_active || !pool->stratum_notify) {
+			applog(LOG_DEBUG, "Work stale due to stratum inactive");
+			return true;
+		}
+
+		same_job = true;
 		mutex_lock(&pool->pool_lock);
 		mutex_lock(&pool->pool_lock);
 		if (strcmp(work->job_id, pool->swork.job_id))
 		if (strcmp(work->job_id, pool->swork.job_id))
 			same_job = false;
 			same_job = false;
@@ -4349,7 +4356,7 @@ void switch_pools(struct pool *selected)
 	{
 	{
 		pool->block_id = 0;
 		pool->block_id = 0;
 		if (pool_strategy != POOL_LOADBALANCE && pool_strategy != POOL_BALANCE) {
 		if (pool_strategy != POOL_LOADBALANCE && pool_strategy != POOL_BALANCE) {
-			applog(LOG_WARNING, "Switching to %s", pool->rpc_url);
+			applog(LOG_WARNING, "Switching to pool %d %s", pool->pool_no, pool->rpc_url);
 		}
 		}
 	}
 	}
 
 
@@ -4508,12 +4515,15 @@ static int block_sort(struct block *blocka, struct block *blockb)
 static void set_blockdiff(const struct work *work)
 static void set_blockdiff(const struct work *work)
 {
 {
 	unsigned char target[32];
 	unsigned char target[32];
+	double diff;
 	uint64_t diff64;
 	uint64_t diff64;
 
 
 	real_block_target(target, work->data);
 	real_block_target(target, work->data);
-	diff64 = target_diff(target);
+	diff = target_diff(target);
+	diff64 = diff;
 
 
 	suffix_string(diff64, block_diff, 0);
 	suffix_string(diff64, block_diff, 0);
+	current_diff = diff;
 }
 }
 
 
 static bool test_work_current(struct work *work)
 static bool test_work_current(struct work *work)
@@ -6071,15 +6081,16 @@ static void *stratum_thread(void *userdata)
 		/* If we fail to receive any notify messages for 2 minutes we
 		/* If we fail to receive any notify messages for 2 minutes we
 		 * assume the connection has been dropped and treat this pool
 		 * assume the connection has been dropped and treat this pool
 		 * as dead */
 		 * as dead */
-		if (!sock_full(pool) && select(pool->sock + 1, &rd, NULL, NULL, &timeout) < 1)
+		if (!sock_full(pool) && select(pool->sock + 1, &rd, NULL, NULL, &timeout) < 1) {
+			applog(LOG_DEBUG, "Stratum select timeout on pool %d", pool->pool_no);
 			s = NULL;
 			s = NULL;
-		else
+		} else
 			s = recv_line(pool);
 			s = recv_line(pool);
 		if (!s) {
 		if (!s) {
 			if (!pool->has_stratum)
 			if (!pool->has_stratum)
 				break;
 				break;
 
 
-			applog(LOG_INFO, "Stratum connection to pool %d interrupted", pool->pool_no);
+			applog(LOG_NOTICE, "Stratum connection to pool %d interrupted", pool->pool_no);
 			pool->getfail_occasions++;
 			pool->getfail_occasions++;
 			total_go++;
 			total_go++;
 
 

+ 1 - 0
miner.h

@@ -880,6 +880,7 @@ extern int opt_fail_pause;
 extern int opt_log_interval;
 extern int opt_log_interval;
 extern unsigned long long global_hashrate;
 extern unsigned long long global_hashrate;
 extern char *current_fullhash;
 extern char *current_fullhash;
+extern double current_diff;
 extern uint64_t best_diff;
 extern uint64_t best_diff;
 extern struct timeval block_timeval;
 extern struct timeval block_timeval;
 
 

+ 7 - 2
ocl.c

@@ -280,6 +280,9 @@ int clDevicesNum(void) {
 	}
 	}
 
 
 	for (i = 0; i < numPlatforms; i++) {
 	for (i = 0; i < numPlatforms; i++) {
+		if (opt_platform_id >= 0 && (int)i != opt_platform_id)
+			continue;
+
 		status = clGetPlatformInfo( platforms[i], CL_PLATFORM_VENDOR, sizeof(pbuff), pbuff, NULL);
 		status = clGetPlatformInfo( platforms[i], CL_PLATFORM_VENDOR, sizeof(pbuff), pbuff, NULL);
 		if (status != CL_SUCCESS) {
 		if (status != CL_SUCCESS) {
 			applog(LOG_ERR, "Error %d: Getting Platform Info. (clGetPlatformInfo)", status);
 			applog(LOG_ERR, "Error %d: Getting Platform Info. (clGetPlatformInfo)", status);
@@ -571,7 +574,8 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 			 strstr(vbuff, "831.4") ||
 			 strstr(vbuff, "831.4") ||
 			 strstr(vbuff, "898.1") ||  // 12.2 driver SDK 
 			 strstr(vbuff, "898.1") ||  // 12.2 driver SDK 
 			 strstr(vbuff, "923.1") ||  // 12.4
 			 strstr(vbuff, "923.1") ||  // 12.4
-			 strstr(vbuff, "938.2"))) { // SDK 2.7
+			 strstr(vbuff, "938.2") ||  // SDK 2.7
+			 strstr(vbuff, "1113.2"))) {// SDK 2.8
 				applog(LOG_INFO, "Selecting diablo kernel");
 				applog(LOG_INFO, "Selecting diablo kernel");
 				clState->chosen_kernel = KL_DIABLO;
 				clState->chosen_kernel = KL_DIABLO;
 		/* Detect all 7970s, older ATI and NVIDIA and use poclbm */
 		/* Detect all 7970s, older ATI and NVIDIA and use poclbm */
@@ -589,7 +593,8 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 		if (clState->chosen_kernel == KL_PHATK &&
 		if (clState->chosen_kernel == KL_PHATK &&
 		    (strstr(vbuff, "844.4") || strstr(vbuff, "851.4") ||
 		    (strstr(vbuff, "844.4") || strstr(vbuff, "851.4") ||
 		     strstr(vbuff, "831.4") || strstr(vbuff, "898.1") ||
 		     strstr(vbuff, "831.4") || strstr(vbuff, "898.1") ||
-		     strstr(vbuff, "923.1") || strstr(vbuff, "938.2"))) {
+		     strstr(vbuff, "923.1") || strstr(vbuff, "938.2") ||
+		     strstr(vbuff, "1113.2"))) {
 			applog(LOG_WARNING, "WARNING: You have selected the phatk kernel.");
 			applog(LOG_WARNING, "WARNING: You have selected the phatk kernel.");
 			applog(LOG_WARNING, "You are running SDK 2.6+ which performs poorly with this kernel.");
 			applog(LOG_WARNING, "You are running SDK 2.6+ which performs poorly with this kernel.");
 			applog(LOG_WARNING, "Downgrade your SDK and delete any .bin files before starting again.");
 			applog(LOG_WARNING, "Downgrade your SDK and delete any .bin files before starting again.");

+ 21 - 12
util.c

@@ -1197,16 +1197,22 @@ bool sock_full(struct pool *pool)
 	return (socket_full(pool, false));
 	return (socket_full(pool, false));
 }
 }
 
 
+static void clear_sockbuf(struct pool *pool)
+{
+	strcpy(pool->sockbuf, "");
+}
+
 static void clear_sock(struct pool *pool)
 static void clear_sock(struct pool *pool)
 {
 {
 	ssize_t n;
 	ssize_t n;
 
 
 	mutex_lock(&pool->stratum_lock);
 	mutex_lock(&pool->stratum_lock);
-	do
+	do {
 		n = recv(pool->sock, pool->sockbuf, RECVSIZE, 0);
 		n = recv(pool->sock, pool->sockbuf, RECVSIZE, 0);
-	while (n > 0);
+	} while (n > 0);
 	mutex_unlock(&pool->stratum_lock);
 	mutex_unlock(&pool->stratum_lock);
-	strcpy(pool->sockbuf, "");
+
+	clear_sockbuf(pool);
 }
 }
 
 
 /* Make sure the pool sockbuf is large enough to cope with any coinbase size
 /* Make sure the pool sockbuf is large enough to cope with any coinbase size
@@ -1951,17 +1957,9 @@ out:
 	return ret;
 	return ret;
 }
 }
 
 
-bool restart_stratum(struct pool *pool)
-{
-	if (!initiate_stratum(pool))
-		return false;
-	if (!auth_stratum(pool))
-		return false;
-	return true;
-}
-
 void suspend_stratum(struct pool *pool)
 void suspend_stratum(struct pool *pool)
 {
 {
+	clear_sockbuf(pool);
 	applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);
 	applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);
 	mutex_lock(&pool->stratum_lock);
 	mutex_lock(&pool->stratum_lock);
 	pool->stratum_active = false;
 	pool->stratum_active = false;
@@ -1972,6 +1970,17 @@ void suspend_stratum(struct pool *pool)
 	mutex_unlock(&pool->stratum_lock);
 	mutex_unlock(&pool->stratum_lock);
 }
 }
 
 
+bool restart_stratum(struct pool *pool)
+{
+	if (pool->stratum_active)
+		suspend_stratum(pool);
+	if (!initiate_stratum(pool))
+		return false;
+	if (!auth_stratum(pool))
+		return false;
+	return true;
+}
+
 void dev_error(struct cgpu_info *dev, enum dev_reason reason)
 void dev_error(struct cgpu_info *dev, enum dev_reason reason)
 {
 {
 	dev->device_last_not_well = time(NULL);
 	dev->device_last_not_well = time(NULL);