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

Function main

src/samples/example_sgbmv.c:80–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasSgbmvFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected