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

Method handleReduceMax

src/library/blas/gens/kprintf.cpp:1283–1412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1281}
1282
1283void kprintf::handleReduceMax(char **_src, char **_dst)
1284{
1285 int numCharsWritten = 0;
1286 // val, maxVal, index, impl
1287 char id1[256], id2[256], id3[256], id4[256];
1288 char tempStr[512];
1289 char * ptr;
1290 char *src = *_src;
1291 char *dst = *_dst;
1292 bool reduceMaxWithIndex = false, followLowIndex = true;
1293
1294 ptr = mystrtok( src, "(,)");
1295 ptr = mystrtok( NULL, "(,)"); // Get first ID
1296 strcpy( id1, ptr);
1297 // After the first parameter is parsed, extract everything till you encounter ';'
1298 // Store this substring in a temp string. Then check if any extra parameter(overloaded) was passed using this substring
1299 ptr = mystrtok( NULL, ";");
1300 *_src = ptr + strlen(ptr) + 1; // 'src' string parsing is over at this point
1301
1302 tempStr[0] = '(';
1303 tempStr[1] = 0;
1304 strcat(tempStr, ptr);
1305 ptr = mystrtok( tempStr, "(,)");
1306 ptr = mystrtok( NULL, "(,)"); // extract 2nd parameter from tempStr. Will be empty if 2nd parameter was not passed
1307 strcpy( id2, ptr);
1308 ptr = mystrtok( NULL, "(,)");
1309 strcpy( id3, ptr);
1310 ptr = mystrtok( NULL, "(,)");
1311 strcpy( id4, ptr);
1312
1313 if(strcmp(id3, "") != 0)
1314 {
1315 reduceMaxWithIndex = true;
1316 }
1317
1318 if(!strcmp(id4, "0"))
1319 {
1320 followLowIndex = false;
1321 }
1322
1323 #ifdef DEBUG_AMAX
1324 std::cerr << "Handling AMAX CASE: reduceMaxWithIndex:" << reduceMaxWithIndex
1325 << " and followLowIndex: " << followLowIndex
1326 << " id1:" << id1 << " id2:" << id2 << " id3:" << id3 << " id4:" << id4 << std::endl;
1327 #endif
1328
1329 if(vectorWidth > 1)
1330 {
1331 if ((s_or_v == SCALAR) && (!reduceMaxWithIndex))
1332 {
1333 for( int i = 0 ; i < (vectorWidth - 1); i++)
1334 {
1335 numCharsWritten = sprintf(dst,"fmax( %s.%s, ", id1, vecIndices[i]);
1336 dst += numCharsWritten;
1337 }
1338 numCharsWritten = sprintf(dst," %s.%s ", id1, vecIndices[ (vectorWidth - 1)]);
1339 dst += numCharsWritten;
1340 for( int i = 0 ; i < (vectorWidth - 1); i++)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected