![]() |
|
|
#1 |
|
May 2014
3·11 Posts |
[Patch] CPU affinity prompt problem in mprime Linux / OS X build
Steps to reproduce: suppose you have 2 CPU threads... $ mv local.txt local.bak.txt $ echo 'Affinity=98' >local.txt $ mprime -m (Choose "2. Test/Worker threads", then press Enter to accept default for all questions and answer Y to "Accept the answers above", and then choose "5. Test/Exit".) $ grep Affinity local.txt (Expected result: 'Affinity=98' unchanged) (Actual result: 'Affinity=99' which means "any CPU" now instead of specific CPU #98) This off-by-one is ugly in asking CPU affinity from user. Suppose we label the first CPU as #1 to user and second as #2 and so on, I would suggest using -1 and 0 for "any CPU" and "smart assignment" settings respecively here. Also caps the (NUM_CPUS * CPU_HYPERTHREADS) number presented in question to 99, because the local.txt format does not yet support pinning to 100th specific CPU (CPU #99) or above. Note: Windows GUI is not affected because it presents "any CPU" and "smart assignment" as first of two items in the drop-down, avoiding the problem that could happen in text prompt. Code:
--- a/linux/menu.c 2016-09-15 10:15:10.000000000 +0800
+++ b/linux/menu.c 2017-02-23 11:00:36.432632390 +0800
@@ -450,16 +450,18 @@
}
if (NUM_CPUS * user_configurable_hyperthreads () > 1) {
- char question[200];
- unsigned long affinity;
+ char question[80];
+ long affinity;
+ int max_affinity;
+ max_affinity = NUM_CPUS * CPU_HYPERTHREADS >= 99U ? 99 : (int) (NUM_CPUS * CPU_HYPERTHREADS);
+ /* The values used in CPU_AFFINITY[] and local.txt are
+ * 0-98=specific CPU, 99=any, 100=smart assignment */
sprintf (question,
- "CPU affinity (1-%d=specific CPU, 99=any CPU, 100=smart assignment)",
- (int) (NUM_CPUS * CPU_HYPERTHREADS));
- affinity = m_affinity[i];
- if (affinity < 99) affinity++;
- askNum (question, &affinity, 1, 100);
- if (affinity < 99) affinity--;
- m_affinity[i] = affinity;
+ "CPU affinity (1-%d=specific CPU, -1=any CPU, 0=smart assignment)",
+ max_affinity);
+ affinity = m_affinity[i] >= 99 ? (long) m_affinity[i] - 100 : (long) m_affinity[i];
+ askInt (question, &affinity, -1, max_affinity);
+ m_affinity[i] = affinity < 1 ? affinity + 100 : affinity;
}
if (NUM_CPUS * user_configurable_hyperthreads () > 1) {
|
|
|
|
|
|
#2 |
|
P90 years forever!
Aug 2002
Yeehaw, FL
35×31 Posts |
Options for setting affinity have been completely reworked in 29.1 build 10. As a result the question with the special values is no longer asked.
|
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| mprime messages line wrap problem (with patch) | Explorer09 | Software | 5 | 2015-03-25 20:48 |
| mprime (Linux) doesn't do "affinity" correctly... | chalsall | Software | 16 | 2014-01-03 15:55 |
| Problem with Windows Command Prompt | M0CZY | Lounge | 20 | 2008-08-28 22:33 |
| Affinity on Linux | bmg9611 | Software | 5 | 2002-11-04 21:26 |
| Linux mprime client v22.8 problem | Prime Monster | Software | 6 | 2002-08-29 11:14 |