bool CudaCompiler::runPreprocessor(std::string& cubinFile, std::string& finalOpts)
{
  // Preprocess.
  finalOpts = "";
  
  if (s_staticOptions.length()) {
    finalOpts += s_staticOptions + " ";
  }
  finalOpts += m_options;

  std::string logFile = m_cachePath + "/preprocess.log";
  
  std::string cmd = s_nvccCommand + " -E -o \"" + m_cachePath + "/preprocessed.cu\" " +
                    "-include \"" + m_cachePath + "/defines.inl\" " + 
                    finalOpts + " \"" + m_sourceFile + 
                    "\" 2>>\"" + logFile + "\"";

  initLogFile( logFile, cmd);
  
  if (0 != system(cmd.c_str()))
  {
    setLoggedError("CudaCompiler: Preprocessing failed!", logFile);
    return false;
  }

  // Specify binary format.
  if (s_staticBinaryFormat.length()) {
    finalOpts += s_staticBinaryFormat;
  } else {
    finalOpts += "-cubin";
  }
  finalOpts += " ";

  
  U32 hashA = FW_HASH_MAGIC;
  U32 hashB = FW_HASH_MAGIC;
  U32 hashC = FW_HASH_MAGIC;
  
  // Override SM architecture.
  S32 smArch = m_overriddenSMArch;
  if (!smArch) {
    smArch = CudaModule::getComputeCapability();
  }

  finalOpts = removeOption(finalOpts, "-arch", true);
  finalOpts = removeOption(finalOpts, "--gpu-architecture", true);
  
  char smArch_str[32];
  sprintf(smArch_str, "-arch sm_%d ", smArch);
  finalOpts += std::string(smArch_str);

  // Override pointer width.
  // CUDA 3.2 => requires -m32 for x86 build and -m64 for x64 build.
  if (CudaModule::getDriverVersion() >= 32)
  {
    finalOpts = removeOption(finalOpts, "-m32", false);
    finalOpts = removeOption(finalOpts, "-m64", false);
    finalOpts = removeOption(finalOpts, "--machine", true);

#if FW_64
    finalOpts += "-m64 ";
#else
    finalOpts += "-m32 ";
#endif
  }
    
  // Hash final compiler options and version.
  hashA += hash<std::string>(finalOpts);
  hashB += s_nvccVersionHash;
  FW_JENKINS_MIX(hashA, hashB, hashC);
  
  // File's timestamp hash to recompile when modified.
  U64 hashD = getFileTimeStamp( m_sourceFile );
  
  std::string fileName = hashToString(hashB) + 
                         hashToString(hashC) +
                         hashToString(hashD);
  
  cubinFile = m_cachePath + "/" + fileName + ".cubin";
  
  return true;
}
Exemple #2
0
 void handleClick(int opt)
 {
 if(gamestate==0)//Main menu
 {
 switch(opt)
 {
 case 0://quit
 done=true;
 break;
 case 2://Hard
 gamestate=3;
 generateHardQuestion();
 break;
 case 3:
 gamestate=2;
 generateMediumQuestion();//Medium
 break;
 case 4://Easy
 gamestate=1;
 generateEasyQuestion();
 break;
 }
 }
 else if(gamestate==1||gamestate==2||gamestate==3)//Easy,Medium,Hard
 {
 if(opt==-1)return;//If no option was clicked, do nothing
 if(options[opt].state==true)return;//TODO-fix problems //If the question was clicked, do nothing
 if(strcmp(answer,options[opt].string)!=0)//If the wrong answer was clicked, remove it and deduct score
 {
 removeOption(opt);
 score--;
 }
 else
 {
 score++; //Increase score and generate next question
 if(gamestate==1)
 {
 generateEasyQuestion();
 }
 else if(gamestate==2)
 {
 generateMediumQuestion();
 }
 else if(gamestate==3)
 {
 generateHardQuestion();
 }
 if(questions==26)
 {
 questions=0;
 gamestate=4;
 showScore();
 }
 }
 }
 else if(gamestate==4)
 {
 if(opt==0)
 {
 score=0;
 gamestate=0;
 displayMainMenu();
 }
 }
 }
void Foam::argList::noParallel()
{
    removeOption("parallel");
    removeOption("roots");
    validParOptions.clear();
}
Exemple #4
0
QT_USE_NAMESPACE

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QCommandLineParser parser;
    parser.setApplicationDescription(QLatin1String("winrtrunner installs, runs, and collects test "
                                                   "results for packages made with Qt."));
    parser.addPositionalArgument(QStringLiteral("package [arguments]"),
                                 QLatin1String("The executable or package manifest to act upon. "
                                               "Arguments after the package name will be passed "
                                               "to the application when it starts."));

    QCommandLineOption testOption(QStringLiteral("test"),
                                  QLatin1String("Install, start, collect output, stop (if needed), "
                                                "and uninstall the package. This is the "
                                                "default action of winrtrunner."));
    parser.addOption(testOption);

    QCommandLineOption startOption(QStringLiteral("start"),
                                   QLatin1String("Start the package. The package is installed if "
                                                 "it is not already installed. Pass --install to "
                                                 "force reinstallation."));
    parser.addOption(startOption);

    QCommandLineOption debugOption(QStringLiteral("debug"),
                                   QLatin1String("Start the package with the debugger attached. "
                                                 "The package is installed if it is not already "
                                                 "installed. Pass --install to force "
                                                 "reinstallation."),
                                   QLatin1Literal("debugger"));
    parser.addOption(debugOption);

    QCommandLineOption debuggerArgumentsOption(QStringLiteral("debugger-arguments"),
                                               QLatin1String("Arguments that are passed to the "
                                                             "debugger when --debug is used. If no "
                                                             "debugger was provided this option is "
                                                             "ignored."),
                                               QLatin1String("arguments"));
    parser.addOption(debuggerArgumentsOption);

    QCommandLineOption suspendOption(QStringLiteral("suspend"),
                                     QLatin1String("Suspend a running package. When combined "
                                                   "with --stop or --test, the app will be "
                                                   "suspended before being terminated."));
    parser.addOption(suspendOption);

    QCommandLineOption stopOption(QStringLiteral("stop"),
                                  QLatin1String("Terminate a running package. Can be be "
                                                "combined with --start and --suspend."));
    parser.addOption(stopOption);

    QCommandLineOption waitOption(QStringLiteral("wait"),
                                  QLatin1String("If the package is running, waits the given "
                                                "number of seconds before continuing to the next "
                                                "task. Passing 0 causes the runner to wait "
                                                "indefinitely."),
                                  QStringLiteral("seconds"));
    parser.addOption(waitOption);

    QCommandLineOption installOption(QStringLiteral("install"),
                                     QStringLiteral("(Re)installs the package."));
    parser.addOption(installOption);

    QCommandLineOption removeOption(QStringLiteral("remove"),
                                    QStringLiteral("Uninstalls the package."));
    parser.addOption(removeOption);

    QCommandLineOption deviceOption(QStringLiteral("device"),
                                    QLatin1String("Specifies the device to target as a device name "
                                                  " or index. Use --list-devices to find available "
                                                  "devices. The default device is the first device "
                                                  "found for the active run profile."),
                                    QStringLiteral("name|index"));
    parser.addOption(deviceOption);

    QCommandLineOption profileOption(QStringLiteral("profile"),
                                     QStringLiteral("Force a particular run profile."),
                                     QStringLiteral("name"));
    parser.addOption(profileOption);

    QCommandLineOption listDevicesOption(QStringLiteral("list-devices"),
                                         QLatin1String("List the available devices "
                                                       "(for use with --device)."));
    parser.addOption(listDevicesOption);

    QCommandLineOption verbosityOption(QStringLiteral("verbose"),
                                       QLatin1String("The verbosity level of the message output "
                                                     "(0 - silent, 1 - info, 2 - debug). Defaults to 1."),
                                       QStringLiteral("level"), QStringLiteral("1"));
    parser.addOption(verbosityOption);

    QCommandLineOption ignoreErrorsOption(QStringLiteral("ignore-errors"),
                                          QStringLiteral("Always exit with code 0, regardless of the error state."));
    parser.addOption(ignoreErrorsOption);

    parser.addHelpOption();
    parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
    QStringList arguments = QCoreApplication::arguments();
    parser.parse(arguments);

    QStringList filterRules = QStringList() // Default logging rules
            << QStringLiteral("qt.winrtrunner.warning=true")
            << QStringLiteral("qt.winrtrunner.critical=true")
            << QStringLiteral("qt.winrtrunner.app=true");
    if (parser.isSet(verbosityOption)) {
        bool ok;
        uint verbosity = parser.value(verbosityOption).toUInt(&ok);
        if (!ok || verbosity > 2) {
            qCCritical(lcWinRtRunner) << "Incorrect value specified for verbosity.";
            parser.showHelp(1);
        }
        switch (verbosity) {
        case 2: // Enable debug print
            filterRules.append(QStringLiteral("qt.winrtrunner.debug=true"));
            break;
        case 1: // Remove warnings
            filterRules.removeFirst();
            // fall through
        case 0: // Silent
            filterRules.removeFirst();
            // fall through
        default: // Impossible
            break;
        }
    }
    QLoggingCategory::setFilterRules(filterRules.join(QLatin1Char('\n')));

    if (parser.isSet(listDevicesOption)) {
        std::wcout << "Available devices:\n";
        const QMap<QString, QStringList> deviceNames = Runner::deviceNames();
        foreach (const QString &profile, deviceNames.keys()) {
            std::wcout << reinterpret_cast<const wchar_t *>(profile.utf16()) << ":\n";
            int index = 0;
            foreach (const QString &device, deviceNames.value(profile)) {
                std::wcout << "  " << index++ << ' '
                           << reinterpret_cast<const wchar_t *>(device.utf16()) << '\n';
            }
        }
        std::wcout << std::endl;
        return 0;
    }