00001 #ifndef Impala_Core_Array_ArrayPool_h
00002 #define Impala_Core_Array_ArrayPool_h
00003
00004 #include "Core/Array/Arrays.h"
00005 #ifdef PX_HORUS_USED
00006 #include "Ops/Array/PxHorus/PxSystem.h"
00007 #include "mpi.h"
00008 #endif
00009
00010 namespace Impala
00011 {
00012 namespace Core
00013 {
00014 namespace Array
00015 {
00016
00018 class ArrayPool
00019 {
00020 public:
00021
00022 ArrayPool(int width, int height, int nrViewX, int nrViewY)
00023 {
00024
00025 #ifdef PX_HORUS_USED
00026 int sizes[2];
00027 sizes[0] = width;
00028 sizes[1] = height;
00029 MPI_Bcast(sizes, 2, MPI_INT, PxRootCPU(), MPI_COMM_WORLD);
00030 mWidth = sizes[0];
00031 mHeight = sizes[1];
00032 #else
00033 mWidth = width;
00034 mHeight = height;
00035 #endif
00036
00037 mNrViewX = nrViewX;
00038 mNrViewY = nrViewY;
00039 mArV3UI8 = new Array2dVec3UInt8*[mNrViewX * mNrViewY];
00040 for (int i=0 ; i<mNrViewX*mNrViewY ; i++)
00041 mArV3UI8[i] = ArrayCreate<Array2dVec3UInt8>(mWidth, mHeight);
00042 mArV3R64 = 0;
00043 mNrV3R64 = 0;
00044 mArSR64 = 0;
00045 mNrSR64 = 0;
00046 mArC64 = 0;
00047 mNrC64 = 0;
00048 }
00049
00050 ~ArrayPool()
00051 {
00052 int i;
00053 for (i=0 ; i<mNrViewX*mNrViewY ; i++)
00054 delete mArV3UI8[i];
00055 delete mArV3UI8;
00056
00057 for (i=0 ; i<mNrV3R64 ; i++)
00058 delete mArV3R64[i];
00059 delete mArV3R64;
00060
00061 for (i=0 ; i<mNrSR64 ; i++)
00062 delete mArSR64[i];
00063 delete mArSR64;
00064
00065 for (i=0 ; i<mNrC64 ; i++)
00066 delete mArC64[i];
00067 delete mArC64;
00068 }
00069
00070 int
00071 Width()
00072 {
00073 return mWidth;
00074 }
00075
00076 int
00077 Height()
00078 {
00079 return mHeight;
00080 }
00081
00082 Array2dVec3UInt8*
00083 GetV3UI8(int viewX, int viewY)
00084 {
00085 return mArV3UI8[viewY * mNrViewX + viewX];
00086 }
00087
00088 UInt8*
00089 GetV3UI8PB(int viewX, int viewY)
00090 {
00091 return mArV3UI8[viewY * mNrViewX + viewX]->PB();
00092 }
00093
00094 void
00095 AllocV3R64(int nrIm, int bw = 0, int bh = 0)
00096 {
00097 mNrV3R64 = nrIm;
00098 mArV3R64 = new Array2dVec3Real64*[mNrV3R64];
00099 for (int i=0 ; i<mNrV3R64 ; i++)
00100 mArV3R64[i] = ArrayCreate<Array2dVec3Real64>(mWidth, mHeight,
00101 bw, bh);
00102 }
00103
00104 Array2dVec3Real64*
00105 GetV3R64(int nr)
00106 {
00107 return mArV3R64[nr];
00108 }
00109
00110 void
00111 AllocSR64(int nrIm, int bw = 0, int bh = 0)
00112 {
00113 mNrSR64 = nrIm;
00114 mArSR64 = new Array2dScalarReal64*[mNrSR64];
00115 for (int i=0 ; i<mNrSR64 ; i++)
00116 mArSR64[i] = ArrayCreate<Array2dScalarReal64>(mWidth, mHeight,
00117 bw, bh);
00118 }
00119
00120 Array2dScalarReal64*
00121 GetSR64(int nr)
00122 {
00123 return mArSR64[nr];
00124 }
00125
00126 void
00127 AllocC64(int nrIm, int bw = 0, int bh = 0)
00128 {
00129 mNrC64 = nrIm;
00130 mArC64 = new Array2dComplex64*[mNrC64];
00131 for (int i=0 ; i<mNrC64 ; i++)
00132 mArC64[i] = ArrayCreate<Array2dComplex64>(mWidth, mHeight,
00133 bw, bh);
00134 }
00135
00136 Array2dComplex64*
00137 GetC64(int nr)
00138 {
00139 return mArC64[nr];
00140 }
00141
00142 private:
00143
00144 int mWidth;
00145 int mHeight;
00146 int mNrViewX;
00147 int mNrViewY;
00148
00149 Array2dVec3UInt8** mArV3UI8;
00150 Array2dVec3Real64** mArV3R64;
00151 int mNrV3R64;
00152 Array2dScalarReal64** mArSR64;
00153 int mNrSR64;
00154 Array2dComplex64** mArC64;
00155 int mNrC64;
00156 };
00157
00158 }
00159 }
00160 }
00161
00162 #endif