mersenneforum.org  

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

Reply
 
Thread Tools
Old 2020-01-20, 08:41   #287
unconnected
 
unconnected's Avatar
 
May 2009
Russia, Moscow

32×271 Posts
Default

Quote:
Originally Posted by rogue View Post
Since you are building on your own, you can comment out the code in the SharedMemoryItem.cpp class in the TryLock(), Lock(), and Release() methods and rebuild. This will only work if you have 1 worker.

If you have any debugging experience, a stack trace would be helpful.
Mark, I've added debug printf to Lock() and found that in case of error return code is 35 (EDEADLK):

Code:
The pthread_mutex_lock() function may fail if: 
EDEADLK The current thread already owns the mutex.
Commenting methods didn't help - source successfully compiled and ran but no sieve at all, only removed algebraic factors.
unconnected is online now   Reply With Quote
Old 2020-01-20, 10:01   #288
Happy5214
 
Happy5214's Avatar
 
"Alexander"
Nov 2008
The Alamo City

11·29 Posts
Default

Quote:
Originally Posted by unconnected View Post
Mark, I've added debug printf to Lock() and found that in case of error return code is 35 (EDEADLK):

Code:
The pthread_mutex_lock() function may fail if: 
EDEADLK The current thread already owns the mutex.
Commenting methods didn't help - source successfully compiled and ran but no sieve at all, only removed algebraic factors.
The offending code appears to be core/Worker.cpp, lines 164-167:
Code:
   SetHasWorkToDo();
   
   // 
   ip_WorkerStatus->Release();
The lock is being released after the worker status is changed, so the first method ends up re-locking the mutex. Flipping the two commands fixed the error for me.
Happy5214 is offline   Reply With Quote
Old 2020-01-21, 01:29   #289
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

169616 Posts
Default

Quote:
Originally Posted by Happy5214 View Post
The offending code appears to be core/Worker.cpp, lines 164-167:
Code:
   SetHasWorkToDo();
   
   // 
   ip_WorkerStatus->Release();
The lock is being released after the worker status is changed, so the first method ends up re-locking the mutex. Flipping the two commands fixed the error for me.
Great catch, but the proper fix is to modify Worker.h. SetHasWorkToDo() should call ip_WorkerStatus->SetValueHaveLock(). This is because the method is called when the thread already has a lock on the ip_WorkerStatus object. This method releases that lock after it has built the collection of primes for the thread.

I wonder why Windows doesn't catch this.
rogue is offline   Reply With Quote
Old 2020-01-21, 07:08   #290
Happy5214
 
Happy5214's Avatar
 
"Alexander"
Nov 2008
The Alamo City

11·29 Posts
Default

Quote:
Originally Posted by rogue View Post
Great catch, but the proper fix is to modify Worker.h. SetHasWorkToDo() should call ip_WorkerStatus->SetValueHaveLock(). This is because the method is called when the thread already has a lock on the ip_WorkerStatus object. This method releases that lock after it has built the collection of primes for the thread.

I wonder why Windows doesn't catch this.
From the Microsoft documentation on EnterCriticalSection:

Quote:
After a thread has ownership of a critical section, it can make additional calls to EnterCriticalSection or TryEnterCriticalSection without blocking its execution. This prevents a thread from deadlocking itself while waiting for a critical section that it already owns. The thread enters the critical section each time EnterCriticalSection and TryEnterCriticalSection succeed. A thread must call LeaveCriticalSection once for each time that it entered the critical section.
I take this to mean that repeated calls don't result in an error, unlike pthreads.

Last fiddled with by Happy5214 on 2020-01-21 at 07:09
Happy5214 is offline   Reply With Quote
Old 2020-01-21, 14:05   #291
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

169616 Posts
Default

Quote:
Originally Posted by Happy5214 View Post
From the Microsoft documentation on EnterCriticalSection:

I take this to mean that repeated calls don't result in an error, unlike pthreads.
Yet another reason to dislike Windows. Thanks for finding the reason.
rogue is offline   Reply With Quote
Old 2020-02-10, 02:32   #292
Dylan14
 
Dylan14's Avatar
 
"Dylan"
Mar 2017

2·241 Posts
Default

A suggestion: when using the -A (or the --applyandexit flag), assume that if there is no file given with -I, assume that the factors are given in a file called "factors.txt", or warn the user that the switch requires a file name to be given with -I to work.
Dylan14 is offline   Reply With Quote
Old 2020-02-10, 12:30   #293
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

132268 Posts
Default

Quote:
Originally Posted by Dylan14 View Post
A suggestion: when using the -A (or the --applyandexit flag), assume that if there is no file given with -I, assume that the factors are given in a file called "factors.txt", or warn the user that the switch requires a file name to be given with -I to work.
Seems reasonable
rogue is offline   Reply With Quote
Old 2020-04-12, 23:09   #294
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

2·72·59 Posts
Default

I posted 1.9.6. I was sitting on it for a while as I forgot to post. Here are the changes:
  • Fixed issue in srsieve2 where it crashes when starting a new sieve.
  • Fixed issue in srsieve2 where it finds an invalid factor and terminates.
  • Refactored logic for "single worker" and "rebuild" logic so they work more nicely together.
  • Fixed calculation of p/sec which is wrong after workers are recreated.
  • Feset factor stats whenever workers are created as the rate is inflated for lower p as far more terms are removed.
  • Fix issue with multiple threads which can cause program to hang.
  • Add support for ABC format to srsieve2.
rogue is offline   Reply With Quote
Old 2020-04-18, 12:20   #295
JeppeSN
 
JeppeSN's Avatar
 
"Jeppe"
Jan 2016
Denmark

5·23 Posts
Question

Silly question: Which is the preferred place to download from if I only care about the Windows (x64) binaries, not the source?

On https://www.mersenneforum.org/rogue/mtsieve.html there is a file with 1.9.6 in its name. The version history on that html page does not go further than 1.7.3.

On https://sourceforge.net/projects/mtsieve/ there is a file with 1.9.7 in its name. Does it include both source and binaries? Is this a "beta" or "unreleased" version?

The README_MTSieve.txt file refers to the former of these two web sites.

/JeppeSN
JeppeSN is offline   Reply With Quote
Old 2020-04-18, 15:00   #296
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

2×72×59 Posts
Default

Quote:
Originally Posted by JeppeSN View Post
Silly question: Which is the preferred place to download from if I only care about the Windows (x64) binaries, not the source?

On https://www.mersenneforum.org/rogue/mtsieve.html there is a file with 1.9.6 in its name. The version history on that html page does not go further than 1.7.3.

On https://sourceforge.net/projects/mtsieve/ there is a file with 1.9.7 in its name. Does it include both source and binaries? Is this a "beta" or "unreleased" version?

The README_MTSieve.txt file refers to the former of these two web sites.

/JeppeSN
Sorry about the confusion. 1.9.6 and 1.9.7 are the same. I misnamed it because the version in the changes.txt file was incorrect. The file is named incorrectly on the one webpage. I need to change that to point to sourceforge.
rogue is offline   Reply With Quote
Old 2020-05-03, 23:26   #297
pepi37
 
pepi37's Avatar
 
Dec 2011
After milion nines:)

3·7·61 Posts
Default

I have found small error ( if we can call it error) In latest twinsieve release if we set -P 10000000 it only sieve up to 10007. I believe it has some connection with chunks ( number of worker or so) So that is nearly cosmetic error. On higher P limit everything is OK
Can you also add in info line cpu usage in percentage?

Last fiddled with by pepi37 on 2020-05-03 at 23:33
pepi37 is online now   Reply With Quote
Reply

Thread Tools


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

Thu Jul 2 22:23:24 UTC 2020 up 99 days, 19:56, 1 user, load averages: 1.85, 2.06, 2.08

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