|
FreeNOS
|
Compute prime numbers using the Sieve of Eratosthenes algorithm. More...
#include <SievePrime.h>
Public Member Functions | |
| SievePrime (int argc, char **argv) | |
| Constructor. More... | |
| virtual | ~SievePrime () |
| Destructor. More... | |
| virtual Result | exec () |
| Execute the application. More... | |
Public Member Functions inherited from POSIXApplication | |
| POSIXApplication (int argc, char **argv) | |
| Class constructor. More... | |
| virtual | ~POSIXApplication () |
| Class destructor. More... | |
Public Member Functions inherited from Application | |
| Application (int argc, char **argv) | |
| Class constructor. More... | |
| virtual | ~Application () |
| Class destructor. More... | |
| virtual int | run () |
| Run the application. More... | |
Protected Member Functions | |
| Result | reportResult (const int n, const u8 *map, Size &resultsWritten, const Size offsetNumber=0) const |
| Report the calculated results. More... | |
| Result | searchSequential (const int n, u8 *map) const |
| Perform sequential search for prime numbers. More... | |
Protected Member Functions inherited from POSIXApplication | |
| virtual Result | output (const char *string) const |
| Print text to output. More... | |
| int | runProgram (const char *path, const char **argv) |
| Runs an external program. More... | |
Protected Member Functions inherited from Application | |
| virtual Result | initialize () |
| Initialize the application. More... | |
| virtual Result | output (String &string) const |
| Print string to output. More... | |
| ArgumentParser & | parser () |
| Get program arguments parser. More... | |
| const ArgumentParser & | parser () const |
| Get constant program arguments parser. More... | |
| const ArgumentContainer & | arguments () const |
| Get program arguments. More... | |
| void | setVersion (const String &version) |
| Set program version. More... | |
Additional Inherited Members | |
Public Types inherited from Application | |
| enum | Result { Success, NotFound, IOError, InvalidArgument, ShowUsage, TimedOut, OutOfMemory } |
| Result codes. More... | |
Protected Attributes inherited from Application | |
| int | m_argc |
| Input argument count. More... | |
| char ** | m_argv |
| Input argument values. More... | |
Compute prime numbers using the Sieve of Eratosthenes algorithm.
Definition at line 31 of file SievePrime.h.
| SievePrime::SievePrime | ( | int | argc, |
| char ** | argv | ||
| ) |
Constructor.
Definition at line 27 of file SievePrime.cpp.
References Application::parser(), ArgumentParser::registerFlag(), ArgumentParser::registerPositional(), and ArgumentParser::setDescription().
|
virtual |
Destructor.
Definition at line 35 of file SievePrime.cpp.
|
virtual |
Execute the application.
Implements Application.
Reimplemented in MpiPrime.
Definition at line 39 of file SievePrime.cpp.
References Application::arguments(), atoi(), errno, ERROR, Application::IOError, malloc(), NULL, reportResult(), searchSequential(), sqrt(), strerror(), Application::Success, and write().
|
protected |
Report the calculated results.
| n | Maximum number to search for prime numbers |
| map | Pointer to array with prime numbers |
| resultsWritten | Number of results written to the output |
| offsetNumber | Add this constant offset value to each result |
Definition at line 96 of file SievePrime.cpp.
References Application::arguments(), POSIXApplication::output(), Application::Success, and write().
Referenced by MpiPrime::collect(), and exec().
|
protected |
Perform sequential search for prime numbers.
| n | Maximum number to search for prime numbers |
| map | Pointer to array with prime numbers marked |
Definition at line 132 of file SievePrime.cpp.
References Application::Success.
Referenced by exec(), and MpiPrime::searchParallel().
1.8.17