Commit bd08172d authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud
Browse files

Clean header.

parent 754f9f66
......@@ -38,7 +38,7 @@ public:
public:
inline dtkDistributedArray(const qlonglong& count, dtkDistributedWork *work);
inline dtkDistributedArray(const QVector<T> & vector, dtkDistributedWork *work);
inline dtkDistributedArray(const QVector<T>& vector, dtkDistributedWork *work);
inline ~dtkDistributedArray(void);
#pragma mark -
......@@ -91,24 +91,8 @@ private:
public:
inline bool empty(void) const { return !m_count; }
inline qlonglong count(void) const { return m_count; }
inline void setAt(const qlonglong& index, const T& value)
{
qint32 owner = static_cast<qint32>(m_mapper->owner(index));
qlonglong pos = m_mapper->globalToLocal(index);
m_comm->put(owner, pos, &(const_cast<T&>(value)), buffer_id);
}
inline T at(const qlonglong& index) const
{
qint32 owner = static_cast<qint32>(m_mapper->owner(index));
qlonglong pos = m_mapper->globalToLocal(index);
if (m_wid == owner) {
return buffer[pos];
} else {
T temp;
m_comm->get(owner, pos, &temp, buffer_id);
return temp;
}
}
inline void setAt(const qlonglong& index, const T& value);
inline T at(const qlonglong& index) const;
inline T first(void) const { return this->at(0); }
inline T last(void) const { return this->at(m_count-1); }
};
......
......@@ -18,12 +18,30 @@
#include "dtkDistributedWork.h"
#include "dtkDistributedWorker.h"
template<typename T> dtkDistributedArray<T>::dtkDistributedArray(const qlonglong& count, dtkDistributedWork *work) : m_handler(0), m_local_handler(*this), m_global_handler(*this), m_wid(work->worker()->wid()), m_count(count), m_mapper(new dtkDistributedMapper), m_worker(work->worker()), m_comm(work->worker()->communicator())
// ///////////////////////////////////////////////////////////////////
// dtkDistributedArray implementation
// ///////////////////////////////////////////////////////////////////
template<typename T> dtkDistributedArray<T>::dtkDistributedArray(const qlonglong& count, dtkDistributedWork *work) : m_handler(0),
m_local_handler(*this),
m_global_handler(*this),
m_wid(work->worker()->wid()),
m_count(count),
m_mapper(new dtkDistributedMapper),
m_worker(work->worker()),
m_comm(work->worker()->communicator())
{
this->initialize();
}
template<typename T> dtkDistributedArray<T>::dtkDistributedArray(const QVector<T> & qvector , dtkDistributedWork *work) : m_handler(0), m_local_handler(*this), m_global_handler(*this), m_wid(work->worker()->wid()), m_count(qvector.count()), m_mapper(new dtkDistributedMapper), m_worker(work->worker()), m_comm(work->worker()->communicator())
template<typename T> dtkDistributedArray<T>::dtkDistributedArray(const QVector<T>& qvector , dtkDistributedWork *work) : m_handler(0),
m_local_handler(*this),
m_global_handler(*this),
m_wid(work->worker()->wid()),
m_count(qvector.count()),
m_mapper(new dtkDistributedMapper),
m_worker(work->worker()),
m_comm(work->worker()->communicator())
{
this->initialize();
for (qlonglong i = 0; i < m_local_handler.buffer_count ; ++i)
......@@ -84,3 +102,27 @@ template<typename T> qlonglong dtkDistributedArray<T>::localToGlobal(const qlong
return m_mapper->localToGlobal(index, m_wid);
}
// ///////////////////////////////////////////////////////////////////
// dtkDistributedArray global handler
// ///////////////////////////////////////////////////////////////////
template<typename T> void dtkDistributedArray<T>::global_handler::setAt(const qlonglong& index, const T& value)
{
qint32 owner = static_cast<qint32>(m_mapper->owner(index));
qlonglong pos = m_mapper->globalToLocal(index);
m_comm->put(owner, pos, &(const_cast<T&>(value)), buffer_id);
}
template<typename T> T dtkDistributedArray<T>::global_handler::at(const qlonglong& index) const
{
qint32 owner = static_cast<qint32>(m_mapper->owner(index));
qlonglong pos = m_mapper->globalToLocal(index);
if (m_wid == owner) {
return buffer[pos];
} else {
T temp;
m_comm->get(owner, pos, &temp, buffer_id);
return temp;
}
}
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