void CmdParserGEMM::validateTile (
    const CmdOption<size_t>& tile_group,
    const CmdOption<size_t>& tile_size,
    size_t max_group_value
)
{
    validatePositiveness(tile_group);
    validatePositiveness(tile_size);

    tile_group.validate(
        size.getValue() % tile_group.getValue() == 0,
        "should divide matrix size without a remainder"
    );

    tile_size.validate(
        size.getValue() % tile_size.getValue() == 0,
        "should divide matrix size without a remainder"
    );

    tile_group.validate(
        tile_group.getValue() <= max_group_value,
        "too big value; should be <= " + to_str(max_group_value)
    );

    if(
        size.getValue() %
        (tile_group.getValue() * tile_size.getValue()) != 0
    )
    {
        throw CmdParser::Error(
            "Multiplication of " + tile_group.name() + " and " + tile_size.name() +
            " parameters should divide matrix size without a remainder."
        );
    }
}
Exemple #2
0
 void validatePositiveness (const CmdOption<T>& parameter)
 {
     parameter.validate(
         parameter.getValue() > 0,
         "negative or zero value is provided; should be positive"
     );
 }
Exemple #3
0
CmdLine::CmdLine(string commande)
{
	this->cmd = CMD::GET;
	this->options = new vector<CmdOption*>();

	string str;
	auto it = commande.cbegin();
	//
	while ((it != commande.cend()) && (*it != ' '
			&& *it != '\n'
			&& *it != '\r'
			&& *it != '\0'))
	{
		str = str + *it;
		it++;
	}

	if(str == "GET")
		this->cmd = GET;
	else if (str == "PUT")
		this->cmd = PUT;
	else if (str == "QUIT")
		this->cmd = QUIT;
	else
		this->cmd = ERR;

	str = "";

	//search option
	while (it != commande.cend())
	{
		if(*it != ' ' && *it != '\r' && *it != '\n' && *it != '\0')
		{
			// Search end of the option name
			str = "";
			while (it != commande.cend() && (*it != ' '
											&& *it != '\r'
											&& *it != '\n'
											&& *it != '\0'))
			{
				str = str + *it;
				++it;
			}

			// Insert name of the option
			CmdOption *o = new CmdOption();
			o->setOption(str);

			// Search for value
			if(it != commande.cend())
			{
				// Search argument
				while ((it != commande.cend())&& (*it == ' '))
					++it;

				if(it != commande.cend() && *it != '-')
				{
					str = "";

					while ( it != commande.cend() && (*it != ' '
													&& *it != '\r'
													&& *it != '\n'
													&& *it != '\0'))
					{
						str = str + *it;
						++it;
					}

					// Set the value and add it to the vector
					o->setValue(str);
				}
			}

			this->options->push_back(o);
		}
		else
			it++;
	}
}