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