mersenneforum.org  

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

Reply
 
Thread Tools
Old 2012-06-23, 20:30   #1442
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3×29×83 Posts
Default

Done, and also I just made you a full blown admin.
Dubslow is offline   Reply With Quote
Old 2012-06-24, 02:32   #1443
flashjh
 
flashjh's Avatar
 
"Jerry"
Nov 2011
Vancouver, WA

1,123 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Done, and also I just made you a full blown admin.
CUDALucas 2.04 Beta x64 binaries are posted to here

Use the included CUDALucas.ini file to resolve the results.txt error (if you haven't already)
flashjh is offline   Reply With Quote
Old 2012-06-27, 20:04   #1444
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
"name field"
Jun 2011
Thailand

41×251 Posts
Default

Stupid question: what are the last 4 bytes of the checkpoint files? From the source I can see there is a double called "x", but it is 3 AM here and I want to go to bed to book 4 hours of sleeping before going to job, and I don't have time to go deeper in that source. I am running a triple check, up to now I got all residues the same like the DC, still 6-7 millions to go, so the same residues, the same file names (the residue in in the file name too) but when I do a binary comparison, the last 4 bytes are always different by a fixed amount (or a fixed mask, I could not figure it out exactly yet). Is that normal, or my card is walking in the weeds already?
LaurV is offline   Reply With Quote
Old 2012-06-27, 20:33   #1445
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts
Default

Depends what version.
Code:
void
write_checkpoint (double *x, int q, int n, int j, long total_time)
{
  <snip>
  fwrite (&q, 1, sizeof (q), fPtr);
  fwrite (&n, 1, sizeof (n), fPtr);
  fwrite (&j, 1, sizeof (j), fPtr);
  fwrite (x, 1, sizeof (double) * n, fPtr);
  fwrite (&total_time, 1, sizeof(total_time), fPtr); // exclude this line < 2.04
So the format is:
Exponent = sizeof(int);
FFT length = sizeof(int);
Iteration = sizeof(int);
Intermediate data = sizeof(double) * 2 * FFT length
(v >= 2.04) Total time = sizeof(long)

Presumably sizeof(long)==48 on your system. Total time is only tracked with precision of 1 second, but there's probably been at least some minor difference in the total time between to two runs. Are you able to compare them bit for bit? That fixed difference you mention shouldn't amount to more than a few seconds.

Here's a couple of programs you could run (they should easily compile with whatever free version of MSVS you have):
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
  printf("The size of a short is %lu\n", sizeof(short));
  printf("The size of an int is %lu\n", sizeof(int));
  printf("The size of a long is %lu\n", sizeof(long));
  printf("The size of a long long is %lu\n", sizeof(long long));
  printf("The size of a float is %lu\n", sizeof(float));
  printf("The size of a double is %lu\n", sizeof(double));
  printf("The size of a long double is %lu\n", sizeof(long double));
  return 7;
}
On my system:
Code:
bill@Gravemind:~/bin/c∰∂ ./size
The size of a short is 2
The size of an int is 4
The size of a long is 8
The size of a long long is 8
The size of a float is 4
The size of a double is 8
The size of a long double is 16
Program 2:
Code:
#include <stdlib.h>
#include <stdio.h>
void print_time_from_seconds (int sec) // copied almost verbatim from CuLu source
{
  if (sec > 3600)
    {
      printf ("%d", sec / 3600);
      sec %= 3600;
      printf (":%02d", sec / 60);
    }
  else
    printf ("%d", sec / 60);
  sec %= 60;
  printf (":%02d\n", sec);
}
int main(int argc, char** argv) {
  char* name;
  int q, n, j;
  long t;
  double* x;
  FILE* f;

  if( !argv[1] ) {
    printf("First argument should be name of checkpoint file\n");
    return -1;
  }
  name = argv[1];
  f = fopen(name, "rb"); // Ignore compiler warnings about "secure functions"
  fread(&q, sizeof(int), 1, f);
  fread(&n, sizeof(int), 1, f);
  fread(&j, sizeof(int), 1, f);
  x = (double*) malloc(sizeof(double)*n);
  fread(x, sizeof(double), n, f);
  fread(&t, sizeof(long), 1, f);
  printf("This is a checkpoint for exp = %d, n = %dK, iter = %d, and total time = %ld = ", q, n/1024, j, t);
  print_time_from_seconds(t);
  return 127;
}
Code:
bill@Gravemind:~/bin/c∰∂ ckp c26448743 
This is a checkpoint for exp = 26448743, n = 1440K, iter = 13820001, and total time = 75137 = 20:52:17

Last fiddled with by Dubslow on 2012-06-27 at 20:52 Reason: removing some warnings, adding my own outputs
Dubslow is offline   Reply With Quote
Old 2012-06-30, 14:39   #1446
apsen
 
Jun 2011

131 Posts
Default

Quote:
Originally Posted by flashjh View Post
CUDALucas 2.04 Beta x64 binaries are posted to here

Use the included CUDALucas.ini file to resolve the results.txt error (if you haven't already)
"CUDALucas2.04 Beta-3.2-sm_13-x64.exe" crashes at the end. It leaves results.txt.lck while it's running. If I restart it crashes again. When I manually delete results.txt.lck before restarting it does not crash.

Thanks,
Andriy
apsen is offline   Reply With Quote
Old 2012-06-30, 15:36   #1447
flashjh
 
flashjh's Avatar
 
"Jerry"
Nov 2011
Vancouver, WA

21438 Posts
Default

Quote:
Originally Posted by apsen View Post
"CUDALucas2.04 Beta-3.2-sm_13-x64.exe" crashes at the end. It leaves results.txt.lck while it's running. If I restart it crashes again. When I manually delete results.txt.lck before restarting it does not crash.

Thanks,
Andriy
Strange, I haven't had any problems with it so far (but I've only completed one DC with it). I will upload a version in a few minutes. Will you test it and let us know if it works? Thanks.

Edit: Ok, I made a minor commit and uploaded the files. Let us know if they work (or not).

Last fiddled with by flashjh on 2012-06-30 at 15:46
flashjh is offline   Reply With Quote
Old 2012-06-30, 17:00   #1448
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

1C3516 Posts
Default

Quote:
Originally Posted by flashjh View Post
Strange, I haven't had any problems with it so far (but I've only completed one DC with it). I will upload a version in a few minutes. Will you test it and let us know if it works? Thanks.

Edit: Ok, I made a minor commit and uploaded the files. Let us know if they work (or not).
Hmmm... why do you think that adding the const will help? Is it something I don't know about Microsoft's library functions? (Strictly speaking, frmt should be const as well...)



Andriy,
Is there any sort of error message? Do you know if it crashes in the lock or unlock function? That is, does it crash before or after actually printing the results to the results file? (As for restarting after the crash while the lock file still exists, that will send it into an infinite sleep loop waiting for the file to be unlocked. Does anyone have any better ideas?)
Thanks,
Bill



PS @Everyone: I just realized I made a fairly serious typo in my initial 2.04 post. I said something like "NOT safe to share work files, but is safe to share work files" where of course I meant "NOT safe to share work files, but is safe to share results file". I'm pretty sure everyone understood what I meant; nevertheless, could a mod please fix it?

Last fiddled with by Dubslow on 2012-06-30 at 17:40
Dubslow is offline   Reply With Quote
Old 2012-06-30, 17:34   #1449
flashjh
 
flashjh's Avatar
 
"Jerry"
Nov 2011
Vancouver, WA

1,123 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Hmmm... why do you think that adding the const will help? Is it something I don't know about Microsoft's library functions? (Strictly speaking, frmt should be const as well...)



Andriy,
Is there any sort of error message? Do you know if it crashes in the lock or unlock function? That is, does it crash before or after actually printing the results to the results file? (As for restarting after the crash while the lock file still exists, that will send it into an infinite sleep loop waiting for the file to be unlocked. Does anyone have any better ideas?)
Thanks,
Bill
I didn't think it would, but I've been using that version with no errors, so I wanted to get it tested and I didn't want to upload without having the source code there.
flashjh is offline   Reply With Quote
Old 2012-06-30, 18:39   #1450
apsen
 
Jun 2011

131 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Andriy,
Is there any sort of error message? Do you know if it crashes in the lock or unlock function? That is, does it crash before or after actually printing the results to the results file? (As for restarting after the crash while the lock file still exists, that will send it into an infinite sleep loop waiting for the file to be unlocked. Does anyone have any better ideas?)
Thanks,
Bill
No it's complete crush. I could try to debug it if you'll get me debug info.

No output to results file or screen and if you start it again it will restart test from the last multiple of checkpoint before the end of test.

Last fiddled with by apsen on 2012-06-30 at 18:41
apsen is offline   Reply With Quote
Old 2012-06-30, 21:17   #1451
apsen
 
Jun 2011

131 Posts
Default

Quote:
Originally Posted by Dubslow View Post
(As for restarting after the crash while the lock file still exists, that will send it into an infinite sleep loop waiting for the file to be unlocked.
No, it crashes.
apsen is offline   Reply With Quote
Old 2012-07-01, 01:36   #1452
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 apsen View Post
No, it crashes.
Sometimes Windows will detect programs going into infinite loops, and report that the program is not responding. That's not what happened?

Here's the relevant code:
Code:
 //parse.c, line 86
#include <winsock2.h>
 
  #include <io.h>
 
  #include <share.h> //used for _sopen_s
 
  #undef close
 
  #define close _close
 
  #define sched_yield SwitchToThread
 
  #define MODE _S_IREAD | _S_IWRITE
 
  #define strncasecmp _strnicmp
 
 
 
  /* Everything from here to the next include is to make MSVS happy. */
 
  #define sscanf sscanf_s /* This only works for scanning numbers, or strings with a defined length (e.g. "%131s") */
 
 
 
  void strcopy(char* dest, char* src, size_t n) 
 
  {
 
    strncpy_s(dest, MAX_LINE_LENGTH+1, src, n);
 
  }
 
  FILE* _fopen(const char* path, const char* mode) 
 
  {
 
    FILE* stream;
 
    errno_t err = fopen_s(&stream, path, mode);
 
    if(err) return NULL;
 
    else return stream;
 
  }
 
  void _sprintf(char* buf, char* frmt, const char* string)
 
  { // only used in filelocking code
 
      sprintf_s(buf, 251, frmt, string);
 
  }
 
  int open_s(const char *filename, int oflag, int pmode)
 
  {
 
     int file_handle;
 
     errno_t err = _sopen_s( &file_handle, filename, oflag, _SH_DENYNO, pmode);
 
     if (err)
 
     {
 
         close (file_handle);
 
         return -1;
 
     }
 
     else return 0;
 
  }
 
  void _strcpy(char *dest, const char *src)
 
  {
 
      strcpy_s (dest, _countof(dest), src);
 
  }
Code:
//parse.c line 728
/*****************************************************************************/
 
/*      mfakto's file locking code                                           */
 
 
 
#define MAX_LOCKED_FILES 3
 
 
 
typedef struct _lockinfo
 
{
 
  int       lockfd;
 
  FILE *    open_file;
 
  char      lock_filename[256];
 
} lockinfo;
 
 
 
static unsigned int num_locked_files = 0;
 
static lockinfo     locked_files[MAX_LOCKED_FILES];
 
 
 
FILE *fopen_and_lock(const char *path, const char *mode)
 
{
 
  unsigned int i;
 
  int lockfd;
 
  FILE *f;
 
  #ifdef EBUG
 
  printf("\nlock() called on %s\n", path);
 
  #endif
 
 
 
  if (strlen(path) > 250)
 
  {
 
    fprintf(stderr, "Cannot open %.250s: Name too long.\n", path);
 
    return NULL;
 
  }
 
 
 
  if (num_locked_files >= MAX_LOCKED_FILES)
 
  {
 
    fprintf(stderr, "Cannot open %.250s: Too many locked files.\n", path);
 
    return NULL;
 
  }
 
 
 
  _sprintf( locked_files[num_locked_files].lock_filename, "%.250s.lck", path);
 
 
 
  for(i=0;;)
 
  {
 
    if ((lockfd = open_s(locked_files[num_locked_files].lock_filename, O_EXCL | O_CREAT, MODE)) < 0)
 
    {
 
      if (errno == EEXIST)
 
      {
 
        if (i==0) fprintf(stderr, "%.250s is locked, waiting ...\n", path);
 
        if (i<1000) i++; // slowly increase sleep time up to 1 sec
 
        Sleep(i);
 
        continue;
 
      }
 
      else
 
      {
 
        perror("Cannot open lockfile");
 
        break;
 
      }
 
    }
 
    break;
 
  }
 
 
 
  locked_files[num_locked_files].lockfd = lockfd;
 
 
 
  if (lockfd > 0 && i > 0)
 
  {
 
    printf("Locked %.250s\n", path);
 
  }
 
 
 
  f = _fopen(path, mode);
 
  if (f)
 
  {
 
    locked_files[num_locked_files++].open_file = f;
 
  }
 
  else
 
  {
 
    if (close(locked_files[num_locked_files].lockfd) != 0) perror("Failed to close lockfile");
 
    if (remove(locked_files[num_locked_files].lock_filename)!= 0) perror("Failed to delete lockfile");
 
  }
 
  #ifdef EBUG
 
  printf("successfully locked %s\n", path);
 
  #endif
 
  #ifdef TEST
 
  while(1);
 
  #endif
 
 
 
  return f;
 
}
 
 
 
int unlock_and_fclose(FILE *f)
 
{
 
  unsigned int i, j;
 
  int ret = 0;
 
  #ifdef EBUG
 
  printf("unlock() called\n");
 
  #endif
 
 
 
  if (f == NULL) return -1;
 
 
 
  for (i=0; i<num_locked_files; i++)
 
  {
 
    if (locked_files[i].open_file == f)
 
    {
 
      ret = fclose(f);
 
      f = NULL;
 
      if (close(locked_files[i].lockfd) != 0) perror("Failed to close lockfile");
 
      if (remove(locked_files[i].lock_filename)!= 0) perror("Failed to delete lockfile");
 
      for (j=i+1; j<num_locked_files; j++)
 
      {
 
        locked_files[j-1].lockfd = locked_files[j].lockfd;
 
        locked_files[j-1].open_file = locked_files[j].open_file;
 
        _strcpy(locked_files[j-1].lock_filename, locked_files[j].lock_filename);
 
      }
 
      num_locked_files--;
 
      break;
 
    }
 
  }
 
  if (f)
 
  {
 
    fprintf(stderr, "File was not locked!\n");
 
    ret = fclose(f);
 
  }
 
  #ifdef EBUG
 
  printf("successfully unlocked\n");
 
  #endif
 
  return ret;
 
}
Code:
//CUDALucas.cu, near the bottom of check() (line ~1400?)
 gettimeofday (&time1, NULL);
      FILE* fp = fopen_and_lock(RESULTSFILE, "a");
      if(!fp) {
        fprintf (stderr, "Cannot write results to %s\n\n", RESULTSFILE);
        exit (1);
      }
      printbits (x, q, n, b, c, high, low, 64, fp, 0);
      if( total_time >= 0 ) { /* Only print time if we don't have an old checkpoint file */
        total_time += (time1.tv_sec - start_time);
        printf (", estimated total time = ");
        print_time_from_seconds(total_time);
      }
 
      if( AID[0] && strncasecmp(AID, "N/A", 3) ) { // If (AID is not null), AND (AID is NOT "N/A") (case insensitive)
        fprintf(fp, ", AID: %s\n", AID);
      } else {
        fprintf(fp, "\n");
      }
      unlock_and_fclose(fp);
      fflush (stdout);
      rm_checkpoint (q);
I can't create Windows executables, and I don't know much about MSVS; you'll have to tell flash how to compile it with debugging symbols in Windows.

Edit: Flash! The fix to open_s() never made it into r35! (It should return file_handle, not 0!)

Last fiddled with by Dubslow on 2012-07-01 at 01:42
Dubslow is offline   Reply With Quote
Reply



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 14:47.


Fri Jul 7 14:47:28 UTC 2023 up 323 days, 12:16, 0 users, load averages: 1.68, 1.45, 1.21

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, 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.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔