- API: change boinc_get_opencl_ids() to use APP_INIT_DATA

instead of cmdline


svn path=/trunk/boinc/; revision=24159
This commit is contained in:
David Anderson 2011-09-11 22:22:55 +00:00
parent 9b7d5702ab
commit 228f626a01
5 changed files with 27 additions and 35 deletions

View File

@ -112,7 +112,7 @@ using std::vector;
#endif
const char* api_version="API_VERSION_"PACKAGE_VERSION;
static APP_INIT_DATA aid;
APP_INIT_DATA aid;
static FILE_LOCK file_lock;
APP_CLIENT_SHM* app_client_shm = 0;
static volatile int time_until_checkpoint;
@ -660,7 +660,7 @@ void boinc_exit(int status) {
fflush(NULL);
#if defined(_WIN32)
// Halt all the threads and cleans up.
// Halt all the threads and clean up.
TerminateProcess(GetCurrentProcess(), status);
// note: the above CAN return!
Sleep(1000);

View File

@ -85,6 +85,7 @@ extern volatile BOINC_STATUS boinc_status;
typedef void (*FUNC_PTR)();
struct APP_INIT_DATA;
extern APP_INIT_DATA aid;
extern int boinc_init(void);
extern int boinc_finish(int status);

View File

@ -47,6 +47,7 @@
#include <string>
#include "error_numbers.h"
#include "boinc_api.h"
#include "coproc.h"
@ -101,35 +102,22 @@ int boinc_get_opencl_ids_aux(
return 0;
}
int boinc_get_opencl_ids(
int argc, char** argv, cl_device_id* device, cl_platform_id* platform
) {
char type[256];
int device_num, retval=0;
int boinc_get_opencl_ids(cl_device_id* device, cl_platform_id* platform) {
int retval=0;
strcpy(type, "");
device_num = -1;
for (int i=1; i<argc; i++) {
if (!strcmp(argv[i], "--gpu_type")) {
strcpy(type, argv[++i]);
}
if (!strcmp(argv[i], "--device")) {
device_num = atoi(argv[++i]);
}
}
if (!strlen(type)) {
if (!strlen(aid.gpu_type)) {
return CL_INVALID_DEVICE_TYPE;
}
if (device_num < 0) {
if (aid.gpu_device_num < 0) {
return CL_INVALID_DEVICE;
}
#ifdef _WIN32
try {
retval = boinc_get_opencl_ids_aux(type, device_num, device, platform);
retval = boinc_get_opencl_ids_aux(
aid.gpu_type, aid.gpu_device_num, device, platform
);
}
catch (...) {
return ERR_SIGNAL_CATCH;
@ -139,7 +127,9 @@ int boinc_get_opencl_ids(
if (setjmp(resume)) {
return ERR_SIGNAL_CATCH;
} else {
retval = boinc_get_opencl_ids_aux(type, device_num, device, platform);
retval = boinc_get_opencl_ids_aux(
aid.gpu_type, aid.gpu_device_num, device, platform
);
}
signal(SIGSEGV, old_sig);

View File

@ -17,17 +17,10 @@
// BOINC API for OpenCL apps
// The BOINC client calls the project application with the arguments:
// --gpu_type TYPE --device N
// where TYPE is ATI or NVIDIA, and N is the GPU number of that type
// For example, for ATI GPU number 0, the arguments will be:
// --gpu_type ATI --device 0
//
// To get the cl_device_id and cl_platform_id for the OpenCL GPU
// asigned to your application call this function:
//
// NOTE: You should compile and link this function as part of your
// application; it is not included in the standard BOINC libraries.
// Get the cl_device_id and cl_platform_id for the OpenCL GPU
// assigned to your job.
//
// NOTE: Compile and link this function with your application;
// it is not included in the standard BOINC libraries.
int boinc_get_opencl_ids(int argc, char** argv, cl_device_id*, cl_platform_id*);
int boinc_get_opencl_ids(cl_device_id*, cl_platform_id*);

View File

@ -5821,3 +5821,11 @@ David 11 Sept 2011
sg_PanelBase.cpp
sg_ProjectPanel.cpp
sg_TaskPanel.cpp
David 11 Sept 2011
- API: change boinc_get_opencl_ids() to use APP_INIT_DATA
instead of cmdline
api/
boinc_api.cpp,h
boinc_opencl.cpp,h