瀏覽代碼

Compile with -Wall

Matthias Vogelgesang 8 年之前
父節點
當前提交
34e35dbf5d
共有 2 個文件被更改,包括 10 次插入12 次删除
  1. 1 1
      Makefile
  2. 9 11
      signal.c

+ 1 - 1
Makefile

@@ -4,7 +4,7 @@ BIN=signal
 
 AMDPATH=/home/nico/opencl/AMDAPPSDK-3.0-0-Beta
 
-CFLAGS=-I$(AMDPATH)/include -g -ggdb -DCL_USE_DEPRECATED_OPENCL_2_0_APIS
+CFLAGS=-I$(AMDPATH)/include -g -ggdb -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -Wall
 LDFLAGS=-L$(AMDPATH)/lib/x86_64 -lOpenCL
 
 include c.mk

+ 9 - 11
signal.c

@@ -24,7 +24,7 @@ typedef struct {
     cl_context context;
     cl_program program;
     cl_kernel kernel;
-    cl_mem fpga_buffer;
+    cl_mem fpga_write_buffer;
     cl_mem check_buffer;
 } App;
 
@@ -72,9 +72,8 @@ close_pcilib (App *app)
 }
 
 static cl_mem
-create_fpga_buffer (App *app, size_t size, cl_int *error)
+create_fpga_write_buffer (App *app, size_t size, cl_int *error)
 {
-    cl_mem buffer;
     cl_mem_flags flags;
     cl_bus_address_amd addr;
 
@@ -89,7 +88,6 @@ static bool
 init_opencl (App *app)
 {
     cl_int error;
-    cl_platform_id platform;
 
     app->ocl = ocl_new_with_queues (0, CL_DEVICE_TYPE_GPU, CL_QUEUE_PROFILING_ENABLE);
     app->device = ocl_get_devices (app->ocl)[0];
@@ -105,7 +103,7 @@ init_opencl (App *app)
     app->check_buffer = clCreateBuffer (app->context, CL_MEM_WRITE_ONLY, 8, NULL, &error);
     OCL_CHECK_ERROR (error);
 
-    app->fpga_buffer = create_fpga_buffer (app, 1024 * 64, &error);
+    app->fpga_write_buffer = create_fpga_write_buffer (app, 1024 * 64, &error);
     OCL_CHECK_ERROR (error);
 
     return error != CL_SUCCESS ? false : true;
@@ -116,7 +114,7 @@ close_opencl (App *app)
 {
     OCL_CHECK_ERROR (clReleaseKernel (app->kernel));
     OCL_CHECK_ERROR (clReleaseProgram (app->program));
-    OCL_CHECK_ERROR (clReleaseMemObject (app->fpga_buffer));
+    OCL_CHECK_ERROR (clReleaseMemObject (app->fpga_write_buffer));
     OCL_CHECK_ERROR (clReleaseMemObject (app->check_buffer));
     ocl_free (app->ocl);
 }
@@ -154,7 +152,7 @@ launch_signal (App *app)
     check_value (app, addr, value);
 
     value = 0xdeadf00d;
-    OCL_CHECK_ERROR (clSetKernelArg (app->kernel, 0, sizeof (cl_mem), &app->fpga_buffer));
+    OCL_CHECK_ERROR (clSetKernelArg (app->kernel, 0, sizeof (cl_mem), &app->fpga_write_buffer));
     OCL_CHECK_ERROR (clSetKernelArg (app->kernel, 1, sizeof (cl_mem), &app->check_buffer));
     OCL_CHECK_ERROR (clSetKernelArg (app->kernel, 2, sizeof (uint32_t), &addr));
     OCL_CHECK_ERROR (clSetKernelArg (app->kernel, 3, sizeof (uint32_t), &value));
@@ -182,11 +180,11 @@ launch_signal (App *app)
     if (check[0] == addr && check[1] == value)
         printf ("success\n");
     else
-        printf ("failed [0x%x != 0x%x || 0x%x != 0x%x]\n", check[0], addr, check[1], value);
+        printf ("failed [0x%x != %p || 0x%x != 0x%x]\n", check[0], (void *) addr, check[1], value);
 
-    printf ("> exec  : %llu ns\n", end - start);
-    printf ("> submit: %llu ns\n", end - submitted);
-    printf ("> queue : %llu ns\n", end - queued);
+    printf ("> exec  : %lu ns\n", end - start);
+    printf ("> submit: %lu ns\n", end - submitted);
+    printf ("> queue : %lu ns\n", end - queued);
 }
 
 int