| 40 | } |
| 41 | |
| 42 | int |
| 43 | main(void) |
| 44 | { |
| 45 | cl_int err; |
| 46 | cl_platform_id platform = 0; |
| 47 | cl_device_id device = 0; |
| 48 | cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 }; |
| 49 | cl_context ctx = 0; |
| 50 | cl_command_queue queue = 0; |
| 51 | cl_mem bufSA, bufSB, bufC, bufS; |
| 52 | cl_event event = NULL; |
| 53 | int ret = 0; |
| 54 | |
| 55 | /* Setup OpenCL environment. */ |
| 56 | err = clGetPlatformIDs(1, &platform, NULL); |
| 57 | if (err != CL_SUCCESS) { |
| 58 | printf( "clGetPlatformIDs() failed with %d\n", err ); |
| 59 | return 1; |
| 60 | } |
| 61 | |
| 62 | err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL); |
| 63 | if (err != CL_SUCCESS) { |
| 64 | printf( "clGetDeviceIDs() failed with %d\n", err ); |
| 65 | return 1; |
| 66 | } |
| 67 | |
| 68 | props[1] = (cl_context_properties)platform; |
| 69 | ctx = clCreateContext(props, 1, &device, NULL, NULL, &err); |
| 70 | if (err != CL_SUCCESS) { |
| 71 | printf( "clCreateContext() failed with %d\n", err ); |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | queue = clCreateCommandQueue(ctx, device, 0, &err); |
| 76 | if (err != CL_SUCCESS) { |
| 77 | printf( "clCreateCommandQueue() failed with %d\n", err ); |
| 78 | clReleaseContext(ctx); |
| 79 | return 1; |
| 80 | } |
| 81 | |
| 82 | /* Setup clblas. */ |
| 83 | err = clblasSetup(); |
| 84 | if (err != CL_SUCCESS) { |
| 85 | printf("clblasSetup() failed with %d\n", err); |
| 86 | clReleaseCommandQueue(queue); |
| 87 | clReleaseContext(ctx); |
| 88 | return 1; |
| 89 | } |
| 90 | |
| 91 | /* Prepare OpenCL memory objects and place matrices inside them. */ |
| 92 | bufSA = clCreateBuffer(ctx, CL_MEM_READ_WRITE, sizeof(cl_float), NULL, &err); |
| 93 | bufSB = clCreateBuffer(ctx, CL_MEM_READ_WRITE, sizeof(cl_float), NULL, &err); |
| 94 | bufC = clCreateBuffer(ctx, CL_MEM_READ_WRITE, sizeof(cl_float), NULL, &err); |
| 95 | bufS = clCreateBuffer(ctx, CL_MEM_READ_WRITE, sizeof(cl_float), NULL, &err); |
| 96 | |
| 97 | err = clEnqueueWriteBuffer(queue, bufSA, CL_TRUE, 0, sizeof(cl_float), &SA, 0, NULL, NULL); |
| 98 | err = clEnqueueWriteBuffer(queue, bufSB, CL_TRUE, 0, sizeof(cl_float), &SB, 0, NULL, NULL); |
| 99 | err = clEnqueueWriteBuffer(queue, bufC, CL_TRUE, 0, sizeof(cl_float), &C, 0, NULL, NULL); |
nothing calls this directly
no test coverage detected