Commit 824f0bac authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud
Browse files

Update container test.

parent 2670fe25
......@@ -21,61 +21,65 @@
#include <dtkDistributed/dtkDistributedArray.h>
#include <dtkDistributed/dtkDistributedArrayHandler.h>
class myWork : public dtkDistributedWork
class containerWork : public dtkDistributedWork
{
myWork *clone(void) { return new myWork(*this); };
containerWork *clone(void) { return new containerWork(*this); };
void run(void)
{
QTime time;
dtkDistributedCommunicator *comm = dtkDistributedWork::worker()->communicator();
dtkDistributedArray<qlonglong> array(11, dtkDistributedWork::worker());
dtkDistributedCommunicator *comm = dtkDistributedWork::worker()->communicator();
dtkDistributedArray<qlonglong> array(11, dtkDistributedWork::worker());
// ---
DTK_DISTRIBUTED_BEGIN_LOCAL
array.m_handler->setLocalMode();
for (qlonglong i = 0; i < array.count(); ++i)
array.set(i, array.mapper()->localToGlobal(i, dtkDistributedWork::worker()->wid()));
qDebug() << array.first() << array.last() << dtkDistributedWork::worker()->wid();
DTK_DISTRIBUTED_END_LOCAL
// ---
DTK_DISTRIBUTED_BEGIN_GLOBAL
array.m_handler->setGlobalMode();
for (qlonglong i = 0; i < array.count(); ++i)
qDebug() << i << array.at(i) << dtkDistributedWork::worker()->wid();
qDebug() << array.first() << array.last() << dtkDistributedWork::worker()->wid();
DTK_DISTRIBUTED_END_GLOBAL
DTK_DISTRIBUTED_BEGIN_LOCAL
array.m_handler->setLocalMode();
// array.clear();
// qDebug() << array.empty() << dtkDistributedWork::worker()->wid();
// qDebug() << array.count() << dtkDistributedWork::worker()->wid();
for (qlonglong i = 0; i < array.count(); ++i)
array.set(i, array.mapper()->localToGlobal(i, dtkDistributedWork::worker()->wid()));
qDebug() << array.first() << array.last() << dtkDistributedWork::worker()->wid();
DTK_DISTRIBUTED_END_LOCAL
DTK_DISTRIBUTED_BEGIN_GLOBAL
array.m_handler->setGlobalMode();
// array.clear();
// qDebug() << array.empty() << dtkDistributedWork::worker()->wid();
// qDebug() << array.count() << dtkDistributedWork::worker()->wid();
for (qlonglong i = 0; i < array.count(); ++i)
qDebug() << i << array.at(i) << dtkDistributedWork::worker()->wid();
qDebug() << array.first() << array.last() << dtkDistributedWork::worker()->wid();
DTK_DISTRIBUTED_END_GLOBAL
DTK_DISTRIBUTED_BEGIN_LOCAL
array.m_handler->setLocalMode();
for (qlonglong i = 0; i < array.count(); ++i)
array[i] += array.mapper()->localToGlobal(i, dtkDistributedWork::worker()->wid());
DTK_DISTRIBUTED_END_LOCAL
DTK_DISTRIBUTED_BEGIN_GLOBAL
array.m_handler->setGlobalMode();
DTK_DISTRIBUTED_BEGIN_LOCAL
array.m_handler->setLocalMode();
for (qlonglong i = 0; i < array.count(); ++i)
array[i] -= i;
for (qlonglong i = 0; i < array.count(); ++i)
array[i] += array.mapper()->localToGlobal(i, dtkDistributedWork::worker()->wid());
DTK_DISTRIBUTED_END_LOCAL
DTK_DISTRIBUTED_BEGIN_GLOBAL
array.m_handler->setGlobalMode();
for (qlonglong i = 0; i < array.count(); ++i)
array[i] -= i;
for (qlonglong i = 0; i < array.count(); ++i)
qDebug() << i << array.at(i) << dtkDistributedWork::worker()->wid();
DTK_DISTRIBUTED_END_GLOBAL
}
};
for (qlonglong i = 0; i < array.count(); ++i)
qDebug() << i << array.at(i) << dtkDistributedWork::worker()->wid();
class globalLocalWork : public dtkDistributedWork
{
globalLocalWork *clone(void) { return new globalLocalWork(*this); };
DTK_DISTRIBUTED_END_GLOBAL
void run(void)
{
// qDebug()<< "run!!!!";
// qlonglong N = 10000000;
......@@ -172,41 +176,41 @@ void dtkDistributedContainerTestCase::init(void)
void dtkDistributedContainerTestCase::testGlobalLocal(void)
{
// dtkDistributedPolicy policy;
// QByteArray numprocs = qgetenv("DTK_NUM_THREADS");
// QByteArray policyEnv = qgetenv("DTK_DISTRIBUTED_POLICY");
// int np = 2;
// policy.setType(dtkDistributedPolicy::MP);
// if (!numprocs.isEmpty()) {
// np = numprocs.toInt();
// qDebug() << "got num procs from env" << np;
// }
// if (!policyEnv.isEmpty()) {
// qDebug() << "got policy from env" << policyEnv;
// if (QString(policyEnv) == "MT"){
// policy.setType(dtkDistributedPolicy::MT);
// } else if (QString(policyEnv) == "MP") {
// policy.setType(dtkDistributedPolicy::MP);
// } else {
// qDebug() << "unknown policy" << policyEnv;
// }
// }
// for (int i=0; i < np; ++i)
// policy.addHost("localhost");
// dtkDistributedWorkerManager manager;
// myWork *work = new myWork();
// manager.setPolicy(&policy);
// qDebug() << "spawn";
// manager.spawn(work);
// manager.unspawn();
dtkDistributedPolicy policy;
QByteArray numprocs = qgetenv("DTK_NUM_THREADS");
QByteArray policyEnv = qgetenv("DTK_DISTRIBUTED_POLICY");
int np = 2;
policy.setType(dtkDistributedPolicy::MP);
if (!numprocs.isEmpty()) {
np = numprocs.toInt();
qDebug() << "got num procs from env" << np;
}
if (!policyEnv.isEmpty()) {
qDebug() << "got policy from env" << policyEnv;
if (QString(policyEnv) == "MT"){
policy.setType(dtkDistributedPolicy::MT);
} else if (QString(policyEnv) == "MP") {
policy.setType(dtkDistributedPolicy::MP);
} else {
qDebug() << "unknown policy" << policyEnv;
}
}
for (int i=0; i < np; ++i)
policy.addHost("localhost");
dtkDistributedWorkerManager manager;
globalLocalWork *work = new globalLocalWork();
manager.setPolicy(&policy);
qDebug() << "spawn";
manager.spawn(work);
manager.unspawn();
}
void dtkDistributedContainerTestCase::testFunctor(void)
void dtkDistributedContainerTestCase::testContainer(void)
{
dtkDistributedPolicy policy;
QByteArray numprocs = qgetenv("DTK_NUM_THREADS");
......@@ -234,7 +238,7 @@ void dtkDistributedContainerTestCase::testFunctor(void)
policy.addHost("localhost");
dtkDistributedWorkerManager manager;
myWork *work = new myWork();
containerWork *work = new containerWork();
manager.setPolicy(&policy);
qDebug() << "spawn";
......
......@@ -26,7 +26,7 @@ private slots:
private slots:
void testGlobalLocal(void);
void testFunctor(void);
void testContainer(void);
private slots:
void cleanupTestCase(void);
......
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