Commit 91bda01a authored by Julien Wintz's avatar Julien Wintz
Browse files

Fixed build tree. Renaming test folder.

parent 10f22c51
......@@ -3,9 +3,9 @@
## Author: Julien Wintz
## Created: Mon Feb 4 10:17:21 2013 (+0100)
## Version:
## Last-Updated: Mon Feb 11 23:25:49 2013 (+0100)
## Last-Updated: Tue Feb 26 14:45:18 2013 (+0100)
## By: Julien Wintz
## Update #: 113
## Update #: 118
######################################################################
##
### Change Log:
......@@ -83,7 +83,7 @@ include_directories(${PROJECT_SOURCE_DIR}/src/dtkTest)
## ###################################################################
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(tst)
## ###################################################################
## Exporting
......
......@@ -34,7 +34,8 @@ dtkDistributedPolicy::dtkDistributedPolicy(void) : QObject(), d(new dtkDistribut
dtkDistributedPolicy::~dtkDistributedPolicy(void)
{
delete d;
d=NULL;
d = NULL;
}
dtkDistributedPolicy::dtkDistributedPolicy(const dtkDistributedPolicy& other)
......@@ -43,11 +44,13 @@ dtkDistributedPolicy::dtkDistributedPolicy(const dtkDistributedPolicy& other)
dtkDistributedPolicy& dtkDistributedPolicy::operator = (const dtkDistributedPolicy& other)
{
return (*this);
}
void dtkDistributedPolicy::addHost(QString host)
{
qDebug() << "add host " << host;
d->hosts.append(host);
}
......@@ -76,5 +79,3 @@ QStringList dtkDistributedPolicy::hosts(void)
{
return d->hosts;
}
......@@ -15,6 +15,7 @@
#include "dtkDistributedWorker.h"
#include <dtkDistributed/dtkDistributedCommunicator.h>
#include <dtkDistributed/dtkDistributedWork.h>
......
......@@ -38,7 +38,8 @@ dtkDistributedWorkerManager::dtkDistributedWorkerManager(void) : QObject(), d(ne
dtkDistributedWorkerManager::~dtkDistributedWorkerManager(void)
{
delete d;
d=NULL;
d = NULL;
}
dtkDistributedWorkerManager::dtkDistributedWorkerManager(const dtkDistributedWorkerManager& other)
......@@ -47,6 +48,7 @@ dtkDistributedWorkerManager::dtkDistributedWorkerManager(const dtkDistributedWor
dtkDistributedWorkerManager& dtkDistributedWorkerManager::operator = (const dtkDistributedWorkerManager& other)
{
return (*this);
}
void dtkDistributedWorkerManager::setCommunicator(dtkDistributedCommunicator *comm)
......@@ -64,6 +66,7 @@ void dtkDistributedWorkerManager::spawn(dtkDistributedWork *work)
{
d->worker.setWork(work);
d->worker.setCommunicator(d->comm);
QStringList hosts = d->policy->hosts();
d->comm->spawn(hosts, hosts.count(), d->worker);
......@@ -73,5 +76,3 @@ void dtkDistributedWorkerManager::unspawn(void)
{
d->comm->uninitialize();
}
......@@ -3,9 +3,9 @@
* Author: Julien Wintz
* Created: Mon Feb 4 14:11:27 2013 (+0100)
* Version:
* Last-Updated: 2013 Tue Feb 12 14:34:04 (+0100)
* By: Thibaud Kloczko
* Update #: 103
* Last-Updated: Tue Feb 26 14:35:33 2013 (+0100)
* By: Julien Wintz
* Update #: 107
*/
/* Change Log:
......@@ -40,11 +40,9 @@ void dtkDistributedCommunicatorTestCase::testPlugin(void)
{
dtkDistributedCommunicator *communicator = dtkDistributed::communicator::pluginFactory().create("mpi");
communicator->initialize();
qDebug() << communicator->metaObject()->className();
qDebug() << communicator->pid();
qDebug() << communicator->size();
communicator->uninitialize();
delete communicator;
}
......
......@@ -21,91 +21,99 @@
class myWork : public dtkDistributedWork
{
myWork *clone(void) {return new myWork(*this); };
myWork *clone(void)
{
return new myWork(*this);
}
void run(void)
{
qDebug()<< "run!!!!";
qlonglong N = 10000000;
qlonglong sum = 0;
for (qlonglong i = 0; i < N; ++i)
sum += 2*i;
dtkDistributedCommunicator *comm = dtkDistributedWork::worker()->communicator();
QTime time, maintime;
maintime.start();
time.start();
{
qDebug()<< "run!!!!";
qlonglong N = 10000000;
qlonglong sum = 0;
for (qlonglong i = 0; i < N; ++i)
sum += 2*i;
dtkDistributedCommunicator *comm = dtkDistributedWork::worker()->communicator();
QTime time, maintime;
maintime.start();
time.start();
dtkDistributedContainer<qlonglong>& c = *(new dtkDistributedContainer<qlonglong>(N,dtkDistributedWork::worker() ));
QVERIFY(N == c.size());
qDebug()<< "allocation time:" <<time.elapsed() << "ms"; time.restart();
DTK_DISTRIBUTED_BEGIN_LOCAL
dtkDistributedContainer<qlonglong>& c = *(new dtkDistributedContainer<qlonglong>(N,dtkDistributedWork::worker() ));
QVERIFY(N == c.size());
dtkDistributedLocalIterator<qlonglong>& it = c.localIterator();
qDebug()<< "allocation time:" <<time.elapsed() << "ms"; time.restart();
DTK_DISTRIBUTED_BEGIN_LOCAL
// Fill the container in parallel
while(it.hasNext()) {
c.setLocal(it.index(), it.globalIndex());
it.next();
}
dtkDistributedLocalIterator<qlonglong>& it = c.localIterator();
comm->barrier();
// Fill the container in parallel
while(it.hasNext()) {
c.setLocal(it.index(), it.globalIndex());
it.next();
}
it.toFront();
comm->barrier();
// Do the computation in parallel
while(it.hasNext()) {
c.setLocal(it.index(), 2 * it.peekNext() );
it.next();
}
it.toFront();
// it.toFront();
// while(it.hasNext()) {
// qDebug() << dtkDistributedWork::worker()->wid() << it.index() << it.peekNext();
// it.next();
// }
// Do the computation in parallel
while(it.hasNext()) {
c.setLocal(it.index(), 2 * it.peekNext() );
it.next();
}
comm->barrier();
// it.toFront();
// while(it.hasNext()) {
// qDebug() << dtkDistributedWork::worker()->wid() << it.index() << it.peekNext();
// it.next();
// }
qlonglong check_sum = 0;
comm->barrier();
dtkDistributedContainer<qlonglong>& partial_sum = *(new dtkDistributedContainer<qlonglong>(dtkDistributedWork::worker()->wct(), dtkDistributedWork::worker() ));
qlonglong check_sum = 0;
dtkDistributedIterator<qlonglong>& it_partial = partial_sum.iterator();
comm->barrier();
it.toFront();
dtkDistributedContainer<qlonglong>& partial_sum = *(new dtkDistributedContainer<qlonglong>(dtkDistributedWork::worker()->wct(), dtkDistributedWork::worker() ));
// Do the partial sum in parallel, and put the result in a parallel container (of size = number of process/threads)
while(it.hasNext()) {
check_sum += c.localAt(it.index());
it.next();
}
partial_sum.setLocal(0,check_sum);
dtkDistributedIterator<qlonglong>& it_partial = partial_sum.iterator();
comm->barrier();
it.toFront();
DTK_DISTRIBUTED_END_LOCAL
// Do the partial sum in parallel, and put the result in a parallel container (of size = number of process/threads)
while(it.hasNext()) {
check_sum += c.localAt(it.index());
it.next();
}
partial_sum.setLocal(0,check_sum);
DTK_DISTRIBUTED_BEGIN_GLOBAL
DTK_DISTRIBUTED_END_LOCAL
// Sum the partial sums in sequential mode
DTK_DISTRIBUTED_BEGIN_GLOBAL
check_sum = 0;
while(it_partial.hasNext()) {
// Sum the partial sums in sequential mode
check_sum = 0;
while(it_partial.hasNext()) {
check_sum += partial_sum.at(it_partial.index());
it_partial.next();
}
check_sum += partial_sum.at(it_partial.index());
it_partial.next();
}
qDebug() << "TOTAL SUM" << check_sum << sum << maintime.elapsed() << "ms";
qDebug() << "TOTAL SUM" << check_sum << sum << maintime.elapsed() << "ms";
QVERIFY(sum == check_sum);
QVERIFY(sum == check_sum);
DTK_DISTRIBUTED_END_GLOBAL
DTK_DISTRIBUTED_END_GLOBAL
delete &c;
delete &partial_sum;
}
delete &c;
delete &partial_sum;
}
};
void dtkDistributedContainerTestCase::initTestCase(void)
......@@ -120,10 +128,11 @@ 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);
......@@ -132,6 +141,7 @@ void dtkDistributedContainerTestCase::testGlobalLocal(void)
np = numprocs.toInt();
qDebug() << "got num procs from env" << np;
}
if (!policyEnv.isEmpty()) {
qDebug() << "got policy from env" << policyEnv;
if (QString(policyEnv) == "MT"){
......
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