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

Method generateMain

src/library/tools/ktest/ktest.cpp:257–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257void
258KTest::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;

Callers

nothing calls this directly

Calls 12

indentFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
matrixSizeMethod · 0.80
vectorSizeMethod · 0.80
copyOfMethod · 0.80
rowsMethod · 0.80
columnsMethod · 0.80
ldMethod · 0.80
nElemsMethod · 0.80
incMethod · 0.80
isMatrixMethod · 0.45

Tested by

no test coverage detected