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

Method handleReductionFramework

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

Source from the content-addressed store, hash-verified

1731}
1732
1733void kprintf::handleReductionFramework(char **_src, char **_dst, REDUCTION_TYPE reductionType)
1734{
1735 /*
1736 * Syntax: %REDUCTION_BY_SUM( privateVariableName ); or
1737 * %REDUCTION_BY_MAX( privateVariableName ); or
1738 * %REDUCTION_BY_MAX( privateVariableName, privateVariableName2, privateVarName3); or
1739 * %REDUCTION_BY_MIN( privateVariableName ); or
1740 * %REDUCTION_BY_HYPOT( privateVariableName ); or
1741 * %REDUCTION_BY_SSQ( scale, ssq );
1742 * Reduces all elements in a workgroup by taking value from 'privateVariableName' of each work-item
1743 * and places the reduced item in 'privateVariableName' of the first work-item (work-item 0)
1744 *
1745 */
1746
1747 int numCharsWritten = 0;
1748 // Value, Index, Implementation
1749 char privateVarName[256], privateVarName2[256], privateVarName3[256];
1750 char tempStr[512];
1751
1752 char * ptr;
1753 char *src = *_src;
1754 char *dst = *_dst;
1755 bool reductionWithIndex = false;
1756 RedWithIndexImpl impl;
1757
1758 ptr = mystrtok( src, "(,)");
1759 ptr = mystrtok( NULL, "(,)"); // Get first ID
1760 strcpy( privateVarName, ptr);
1761 // After the first parameter is parsed, extract everything till you encounter ';'
1762 // Store this substring in a temp string. Then check if any extra parameter(overloaded) was passed using this substring
1763 ptr = mystrtok( NULL, ";");
1764 *_src = ptr + strlen(ptr) + 1; // 'src' string parsing is over at this point
1765
1766 tempStr[0] = '(';
1767 tempStr[1] = 0;
1768 strcat(tempStr, ptr);
1769 ptr = mystrtok( tempStr, "(,)");
1770 ptr = mystrtok( NULL, "(,)"); // extract 2nd parameter from tempStr. Will be empty if 2nd parameter was not passed
1771 strcpy( privateVarName2, ptr);
1772 ptr = mystrtok( NULL, "(,)");
1773 strcpy( privateVarName3, ptr);
1774
1775
1776 // This indicates that there was a second parameter in the call
1777 // Overloaded call of REDUCTION_BY_MAX for MAX_WITH_INDEX
1778 //
1779 if(strcmp(privateVarName3, "") != 0)
1780 {
1781 reductionWithIndex = true;
1782
1783 if(!strcmp(privateVarName3, "0"))
1784 {
1785 impl = ATOMIC_FLI;
1786 }
1787 else if(!strcmp(privateVarName3, "1"))
1788 {
1789 impl = REG_FLI;
1790 }

Callers

nothing calls this directly

Calls 1

getFunction · 0.85

Tested by

no test coverage detected