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

Function main

src/samples/example_strmm.c:79–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasStrmmFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected