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

Function main

src/samples/example_srotmg.c:50–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

clblasSetupFunction · 0.85
clblasSrotmgFunction · 0.85
clblasTeardownFunction · 0.85
printResultFunction · 0.70

Tested by

no test coverage detected