00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _COPROC_
00019 #define _COPROC_
00020
00021 #include <vector>
00022 #include <string>
00023 #include <cstring>
00024
00025 #ifdef _USING_FCGI_
00026 #include "boinc_fcgi.h"
00027 #endif
00028
00029 #include "miofile.h"
00030
00031 #define MAX_COPROC_INSTANCES 8
00032
00033 struct COPROC {
00034 char type[256];
00035 int count;
00036 int used;
00037 void* owner[MAX_COPROC_INSTANCES];
00038
00039
00040 #ifndef _USING_FCGI_
00041 virtual void write_xml(MIOFILE&);
00042 #endif
00043 COPROC(const char* t){
00044 strcpy(type, t);
00045 count = 0;
00046 used = 0;
00047 memset(&owner, 0, sizeof(owner));
00048 }
00049 virtual void description(char*){};
00050 virtual ~COPROC(){}
00051 int parse(MIOFILE&);
00052 };
00053
00054 struct COPROCS {
00055 std::vector<COPROC*> coprocs;
00056
00057
00058 COPROCS(){}
00059 ~COPROCS(){}
00060 void delete_coprocs(){
00061 for (unsigned int i=0; i<coprocs.size(); i++) {
00062 delete coprocs[i];
00063 }
00064 }
00065 #ifndef _USING_FCGI_
00066 void write_xml(MIOFILE& out) {
00067 for (unsigned int i=0; i<coprocs.size(); i++) {
00068 coprocs[i]->write_xml(out);
00069 }
00070 }
00071 #endif
00072 std::vector<std::string> get();
00073 int parse(FILE*);
00074 COPROC* lookup(char*);
00075 bool sufficient_coprocs(COPROCS&, bool log_flag, const char* prefix);
00076 void reserve_coprocs(COPROCS&, void*, bool log_flag, const char* prefix);
00077 void free_coprocs(COPROCS&, void*, bool log_flag, const char* prefix);
00078 bool fully_used() {
00079 for (unsigned int i=0; i<coprocs.size(); i++) {
00080 COPROC* cp = coprocs[i];
00081 if (cp->used < cp->count) return false;
00082 }
00083 return true;
00084 }
00085
00086
00087
00088
00089
00090 void clone(COPROCS& c, bool copy_used) {
00091 for (unsigned int i=0; i<c.coprocs.size(); i++) {
00092 COPROC* cp = c.coprocs[i];
00093 COPROC* cp2 = new COPROC(cp->type);
00094 cp2->count = cp->count;
00095 if (copy_used) cp2->used = cp->used;
00096 coprocs.push_back(cp2);
00097 }
00098 }
00099 };
00100
00101
00102
00103 struct cudaDeviceProp {
00104 char name[256];
00105 size_t totalGlobalMem;
00106 size_t sharedMemPerBlock;
00107 int regsPerBlock;
00108 int warpSize;
00109 size_t memPitch;
00110 int maxThreadsPerBlock;
00111 int maxThreadsDim[3];
00112 int maxGridSize[3];
00113 int clockRate;
00114 size_t totalConstMem;
00115 int major;
00116 int minor;
00117 size_t textureAlignment;
00118 int deviceOverlap;
00119 int multiProcessorCount;
00120 int __cudaReserved[40];
00121 };
00122
00123 struct COPROC_CUDA : public COPROC {
00124 cudaDeviceProp prop;
00125
00126 #ifndef _USING_FCGI_
00127 virtual void write_xml(MIOFILE&);
00128 #endif
00129 COPROC_CUDA(): COPROC("CUDA"){}
00130 virtual ~COPROC_CUDA(){}
00131 static const char* get(COPROCS&);
00132 virtual void description(char*);
00133 void clear();
00134 int parse(FILE*);
00135 };
00136
00137
00138 struct COPROC_CELL_SPE : public COPROC {
00139 static const char* get(COPROCS&);
00140 COPROC_CELL_SPE() : COPROC("Cell SPE"){}
00141 virtual void description(char*);
00142 virtual ~COPROC_CELL_SPE(){}
00143 };
00144
00145 void fake_cuda(COPROCS&, int);
00146
00147 #endif