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

Function main

src/samples/example_dtrmv.c:78–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasDtrmvFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected