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
|
|
|
|
2009-04-21 08:11:28 +00:00
|
|
|
// Structures representing coprocessors (e.g. GPUs);
|
|
|
|
// used in both client and server.
|
|
|
|
//
|
|
|
|
// Notes:
|
|
|
|
//
|
|
|
|
// 1) The use of "CUDA" is misleading; it really means "NVIDIA GPU".
|
|
|
|
// 2) The design treats each resource type as a pool of identical devices;
|
|
|
|
// for example, there is a single "CUDA long-term debt" per project,
|
|
|
|
// and a scheduler request contains a request (#instances, instance-seconds)
|
|
|
|
// for CUDA jobs.
|
|
|
|
// In reality, the instances of a resource type can have different properties:
|
|
|
|
// In the case of CUDA, "compute capability", driver version, RAM, speed, etc.
|
|
|
|
// How to resolve this discrepancy?
|
|
|
|
//
|
|
|
|
// Prior to 21 Apr 09 we identified the fastest instance
|
|
|
|
// and pretended that the others were identical to it.
|
|
|
|
// This approach has a serious flaw:
|
|
|
|
// suppose that the fastest instance has characteristics
|
|
|
|
// (version, RAM etc.) that satisfy the project's requirements,
|
|
|
|
// but other instances to not.
|
|
|
|
// Then BOINC executes jobs on GPUs that can't handle them,
|
|
|
|
// the jobs fail, the host is punished, etc.
|
|
|
|
//
|
|
|
|
// We could treat each GPU has a separate resource,
|
|
|
|
// with its own set of debts, backoffs, etc.
|
|
|
|
// However, this would imply tying jobs to instances,
|
|
|
|
// which is undesirable from a scheduling viewpoint.
|
|
|
|
// It would also be a big code change in both client and server.
|
|
|
|
//
|
|
|
|
// Instead, (as of 21 Apr 09) our approach is to identify a
|
|
|
|
// "most capable" instance, which in the case of CUDA is based on
|
|
|
|
// a) compute capability
|
|
|
|
// b) driver version
|
|
|
|
// c) RAM size
|
|
|
|
// d) est. FLOPS
|
|
|
|
// (in decreasing priority).
|
|
|
|
// We ignore and don't use any instances that are less capable
|
|
|
|
// on any of these axes.
|
|
|
|
//
|
|
|
|
// This design avoids running coprocessor apps on instances
|
|
|
|
// that are incapable of handling them, and it involves no server changes.
|
|
|
|
// Its drawback is that, on systems with multiple and differing GPUs,
|
|
|
|
// it may not use some GPUs that actually could be used.
|
|
|
|
|
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_
|
2008-09-09 19:10:42 +00:00
|
|
|
#include "boinc_fcgi.h"
|
2008-04-17 15:43:51 +00:00
|
|
|
#endif
|
|
|
|
|
2008-04-01 15:08:47 +00:00
|
|
|
#include "miofile.h"
|
|
|
|
|
2009-03-06 23:10:45 +00:00
|
|
|
#define MAX_COPROC_INSTANCES 64
|
|
|
|
|
2009-04-22 02:09:53 +00:00
|
|
|
// represents a set of equivalent coprocessors
|
|
|
|
//
|
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)
|
2009-01-03 06:01:17 +00:00
|
|
|
|
2009-01-30 21:25:24 +00:00
|
|
|
// the following are used in both client and server for work-fetch info
|
|
|
|
//
|
2009-01-03 06:01:17 +00:00
|
|
|
double req_secs; // how many instance-seconds of work requested
|
|
|
|
int req_instances; // requesting enough jobs to use this many instances
|
2009-01-30 21:25:24 +00:00
|
|
|
double estimated_delay; // resource will be saturated for this long
|
2009-01-03 06:01:17 +00:00
|
|
|
|
2009-03-06 23:10:45 +00:00
|
|
|
// Used in client to keep track of which tasks are using which instances
|
|
|
|
// The pointers point to ACTIVE_TASK
|
|
|
|
//
|
|
|
|
void* owner[MAX_COPROC_INSTANCES];
|
|
|
|
|
2009-04-21 08:11:28 +00:00
|
|
|
// the device number of each instance
|
|
|
|
// These are not sequential if we omit instances (see above)
|
|
|
|
//
|
2009-04-22 02:09:53 +00:00
|
|
|
int device_nums[MAX_COPROC_INSTANCES];
|
|
|
|
int device_num; // temp used in scan process
|
2009-04-21 08:11:28 +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
|
2009-03-06 23:27:19 +00:00
|
|
|
inline void clear() {
|
|
|
|
// can't just memcpy() - trashes vtable
|
|
|
|
type[0] = 0;
|
|
|
|
count = 0;
|
|
|
|
used = 0;
|
|
|
|
req_secs = 0;
|
|
|
|
req_instances = 0;
|
|
|
|
estimated_delay = 0;
|
|
|
|
memset(owner, 0, sizeof(owner));
|
|
|
|
}
|
2008-06-26 19:27:23 +00:00
|
|
|
COPROC(const char* t){
|
2009-03-06 23:27:19 +00:00
|
|
|
clear();
|
2008-05-09 20:54:52 +00:00
|
|
|
strcpy(type, t);
|
2009-03-06 22:21:47 +00:00
|
|
|
}
|
|
|
|
COPROC() {
|
2009-03-06 23:27:19 +00:00
|
|
|
clear();
|
2008-04-01 20:46:41 +00:00
|
|
|
}
|
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*);
|
2008-12-16 18:46:28 +00:00
|
|
|
void summary_string(char*, int);
|
2009-01-12 23:47:52 +00:00
|
|
|
COPROC* lookup(const char*);
|
2008-10-03 21:55:34 +00:00
|
|
|
bool sufficient_coprocs(COPROCS&, bool log_flag, const char* prefix);
|
2009-03-06 22:21:47 +00:00
|
|
|
void reserve_coprocs(COPROCS&, bool log_flag, const char* prefix);
|
|
|
|
void free_coprocs(COPROCS&, bool log_flag, const char* prefix);
|
2008-09-25 01:04:53 +00:00
|
|
|
bool fully_used() {
|
|
|
|
for (unsigned int i=0; i<coprocs.size(); i++) {
|
|
|
|
COPROC* cp = coprocs[i];
|
|
|
|
if (cp->used < cp->count) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2008-07-21 16:25:03 +00:00
|
|
|
|
2009-02-22 04:05:34 +00:00
|
|
|
// Copy a coproc set, possibly setting usage to zero.
|
2008-08-20 17:34:18 +00:00
|
|
|
// used in round-robin simulator and CPU scheduler,
|
|
|
|
// to avoid messing w/ master copy
|
|
|
|
//
|
2008-10-03 21:55:34 +00:00
|
|
|
void clone(COPROCS& c, bool copy_used) {
|
2008-05-23 22:03:27 +00:00
|
|
|
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;
|
2008-10-03 21:55:34 +00:00
|
|
|
if (copy_used) cp2->used = cp->used;
|
2008-05-23 22:03:27 +00:00
|
|
|
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-10-09 19:06:01 +00:00
|
|
|
char name[256];
|
|
|
|
size_t totalGlobalMem;
|
2008-12-22 22:12:57 +00:00
|
|
|
// not used on the server; dtotalGlobalMem is used instead
|
|
|
|
// (since some boards have >= 4GB)
|
2008-10-09 19:06:01 +00:00
|
|
|
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];
|
2009-04-22 02:09:53 +00:00
|
|
|
double dtotalGlobalMem; // not defined in client
|
2008-03-10 20:40:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct COPROC_CUDA : public COPROC {
|
2009-02-16 23:03:03 +00:00
|
|
|
int drvVersion; // display driver version, obtained from NVAPI
|
2008-03-10 20:40:35 +00:00
|
|
|
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(){}
|
2009-04-20 00:00:11 +00:00
|
|
|
static void get(COPROCS&, std::vector<std::string>&);
|
2009-01-14 23:56:07 +00:00
|
|
|
void description(char*);
|
2008-03-10 21:59:27 +00:00
|
|
|
void clear();
|
|
|
|
int parse(FILE*);
|
2008-12-11 21:44:22 +00:00
|
|
|
|
|
|
|
// rough estimate of FLOPS
|
2008-12-31 23:07:59 +00:00
|
|
|
// The following is based on SETI@home CUDA,
|
|
|
|
// which gets 50 GFLOPS on a Quadro FX 3700,
|
|
|
|
// which has 14 MPs and a clock rate of 1.25 MHz
|
|
|
|
//
|
|
|
|
inline double flops_estimate() {
|
|
|
|
double x = (prop.clockRate * prop.multiProcessorCount)*5e10/(14*1.25e6);
|
|
|
|
return x?x:5e10;
|
2008-12-11 21:44:22 +00:00
|
|
|
}
|
2008-03-10 20:40:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct COPROC_CELL_SPE : public COPROC {
|
2009-04-20 00:00:11 +00:00
|
|
|
static void get(COPROCS&, std::vector<std::string>&);
|
2008-05-09 21:07:15 +00:00
|
|
|
COPROC_CELL_SPE() : COPROC("Cell SPE"){}
|
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
|