| 255 | } |
| 256 | |
| 257 | void |
| 258 | KTest::generateMain(std::stringstream& ss, bool withAccuracy) |
| 259 | { |
| 260 | ArrayVarList list; |
| 261 | std::map<unsigned int, const Variable*> kargMap = masterStep_->kargMap(); |
| 262 | std::string size; |
| 263 | |
| 264 | ss << std::endl; |
| 265 | ss << indent() << "int" << std::endl; |
| 266 | if (useSeveralKernels_) { |
| 267 | ss << indent() << "main(int argc, char *argv[])" << std::endl; |
| 268 | } |
| 269 | else { |
| 270 | ss << indent() << "main(void)" << std::endl; |
| 271 | } |
| 272 | |
| 273 | ss << indent() << "{" << std::endl; |
| 274 | indent_ += 4; |
| 275 | |
| 276 | ss << std::endl |
| 277 | << indent() << "char *source;" << std::endl |
| 278 | << indent() << "cl_ulong start, end;" << std::endl; |
| 279 | |
| 280 | ss << std::endl |
| 281 | << indent() << "srand((unsigned int)time(NULL));" << std::endl; |
| 282 | |
| 283 | mainInit(ss); |
| 284 | |
| 285 | ss << std::endl; |
| 286 | list = masterStep_->arrays(); |
| 287 | for (ArrayVarList::const_iterator it = list.begin(); it != list.end(); ++it) { |
| 288 | ss << indent() << (*it)->name() << " = (" <<(*it)->type() << ")calloc("; |
| 289 | if ((*it)->isMatrix()) { |
| 290 | ss << masterStep_->matrixSize((MatrixVariable*)(*it)); |
| 291 | } |
| 292 | else { |
| 293 | ss << masterStep_->vectorSize((VectorVariable*)(*it)); |
| 294 | } |
| 295 | ss << ", " |
| 296 | << "sizeof(*" << (*it)->name() << "));" << std::endl; |
| 297 | ss << indent() << "assert(" << (*it)->name() << " != NULL);" << std::endl; |
| 298 | if ((*it)->copyOf() != NULL) { |
| 299 | continue; |
| 300 | } |
| 301 | if ((*it)->isMatrix()) { |
| 302 | MatrixVariable *var = (MatrixVariable*)(*it); |
| 303 | |
| 304 | ss << indent() << matrixGenName(matrixGen_) << "(order, " |
| 305 | << var->rows()->name() << ", " |
| 306 | << var->columns()->name() << ", " << var->matrixPointer() << ", " |
| 307 | << var->ld()->name() << ");" << std::endl; |
| 308 | } |
| 309 | else { |
| 310 | VectorVariable *var = (VectorVariable*)(*it); |
| 311 | ss << indent() << vectorGenName(matrixGen_) << "(" |
| 312 | << var->nElems()->name() << ", " |
| 313 | << var->vectorPointer() << ", " << var->inc()->name() |
| 314 | << ");" << std::endl; |
nothing calls this directly
no test coverage detected