00001 #ifndef _MODEL_H_NOU_ 00002 #define _MODEL_H_NOU_ 00003 00004 #include <string> 00005 #include <vector> 00006 #include <CL/cl.h> 00007 #include "cellspace.h" 00008 00009 using namespace std; 00010 00011 class Machine; 00012 00013 class Model 00014 { 00015 private: 00016 cl_program program; 00017 vector<CellSpace*> patterns; 00018 public: 00019 Model(Machine *parent); 00020 virtual ~Model(); 00021 Machine* getParent(){ return parent; } 00022 void addChild(CellSpace *child); 00023 void removeChild(CellSpace *child); 00024 cl_kernel getKernel(CellSpace *pattern); 00025 virtual void run(CellSpace *pattern, int which, int iteration = 1) = 0; 00026 virtual int getCellSize() = 0; 00027 virtual void loadSource() = 0; 00028 protected: 00029 cl_int build(string source, string options); 00030 cl_kernel kernel; 00031 Machine *parent; 00032 }; 00033 00034 class SynchronousModel : public Model 00035 { 00036 public: 00037 SynchronousModel(Machine *parent, string model_definition); 00038 int getCellSize(){ return sizeof(int)*2; } 00039 void loadSource(); 00040 void run(CellSpace *pattern, int which, int iteration = 1); 00041 private: 00042 string source; 00043 }; 00044 00045 #endif // _MODEL_H_NOU_