Exemplo n.º 1
0
 /**
 ***************************************************************************
 * @fn parseCommandLine
 * @brief parses the command line options given by user
 * @param argc Number of elements in cmd line input
 * @param argv Array of char* storing the CmdLine Options
 * @return SDK_SUCCESS on success, SDK_FAILURE otherwise
 **************************************************************************/
 int parseCommandLine(int argc, char **argv)
 {
     if(!parse(argv,argc))
     {
         usage();
         if(isArgSet("h",true) == true)
         {
             exit(SDK_SUCCESS);
         }
         return SDK_FAILURE;
     }
     if(isArgSet("h", true) == true)
     {
         usage();
         exit(SDK_SUCCESS);
     }
     if(isArgSet("v", true) || isArgSet("version", false))
     {
         std::cout << "APP SDK version : " << std::endl
                   << sampleVerStr.c_str() << std::endl;
         std::cout << "Bolt version : " << std::endl
                   << getBoltVerStr().c_str() << std::endl;
         exit(SDK_SUCCESS);
     }
     if(samples <= 0)
     {
         std::cout << "Number input samples should be more than Zero"
                   << std::endl << "Exiting..." << std::endl;
         return SDK_FAILURE;
     }
     if(iterations <= 0)
     {
         std::cout << "Number iterations should be more than Zero"
                   << std::endl << "Exiting..." << std::endl;
         return SDK_FAILURE;
     }
     if( !(runMode.empty()) )                    // If device was specified
     {
         if( (strComparei(runMode, "gpu") == false) &&
                 (strComparei(runMode, "serialcpu") == false) &&
                 (strComparei(runMode, "auto") == false) &&
                 (strComparei(runMode, "multicorecpu") == false) )
         {
             std::cout << "Specified device is incorrect"
                       << std::endl << "Exiting..." << std::endl;
             return SDK_FAILURE;
         }
     }
     return SDK_SUCCESS;
 }
Exemplo n.º 2
0
/******************************************************************************
* Implementation of BoltSample::parseCommandLine()                            *
******************************************************************************/
int BoltSample::parseCommandLine(int argc, char**argv)
{
    if(sampleArgs==NULL)
    {
        std::cout<<"Error. Command line parser not initialized.\n";
        return SDK_FAILURE;
    }
    else
    {
        if(!sampleArgs->parse(argv,argc))
        {
            usage();
            return SDK_FAILURE;
        }
        if(sampleArgs->isArgSet("h",true) != SDK_SUCCESS)
        {
            usage();
            return SDK_FAILURE;
        }
        if(sampleArgs->isArgSet("v", true) || sampleArgs->isArgSet("version", false))
        {
            std::cout << "Bolt version : " << std::endl 
                << getBoltVerStr().c_str() << std::endl;
            exit(0);
        }
        if(samples <= 0)
        {
            std::cout << "Number input samples should be more than Zero"
                      << std::endl << "Exiting..." << std::endl;
            return SDK_FAILURE;
        }
        if(iterations <= 0)
        {
            std::cout << "Number iterations should be more than Zero"
                      << std::endl << "Exiting..." << std::endl;
            return SDK_FAILURE;
        }
    }

    return SDK_SUCCESS;
}