mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Software

Reply
 
Thread Tools
Old 2015-01-03, 01:48   #1
Explorer09
 
May 2014

2116 Posts
Default mprime messages line wrap problem (with patch)

This is a personal complaint rather than a bug. On my Linux system with an 80 character wide terminal:

Code:
[Main thread Dec 30 08:36] Starting workers.
[Worker #1 Dec 30 08:36] Worker starting
[Worker #1 Dec 30 08:36] Setting affinity to run worker on logical CPU #1
[Worker #2 Dec 30 08:36] Worker starting
[Worker #2 Dec 30 08:36] Setting affinity to run worker on logical CPU #2
[Worker #1 Dec 30 08:36] Beginning a continuous self-test to check your computer
.
[Worker #1 Dec 30 08:36] Please read stress.txt.  Hit ^C to end this test.
[Worker #2 Dec 30 08:36] Beginning a continuous self-test to check your computer
.
[Worker #2 Dec 30 08:36] Please read stress.txt.  Hit ^C to end this test.
[Worker #1 Dec 30 08:36] Test 1, 7800 Lucas-Lehmer iterations of M9961473 using 
Pentium4 type-2 FFT length 512K, Pass1=256, Pass2=2K.
[Worker #2 Dec 30 08:36] Test 1, 7800 Lucas-Lehmer iterations of M9961473 using 
Pentium4 type-2 FFT length 512K, Pass1=256, Pass2=2K.
See the period get wrapped to the next line and an entire line is wasted for this.
This wasn't a problem before mprime supports multithreading. After multithreading support, some messages that originally fit a line get wrapped strangely like this.

This is my way to solve it. Change the wording of some of the messages so that they fit one line. (It was a quick hack, and I think mprime developers can rewrite messages better than me.)
Code:
diff -r -u a/commonb.c b/commonb.c
--- a/commonb.c	2014-05-28 23:39:04.000000000 +0800
+++ b/commonb.c	2015-01-02 21:02:54.125341836 +0800
@@ -26,7 +26,7 @@
 char ERRMSG1D[] = "ERROR: Shift counter corrupt.\n";
 char ERRMSG1E[] = "ERROR: Illegal double encountered.\n";
 char ERRMSG1F[] = "ERROR: FFT data has been zeroed!\n";
-char ERRMSG2[] = "Possible hardware failure, consult the readme.txt file.\n";
+char ERRMSG2[] = "Possible hardware failure, consult readme.txt file.\n";
 char ERRMSG3[] = "Continuing from last save file.\n";
 char ERRMSG4[] = "Waiting five minutes before restarting.\n";
 char ERRMSG5[] = "For added safety, redoing iteration using a slower, more reliable method.\n";
@@ -550,7 +550,7 @@
 			if (diff == 99999) {
 				AFFINITY_SCRAMBLE_STATE = 0;
 			} else {
-				OutputStr (MAIN_THREAD_NUM, "Enough information obtained to make a reasonable guess.\n");
+				OutputStr (MAIN_THREAD_NUM, "Have enough information to make a reasonable guess.\n");
 			}
 		}
 		if (AFFINITY_SCRAMBLE_STATE == 0 && scramble[0] == '*') {
@@ -578,7 +578,7 @@
 
 no_auto_detect:
 	if (scramble[0] != '*') {
-		OutputStr (MAIN_THREAD_NUM, "Using AffinityScramble2 settings to set affinity mask.\n");
+		OutputStr (MAIN_THREAD_NUM, "Using AffinityScramble2 setting to set affinity mask.\n");
 		AFFINITY_SCRAMBLE_STATE = 2;
 		for (i = 0; i < MAX_NUM_WORKER_THREADS && i < strlen (scramble); i++) {
 			if (scramble[i] >= '0' && scramble[i] <= '9')
@@ -1063,7 +1063,7 @@
 	int	thread_num)
 {
 	if (WORKER_THREADS_ACTIVE && ! STOP_FOR_PRIORITY_WORK[thread_num]) {
-		OutputStr (thread_num, "Restarting worker to do factoring prior to an LL test.\n");
+		OutputStr (thread_num, "Restarting worker to do factoring prior to LL test.\n");
 		STOP_FOR_PRIORITY_WORK[thread_num] = 1;
 	}
 }
@@ -5870,15 +5870,14 @@
 /* Torture test code */
 /*********************/
 
-#define TORTURE1 "Beginning a continuous self-test to check your computer.\n"
+#define TORTURE1 "Beginning a continuous self-test on your computer.\n"
 #if defined (__linux__) || defined (__FreeBSD__) || defined (__EMX__)
 #define TORTURE2 "Please read stress.txt.  Hit ^C to end this test.\n"
 #else
 #define TORTURE2 "Please read stress.txt.  Choose Test/Stop to end this test.\n"
 #endif
-#define SELFMSG1A "The program will now perform a self-test to make sure the\n"
-#define SELFMSG1B "Lucas-Lehmer code is working properly on your computer.\n"
-#define SELFMSG1C "This will take about an hour.\n"
+#define SELFMSG1A "The program will now perform a self-test to make sure the Lucas-Lehmer code is working properly on your computer.\n"
+#define SELFMSG1B "This will take about an hour.\n"
 #define SELF1 "Test %i, %i Lucas-Lehmer iterations of M%ld using %s.\n"
 #define SELFFAIL "FATAL ERROR: Final result was %08lX, expected: %08lX.\n"
 char SELFFAIL1[] = "ERROR: ILLEGAL SUMOUT\n";
@@ -6835,7 +6834,6 @@
 
 	OutputStr (thread_num, SELFMSG1A);
 	OutputStr (thread_num, SELFMSG1B);
-	OutputStr (thread_num, SELFMSG1C);
 
 /* Do the self test */
By the way, the coding style of those message strings are terrible. Some of them are #define'd as macros, some of them are declared as char[] global variables (without const), and some non-trivial messages are inlined as arguments in OutputStr(). The serious inconsistency of the definition of the strings should be fixed some day.
Explorer09 is offline   Reply With Quote
Old 2015-01-03, 03:11   #2
Mark Rose
 
Mark Rose's Avatar
 
"/X\(‘-‘)/X\"
Jan 2013

293110 Posts
Default

Quote:
Originally Posted by Explorer09 View Post
By the way, the coding style of those message strings are terrible. Some of them are #define'd as macros, some of them are declared as char[] global variables (without const), and some non-trivial messages are inlined as arguments in OutputStr(). The serious inconsistency of the definition of the strings should be fixed some day.
Perhaps you should provide a patch for that ;)
Mark Rose is offline   Reply With Quote
Old 2015-01-03, 16:38   #3
Explorer09
 
May 2014

2116 Posts
Default

Quote:
Originally Posted by Mark Rose View Post
Perhaps you should provide a patch for that ;)
You mean something like this?

Attachment: prime95-string-const-macro.patch.7z (Don't try to apply this one directly. Review it and apply it by hand instead. Because I'm making this diff on my own tree which have other changes not in original Prime95 source.)

1. I changed those string constants to macros because (1) they won't be compiled in if the message is never referenced, and (2) better leave out this JUNK because there's one copyright string already in menu.c:
Code:
/* In commonc.c */
char JUNK[]="Copyright 1996-2014 Mersenne Research, Inc. All rights reserved"
(Converting it to "const char JUNK[]" will still end up being compiled into the binary.)

There are other changes in this patch:
2. SELF_TEST_DATA arrays (used in torture testing) are now all "const struct self_test_info". These arrays are never supposed to be edited anyway. (Compilers will now put these in ".rodata" section rather than ".data")
3. OutputSomewhere, OutputBoth, OutputStr, OutputStrNoTimeStamp, writeResults, LogMsg, RealOutputStr functions now all take "const char *" string argument.
Attached Files
File Type: 7z prime95-string-const-macro.patch.7z (3.2 KB, 81 views)

Last fiddled with by Explorer09 on 2015-01-03 at 16:41
Explorer09 is offline   Reply With Quote
Old 2015-01-04, 02:47   #4
Explorer09
 
May 2014

3·11 Posts
Default

Patch v2. Fixes primenet.c also.
Attached Files
File Type: 7z prime95-string-const-macro-v2.patch.7z (3.6 KB, 84 views)
Explorer09 is offline   Reply With Quote
Old 2015-01-04, 03:23   #5
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

7,487 Posts
Default

I've made a note to myself to look at these things for the next prime95 release. Alas, no prime95 development is currently underway.
Prime95 is online now   Reply With Quote
Old 2015-03-25, 20:48   #6
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

11101001111112 Posts
Default

Quote:
Originally Posted by Explorer09 View Post
Patch v2. Fixes primenet.c also.
Patches applied to source code.
Prime95 is online now   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
(Patch) Handling of SIGHUP and SIGPIPE (for mprime) Explorer09 Software 2 2017-03-08 05:37
[Patch] CPU affinity prompt problem in mprime Linux / OS X build Explorer09 Software 1 2017-03-01 02:34
Problem with mprime (Fixed with mprime -d) antiroach Software 2 2004-07-19 04:07
mprime finished factoring almost immediately, possible HW problem? optim Software 4 2004-06-21 22:19
Linux mprime client v22.8 problem Prime Monster Software 6 2002-08-29 11:14

All times are UTC. The time now is 05:01.

Tue May 11 05:01:20 UTC 2021 up 32 days, 23:42, 1 user, load averages: 2.18, 1.81, 2.02

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.