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

Function main

src/samples/example_chbmv.c:74–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasChbmvFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected