FreeNOS
MpiPrime.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __BIN_MPIPRIME_MPIPRIME_H
19 #define __BIN_MPIPRIME_MPIPRIME_H
20 
21 #include <POSIXApplication.h>
22 #include "SievePrime.h"
23 
32 class MpiPrime : public SievePrime
33 {
34  private:
35 
36  public:
37 
44  MpiPrime(int argc, char **argv);
45 
49  virtual ~MpiPrime();
50 
56  virtual Result initialize();
57 
63  virtual Result exec();
64 
65  private:
66 
77  Result searchParallel(int k, int n, u8 *rootMap, u8 *map);
78 
88  Result collect(int n, u8 *rootMap, u8 *map);
89 
90  private:
91 
94 
96  int m_id;
97 
100 
103 
106 
109 };
110 
115 #endif /* __BIN_MPIPRIME_MPIPRIME_H */
MpiPrime::m_cores
Size m_cores
Total number of cores.
Definition: MpiPrime.h:99
MpiPrime::m_id
int m_id
MPI core identifier (rank) of the current process.
Definition: MpiPrime.h:96
MpiPrime::MpiPrime
MpiPrime(int argc, char **argv)
Constructor.
Definition: MpiPrime.cpp:30
MpiPrime::exec
virtual Result exec()
Execute the application.
Definition: MpiPrime.cpp:68
MpiPrime::m_numberEnd
Size m_numberEnd
Prime numbers array range end for this core.
Definition: MpiPrime.h:108
SievePrime
Compute prime numbers using the Sieve of Eratosthenes algorithm.
Definition: SievePrime.h:31
POSIXApplication.h
MpiPrime::m_numberStart
Size m_numberStart
Prime numbers array range start for this core.
Definition: MpiPrime.h:105
MpiPrime::m_mpiInitResult
int m_mpiInitResult
Result of MPI initialization.
Definition: MpiPrime.h:93
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
MpiPrime::collect
Result collect(int n, u8 *rootMap, u8 *map)
Collect prime number results.
Definition: MpiPrime.cpp:213
Application::Result
Result
Result codes.
Definition: Application.h:53
MpiPrime::m_numbersPerCore
Size m_numbersPerCore
Prime numbers calculated per core.
Definition: MpiPrime.h:102
MpiPrime::initialize
virtual Result initialize()
Initialize the application.
Definition: MpiPrime.cpp:43
MpiPrime
Calculate prime numbers in parallel.
Definition: MpiPrime.h:32
MpiPrime::searchParallel
Result searchParallel(int k, int n, u8 *rootMap, u8 *map)
Calculate prime numbers in parallel.
Definition: MpiPrime.cpp:146
u8
unsigned char u8
Unsigned 8-bit number.
Definition: Types.h:59
MpiPrime::~MpiPrime
virtual ~MpiPrime()
Destructor.
Definition: MpiPrime.cpp:38
SievePrime.h