Commit 3a5f8724 authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud
Browse files

Spread mode to all containers from each worker.

parent e15897c6
......@@ -15,13 +15,13 @@ class dtkDistributedCommunicatorPluginFactory;
class dtkDistributedCommunicatorPluginManager;
#define DTK_DISTRIBUTED_BEGIN_GLOBAL \
comm->barrier(); dtkDistributed::setMode(dtkDistributed::Global); if (dtkDistributedWork::worker()->master()) { time.restart();
comm->barrier(); dtkDistributed::setMode(dtkDistributed::Global); dtkDistributedWork::worker()->setMode(dtkDistributed::mode()); if (dtkDistributedWork::worker()->master()) { time.restart();
#define DTK_DISTRIBUTED_END_GLOBAL \
qDebug() << "global section:" << time.elapsed() << "ms"; } ; comm->barrier();
qDebug() << "global section:" << time.elapsed() << "ms"; } ; comm->barrier();
#define DTK_DISTRIBUTED_BEGIN_LOCAL \
comm->barrier(); dtkDistributed::setMode(dtkDistributed::Local); time.restart();
comm->barrier(); dtkDistributed::setMode(dtkDistributed::Local); dtkDistributedWork::worker()->setMode(dtkDistributed::mode()); time.restart();
#define DTK_DISTRIBUTED_END_LOCAL \
qDebug() << "local section:" << time.elapsed() << "ms";
......
......@@ -32,6 +32,9 @@ public:
inline dtkDistributedArray(const qlonglong& count, dtkDistributedWorker *worker);
inline ~dtkDistributedArray(void);
public:
inline void setMode(const dtkDistributed::Mode& mode);
public:
inline void clear(void);
......
......@@ -14,6 +14,7 @@
//#prama once
#include "dtkDistributed.h"
class dtkDistributedCommunicator;
......@@ -32,6 +33,21 @@ template<typename T> dtkDistributedArray<T>::~dtkDistributedArray(void)
delete m_handler;
}
template <typename T> void dtkDistributedArray<T>::setMode(const dtkDistributed::Mode& mode)
{
switch(mode) {
case dtkDistributed::Local:
m_handler->setLocalMode();
break;
case dtkDistributed::Global:
m_handler->setGlobalMode();
break;
default:
m_handler->setGlobalMode();
break;
}
}
template<typename T> void dtkDistributedArray<T>::clear(void)
{
return m_handler->clear();
......
......@@ -14,6 +14,7 @@
#pragma once
#include "dtkDistributed.h"
#include "dtkDistributedCommunicator.h"
#include "dtkDistributedMapper.h"
#include "dtkDistributedWorker.h"
......@@ -29,9 +30,10 @@ template <typename T> dtkDistributedArrayHandler<T>::dtkDistributedArrayHandler(
template <typename T> dtkDistributedArrayHandler<T>::~dtkDistributedArrayHandler(void)
{
m_comm->deallocate( m_wid, m_buffer_id);
m_comm->deallocate(m_wid, m_buffer_id);
m_worker->unrecord(m_array);
m_array->setMode(dtkDistributed::mode());
if (m_mapper)
delete m_mapper;
......
......@@ -26,7 +26,7 @@ public:
virtual ~dtkDistributedContainerBase(void) { ; }
public:
//virtual void setMode(const dtkDistributed::Mode& mode) = 0;
virtual void setMode(const dtkDistributed::Mode& mode) = 0;
};
// /////////////////////////////////////////////////////////////////
......
......@@ -17,6 +17,7 @@
#include "dtkDistributedWorker.h"
#include <dtkDistributed/dtkDistributedCommunicator.h>
#include <dtkDistributed/dtkDistributedContainer.h>
#include <dtkDistributed/dtkDistributedWork.h>
#include <QtCore>
......@@ -85,6 +86,16 @@ dtkDistributedWorker& dtkDistributedWorker::operator = (const dtkDistributedWork
return (*this);
}
void dtkDistributedWorker::setMode(const dtkDistributed::Mode& mode)
{
QHashIterator<dtkDistributedContainerBase*, qlonglong> it(d->containers);
while( it.hasNext()) {
it.next();
it.key()->setMode(mode);
}
}
void dtkDistributedWorker::setWid(qlonglong wid)
{
d->wid = wid;
......
......@@ -17,6 +17,8 @@
#include <QtCore>
#include "dtkDistributed.h"
class dtkDistributedCommunicator;
class dtkDistributedContainerBase;
class dtkDistributedWork;
......@@ -36,6 +38,9 @@ public:
public:
void run(void);
public:
void setMode(const dtkDistributed::Mode& mode);
public:
void setWid(qlonglong wid);
void setWct(qlonglong wct);
......
......@@ -32,7 +32,6 @@ class containerWork : public dtkDistributedWork
// ---
DTK_DISTRIBUTED_BEGIN_LOCAL
array.m_handler->setLocalMode();
for (qlonglong i = 0; i < array.count(); ++i)
array.set(i, array.localToGlobal(i));
......@@ -43,7 +42,6 @@ class containerWork : public dtkDistributedWork
// ---
DTK_DISTRIBUTED_BEGIN_GLOBAL
array.m_handler->setGlobalMode();
for (qlonglong i = 0; i < array.count(); ++i)
qDebug() << i << array.at(i) << dtkDistributedWork::worker()->wid();
......@@ -53,7 +51,6 @@ class containerWork : public dtkDistributedWork
DTK_DISTRIBUTED_END_GLOBAL
DTK_DISTRIBUTED_BEGIN_LOCAL
array.m_handler->setLocalMode();
for (qlonglong i = 0; i < array.count(); ++i)
array[i] += array.localToGlobal(i);
......@@ -61,7 +58,6 @@ class containerWork : public dtkDistributedWork
DTK_DISTRIBUTED_END_LOCAL
DTK_DISTRIBUTED_BEGIN_GLOBAL
array.m_handler->setGlobalMode();
for (qlonglong i = 0; i < array.count(); ++i)
array[i] -= i;
......@@ -289,9 +285,9 @@ void dtkDistributedContainerTestCase::testAll(void)
manager.spawn();
manager.exec(work);
//manager.exec(work2);
manager.exec(work2);
//manager.exec(work3);
manager.exec(work3);
manager.unspawn();
......
Supports Markdown
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