| 66 | } |
| 67 | |
| 68 | int |
| 69 | main(void) |
| 70 | { |
| 71 | cl_int err; |
| 72 | cl_platform_id platform = 0; |
| 73 | cl_device_id device = 0; |
| 74 | cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 }; |
| 75 | cl_context ctx = 0; |
| 76 | cl_command_queue queue = 0; |
| 77 | cl_mem bufX, bufY; |
| 78 | cl_event event = NULL; |
| 79 | int ret = 0; |
| 80 | int lenX = 1 + (N-1)*abs(incx); |
| 81 | int lenY = 1 + (N-1)*abs(incy); |
| 82 | |
| 83 | /* Setup OpenCL environment. */ |
| 84 | err = clGetPlatformIDs(1, &platform, NULL); |
| 85 | |
| 86 | err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, &device, NULL); |
| 87 | if (err != CL_SUCCESS) { |
| 88 | printf( "clGetPlatformIDs() failed with %d\n", err ); |
| 89 | return 1; |
| 90 | } |
| 91 | |
| 92 | err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL); |
| 93 | |
| 94 | if (err != CL_SUCCESS) { |
| 95 | printf( "clGetDeviceIDs() failed with %d\n", err ); |
| 96 | return 1; |
| 97 | } |
| 98 | |
| 99 | props[1] = (cl_context_properties)platform; |
| 100 | ctx = clCreateContext(props, 1, &device, NULL, NULL, &err); |
| 101 | if (err != CL_SUCCESS) { |
| 102 | printf( "clCreateContext() failed with %d\n", err ); |
| 103 | return 1; |
| 104 | } |
| 105 | |
| 106 | queue = clCreateCommandQueue(ctx, device, 0, &err); |
| 107 | if (err != CL_SUCCESS) { |
| 108 | printf( "clCreateCommandQueue() failed with %d\n", err ); |
| 109 | clReleaseContext(ctx); |
| 110 | return 1; |
| 111 | } |
| 112 | |
| 113 | /* Setup clblas. */ |
| 114 | err = clblasSetup(); |
| 115 | if (err != CL_SUCCESS) { |
| 116 | printf("clblasSetup() failed with %d\n", err); |
| 117 | clReleaseCommandQueue(queue); |
| 118 | clReleaseContext(ctx); |
| 119 | return 1; |
| 120 | } |
| 121 | |
| 122 | /* Prepare OpenCL memory objects and place matrices inside them. */ |
| 123 | bufX = clCreateBuffer(ctx, CL_MEM_READ_WRITE, (lenX*sizeof(cl_float)), NULL, &err); |
| 124 | bufY = clCreateBuffer(ctx, CL_MEM_READ_WRITE, (lenY*sizeof(cl_float)), NULL, &err); |
| 125 |
nothing calls this directly
no test coverage detected