From 76ee68f96d864a27312c9aa09856ddda559a5cd9 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Thu, 28 Aug 2014 02:11:46 +0000
Subject: [PATCH] Trying some stuff w/ dropout

---
 src/opencl.c |   61 +++++++++++++++++++++++++++---
 1 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/src/opencl.c b/src/opencl.c
index 8f9edd3..bcc0f09 100644
--- a/src/opencl.c
+++ b/src/opencl.c
@@ -11,6 +11,7 @@
 
 void check_error(cl_info info)
 {
+    clFinish(cl.queue);
     if (info.error != CL_SUCCESS) {
         printf("\n Error number %d", info.error);
         exit(1);
@@ -27,13 +28,60 @@
     // Fetch the Platform and Device IDs; we only want one.
     cl_device_id devices[MAX_DEVICES];
     info.error=clGetPlatformIDs(1, &info.platform, &num_platforms);
+
+    printf("=== %d OpenCL platform(s) found: ===\n", num_platforms);
+    char buffer[10240];
+    clGetPlatformInfo(info.platform, CL_PLATFORM_PROFILE, 10240, buffer, NULL);
+    printf("  PROFILE = %s\n", buffer);
+    clGetPlatformInfo(info.platform, CL_PLATFORM_VERSION, 10240, buffer, NULL);
+    printf("  VERSION = %s\n", buffer);
+    clGetPlatformInfo(info.platform, CL_PLATFORM_NAME, 10240, buffer, NULL);
+    printf("  NAME = %s\n", buffer);
+    clGetPlatformInfo(info.platform, CL_PLATFORM_VENDOR, 10240, buffer, NULL);
+    printf("  VENDOR = %s\n", buffer);
+    clGetPlatformInfo(info.platform, CL_PLATFORM_EXTENSIONS, 10240, buffer, NULL);
+    printf("  EXTENSIONS = %s\n", buffer);
+
     check_error(info);
     info.error=clGetDeviceIDs(info.platform, CL_DEVICE_TYPE_ALL, MAX_DEVICES, devices, &num_devices);
     if(num_devices > MAX_DEVICES) num_devices = MAX_DEVICES;
+    printf("=== %d OpenCL device(s) found on platform:\n", num_devices);
+    int i;
+    for (i=0; i<num_devices; i++)
+    {
+        char buffer[10240];
+        cl_uint buf_uint;
+        cl_ulong buf_ulong;
+        printf("  -- %d --\n", i);
+        clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sizeof(buffer), buffer, NULL);
+        printf("  DEVICE_NAME = %s\n", buffer);
+        clGetDeviceInfo(devices[i], CL_DEVICE_VENDOR, sizeof(buffer), buffer, NULL);
+        printf("  DEVICE_VENDOR = %s\n", buffer);
+        clGetDeviceInfo(devices[i], CL_DEVICE_VERSION, sizeof(buffer), buffer, NULL);
+        printf("  DEVICE_VERSION = %s\n", buffer);
+        clGetDeviceInfo(devices[i], CL_DRIVER_VERSION, sizeof(buffer), buffer, NULL);
+        printf("  DRIVER_VERSION = %s\n", buffer);
+        clGetDeviceInfo(devices[i], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(buf_uint), &buf_uint, NULL);
+        printf("  DEVICE_MAX_COMPUTE_UNITS = %u\n", (unsigned int)buf_uint);
+        clGetDeviceInfo(devices[i], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(buf_uint), &buf_uint, NULL);
+        printf("  DEVICE_MAX_CLOCK_FREQUENCY = %u\n", (unsigned int)buf_uint);
+        clGetDeviceInfo(devices[i], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(buf_ulong), &buf_ulong, NULL);
+        printf("  DEVICE_GLOBAL_MEM_SIZE = %llu\n", (unsigned long long)buf_ulong);
+        clGetDeviceInfo(devices[i], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(buf_ulong), &buf_ulong, NULL);
+        printf("  DEVICE_MAX_WORK_GROUP_SIZE = %llu\n", (unsigned long long)buf_ulong);
+        cl_uint items;
+        clGetDeviceInfo( devices[i], CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(cl_uint), 
+                                       &items, NULL);
+        printf("  DEVICE_MAX_WORK_ITEM_DIMENSIONS = %u\n", (unsigned int)items);
+        size_t workitem_size[10];
+        clGetDeviceInfo(devices[i], CL_DEVICE_MAX_WORK_ITEM_SIZES, 10*sizeof(workitem_size), workitem_size, NULL);
+        printf("  DEVICE_MAX_WORK_ITEM_SIZES = %u / %u / %u \n", (unsigned int)workitem_size[0], (unsigned int)workitem_size[1], (unsigned int)workitem_size[2]);
+
+    }
     int index = getpid()%num_devices;
     printf("%d rand, %d devices, %d index\n", getpid(), num_devices, index);
     //info.device = devices[index];
-    info.device = devices[1];
+    info.device = devices[0];
     fprintf(stderr, "Found %d device(s)\n", num_devices);
     check_error(info);
 
@@ -52,8 +100,8 @@
 cl_program cl_fprog(char *filename, char *options, cl_info info)
 {
 	size_t srcsize;
-	char src[8192];
-	memset(src, 0, 8192);
+	char src[64*1024];
+	memset(src, 0, 64*1024);
 	FILE *fil=fopen(filename,"r");
 	srcsize=fread(src, sizeof src, 1, fil);
 	fclose(fil);
@@ -61,12 +109,12 @@
 	// Submit the source code of the example kernel to OpenCL
 	cl_program prog=clCreateProgramWithSource(info.context,1, srcptr, &srcsize, &info.error);
 	check_error(info);
-	char build_c[4096];
+	char build_c[1024*64];
 	// and compile it (after this we could extract the compiled version)
 	info.error=clBuildProgram(prog, 0, 0, options, 0, 0);
 	if ( info.error != CL_SUCCESS ) {
 		fprintf(stderr, "Error Building Program: %d\n", info.error);
-		clGetProgramBuildInfo( prog, info.device, CL_PROGRAM_BUILD_LOG, 4096, build_c, 0);
+		clGetProgramBuildInfo( prog, info.device, CL_PROGRAM_BUILD_LOG, 1024*64, build_c, 0);
 		fprintf(stderr, "Build Log for %s program:\n%s\n", filename, build_c);
 	}
 	check_error(info);
@@ -115,7 +163,8 @@
     cl_buffer_region r;
     r.origin = offset*sizeof(float);
     r.size = size*sizeof(float);
-    cl_mem sub = clCreateSubBuffer(src, CL_MEM_USE_HOST_PTR, CL_BUFFER_CREATE_TYPE_REGION, &r, 0);
+    cl_mem sub = clCreateSubBuffer(src, CL_MEM_READ_WRITE, CL_BUFFER_CREATE_TYPE_REGION, &r, &cl.error);
+    check_error(cl);
     return sub;
 }
 

--
Gitblit v1.10.0