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

Function main

src/samples/example_csscal.c:55–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55int
56main(void)
57{
58 cl_int err;
59 cl_platform_id platform = 0;
60 cl_device_id device = 0;
61 cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 };
62 cl_context ctx = 0;
63 cl_command_queue queue = 0;
64 cl_mem bufX;
65 cl_event event = NULL;
66 int ret = 0;
67 int lenX = 1 + (N-1)*abs(incx);
68
69 /* Setup OpenCL environment. */
70 err = clGetPlatformIDs(1, &platform, NULL);
71 if (err != CL_SUCCESS) {
72 printf( "clGetPlatformIDs() failed with %d\n", err );
73 return 1;
74 }
75
76 err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);
77 if (err != CL_SUCCESS) {
78 printf( "clGetDeviceIDs() failed with %d\n", err );
79 return 1;
80 }
81
82 props[1] = (cl_context_properties)platform;
83 ctx = clCreateContext(props, 1, &device, NULL, NULL, &err);
84 if (err != CL_SUCCESS) {
85 printf( "clCreateContext() failed with %d\n", err );
86 return 1;
87 }
88
89 queue = clCreateCommandQueue(ctx, device, 0, &err);
90 if (err != CL_SUCCESS) {
91 printf( "clCreateCommandQueue() failed with %d\n", err );
92 clReleaseContext(ctx);
93 return 1;
94 }
95
96 /* Setup clblas. */
97 err = clblasSetup();
98 if (err != CL_SUCCESS) {
99 printf("clblasSetup() failed with %d\n", err);
100 clReleaseCommandQueue(queue);
101 clReleaseContext(ctx);
102 return 1;
103 }
104
105
106 /* Prepare OpenCL memory objects and place vectors inside them. */
107 bufX = clCreateBuffer(ctx, CL_MEM_READ_WRITE, ( lenX * sizeof(cl_float2)),
108 NULL, &err);
109
110 err = clEnqueueWriteBuffer(queue, bufX, CL_TRUE, 0,
111 (lenX * sizeof(cl_float2)), X, 0, NULL, NULL);
112

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70
clblasCsscalFunction · 0.50

Tested by

no test coverage detected