define engine type and overload all GetVolt/GetCurr

This commit is contained in:
Thorsten Liebig 2010-05-17 13:08:27 +02:00
parent b2c436282e
commit 98c10c7628
6 changed files with 22 additions and 4 deletions

View File

@ -31,6 +31,7 @@ Engine* Engine::New(const Operator* op)
Engine::Engine(const Operator* op)
{
m_type = BASIC;
numTS = 0;
Op = op;
for (int n=0;n<3;++n)

View File

@ -26,6 +26,11 @@ class Engine_Extension;
class Engine
{
public:
enum EngineType
{
BASIC, SSE, UNKNOWN
};
static Engine* New(const Operator* op);
virtual ~Engine();
@ -37,11 +42,11 @@ public:
virtual unsigned int GetNumberOfTimesteps() {return numTS;};
//this access functions muss be overloaded by any new engine using a different storage model
inline virtual FDTD_FLOAT& GetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return volt[n][x][y][z]; }
inline virtual FDTD_FLOAT& GetVolt( unsigned int n, unsigned int pos[] ) { return volt[n][pos[0]][pos[1]][pos[2]]; }
inline virtual FDTD_FLOAT& GetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return curr[n][x][y][z]; }
inline virtual FDTD_FLOAT& GetVolt( unsigned int n, unsigned int pos[] ) { return GetVolt(n,pos[0],pos[1],pos[2]); }
inline virtual FDTD_FLOAT& GetCurr( unsigned int n, unsigned int pos[] ) { return GetCurr(n,pos[0],pos[1],pos[2]); }
inline virtual FDTD_FLOAT& GetCurr( unsigned int n, unsigned int pos[] ) { return curr[n][pos[0]][pos[1]][pos[2]]; }
virtual void UpdateVoltages(unsigned int startX, unsigned int numX);
virtual void ApplyVoltageExcite();
@ -51,7 +56,11 @@ public:
inline size_t GetExtensionCount() {return m_Eng_exts.size();}
inline Engine_Extension* GetExtension(size_t nr) {return m_Eng_exts.at(nr);}
EngineType GetType() const {return m_type;}
protected:
EngineType m_type;
Engine(const Operator* op);
const Operator* Op;

View File

@ -45,6 +45,7 @@ Engine_Multithread* Engine_Multithread::New(const Operator* op, unsigned int num
Engine_Multithread::Engine_Multithread(const Operator* op) : Engine(op)
{
m_type = UNKNOWN;
m_RunEngine = NULL;
}

View File

@ -82,8 +82,11 @@ public:
static Engine_Multithread* New(const Operator* op, unsigned int numThreads = 0);
virtual ~Engine_Multithread();
//this access functions muss be overloaded by any new engine using a different storage model
inline virtual FDTD_FLOAT& GetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return m_RunEngine->GetVolt(n,x,y,z); }
inline virtual FDTD_FLOAT& GetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return m_RunEngine->GetCurr(n,x,y,z);}
inline virtual FDTD_FLOAT& GetVolt( unsigned int n, unsigned int pos[3] ) const { return m_RunEngine->GetVolt(n,pos); }
inline virtual FDTD_FLOAT& GetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return m_RunEngine->GetCurr(n,x,y,z); }
inline virtual FDTD_FLOAT& GetCurr( unsigned int n, unsigned int pos[3] ) const { return m_RunEngine->GetCurr(n,pos);}
virtual void setNumThreads( unsigned int numThreads );
virtual void Init();

View File

@ -28,6 +28,7 @@ Engine_sse* Engine_sse::New(const Operator_sse* op)
Engine_sse::Engine_sse(const Operator_sse* op) : Engine(op)
{
m_type = SSE;
Op = op;
f4_volt = 0;
f4_curr = 0;

View File

@ -32,8 +32,11 @@ public:
virtual unsigned int GetNumberOfTimesteps() {return numTS;};
//this access functions muss be overloaded by any new engine using a different storage model
inline virtual FDTD_FLOAT& GetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return f4_volt[n][x][y][z%numVectors].f[z/numVectors]; }
inline virtual FDTD_FLOAT& GetVolt( unsigned int n, unsigned int pos[3] ) const { return f4_volt[n][pos[0]][pos[1]][pos[2]%numVectors].f[pos[2]/numVectors]; }
inline virtual FDTD_FLOAT& GetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return f4_curr[n][x][y][z%numVectors].f[z/numVectors]; }
inline virtual FDTD_FLOAT& GetCurr( unsigned int n, unsigned int pos[3] ) const { return f4_curr[n][pos[0]][pos[1]][pos[2]%numVectors].f[pos[2]/numVectors]; }
protected:
Engine_sse(const Operator_sse* op);