Skip to content
Snippets Groups Projects
Commit ce535e43 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

Fix wrong job distribution

parent 2a3c41cd
No related branches found
No related tags found
No related merge requests found
Pipeline #6325 passed
...@@ -23,9 +23,6 @@ ...@@ -23,9 +23,6 @@
#include "ThreadData.h" #include "ThreadData.h"
#pragma omp declare reduction(dataSum: ThreadData : omp_out += omp_in ) initializer(omp_priv(omp_orig))
struct PasswordStats { struct PasswordStats {
int pass_length = 0; int pass_length = 0;
std::string advancedmask_string = ""; std::string advancedmask_string = "";
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
typedef std::unordered_map<std::string, uint64_t> StringOccurrence; typedef std::unordered_map<std::string, uint64_t> StringOccurrence;
typedef std::unordered_map<int, uint64_t> IntOccurrence; typedef std::unordered_map<int, uint64_t> IntOccurrence;
/** /**
* @brief minimal number of digits of a password, etc. * @brief minimal number of digits of a password, etc.
*/ */
...@@ -61,4 +62,6 @@ struct ThreadData { ...@@ -61,4 +62,6 @@ struct ThreadData {
SecurityRules sr; SecurityRules sr;
}; };
#pragma omp declare reduction(dataSum: ThreadData : omp_out += omp_in ) initializer(omp_priv(omp_orig))
#endif // THREAD_DATA_H #endif // THREAD_DATA_H
\ No newline at end of file
...@@ -70,22 +70,24 @@ int Statsgen::generate_stats() { ...@@ -70,22 +70,24 @@ int Statsgen::generate_stats() {
} }
started = true; started = true;
#pragma omp parallel #pragma omp parallel reduction(dataSum:results)
{ {
#pragma omp single #pragma omp single
{ {
nbThread = omp_get_num_threads(); nbThread = omp_get_num_threads();
} }
uint thread_id = omp_get_thread_num();
ifstream inputfile(filename); ifstream inputfile(filename);
string line; string line;
#pragma omp for schedule(dynamic) private(line) reduction(dataSum:results)
for(uint numline = 0; numline < nblines; ++numline){ for(uint numline = 0; numline < nblines; ++numline){
getline(inputfile, line); getline(inputfile, line);
if((numline % nbThread) == thread_id){
handle_password(line, 1, results); handle_password(line, 1, results);
#pragma omp atomic #pragma omp atomic
++processed; ++processed;
} }
} }
}
finished = true; finished = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment