| 232 | |
| 233 | |
| 234 | template <typename ElemType> nano_time_t |
| 235 | AxpyPerformanceTest<ElemType>::clblasPerfSingle(void) |
| 236 | { |
| 237 | nano_time_t time; |
| 238 | cl_event event; |
| 239 | cl_int status; |
| 240 | cl_command_queue queue = base_->commandQueues()[0]; |
| 241 | |
| 242 | status = clEnqueueWriteBuffer(queue, mobjX_, CL_TRUE, 0, |
| 243 | (lengthX + params_.offBX) * sizeof(ElemType), X_, 0, NULL, &event); |
| 244 | status |= clEnqueueWriteBuffer(queue, mobjY_, CL_TRUE, 0, |
| 245 | (lengthY + params_.offCY) * sizeof(ElemType), Y_, 0, NULL, &event); |
| 246 | if (status != CL_SUCCESS) |
| 247 | { |
| 248 | cerr << "mobjX_ or mobjY_ buffer object enqueuing error, status = " << |
| 249 | status << endl; |
| 250 | |
| 251 | return NANOTIME_ERR; |
| 252 | } |
| 253 | |
| 254 | status = clWaitForEvents(1, &event); |
| 255 | if (status != CL_SUCCESS) |
| 256 | { |
| 257 | cout << "Wait on event failed, status = " << |
| 258 | status << endl; |
| 259 | |
| 260 | return NANOTIME_ERR; |
| 261 | } |
| 262 | |
| 263 | event = NULL; |
| 264 | time = getCurrentTime(); |
| 265 | |
| 266 | #define TIMING |
| 267 | #ifdef TIMING |
| 268 | clFinish( queue); |
| 269 | int iter = 50; |
| 270 | for ( int i=1; i <= iter; i++) |
| 271 | { |
| 272 | #endif |
| 273 | |
| 274 | status = (cl_int)clMath::clblas::axpy(params_.N, alpha_, mobjX_, params_.offBX, params_.incx, mobjY_, params_.offCY, params_.incy, |
| 275 | 1, &queue, 0, NULL, &event); |
| 276 | if (status != CL_SUCCESS) { |
| 277 | cerr << "The CLBLAS AXPY function failed, status = " << |
| 278 | status << endl; |
| 279 | |
| 280 | return NANOTIME_ERR; |
| 281 | } |
| 282 | #ifdef TIMING |
| 283 | } // iter loop |
| 284 | clFinish( queue); |
| 285 | time = getCurrentTime() - time; |
| 286 | time /= iter; |
| 287 | #else |
| 288 | |
| 289 | status = flushAll(1, &queue); |
| 290 | if (status != CL_SUCCESS) { |
| 291 | cerr << "clFlush() failed, status = " << status << endl; |
nothing calls this directly
no test coverage detected