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

Method SetUp

src/tests/BlasBase.cpp:159–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159void
160BlasBase::SetUp()
161{
162 cl_int err = CL_SUCCESS;
163 cl_context_properties props[] = { CL_CONTEXT_PLATFORM, 0, 0 };
164 cl_uint i = 1;
165 cl_uint addDevQueueIdx = MAX_COMMAND_QUEUES;
166 cl_device_id devices[2] = {NULL, NULL};
167
168 primaryDevice_ = getDevice(devType_, devName_, &err);
169
170 if ((err != CL_SUCCESS) || (primaryDevice_ == NULL)) {
171 ASSERT_EQ(CL_SUCCESS, clGetPlatformIDs(1, &platform_, NULL));
172 ASSERT_EQ(CL_SUCCESS,
173 clGetDeviceIDs(platform_, devType_, 1, &primaryDevice_, NULL));
174 }
175
176 devices[0] = primaryDevice_;
177
178#if !defined(TEST_WITH_SINGLE_DEVICE)
179 cl_device_type addDevType;
180
181 if (MAX_COMMAND_QUEUES > 1) {
182 addDevType = (devType_ == CL_DEVICE_TYPE_GPU) ? CL_DEVICE_TYPE_CPU :
183 CL_DEVICE_TYPE_GPU;
184 additionalDevice_ = getDevice(addDevType, NULL, NULL);
185 if (additionalDevice_ != NULL) {
186 addDevQueueIdx = (MAX_COMMAND_QUEUES <= 3) ?
187 (MAX_COMMAND_QUEUES - 1) : 2;
188 devices[1] = additionalDevice_;
189 i = 2;
190 }
191 }
192#endif /* !TEST_WITH_SINGLE_DEVICE */
193
194 props[1] = (cl_context_properties)platform_;
195
196 context_ = clCreateContext(props, i, devices, NULL, NULL, &err);
197 ASSERT_EQ(CL_SUCCESS, err) << "clCreateContext() failed";
198 #ifdef DEBUG_CONTEXT
199 printf("SetUp: Created context %p\n", context_);
200 #endif
201 printf("SetUp: about to create command queues\n");
202 for (i = 0; i < numCommandQueues_; i++) {
203 cl_device_id dev;
204
205 dev = (i == addDevQueueIdx) ? additionalDevice_ : primaryDevice_;
206 commandQueues_[i] = clCreateCommandQueue(context_, dev,
207 0 /*CL_QUEUE_PROFILING_ENABLE*/, &err);
208 ASSERT_EQ(CL_SUCCESS, err) << "clCreateCommandQueue() failed";
209 }
210
211 ASSERT_EQ(CL_SUCCESS, clblasSetup());
212}
213
214void
215BlasBase::TearDown()

Callers

nothing calls this directly

Calls 2

clblasSetupFunction · 0.85
getDeviceFunction · 0.50

Tested by

no test coverage detected