Go to the documentation of this file.
32 , m_mpiInitResult(
MPI_Init(&m_argc, &m_argv))
54 ERROR(
"failed to lookup MPI rank: result = " << result);
61 ERROR(
"failed to lookup total number of cores: result = " << result);
99 for (
int i = 0; i < n_root; i++)
128 printf(
"Search_parallel: ");
149 int sqrt_of_n =
sqrt(n);
167 while (k < sqrt_of_n)
216 const int sqrt_of_n =
sqrt(n);
227 Size resultsWritten = 0;
Size m_cores
Total number of cores.
virtual Result output(const char *string) const
Print text to output.
u32 sqrt(u32 number)
Compute the square root of a number.
ssize_t write(int fildes, const void *buf, size_t nbyte)
Write on a file.
C int errno
The lvalue errno is used by many functions to return error values.
int m_id
MPI core identifier (rank) of the current process.
C int atoi(const char *nptr)
Convert a string to an integer.
MpiPrime(int argc, char **argv)
Constructor.
virtual Result exec()
Execute the application.
C int MPI_Comm_size(MPI_Comm comm, int *size)
const ArgumentContainer & arguments() const
Get program arguments.
void printDiff(const SystemClock &clock) const
Print difference between two clocks to stdout.
void setDescription(const String &desc)
Set program description.
uint MPI_Status
Status holder.
C void * malloc(size_t size)
A memory allocator.
Provides an abstract interface to the system clock.
Size m_numberEnd
Prime numbers array range end for this core.
Compute prime numbers using the Sieve of Eratosthenes algorithm.
#define DEBUG(msg)
Output a debug message to standard output.
int printf(const char *format,...)
Output a formatted string to standard output.
Size m_numberStart
Prime numbers array range start for this core.
C int MPI_Init(int *argc, char ***argv)
char * strerror(int errnum)
The strerror function maps the number in errnum to a message string.
#define NULL
NULL means zero.
int m_mpiInitResult
Result of MPI initialization.
unsigned int Size
Any sane size indicator cannot go negative.
Result collect(int n, u8 *rootMap, u8 *map)
Collect prime number results.
Size m_numbersPerCore
Prime numbers calculated per core.
C int MPI_Comm_rank(MPI_Comm comm, int *rank)
virtual Result initialize()
Initialize the application.
Result reportResult(const int n, const u8 *map, Size &resultsWritten, const Size offsetNumber=0) const
Report the calculated results.
Result now()
Get the current time.
ArgumentParser & parser()
Get program arguments parser.
Result searchParallel(int k, int n, u8 *rootMap, u8 *map)
Calculate prime numbers in parallel.
#define ERROR(msg)
Output an error message.
C int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
unsigned char u8
Unsigned 8-bit number.
C int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
Result searchSequential(const int n, u8 *map) const
Perform sequential search for prime numbers.
virtual ~MpiPrime()
Destructor.
C void free(void *ptr)
Free allocated memory.