mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-20 02:55:47 +00:00
Implement blockAndWait for threaded
This commit is contained in:
parent
741fff75c8
commit
9da2b86d72
@ -341,10 +341,9 @@ protected:
|
|||||||
//2. numLocalTerm + this->TotalNumberOfTerminatedParticles == this->TotalNumberOfParticles
|
//2. numLocalTerm + this->TotalNumberOfTerminatedParticles == this->TotalNumberOfParticles
|
||||||
//So, if neither are true, we can safely block and wait for communication to come in.
|
//So, if neither are true, we can safely block and wait for communication to come in.
|
||||||
|
|
||||||
if (this->Active.empty() &&
|
if (this->Active.empty() && this->Inactive.empty() &&
|
||||||
(numLocalTerm + this->TotalNumTerminatedParticles < this->TotalNumParticles))
|
(numLocalTerm + this->TotalNumTerminatedParticles < this->TotalNumParticles))
|
||||||
{
|
{
|
||||||
std::cout << " BLOCK!! rank= " << this->Rank << std::endl;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,11 @@ protected:
|
|||||||
bool GetActiveParticles(std::vector<vtkm::Particle>& particles, vtkm::Id& blockId) override
|
bool GetActiveParticles(std::vector<vtkm::Particle>& particles, vtkm::Id& blockId) override
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(this->Mutex);
|
std::lock_guard<std::mutex> lock(this->Mutex);
|
||||||
return this->AdvectorBaseAlgorithm<ResultType>::GetActiveParticles(particles, blockId);
|
bool val = this->AdvectorBaseAlgorithm<ResultType>::GetActiveParticles(particles, blockId);
|
||||||
|
|
||||||
|
this->WorkerIdle = !val;
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateActive(const std::vector<vtkm::Particle>& particles,
|
void UpdateActive(const std::vector<vtkm::Particle>& particles,
|
||||||
@ -77,8 +81,7 @@ protected:
|
|||||||
|
|
||||||
void WorkerWait()
|
void WorkerWait()
|
||||||
{
|
{
|
||||||
this->WorkerIdle = true;
|
// this->WorkerIdle = true;
|
||||||
|
|
||||||
// std::cout<<"Worker wait..."<<std::endl;
|
// std::cout<<"Worker wait..."<<std::endl;
|
||||||
// std::unique_lock<std::mutex> lock(this->WorkAvailMutex);
|
// std::unique_lock<std::mutex> lock(this->WorkAvailMutex);
|
||||||
// this->WorkAvailableCondition.wait(lock);
|
// this->WorkAvailableCondition.wait(lock);
|
||||||
@ -92,7 +95,6 @@ protected:
|
|||||||
vtkm::Id blockId = -1;
|
vtkm::Id blockId = -1;
|
||||||
if (this->GetActiveParticles(v, blockId))
|
if (this->GetActiveParticles(v, blockId))
|
||||||
{
|
{
|
||||||
this->WorkerIdle = false;
|
|
||||||
const auto& block = this->GetDataSet(blockId);
|
const auto& block = this->GetDataSet(blockId);
|
||||||
|
|
||||||
ResultType r;
|
ResultType r;
|
||||||
@ -139,25 +141,16 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Let the workers know that we are done.
|
//Let the workers know that we are done.
|
||||||
std::cout << this->Rank << " DONE" << std::endl;
|
|
||||||
this->SetDone();
|
this->SetDone();
|
||||||
// this->WorkAvailableCondition.notify_all();
|
// this->WorkAvailableCondition.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetBlockAndWait(const vtkm::Id& numLocalTerm) override
|
bool GetBlockAndWait(const vtkm::Id& numLocalTerm) override
|
||||||
{
|
{
|
||||||
return false;
|
|
||||||
/*
|
|
||||||
std::lock_guard<std::mutex> lock(this->Mutex);
|
std::lock_guard<std::mutex> lock(this->Mutex);
|
||||||
bool val = this->AdvectorBaseAlgorithm<ResultType>::GetBlockAndWait(numLocalTerm);
|
|
||||||
if (val && this->WorkerIdle)
|
|
||||||
val = true;
|
|
||||||
else
|
|
||||||
val = false;
|
|
||||||
if (this->Rank == 0) std::cout<<" M: GBW: val= "<<val<<" ((wi= "<<this->WorkerIdle<<" Asz= "<<this->Active.size()<<std::endl;
|
|
||||||
|
|
||||||
return val;
|
return (this->AdvectorBaseAlgorithm<ResultType>::GetBlockAndWait(numLocalTerm) &&
|
||||||
*/
|
this->WorkerIdle && this->WorkerResults.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetWorkerResults(std::unordered_map<vtkm::Id, std::vector<ResultType>>& results)
|
void GetWorkerResults(std::unordered_map<vtkm::Id, std::vector<ResultType>>& results)
|
||||||
|
Loading…
Reference in New Issue
Block a user