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

Function main

src/samples/example_cherk.cpp:84–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasCherkFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected