Newer
Older
#include <PthreadSimulation.hpp>
#include <iostream>
using namespace std;
PthreadSimulation::PthreadSimulation(int& argc, char**& argv) {
//TODO: change
this->parallelRank = 0;
if (argc == 2) {
this->correctState = this->readInputData(string(argv[1]));
} else {
this->correctState = false;
}
this->tree.build(this->bodies);
}
PthreadSimulation::~PthreadSimulation() {
}
void PthreadSimulation::cleanup() {
}
int PthreadSimulation::getNumberOfProcesses() {
return this->threads.size();
}
int PthreadSimulation::getProcessId() {
vector<pthread_t>::iterator it = this->threads.begin();
int id = 0;
while (*it != pthread_self() && it != this->threads.end()) {
id++;
it++;
}
if (it != this->threads.end()) {
return id;
} else {
return -1;
}
}
void PthreadSimulation::runStep() {
//cout << this->tree.getRootBB().volume() << endl;
this->tree.computeForces();
this->tree.advance();