From 247413b2913069d917909d20fea091ceea8158d5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 1 Apr 2011 19:39:58 +0000 Subject: [PATCH] - server/client: make a stripped-down OpenCL header file, lib/cl_boinc.h, for the things that BOINC actually needs (fixes server compile problems) - client: fix various compile errors in coproc_detect.cpp svn path=/trunk/boinc/; revision=23310 --- checkin_notes | 13 +++ client/coproc_detect.cpp | 24 +++--- doc/projects.inc | 2 +- lib/Makefile.am | 1 + lib/cl_boinc.h | 173 +++++++++++++++++++++++++++++++++++++++ lib/coproc.h | 2 +- 6 files changed, 201 insertions(+), 14 deletions(-) create mode 100644 lib/cl_boinc.h diff --git a/checkin_notes b/checkin_notes index 57a0c16a32..3c6d2c3a9a 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2056,3 +2056,16 @@ Charlie 31 Mar 2011 client/ coproc_detect.cpp + +David 1 Apr 2011 + - server/client: make a stripped-down OpenCL header file, lib/cl_boinc.h, + for the things that BOINC actually needs + (fixes server compile problems) + - client: fix various compile errors in coproc_detect.cpp + + lib/ + coproc.h + cl_boinc.h + Makefile.am + client/ + coproc_detect.cpp diff --git a/client/coproc_detect.cpp b/client/coproc_detect.cpp index 63842e7883..0a4ca84c38 100644 --- a/client/coproc_detect.cpp +++ b/client/coproc_detect.cpp @@ -281,10 +281,10 @@ void COPROCS::get_opencl(bool use_all, vector&warnings) { //TODO: Temporary code for testing if (log_flags.coproc_debug) { msg_printf(0, MSG_INFO, - "[coproc-test] COPROC_NVIDIA [no CUDA]: nvidia_opencls[%d].name = '%s'; nvidia_opencls[%d].device_id = %d", - i, nvidia_opencls[i].name, i, (int)nvidia_opencls[i].device_id); + "[coproc-test] COPROC_NVIDIA [no CUDA]: nvidia_opencls[%d].name = '%s'; nvidia_opencls[%d].device_id = %p", + i, nvidia_opencls[i].name, i, nvidia_opencls[i].device_id); msg_printf(0, MSG_INFO, - "[coproc-test] COPROC_NVIDIA [no CUDA]: nvidia_opencls[%d].global_RAM = %llu; nvidia_opencls[%d].local_RAM = %llu", + "[coproc-test] COPROC_NVIDIA [no CUDA]: nvidia_opencls[%d].global_RAM = %lu; nvidia_opencls[%d].local_RAM = %lu", i, nvidia_opencls[i].global_RAM, i, nvidia_opencls[i].local_RAM); } // if (in_vector(nvidia_opencls[i].device_num, ignore_devs)) continue; @@ -345,10 +345,10 @@ void COPROCS::get_opencl(bool use_all, vector&warnings) { //TODO: Temporary code for testing if (log_flags.coproc_debug) { msg_printf(0, MSG_INFO, - "[coproc-test] COPROC_ATI [no CAL]: ati_opencls[%d].name = '%s'; ati_opencls[%d].device_id = %d", - i, ati_opencls[i].name, i, (int)ati_opencls[i].device_id); + "[coproc-test] COPROC_ATI [no CAL]: ati_opencls[%d].name = '%s'; ati_opencls[%d].device_id = %p", + i, ati_opencls[i].name, i, ati_opencls[i].device_id); msg_printf(0, MSG_INFO, - "[coproc-test] COPROC_ATI [no CAL]: ati_opencls[%d].global_RAM = %llu; ati_opencls[%d].local_RAM = %llu", + "[coproc-test] COPROC_ATI [no CAL]: ati_opencls[%d].global_RAM = %lu; ati_opencls[%d].local_RAM = %lu", i, ati_opencls[i].global_RAM, i, ati_opencls[i].local_RAM); } // if (in_vector(ati_opencls[i].device_num, ignore_devs)) continue; @@ -1044,10 +1044,10 @@ bool COPROC_NVIDIA::matches(OPENCL_DEVICE_PROP& OpenCLprop) { "[coproc-test] COPROC_NVIDIA [in matches()]: prop.name = '%s'; OpenCLprop.name = '%s'", prop.name, OpenCLprop.name); msg_printf(0, MSG_INFO, - "[coproc-test] COPROC_NVIDIA [in matches()]: device_num = %d, prop.deviceHandle = %d; OpenCLprop.device_id = %d", - device_num, prop.deviceHandle, (int)OpenCLprop.device_id); + "[coproc-test] COPROC_NVIDIA [in matches()]: device_num = %d, prop.deviceHandle = %d; OpenCLprop.device_id = %p", + device_num, prop.deviceHandle, OpenCLprop.device_id); msg_printf(0, MSG_INFO, - "[coproc-test] COPROC_NVIDIA [in matches()]: prop.totalGlobalMem = %u; OpenCLprop.global_RAM = %llu; OpenCLprop.local_RAM = %llu", + "[coproc-test] COPROC_NVIDIA [in matches()]: prop.totalGlobalMem = %u; OpenCLprop.global_RAM = %lu; OpenCLprop.local_RAM = %lu", prop.totalGlobalMem, OpenCLprop.global_RAM, OpenCLprop.local_RAM); } @@ -1510,10 +1510,10 @@ bool COPROC_ATI::matches(OPENCL_DEVICE_PROP& OpenCLprop) { "[coproc-test] COPROC_ATI [in matches()]: prop.name = '%s'; OpenCLprop.name = '%s'", name, OpenCLprop.name); msg_printf(0, MSG_INFO, - "[coproc-test] COPROC_ATI [in matches()]: device_num = %d; OpenCLprop.device_id = %d", - device_num, (int)OpenCLprop.device_id); + "[coproc-test] COPROC_ATI [in matches()]: device_num = %d; OpenCLprop.device_id = %p", + device_num, OpenCLprop.device_id); msg_printf(0, MSG_INFO, - "[coproc-test] COPROC_ATI [in matches()]: attribs.localRAM = %u; OpenCLprop.global_RAM = %llu; OpenCLprop.local_RAM = %llu", + "[coproc-test] COPROC_ATI [in matches()]: attribs.localRAM = %u; OpenCLprop.global_RAM = %lu; OpenCLprop.local_RAM = %lu", attribs.localRAM, OpenCLprop.global_RAM, OpenCLprop.local_RAM); } diff --git a/doc/projects.inc b/doc/projects.inc index 1afc97591c..7a69be0a6b 100644 --- a/doc/projects.inc +++ b/doc/projects.inc @@ -41,7 +41,7 @@ $biomed = array( "docking.png" ), array( - "GPUGrid.net ", + "GPUGrid.net", "http://www.gpugrid.net/", "Barcelona Biomedical Research Park (PRBB)", "Molecular simulations of proteins", diff --git a/lib/Makefile.am b/lib/Makefile.am index 07ca71e2a8..b894a1475a 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -97,6 +97,7 @@ pkginclude_HEADERS = \ boinc_win.h \ cal_boinc.h \ cert_sig.h \ + cl_boinc.h \ common_defs.h \ coproc.h \ crypt.h \ diff --git a/lib/cl_boinc.h b/lib/cl_boinc.h new file mode 100644 index 0000000000..c7e3946c06 --- /dev/null +++ b/lib/cl_boinc.h @@ -0,0 +1,173 @@ +// a stripped-down subset of cl.h and cl_platform.h, for BOINC + +#if (defined (_WIN32) && defined(_MSC_VER)) + +/* scalar types */ +typedef signed __int8 cl_char; +typedef unsigned __int8 cl_uchar; +typedef signed __int16 cl_short; +typedef unsigned __int16 cl_ushort; +typedef signed __int32 cl_int; +typedef unsigned __int32 cl_uint; +typedef signed __int64 cl_long; +typedef unsigned __int64 cl_ulong; +typedef unsigned __int16 cl_half; +#else /* !_WIN32 */ +#include +typedef int8_t cl_char; +typedef uint8_t cl_uchar; +typedef int16_t cl_short; +typedef uint16_t cl_ushort; +typedef int32_t cl_int; +typedef uint32_t cl_uint; +typedef int64_t cl_long; +typedef uint64_t cl_ulong; +typedef uint16_t cl_half; +#endif /* !_WIN32 */ +typedef float cl_float; +typedef double cl_double; + +typedef struct _cl_platform_id * cl_platform_id; +typedef struct _cl_device_id * cl_device_id; +typedef struct _cl_context * cl_context; +typedef struct _cl_command_queue * cl_command_queue; +typedef struct _cl_mem * cl_mem; +typedef struct _cl_program * cl_program; +typedef struct _cl_kernel * cl_kernel; +typedef struct _cl_event * cl_event; +typedef struct _cl_sampler * cl_sampler; + +typedef cl_uint cl_bool; +typedef cl_ulong cl_bitfield; +typedef cl_bitfield cl_device_type; +typedef cl_uint cl_platform_info; +typedef cl_uint cl_device_info; +typedef cl_bitfield cl_device_fp_config; +typedef cl_uint cl_device_mem_cache_type; +typedef cl_uint cl_device_local_mem_type; +typedef cl_bitfield cl_device_exec_capabilities; +typedef cl_bitfield cl_command_queue_properties; + +/* Error Codes */ +#define CL_SUCCESS 0 +#define CL_DEVICE_NOT_FOUND -1 +#define CL_DEVICE_NOT_AVAILABLE -2 +#define CL_COMPILER_NOT_AVAILABLE -3 +#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4 +#define CL_OUT_OF_RESOURCES -5 +#define CL_OUT_OF_HOST_MEMORY -6 +#define CL_PROFILING_INFO_NOT_AVAILABLE -7 +#define CL_MEM_COPY_OVERLAP -8 +#define CL_IMAGE_FORMAT_MISMATCH -9 +#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10 +#define CL_BUILD_PROGRAM_FAILURE -11 +#define CL_MAP_FAILURE -12 +#define CL_MISALIGNED_SUB_BUFFER_OFFSET -13 +#define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14 + +#define CL_INVALID_VALUE -30 +#define CL_INVALID_DEVICE_TYPE -31 +#define CL_INVALID_PLATFORM -32 +#define CL_INVALID_DEVICE -33 +#define CL_INVALID_CONTEXT -34 +#define CL_INVALID_QUEUE_PROPERTIES -35 +#define CL_INVALID_COMMAND_QUEUE -36 +#define CL_INVALID_HOST_PTR -37 +#define CL_INVALID_MEM_OBJECT -38 +#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39 +#define CL_INVALID_IMAGE_SIZE -40 +#define CL_INVALID_SAMPLER -41 +#define CL_INVALID_BINARY -42 +#define CL_INVALID_BUILD_OPTIONS -43 +#define CL_INVALID_PROGRAM -44 +#define CL_INVALID_PROGRAM_EXECUTABLE -45 +#define CL_INVALID_KERNEL_NAME -46 +#define CL_INVALID_KERNEL_DEFINITION -47 +#define CL_INVALID_KERNEL -48 +#define CL_INVALID_ARG_INDEX -49 +#define CL_INVALID_ARG_VALUE -50 +#define CL_INVALID_ARG_SIZE -51 +#define CL_INVALID_KERNEL_ARGS -52 +#define CL_INVALID_WORK_DIMENSION -53 +#define CL_INVALID_WORK_GROUP_SIZE -54 +#define CL_INVALID_WORK_ITEM_SIZE -55 +#define CL_INVALID_GLOBAL_OFFSET -56 +#define CL_INVALID_EVENT_WAIT_LIST -57 +#define CL_INVALID_EVENT -58 +#define CL_INVALID_OPERATION -59 +#define CL_INVALID_GL_OBJECT -60 +#define CL_INVALID_BUFFER_SIZE -61 +#define CL_INVALID_MIP_LEVEL -62 +#define CL_INVALID_GLOBAL_WORK_SIZE -63 +#define CL_INVALID_PROPERTY -64 + +/* cl_device_type - bitfield */ +#define CL_DEVICE_TYPE_DEFAULT (1 << 0) +#define CL_DEVICE_TYPE_CPU (1 << 1) +#define CL_DEVICE_TYPE_GPU (1 << 2) +#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3) +#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF + +/* cl_device_info */ +#define CL_DEVICE_TYPE 0x1000 +#define CL_DEVICE_VENDOR_ID 0x1001 +#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002 +#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003 +#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004 +#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B +#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C +#define CL_DEVICE_ADDRESS_BITS 0x100D +#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E +#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F +#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010 +#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011 +#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012 +#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013 +#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014 +#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015 +#define CL_DEVICE_IMAGE_SUPPORT 0x1016 +#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017 +#define CL_DEVICE_MAX_SAMPLERS 0x1018 +#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019 +#define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A +#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B +#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C +#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D +#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E +#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F +#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020 +#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021 +#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022 +#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023 +#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024 +#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025 +#define CL_DEVICE_ENDIAN_LITTLE 0x1026 +#define CL_DEVICE_AVAILABLE 0x1027 +#define CL_DEVICE_COMPILER_AVAILABLE 0x1028 +#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029 +#define CL_DEVICE_QUEUE_PROPERTIES 0x102A +#define CL_DEVICE_NAME 0x102B +#define CL_DEVICE_VENDOR 0x102C +#define CL_DRIVER_VERSION 0x102D +#define CL_DEVICE_PROFILE 0x102E +#define CL_DEVICE_VERSION 0x102F +#define CL_DEVICE_EXTENSIONS 0x1030 +#define CL_DEVICE_PLATFORM 0x1031 +#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032 +#define CL_DEVICE_HALF_FP_CONFIG 0x1033 +#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034 +#define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039 +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B +#define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C +#define CL_DEVICE_OPENCL_C_VERSION 0x103D diff --git a/lib/coproc.h b/lib/coproc.h index 5665059def..228ab0478c 100644 --- a/lib/coproc.h +++ b/lib/coproc.h @@ -73,7 +73,7 @@ #include "miofile.h" #include "parse.h" #include "cal_boinc.h" -#include "cl.h" +#include "cl_boinc.h" #define MAX_COPROC_INSTANCES 64 #define MAX_RSC 8