| 206 | |
| 207 | |
| 208 | template <typename ElemType> nano_time_t |
| 209 | AsumPerformanceTest<ElemType>::clblasPerfSingle(void) |
| 210 | { |
| 211 | nano_time_t time; |
| 212 | cl_event event; |
| 213 | cl_int status; |
| 214 | cl_command_queue queue = base_->commandQueues()[0]; |
| 215 | |
| 216 | DataType type; |
| 217 | type = ( typeid(ElemType) == typeid(float))? TYPE_FLOAT:( typeid(ElemType) == typeid(double))? TYPE_DOUBLE: |
| 218 | ( typeid(ElemType) == typeid(FloatComplex))? TYPE_COMPLEX_FLOAT: TYPE_COMPLEX_DOUBLE; |
| 219 | |
| 220 | event = NULL; |
| 221 | clFinish( queue); |
| 222 | time = getCurrentTime(); |
| 223 | |
| 224 | #define TIMING |
| 225 | #ifdef TIMING |
| 226 | int iter = 100; |
| 227 | for ( int i=1; i <= iter; i++) |
| 228 | { |
| 229 | #endif |
| 230 | |
| 231 | status = (cl_int)clMath::clblas::asum( type, params_.N, mobjAsum_, params_.offa, mobjX_, params_.offBX, params_.incx, |
| 232 | scratchBuff, 1, &queue, 0, NULL, &event); |
| 233 | if (status != CL_SUCCESS) { |
| 234 | cerr << "The CLBLAS ASUM function failed, status = " << |
| 235 | status << endl; |
| 236 | |
| 237 | return NANOTIME_ERR; |
| 238 | } |
| 239 | #ifdef TIMING |
| 240 | } // iter loop |
| 241 | clFinish( queue); |
| 242 | time = getCurrentTime() - time; |
| 243 | time /= iter; |
| 244 | #else |
| 245 | |
| 246 | status = flushAll(1, &queue); |
| 247 | if (status != CL_SUCCESS) { |
| 248 | cerr << "clFlush() failed, status = " << status << endl; |
| 249 | return NANOTIME_ERR; |
| 250 | } |
| 251 | |
| 252 | time = getCurrentTime(); |
| 253 | status = waitForSuccessfulFinish(1, &queue, &event); |
| 254 | if (status == CL_SUCCESS) { |
| 255 | time = getCurrentTime() - time; |
| 256 | } |
| 257 | else { |
| 258 | cerr << "Waiting for completion of commands to the queue failed, " |
| 259 | "status = " << status << endl; |
| 260 | time = NANOTIME_ERR; |
| 261 | } |
| 262 | #endif |
| 263 | return time; |
| 264 | } |
| 265 |
nothing calls this directly
no test coverage detected