Commit 25f6a1fb authored by Vladimír Ulman's avatar Vladimír Ulman
Browse files

test suite exnteded in accord

parent da8e2d99
......@@ -2,9 +2,12 @@
#include <atomic>
#include <vector>
#include <list>
#include <map>
#include <thread>
#include <cstdlib>
#include <omp.h>
#define DEBUG_REPORT(x) std::cout << x << "\n";
#include "/home/ulm0023/devel/EmbryoGen_PM/src/util/ParallelList.hpp"
......@@ -18,6 +21,7 @@ public:
int id;
void touchMe() { processed.fetch_add(1); }
void touchMeFake() const { }
void reportMe()
{
std::cout << "job " << id << " @" << (size_t)this
......@@ -59,6 +63,7 @@ int main(void)
//std::vector<int> Vec { 10, 20, 30, 40, 50, 60, 70, 80, 15,25,35,45,55,65,75,85,90};
std::vector<Job> Vec;
std::list<Job*> List;
std::map<int,Job*> Map;
Job templateJob;
for (int i=0; i < 20; ++i)
{
......@@ -66,14 +71,17 @@ int main(void)
Vec.push_back(templateJob);
Job* j = new Job(); j->id = templateJob.id;
List.push_back(j);
Map[templateJob.id] = j;
}
/*
#pragma omp parallel for
for (auto it=Vec.begin(); it != Vec.end(); ++it)
{
it->touchMe();
process_a(it->id,omp_get_thread_num());
}
*/
std::cout << "=========================================\n";
......@@ -86,12 +94,33 @@ int main(void)
for (int i=0; i < 50; ++i) { iterCounts[i]=0; trueWorks[i]=0; }
// DEBUG
visitEveryObject<Job*>(List, [&trueWorks](Job* j) {
visitEveryObject<Job*>(List, [&trueWorks](Job*& j) {
j->touchMe();
process_a(j->id,omp_get_thread_num());
trueWorks[omp_get_thread_num()]++;;
} );
visitEveryObject<std::list<Job*>,Job*>(List.cbegin(),List.cend(),
[&trueWorks](Job* const & j) {
j->touchMe();
process_a(j->id,omp_get_thread_num());
trueWorks[omp_get_thread_num()]++;;
} );
visitEveryObject< std::map<int,Job*>, std::pair<const int,Job*> >(
Map.begin(),Map.end(),
[&trueWorks](auto p) { // auto = std::pair<const int,Job*>&
p.second->touchMe();
process_a(p.second->id,omp_get_thread_num());
trueWorks[omp_get_thread_num()]++;;
} );
visitEveryObject_const<int,Job*>(Map, [&trueWorks](Job* const & p) {
p->touchMe();
process_a(p->id,omp_get_thread_num());
trueWorks[omp_get_thread_num()]++;;
} );
int workSum = 0;
for (int i=0; i < numThreads; ++i)
{
......@@ -102,8 +131,8 @@ int main(void)
std::cout << "total amount of work done: " << workSum << "\n";
std::cout << "=========================================\n";
for (auto it=Vec.begin(); it != Vec.end(); ++it) it->reportMe();
//std::cout << "=========================================\n";
//for (auto it=Vec.begin(); it != Vec.end(); ++it) it->reportMe();
std::cout << "=========================================\n";
for (auto it=List.begin(); it != List.end(); ++it) (*it)->reportMe();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment