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

Method clblasPerfSingle

src/tests/performance/perf-gemm.cpp:275–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273
274
275template <typename ElemType> nano_time_t
276GemmPerformanceTest<ElemType>::clblasPerfSingle(void)
277{
278 nano_time_t time;
279 cl_event event;
280 cl_int status;
281 cl_command_queue queue = base_->commandQueues()[0];
282
283 status = clEnqueueWriteBuffer(queue, mobjC_, CL_TRUE, 0,
284 params_.rowsC * params_.columnsC *
285 sizeof(ElemType), backC_, 0, NULL, &event);
286 if (status != CL_SUCCESS) {
287 cerr << "Matrix C buffer object enqueuing error, status = " <<
288 status << endl;
289
290 return NANOTIME_ERR;
291 }
292
293 status = clWaitForEvents(1, &event);
294 if (status != CL_SUCCESS) {
295 cout << "Wait on event failed, status = " <<
296 status << endl;
297
298 return NANOTIME_ERR;
299 }
300
301 event = NULL;
302 status = (cl_int)clMath::clblas::gemm(params_.order,
303 params_.transA, params_.transB, params_.M, params_.N, params_.K, alpha_,
304 mobjA_, params_.offA, params_.lda, mobjB_, params_.offBX, params_.ldb,
305 beta_, mobjC_, params_.offCY, params_.ldc, 1, &queue, 0, NULL, &event);
306 if (status != CL_SUCCESS) {
307 cerr << "The CLBLAS GEMM function failed, status = " <<
308 status << endl;
309
310 return NANOTIME_ERR;
311 }
312 status = flushAll(1, &queue);
313 if (status != CL_SUCCESS) {
314 cerr << "clFlush() failed, status = " << status << endl;
315 return NANOTIME_ERR;
316 }
317
318 time = getCurrentTime();
319 status = waitForSuccessfulFinish(1, &queue, &event);
320 if (status == CL_SUCCESS) {
321 time = getCurrentTime() - time;
322 }
323 else {
324 cerr << "Waiting for completion of commands to the queue failed, "
325 "status = " << status << endl;
326 time = NANOTIME_ERR;
327 }
328
329 return time;
330}
331
332} // namespace clMath

Callers

nothing calls this directly

Calls 5

commandQueuesMethod · 0.80
gemmFunction · 0.50
flushAllFunction · 0.50
getCurrentTimeFunction · 0.50
waitForSuccessfulFinishFunction · 0.50

Tested by

no test coverage detected