mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Hardware > GPU Computing

Reply
 
Thread Tools
Old 2012-05-15, 23:02   #1288
flashjh
 
flashjh's Avatar
 
"Jerry"
Nov 2011
Vancouver, WA

112310 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Hey LaurV/anybody else, I got another mismatch (still using 2.00). Could you run M25831787 and tell me when you submit the result?
I'm running it now, I'll let you know.
flashjh is offline   Reply With Quote
Old 2012-05-16, 02:51   #1289
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

227008 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Hey LaurV...
Sorry, I am temporary out of the game, half of the resources are totally busy, and the other half are split down to pieces and spread through all the house, fact that is maximum pissing off Mrs LaurV... (switching to liquid cooling).

Last fiddled with by LaurV on 2012-05-16 at 02:52
LaurV is offline   Reply With Quote
Old 2012-05-16, 22:30   #1290
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts
Default

Could someone help me understand what this code does?

Code:
int
_kbhit (void)
{
  struct termios oldt, newt;
  int ch;
  int oldf;

  tcgetattr (STDIN_FILENO, &oldt);
  newt = oldt;
  newt.c_lflag &= ~(ICANON | ECHO);
  tcsetattr (STDIN_FILENO, TCSANOW, &newt);
  oldf = fcntl (STDIN_FILENO, F_GETFL, 0);
  fcntl (STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);

  ch = getchar ();

  tcsetattr (STDIN_FILENO, TCSANOW, &oldt);
  fcntl (STDIN_FILENO, F_SETFL, oldf);

  if (ch != EOF)
    {
      ungetc (ch, stdin);
      return 1;
    }

  return 0;
}
Dubslow is offline   Reply With Quote
Old 2012-05-16, 23:07   #1291
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

224318 Posts
Default

Looks like it checks if a key was pressed, and if so, put it back in the queue but signal the caller that a character can now be retrieved.


P.S. A copy of the normal term i/o handler is created except it is now non-blocking. If you ask for a char from normal code, it will sit doing nothing _until_ you press the key. Here, this routine will report to the caller - "there was no activity, carry on".

Last fiddled with by Batalov on 2012-05-16 at 23:20
Batalov is offline   Reply With Quote
Old 2012-05-16, 23:15   #1292
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts
Default

Quote:
Originally Posted by Batalov View Post
Looks like it checks if a key was pressed, and if so, put it back in the queue but signal the caller that a character can now be retrieved.
Hmm... that's what the last few lines looked like, but I've never run across termios before... to that end, I'm going through this and its follow-ups; why not just do something like
Code:
char c = getchar(); if(c!=EOF) { ungetc(c, stdin); return 1;} else return 0;
...? In other words, what's the point of the termios stuff? I'll try and figure it out on my own, but I'm leaving soon for a couple of hours.
Dubslow is offline   Reply With Quote
Old 2012-05-17, 02:12   #1293
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

100101110000002 Posts
Default

Quote:
Originally Posted by Dubslow View Post
why not just do something like
Code:
char c = getchar(); if(c!=EOF) { ungetc(c, stdin); return 1;} else return 0;
...?
Because in that case (your code) the computer is locked until you decide to press the dammit key. The monkey bar joke. When I was child I did a lot of quarters with "I bet you a quarter you can't hang on it until I count to 10". Many of my friends took the bet, then I was counting very fast to 9, and going away living them hanging on the bar. Eventually they felt down and lost the bet, because they could not hold on it until I counted to 10.

The original code does a lot of work to modify the behavior of the getchar() routine to return immediately in case no key was already pressed, without waiting for the key, and if a key was pressed, to get its scan code, (accepting key combinations, like CTRL+ALT+F12), and terminate if ctrl+c was pressed. After the key is read, the old behavior (waiting for the key) is restored.

Se for details here and here (follow the fork link in that post).

Last fiddled with by LaurV on 2012-05-17 at 02:13
LaurV is offline   Reply With Quote
Old 2012-05-17, 03:03   #1294
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts
Default

Quote:
Originally Posted by LaurV View Post
Because in that case (your code) the computer is locked until you decide to press the dammit key. The monkey bar joke. When I was child I did a lot of quarters with "I bet you a quarter you can't hang on it until I count to 10". Many of my friends took the bet, then I was counting very fast to 9, and going away living them hanging on the bar. Eventually they felt down and lost the bet, because they could not hold on it until I counted to 10.

The original code does a lot of work to modify the behavior of the getchar() routine to return immediately in case no key was already pressed, without waiting for the key, and if a key was pressed, to get its scan code, (accepting key combinations, like CTRL+ALT+F12), and terminate if ctrl+c was pressed. After the key is read, the old behavior (waiting for the key) is restored.

Se for details here and here (follow the fork link in that post).
Sweet! I knew there was a stupidly easy and obvious explanation

I swear I'm not usually this dumb

Edit: It seems to be formulaic enough that I can reuse it without a problem; it seems that actually understanding it will require quite a bit of time reading through 'man termios', which I'll do later. Thanks for the help, B&L.

Last fiddled with by Dubslow on 2012-05-17 at 03:58
Dubslow is offline   Reply With Quote
Old 2012-05-17, 23:17   #1295
flashjh
 
flashjh's Avatar
 
"Jerry"
Nov 2011
Vancouver, WA

1,123 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Hey LaurV/anybody else, I got another mismatch (still using 2.00). Could you run M25831787 and tell me when you submit the result?
Original is correct. You want me to post the DC to PrimeNet?
flashjh is offline   Reply With Quote
Old 2012-05-17, 23:49   #1296
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

251916 Posts
Default

{sarcasm}
No, clearly, to make things right you should pass the residue to Dubslow, so that he could submit it as a CUDALucas residue. After all, the error was now corrected!
{/sarcasm}

Seriously, if you don't want people to make suggestions like the above you could PM each other. OTOH, if you value other people's opinions, you should simply let the server do its job of tallying correct and incorrect residues and enforce impartiality by assigning the double-check to a random person computer that is not going to have an preconceived agenda if it is right, or even "polite" to correct someone else's mistake ("What if I hurt his feelings by pointing out that his residue was incorrect? Ah, ah, ah, what should I do?!").

Dudes, grow up already - these are just numbers! You voluntarily turn yourselves into human computers.
Batalov is offline   Reply With Quote
Old 2012-05-18, 00:01   #1297
flashjh
 
flashjh's Avatar
 
"Jerry"
Nov 2011
Vancouver, WA

112310 Posts
Default

Quote:
Originally Posted by Batalov View Post
{sarcasm}
No, clearly, to make things right you should pass the residue to Dubslow, so that he could submit it as a CUDALucas residue. After all, the error was now corrected!
{/sarcasm}

Seriously, if you don't want people to make suggestions like the above you could PM each other. OTOH, if you value other people's opinions, you should simply let the server do its job of tallying correct and incorrect residues and enforce impartiality by assigning the double-check to a random person computer that is not going to have an preconceived agenda if it is right, or even "polite" to correct someone else's mistake ("What if I hurt his feelings by pointing out that his residue was incorrect? Ah, ah, ah, what should I do?!").

Dudes, grow up already - these are just numbers! You voluntarily turn yourselves into human computers.
No problem either way... He asked someone to run a TC, and I did. I had no intention good or bad, I just want to know if he wants me to submit to PrimeNet or if he wants to run it again. I'm not sure where you perceieved a problem, but there is none.
flashjh is offline   Reply With Quote
Old 2012-05-18, 00:46   #1298
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

19·397 Posts
Default

Submit the successful triple-check first.

If you submit the bad double-check first, then there is a window where the server will make the exponent available to some poor unsuspecting user for a triple-check.
Prime95 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Don't DC/LL them with CudaLucas LaurV Data 131 2017-05-02 18:41
CUDALucas / cuFFT Performance on CUDA 7 / 7.5 / 8 Brain GPU Computing 13 2016-02-19 15:53
CUDALucas: which binary to use? Karl M Johnson GPU Computing 15 2015-10-13 04:44
settings for cudaLucas fairsky GPU Computing 11 2013-11-03 02:08
Trying to run CUDALucas on Windows 8 CP Rodrigo GPU Computing 12 2012-03-07 23:20

All times are UTC. The time now is 23:20.


Fri Aug 6 23:20:17 UTC 2021 up 14 days, 17:49, 1 user, load averages: 4.56, 4.17, 4.08

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.