| 71 | } |
| 72 | |
| 73 | int |
| 74 | main(void) |
| 75 | { |
| 76 | cl_int err; |
| 77 | cl_platform_id platform = 0; |
| 78 | cl_device_id device = 0; |
| 79 | cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 }; |
| 80 | cl_context ctx = 0; |
| 81 | cl_command_queue queue = 0; |
| 82 | cl_mem bufAP, bufX, bufY; |
| 83 | cl_event event = NULL; |
| 84 | int ret = 0, numElementsAP; |
| 85 | |
| 86 | /* Setup OpenCL environment. */ |
| 87 | err = clGetPlatformIDs(1, &platform, NULL); |
| 88 | if (err != CL_SUCCESS) { |
| 89 | printf( "clGetPlatformIDs() failed with %d\n", err ); |
| 90 | return 1; |
| 91 | } |
| 92 | |
| 93 | err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL); |
| 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 | numElementsAP = (N * (N+1)) / 2; // To get number of elements in a packed matrix |
| 123 | |
| 124 | /* Prepare OpenCL memory objects and place matrices inside them. */ |
| 125 | bufAP = clCreateBuffer(ctx, CL_MEM_READ_ONLY, numElementsAP * sizeof(cl_float), |
| 126 | NULL, &err); |
| 127 | bufX = clCreateBuffer(ctx, CL_MEM_READ_ONLY, N * sizeof(cl_float), |
| 128 | NULL, &err); |
| 129 | bufY = clCreateBuffer(ctx, CL_MEM_READ_WRITE, N * sizeof(cl_float), |
| 130 | NULL, &err); |
nothing calls this directly
no test coverage detected