Commit ce535e43 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

Fix wrong job distribution

parent 2a3c41cd
Loading
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -23,9 +23,6 @@
#include "ThreadData.h"


#pragma omp declare reduction(dataSum: ThreadData : omp_out += omp_in ) initializer(omp_priv(omp_orig))


struct PasswordStats {
	int pass_length = 0;
	std::string advancedmask_string = "";
+3 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
typedef std::unordered_map<std::string, uint64_t> StringOccurrence;
typedef std::unordered_map<int, uint64_t> IntOccurrence;


/**
 * @brief minimal number of digits of a password, etc.
 */
@@ -61,4 +62,6 @@ struct ThreadData {
	SecurityRules sr;
};

#pragma omp declare reduction(dataSum: ThreadData : omp_out += omp_in ) initializer(omp_priv(omp_orig))

#endif // THREAD_DATA_H
 No newline at end of file
+6 −4
Original line number Diff line number Diff line
@@ -70,22 +70,24 @@ int Statsgen::generate_stats() {
	}

	started = true;
#pragma omp parallel
#pragma omp parallel reduction(dataSum:results)
	{
#pragma omp single
		{
			nbThread = omp_get_num_threads();
		}
		uint thread_id = omp_get_thread_num();
		ifstream inputfile(filename);
		string line;
#pragma omp for schedule(dynamic) private(line) reduction(dataSum:results)
		for(uint numline = 0; numline < nblines; ++numline){
			getline(inputfile, line);
			if((numline % nbThread) == thread_id){
				handle_password(line, 1, results);
#pragma omp atomic
				++processed;
			}
		}
	}

	finished = true;