Bitcoin Forum
December 10, 2016, 06:41:35 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: « 1 ... 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 »
  Print  
Author Topic: An (even more) optimized version of cpuminer (pooler's cpuminer, CPU-only)  (Read 1531123 times)
konradp
Full Member
***
Offline Offline

Activity: 126


View Profile
June 13, 2014, 08:08:55 AM
 #1041

Do you guys know what stratum_gen_work function does? (cpu-miner.c -> line 653).
For example I don't understand the purpose of this line:
/* Increment extranonce2 */
   for (i = 0; i < sctx->xnonce2_size && !++sctx->job.xnonce2; i++);

As stated in the comment, that line increments the extranonce2 field so that every time that new work is generated it is different. See the Stratum protocol specifications.

Thanks, I just don't understand why isn't it simply
Code:
sctx->job.xnonce2++

But that isn't very important for right now, I was just curious.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481395295
Hero Member
*
Offline Offline

Posts: 1481395295

View Profile Personal Message (Offline)

Ignore
1481395295
Reply with quote  #2

1481395295
Report to moderator
1481395295
Hero Member
*
Offline Offline

Posts: 1481395295

View Profile Personal Message (Offline)

Ignore
1481395295
Reply with quote  #2

1481395295
Report to moderator
1481395295
Hero Member
*
Offline Offline

Posts: 1481395295

View Profile Personal Message (Offline)

Ignore
1481395295
Reply with quote  #2

1481395295
Report to moderator
pooler
Hero Member
*****
Offline Offline

Activity: 644


View Profile
June 13, 2014, 08:55:03 AM
 #1042

Thanks, I just don't understand why isn't it simply
Code:
sctx->job.xnonce2++

Because xnonce2 is not an integer, but an array of bytes.

BTC: 15MRTcUweNVJbhTyH5rq9aeSdyigFrskqE · LTC: LTCPooLqTK1SANSNeTR63GbGwabTKEkuS7
konradp
Full Member
***
Offline Offline

Activity: 126


View Profile
June 13, 2014, 08:56:11 AM
 #1043

Thanks, I just don't understand why isn't it simply
Code:
sctx->job.xnonce2++

Because xnonce2 is not an integer, but an array of bytes.

Ach, indeed, I didn't notice, thanks!
wintrop
Full Member
***
Offline Offline

Activity: 160


View Profile
June 16, 2014, 09:00:50 AM
 #1044

Hi all. Please tell me how to configure cpuminer under quark algorithm?

Grifftech2k4
Full Member
***
Offline Offline

Activity: 210


View Profile
June 16, 2014, 08:01:08 PM
 #1045

Is this usable with Talkcoin?
jedimstr
Hero Member
*****
Offline Offline

Activity: 784



View Profile
June 17, 2014, 02:46:02 AM
 #1046

Hi all. Please tell me how to configure cpuminer under quark algorithm?
Is this usable with Talkcoin?

Read the first post in the thread, the third Q and A item.  Your answers are there.

Basically, you walked into a Catholic Church asking about the Book of Mormon. Or the Koran.

primer-
Legendary
*
Offline Offline

Activity: 924



View Profile
June 19, 2014, 12:59:33 AM
 #1047

I'm looking to modify cpu-miner.c to include the entire command line. When compiled, instead of using options and args (./minerd -o XXX:XX -u xxx -p xxx -q -B) i want to specify them all in the source.
This has to work on all/most cpuminer forks, if anyone can do it, PM me for a 0.05BTC bounty.

Massimo80
Full Member
***
Offline Offline

Activity: 168


View Profile
June 25, 2014, 05:31:46 AM
 #1048

I'm looking to modify cpu-miner.c to include the entire command line. When compiled, instead of using options and args (./minerd -o XXX:XX -u xxx -p xxx -q -B) i want to specify them all in the source.
This has to work on all/most cpuminer forks, if anyone can do it, PM me for a 0.05BTC bounty.

You want to hardcode command-line parameters into the source code? Why in the world would you want that? Recompiling the software from source everytime a paramater needs to be changed just doesn't make any sense.

If you want a simpler way to launch the program, just put the full command line in a script and then launch that.
jedimstr
Hero Member
*****
Offline Offline

Activity: 784



View Profile
June 25, 2014, 08:37:48 PM
 #1049

I'm looking to modify cpu-miner.c to include the entire command line. When compiled, instead of using options and args (./minerd -o XXX:XX -u xxx -p xxx -q -B) i want to specify them all in the source.
This has to work on all/most cpuminer forks, if anyone can do it, PM me for a 0.05BTC bounty.

You want to hardcode command-line parameters into the source code? Why in the world would you want that? Recompiling the software from source everytime a paramater needs to be changed just doesn't make any sense.

If you want a simpler way to launch the program, just put the full command line in a script and then launch that.

Or better yet, make a JSON conf file.  minerd supports using configuration files with the -c parameter.  Any changes to configuration can be put in the conf file and then you'd only need to load ./minerd -c miner.conf everytime.

jarvis
Sr. Member
****
Offline Offline

Activity: 322


View Profile
June 26, 2014, 10:00:04 PM
 #1050

does this miner have an api function?
pooler
Hero Member
*****
Offline Offline

Activity: 644


View Profile
June 26, 2014, 10:04:21 PM
 #1051

does this miner have an api function?
No.

BTC: 15MRTcUweNVJbhTyH5rq9aeSdyigFrskqE · LTC: LTCPooLqTK1SANSNeTR63GbGwabTKEkuS7
skimmer333
Newbie
*
Offline Offline

Activity: 3


View Profile
June 27, 2014, 04:24:44 AM
 #1052

Hi,
Noob question. I'm using win7-64bit
Can i solo mine using minerd?
If so, can you assist with the command line?
Is there anything else I need to install?

Cheers,
Skimmer.
alalalk71
Newbie
*
Offline Offline

Activity: 25


View Profile
June 28, 2014, 08:49:43 AM
 #1053

Quote
minerd -a scrypt -t 12 -s 6 -o stratum+tcp://doge-eu.poolerino.com:3333 -O alalalk71:a1s2d3f4
[2014-06-28 13:18:14] Starting Stratum on stratum+tcp://doge-eu.poolerino.com:33
33
[2014-06-28 13:18:14] Binding thread 2 to cpu 2
[2014-06-28 13:18:14] Binding thread 5 to cpu 5
[2014-06-28 13:18:14] Binding thread 9 to cpu 9
[2014-06-28 13:18:14] Binding thread 11 to cpu 11
[2014-06-28 13:18:14] Binding thread 0 to cpu 0
[2014-06-28 13:18:14] Binding thread 4 to cpu 4
[2014-06-28 13:18:14] Binding thread 6 to cpu 6
[2014-06-28 13:18:14] Binding thread 7 to cpu 7
[2014-06-28 13:18:14] Binding thread 10 to cpu 10
[2014-06-28 13:18:14] 12 miner threads started, using 'scrypt' algorithm.
[2014-06-28 13:18:14] Binding thread 3 to cpu 3
[2014-06-28 13:18:14] Binding thread 8 to cpu 8
[2014-06-28 13:18:14] Binding thread 1 to cpu 1
[2014-06-28 13:18:17] Stratum authentication failed
[2014-06-28 13:18:17] ...retry after 30 seconds
Stratum authentication failed  i  see this error and what can id o for resolve it ?
nuggetbram
Full Member
***
Offline Offline

Activity: 124


View Profile
June 29, 2014, 12:44:09 PM
 #1054

I'm getting
Code:
fatal error: openssl/sha.h: no such file or directory
while trying to build on windows with mingw. I don't think there's any openssl packages I need to get for this so what have I done wrong?

Click HERE for free totally legit free money!
pooler
Hero Member
*****
Offline Offline

Activity: 644


View Profile
June 29, 2014, 12:49:31 PM
 #1055

I'm getting
Code:
fatal error: openssl/sha.h: no such file or directory
while trying to build on windows with mingw. I don't think there's any openssl packages I need to get for this so what have I done wrong?

OpenSSL is referenced nowhere in the source code of cpuminer. You must be trying to compile something else, probably a fork of it.

BTC: 15MRTcUweNVJbhTyH5rq9aeSdyigFrskqE · LTC: LTCPooLqTK1SANSNeTR63GbGwabTKEkuS7
nuggetbram
Full Member
***
Offline Offline

Activity: 124


View Profile
June 29, 2014, 01:16:32 PM
 #1056

I'm getting
Code:
fatal error: openssl/sha.h: no such file or directory
while trying to build on windows with mingw. I don't think there's any openssl packages I need to get for this so what have I done wrong?

OpenSSL is referenced nowhere in the source code of cpuminer. You must be trying to compile something else, probably a fork of it.

Yeah, this is a fork, skeincoin. Thought they were *mostly* identical and I'd get a faster response here (if any!)

Thanks anyway!

Click HERE for free totally legit free money!
ag123
Newbie
*
Offline Offline

Activity: 2


View Profile
July 04, 2014, 04:37:58 AM
 #1057

hi pooler,

here's some feature requests not sure if these features may have made it into the updated versions

1) a sharelog
cpuminer runs with debug output, however, the output are often not captured
a share log is needed, i.e. for the shares submitted to a mining pool it would be helpful to log the
- time
- disposition (accept or reject)
- target
- hash
- data

and perhaps some other info in a text sharelog file. this would help with verifying from historical submitted entries if there are issues

2) a GUI
today cpuminer is running with text messages, however, most PCs/laptops etc are already running in a windowing gui environment. it'd probably be a good idea to start developing a gui for it instead of showing k/hashes per sec or m/hashes per sec as texts, those could possibly become running graphs / charts in a window. it would also pave the way for more interactivity during the runs, e.g. the user can pause/start the activities and add future options

i'm thinking could use Qt or some similar cross platform gui libs to develop these. This would help simplying the programming task (Qt is cross platform - one code many platforms) and after all most of the offline bitcoin/litecoin etc wallets are using Qt for their Gui wallets.
the 'gui' can run in its own thread and is likely low cpu load consumption for that matter. The makefiles could have options to 'exclude' compiling the gui for those who's not interested in having it.

the 'old' text output can even be accomodated in the 'gui' thread by having applog push the text output into a queue and for the 'gui' thread pop them and to spool them out to stdout/stderr. the 'gui' thread can go in a loop waiting for commands so that you could implement features like pause / continue similar to the gui

just 2 cents
pooler
Hero Member
*****
Offline Offline

Activity: 644


View Profile
July 04, 2014, 06:39:04 AM
 #1058

1) a sharelog
cpuminer runs with debug output, however, the output are often not captured
a share log is needed, i.e. for the shares submitted to a mining pool it would be helpful to log the
- time
- disposition (accept or reject)
- target
- hash
- data

and perhaps some other info in a text sharelog file. this would help with verifying from historical submitted entries if there are issues
As I've already said, this could indeed be useful, but the changes required to implement it properly are nontrivial (cpuminer does not currently keep track of submitted shares). I don't have much free time in this period, but I will put this on my to-do list.

2) a GUI
There was a Qt GUI that interfaced with cpuminer, and it worked quite well. The project is now abandoned, but its source code is still available under the MIT license for anybody to fork.
https://bitcointalk.org/index.php?topic=62414.0

BTC: 15MRTcUweNVJbhTyH5rq9aeSdyigFrskqE · LTC: LTCPooLqTK1SANSNeTR63GbGwabTKEkuS7
ag123
Newbie
*
Offline Offline

Activity: 2


View Profile
July 04, 2014, 01:12:40 PM
 #1059

1) a sharelog
cpuminer runs with debug output, however, the output are often not captured
a share log is needed, i.e. for the shares submitted to a mining pool it would be helpful to log the
- time
- disposition (accept or reject)
- target
- hash
- data

and perhaps some other info in a text sharelog file. this would help with verifying from historical submitted entries if there are issues
As I've already said, this could indeed be useful, but the changes required to implement it properly are nontrivial (cpuminer does not currently keep track of submitted shares). I don't have much free time in this period, but I will put this on my to-do list.

hi pooler,

thanks much for the quick response, here is some codes i'm not sure if this is optimum but the changes are something like this:

i moved struct work into miner.h and added hash field which is the winning hash that scanhash has found

struct work {
   uint32_t data[32];
   uint32_t target[8];
   uint32_t hash[8]; // <-- new field

   char job_id[128];
   size_t xnonce2_len;
   unsigned char xnonce2[32];
};

i modified scanhash* function so that scanhash can pass the winning hash back
e.g.
 miner_thread calls scanhash as such:
      /* scan nonces for a proof-of-work hash */
      switch (opt_algo) {
      case ALGO_SCRYPT:
         rc = scanhash_scrypt(thr_id, work.data, scratchbuf, work.target,
                              max_nonce, &hashes_done, work.hash);
         break;
...

then in scanhash:
int scanhash_scrypt(int thr_id, uint32_t *pdata,
   unsigned char *scratchbuf, const uint32_t *ptarget,
   uint32_t max_nonce, unsigned long *hashes_done,
   uint32_t *phash); {

...
      for (i = 0; i < throughput; i++) {

         if (hash[i * 8 + 7] <= Htarg && fulltest(hash + i * 8, ptarget)) {
            *hashes_done = n - pdata[19] + 1;
            pdata[19] = data[i * 20 + 19];
            memcpy(phash, hash + i * 8, 32); // <- copy the winning hash into struct work
            return 1;
         }
      }


that goes back to miner_thread, which calls submit_work
that in turns gets picked up by workio_thread -> workio_submit_work -> submit_upstream_work

then i modify submit_upstream_work

if (have_stratum) {

   .... codes that build that rpc call ...

      /* place work in the queue for share_result*/
      pwork = malloc(sizeof(struct work));
      if (!pwork)
         goto err_out;
      memcpy(pwork, work, sizeof(struct work));
      if (!tq_push(tq_result_work, pwork))
         goto err_out;

                /* existing code
      if (unlikely(!stratum_send_line(&stratum, s))) {
         applog(LOG_ERR, "submit_upstream_work stratum_send_line failed");
         goto out;
      }
} else { // no stratum

              again before that rpc call

      /* place work in the queue for share_result*/
      pwork = malloc(sizeof(struct work));
      if (!pwork)
         goto err_out;
      memcpy(pwork, work, sizeof(struct work));
      if (!tq_push(tq_result_work, pwork))
         goto err_out;

      /* build JSON-RPC request */
      sprintf(s,
         "{\"method\": \"getwork\", \"params\": [ \"%s\" ], \"id\":1}\r\n",
         str);

      /* issue JSON-RPC request */
      val = json_rpc_call(curl, rpc_url, rpc_userpass, s, false, false, NULL);
      if (unlikely(!val)) {
         applog(LOG_ERR, "submit_upstream_work json_rpc_call failed");
         goto out;
      }

tq_result_work is actually a "thread queue" in util.c i.e.

struct thread_q *tq_result_work;

i simply make tq_result_work a global variable in cpu-miner.c and let the mutexes in thread_q co-ordinate access to that data
- not sure if a deadlock is possible

it is initialised shortly after workio thread is initialised in main
   /* init workio thread info */
   work_thr_id = opt_n_threads;
   thr = &thr_info[work_thr_id];
   thr->id = work_thr_id;
   thr->q = tq_new();
   if (!thr->q)
      return 1;
   /* init work result q
    * used to pass work between workio - submit_upstream_work and
    * and share_result*/
   tq_result_work = tq_new();
   if (!tq_result_work)
      return 1;


i simply make a copy of struct work in submit_upstream work and push the struct work into tq_result_work queue. this queue is used to pass work to share_result as follows:

when stratum_thread process the return results it calls share_result

then i modify share_result
static void share_result(int result, const char *reason)
{
   char s[345];
   double hashrate;
   int i;
   struct work *pwork;

   hashrate = 0.;
   pthread_mutex_lock(&stats_lock);
   for (i = 0; i < opt_n_threads; i++)
      hashrate += thr_hashrates;
   result ? accepted_count++ : rejected_count++;
   pthread_mutex_unlock(&stats_lock);
   
   sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", 1e-3 * hashrate);
   applog(LOG_INFO, "accepted: %lu/%lu (%.2f%%), %s khash/s %s",
         accepted_count,
         accepted_count + rejected_count,
         100. * accepted_count / (accepted_count + rejected_count),
         s,
         result ? "(yay!!!)" : "(booooo)");

   /* retrieve work from queue from submit_upstream_work  and log share to a file*/
   pwork = tq_pop(tq_result_work, NULL);
   if (pwork && opt_sharelog) {
         share_log(result ? "accept" : "reject", pwork);

      free(pwork);
   }

   if (opt_debug && reason)
      applog(LOG_DEBUG, "DEBUG: reject reason: %s", reason);

   return;

then i create the supporting functions for share_log:

void sharelog_init(char *filename) {
   pthread_mutex_init(&sharelog_lock, NULL);
   sharelog_file = fopen(filename, "a");
     if (!sharelog_file)
    applog(LOG_ERR, "Failed to open %s for share log", filename);
}


void share_log(const char*disposition, const struct work *pwork)
{
   char *target, *hash, *data;
   unsigned long int t;
   struct pool *pool;
   char s[1024];
   size_t ret;

   char ts[50];
   int len;
   time_t now;
   struct tm tm, *tm_p;

   uint32_t hash_be[8], target_be[8];

   //sharelog file stream cannot be null
   if (!sharelog_file)
      return;

   time(&now);

   pthread_mutex_lock(&sharelog_lock);
   tm_p = localtime(&now);
   memcpy(&tm, tm_p, sizeof(tm));

   sprintf(ts, "%d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900,
         tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);


   for (int i = 0; i < 8; i++) {
      be32enc(hash_be + i, pwork->hash[7 - i]);
      be32enc(target_be + i, pwork->target[7 - i]);
   }

   target = bin2hex((unsigned char *) target_be, sizeof(pwork->target));
   hash = bin2hex((unsigned char *) hash_be, sizeof(pwork->hash));
   data = bin2hex((unsigned char *) pwork->data, sizeof(pwork->data));

   // timestamp,disposition,target,sharehash,sharedata
   len = sprintf(s, "%s,%s,%s,%s,%s\n", ts, disposition, target,
         hash, data);
   free(target);
   free(hash);
   free(data);

   fwrite(s, 1, len, sharelog_file);
   fflush(sharelog_file);
   ret = ferror(sharelog_file);
   pthread_mutex_unlock(&sharelog_lock);

   if (ret)
      applog(LOG_ERR, "sharelog fwrite error");
}

the remaining is to create the opt_sharelog
   case 'L':
      free(opt_sharelog);
      opt_sharelog = strdup(arg);
      applog(LOG_DEBUG, "logging to sharelog: %s", opt_sharelog);
      sharelog_init(opt_sharelog);
      break;

static struct option const options[] = {
...
   { "sharelog", 1, NULL, 'L' },
...
and to update the help text

note that this is more of a 'hack' than a proper solution as the request-response protocol for submit work (e.g. stratum) needs to be strictly honoured. there is no error handling such as if a response is missing or some other permutations occurs, that'd throw things out of order. perhaps a more robust solution may need some re-design to be done in stratum_thread or workio_thread e.g. for one of them to handle the request / response of submit work rather than currently for stratum the request is send in workio_thread but response processed in stratum_thread

hopes the above  may be useful
 

There was a Qt GUI that interfaced with cpuminer, and it worked quite well. The project is now abandoned, but its source code is still available under the MIT license for anybody to fork.
https://bitcointalk.org/index.php?topic=62414.0

thanks for the link ! Smiley

thanks and cheers Smiley
dicser
Full Member
***
Offline Offline

Activity: 132


View Profile
July 04, 2014, 03:43:47 PM
 #1060

Hello I write from Italy who knows settings and procedure mining groundwater stratum + tcp :/ / www.crypthash.fr:3334-u-py ser.x
Pages: « 1 ... 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 »
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!