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

Function main

src/samples/example_strmv.c:62–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasStrmvFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected