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
32class 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 */
Result
Result codes.
Definition Application.h:54
Calculate prime numbers in parallel.
Definition MpiPrime.h:33
Size m_cores
Total number of cores.
Definition MpiPrime.h:99
Result searchParallel(int k, int n, u8 *rootMap, u8 *map)
Calculate prime numbers in parallel.
Definition MpiPrime.cpp:146
Size m_numberEnd
Prime numbers array range end for this core.
Definition MpiPrime.h:108
int m_id
MPI core identifier (rank) of the current process.
Definition MpiPrime.h:96
virtual Result exec()
Execute the application.
Definition MpiPrime.cpp:68
int m_mpiInitResult
Result of MPI initialization.
Definition MpiPrime.h:93
virtual Result initialize()
Initialize the application.
Definition MpiPrime.cpp:43
virtual ~MpiPrime()
Destructor.
Definition MpiPrime.cpp:38
Size m_numberStart
Prime numbers array range start for this core.
Definition MpiPrime.h:105
Result collect(int n, u8 *rootMap, u8 *map)
Collect prime number results.
Definition MpiPrime.cpp:213
Size m_numbersPerCore
Prime numbers calculated per core.
Definition MpiPrime.h:102
Compute prime numbers using the Sieve of Eratosthenes algorithm.
Definition SievePrime.h:32
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
unsigned char u8
Unsigned 8-bit number.
Definition Types.h:59