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

Function main

src/samples/example_ssymv.c:85–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasSsymvFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected