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

Function main

src/samples/example_ssyr2.c:77–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasSsyr2Function · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected