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

Function deviceL2CacheSize

src/library/common/devinfo-cache.c:122–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120 "} \n";
121
122cl_ulong
123deviceL2CacheSize(
124 cl_device_id device,
125 cl_int *error)
126{
127 const size_t MAX_CACHE_SIZE = 1024 * 1024;
128 const size_t MIN_CACHE_SIZE = 1 * 1024;
129 const size_t STEP = 4 * 1024;
130
131 /* Bigger number of rounds increases time measurement precision,
132 * but slows the test down.
133 */
134 const unsigned int ROUNDS = 32;
135
136 /* Repeat each kernel run sereval times for higher reliability. */
137 const unsigned int RELIABILITY_ROUNDS = 5;
138
139 cl_int err;
140
141 cl_uint maxComputeUnits;
142 cl_bool imageSupport;
143
144 cl_platform_id platform;
145 cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 };
146 cl_context ctx;
147 cl_command_queue queue;
148 cl_program program;
149 cl_kernel kernel;
150 cl_event event;
151
152 cl_float *in;
153 size_t width, height;
154 const cl_image_format format = { CL_RGBA, CL_FLOAT };
155 cl_mem imgIn;
156 size_t origin[3], region[3];
157
158 cl_float4 out;
159 cl_mem bufOut;
160
161 size_t global_work_size, local_work_size;
162 cl_ulong start, end, avg;
163 cl_long *times;
164 cl_double d, max;
165
166 size_t steps;
167 size_t i, t;
168
169 /* Collect device properties. */
170 err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS,
171 sizeof(cl_uint), &maxComputeUnits, NULL);
172 if (err != CL_SUCCESS) {
173 if (error != NULL) {
174 *error = err;
175 }
176 return 0;
177 }
178 err = clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT,
179 sizeof(cl_bool), &imageSupport, NULL);

Callers

nothing calls this directly

Calls 1

closestPowerOf2Function · 0.85

Tested by

no test coverage detected