MCPcopy Create free account
hub / github.com/clMathLibraries/clBLAS / main

Function main

src/samples/example_cher.c:67–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasCherFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected