2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2008-03-10 20:40:35 +00:00
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2008-03-10 20:40:35 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2008-03-10 20:40:35 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2008-03-10 20:40:35 +00:00
|
|
|
|
|
|
|
#ifndef _COPROC_
|
|
|
|
#define _COPROC_
|
|
|
|
|
|
|
|
#include <vector>
|
2008-07-10 21:57:18 +00:00
|
|
|
#include <string>
|
2008-04-02 19:33:12 +00:00
|
|
|
#include <cstring>
|
2008-03-10 20:40:35 +00:00
|
|
|
|
2008-04-17 15:43:51 +00:00
|
|
|
#ifdef _USING_FCGI_
|
|
|
|
#include "fcgi_stdio.h"
|
|
|
|
#endif
|
|
|
|
|
2008-04-01 15:08:47 +00:00
|
|
|
#include "miofile.h"
|
|
|
|
|
2008-07-21 16:25:03 +00:00
|
|
|
#define MAX_COPROC_INSTANCES 8
|
|
|
|
|
2008-03-10 20:40:35 +00:00
|
|
|
struct COPROC {
|
2008-05-09 20:54:52 +00:00
|
|
|
char type[256]; // must be unique
|
2008-03-10 20:40:35 +00:00
|
|
|
int count; // how many are present
|
2008-03-29 21:53:45 +00:00
|
|
|
int used; // how many are in use (used by client)
|
2008-07-21 16:25:03 +00:00
|
|
|
void* owner[MAX_COPROC_INSTANCES];
|
|
|
|
// which ACTIVE_TASK each one is allocated to
|
2008-03-10 20:40:35 +00:00
|
|
|
|
2008-04-17 15:43:51 +00:00
|
|
|
#ifndef _USING_FCGI_
|
2008-04-01 20:46:41 +00:00
|
|
|
virtual void write_xml(MIOFILE&);
|
2008-04-17 15:43:51 +00:00
|
|
|
#endif
|
2008-06-26 19:27:23 +00:00
|
|
|
COPROC(const char* t){
|
2008-05-09 20:54:52 +00:00
|
|
|
strcpy(type, t);
|
2008-04-01 20:46:41 +00:00
|
|
|
count = 0;
|
|
|
|
used = 0;
|
2008-07-21 19:56:01 +00:00
|
|
|
memset(&owner, 0, sizeof(owner));
|
2008-04-01 20:46:41 +00:00
|
|
|
}
|
2008-07-21 19:56:01 +00:00
|
|
|
virtual void description(char*){};
|
2008-03-10 20:40:35 +00:00
|
|
|
virtual ~COPROC(){}
|
2008-04-01 15:08:47 +00:00
|
|
|
int parse(MIOFILE&);
|
2008-03-10 20:40:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct COPROCS {
|
2008-04-01 20:46:41 +00:00
|
|
|
std::vector<COPROC*> coprocs; // not deleted in destructor
|
|
|
|
// so any structure that includes this needs to do it manually
|
2008-03-10 20:40:35 +00:00
|
|
|
|
|
|
|
COPROCS(){}
|
2008-04-01 20:46:41 +00:00
|
|
|
~COPROCS(){}
|
|
|
|
void delete_coprocs(){
|
2008-03-31 16:19:45 +00:00
|
|
|
for (unsigned int i=0; i<coprocs.size(); i++) {
|
|
|
|
delete coprocs[i];
|
|
|
|
}
|
|
|
|
}
|
2008-04-17 15:43:51 +00:00
|
|
|
#ifndef _USING_FCGI_
|
2008-04-01 20:46:41 +00:00
|
|
|
void write_xml(MIOFILE& out) {
|
2008-04-01 15:08:47 +00:00
|
|
|
for (unsigned int i=0; i<coprocs.size(); i++) {
|
2008-04-01 20:46:41 +00:00
|
|
|
coprocs[i]->write_xml(out);
|
2008-04-01 15:08:47 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-17 15:43:51 +00:00
|
|
|
#endif
|
2008-07-10 21:57:18 +00:00
|
|
|
std::vector<std::string> get();
|
2008-04-01 20:46:41 +00:00
|
|
|
int parse(FILE*);
|
|
|
|
COPROC* lookup(char*);
|
2008-08-20 17:34:18 +00:00
|
|
|
bool sufficient_coprocs(COPROCS&, bool verbose, const char* prefix);
|
|
|
|
void reserve_coprocs(COPROCS&, void*, bool verbose, const char* prefix);
|
2008-07-21 16:25:03 +00:00
|
|
|
void free_coprocs(COPROCS&, void*, bool verbose);
|
|
|
|
|
2008-08-20 17:34:18 +00:00
|
|
|
// Copy a coproc set, setting usage to zero.
|
|
|
|
// used in round-robin simulator and CPU scheduler,
|
|
|
|
// to avoid messing w/ master copy
|
|
|
|
//
|
2008-05-23 22:03:27 +00:00
|
|
|
void clone(COPROCS& c) {
|
|
|
|
for (unsigned int i=0; i<c.coprocs.size(); i++) {
|
|
|
|
COPROC* cp = c.coprocs[i];
|
|
|
|
COPROC* cp2 = new COPROC(cp->type);
|
|
|
|
cp2->count = cp->count;
|
|
|
|
coprocs.push_back(cp2);
|
|
|
|
}
|
|
|
|
}
|
2008-03-10 20:40:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// the following copied from /usr/local/cuda/include/driver_types.h
|
|
|
|
//
|
|
|
|
struct cudaDeviceProp {
|
2008-08-22 22:15:08 +00:00
|
|
|
char name[256];
|
|
|
|
size_t totalGlobalMem;
|
|
|
|
size_t sharedMemPerBlock;
|
|
|
|
int regsPerBlock;
|
|
|
|
int warpSize;
|
|
|
|
size_t memPitch;
|
|
|
|
int maxThreadsPerBlock;
|
|
|
|
int maxThreadsDim[3];
|
|
|
|
int maxGridSize[3];
|
|
|
|
int clockRate;
|
|
|
|
size_t totalConstMem;
|
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
size_t textureAlignment;
|
|
|
|
int deviceOverlap;
|
|
|
|
int multiProcessorCount;
|
|
|
|
int __cudaReserved[40];
|
2008-03-10 20:40:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct COPROC_CUDA : public COPROC {
|
|
|
|
cudaDeviceProp prop;
|
|
|
|
|
2008-04-17 15:43:51 +00:00
|
|
|
#ifndef _USING_FCGI_
|
2008-04-01 20:46:41 +00:00
|
|
|
virtual void write_xml(MIOFILE&);
|
2008-04-17 15:43:51 +00:00
|
|
|
#endif
|
2008-05-09 20:54:52 +00:00
|
|
|
COPROC_CUDA(): COPROC("CUDA"){}
|
2008-03-10 20:40:35 +00:00
|
|
|
virtual ~COPROC_CUDA(){}
|
2008-06-26 19:27:23 +00:00
|
|
|
static const char* get(COPROCS&);
|
2008-07-21 19:56:01 +00:00
|
|
|
virtual void description(char*);
|
2008-03-10 21:59:27 +00:00
|
|
|
void clear();
|
|
|
|
int parse(FILE*);
|
2008-03-10 20:40:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct COPROC_CELL_SPE : public COPROC {
|
2008-06-26 19:27:23 +00:00
|
|
|
static const char* get(COPROCS&);
|
2008-05-09 21:07:15 +00:00
|
|
|
COPROC_CELL_SPE() : COPROC("Cell SPE"){}
|
2008-07-21 19:56:01 +00:00
|
|
|
virtual void description(char*);
|
2008-03-10 20:40:35 +00:00
|
|
|
virtual ~COPROC_CELL_SPE(){}
|
|
|
|
};
|
|
|
|
|
2008-07-21 19:56:01 +00:00
|
|
|
void fake_cuda(COPROCS&, int);
|
2008-03-28 20:20:10 +00:00
|
|
|
|
2008-03-10 20:40:35 +00:00
|
|
|
#endif
|