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

Function main

src/samples/example_stbsv.c:66–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasStbsvFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected