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