Exemplo n.º 1
0
// ****************************************************************************
// Function: RunBenchmark
//
// Purpose:
//   Measures the floating point capability of the device for a variety of 
//   combinations of arithmetic operations.
//
// Arguments:
//   op: the options parser / parameter database
//
// Returns:  nothing
//
// Programmer: Zhi Ying([email protected])
//             Jun Jin([email protected])
//
// Creation: May 23, 2011
//
// Modifications:
// 12/12/12 - Kyle Spafford - Code style and minor integration updates
//
// ****************************************************************************
void RunBenchmark(OptionParser &op, ResultDatabase &resultDB)
{
    const bool verbose = op.getOptionBool("verbose");
    // Quiet == no progress bar.
    const bool quiet   = op.getOptionBool("quiet");
    const unsigned int passes = op.getOptionInt("passes");
    const int micdev = op.getOptionInt("target");

    double repeatF = 3;
    cout << "Adjust repeat factor = " << repeatF << "\n";

    // Initialize progress bar
    int totalRuns = 16*passes*2;
    ProgressBar pb(totalRuns);
    if (!verbose && !quiet) 
    {
        pb.Show(stdout);
    }

    RunTest<float>(resultDB, passes, verbose, quiet,
                   repeatF, pb, "-SP", micdev);
    RunTest<double>(resultDB, passes, verbose, quiet,
                    repeatF, pb, "-DP", micdev);

    if (!verbose) cout << endl;
}
Exemplo n.º 2
0
int main (int argc, const char* argv[]) {
	OptionParser parser;
	parser.description("split input file by odd lines and even lines into two files\n"
		"input from stdin, output odd lines to stdout, even lines to stderr")
		.usage("%prog [OPTIONS] < INPUT > ODD_LINES 2> EVEN_LINES")
		.version("1.0")
		.epilog("By jadesoul @ 2013-11-19 14:47:14\n"
			"please report bugs to " JADESOUL_EMAIL);
	parser.add_option("-v", "--verbose")
		.action("store_true")
		.dest("verbose")
		.set_default("0")
		.help("print status messages to stdlog");
	OptionArgs& optargs = parser.parse_args(argc, argv);
	bool verbose=optargs.get("verbose");
	
	if (verbose) cout<<"begin ..."<<endl;
	
	uint i=0;
	string s;
	while (getline(cin, s))
		if (++i%2==1) cout<<s<<endl;
		else cerr<<s<<endl;
		
	if (verbose) cout<<"finished"<<endl;
	return 0;
}
int CDECL main(int aArgc, char* aArgv[])
{
	InitialisationParams* initParams = InitialisationParams::Create();

    OptionParser parser;
    OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test");
    parser.AddOption(&optionDuration);
    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    Library* lib = new Library(initParams);
    std::vector<NetworkAdapter*>* subnetList = lib->CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    Library::DestroySubnetList(subnetList);
    CpStack* cpStack = lib->StartCp(subnet);

    // Debug::SetLevel(Debug::kTopology);

	ReceiverManager1Logger* logger = new ReceiverManager1Logger(*cpStack);
	
    Blocker* blocker = new Blocker(lib->Env());
    blocker->Wait(optionDuration.Value());
    delete blocker;
	
	delete (logger);

	Print("Closing ... ");
	delete lib;
	Print("closed\n");
}
Exemplo n.º 4
0
void TestNetwork(const std::vector<Brn>& aArgs)
{
    OptionParser parser;
    OptionUint adapter("-i", "--interface", 0, "index of network adapter to use");
    parser.AddOption(&adapter);
    if (!parser.Parse(aArgs) || parser.HelpDisplayed()) {
        return;
    }

    std::vector<NetworkAdapter*>* ifs = Os::NetworkListAdapters(Net::InitialisationParams::ELoopbackUse, "TestNetwork");
    ASSERT(ifs->size() > 0 && adapter.Value() < ifs->size());
    TIpAddress addr = (*ifs)[adapter.Value()]->Address();
    for (TUint i=0; i<ifs->size(); i++) {
        (*ifs)[i]->RemoveRef("TestNetwork");
    }
    delete ifs;
    Endpoint endpt(0, addr);
    Endpoint::AddressBuf buf;
    endpt.AppendAddress(buf);
    Print("Using network interface %s\n\n", buf.Ptr());
    Thread* th = new MainNetworkTestThread(addr);
    th->Start();
    th->Wait();
    delete th;
}
Exemplo n.º 5
0
// validate stencil-independent values
void
CheckOptions( const OptionParser& opts )
{
    // check matrix dimensions - must be 2d, must be positive
    std::vector<long long> arrayDims = opts.getOptionVecInt( "customSize" );
    if( arrayDims.size() != 2 )
    {
        throw InvalidArgValue( "overall size must have two dimensions" );
    }
    if( (arrayDims[0] < 0) || (arrayDims[1] < 0) )
    {
        throw InvalidArgValue( "each size dimension must be positive" );
    }

    // validation error threshold must be positive
    float valThreshold = opts.getOptionFloat( "val-threshold" );
    if( valThreshold <= 0.0f )
    {
        throw InvalidArgValue( "validation threshold must be positive" );
    }

    // number of validation errors to print must be non-negative
    int nErrsToPrint = opts.getOptionInt( "val-print-limit" );
    if( nErrsToPrint < 0 )
    {
        throw InvalidArgValue( "number of validation errors to print must be non-negative" );
    }

    int nWarmupPasses = opts.getOptionInt( "warmupPasses" );
    if( nWarmupPasses < 0 )
    {
        throw InvalidArgValue( "number of warmup passes must be non-negative" );
    }
}
Exemplo n.º 6
0
// parse a STATA command 
DwUseOptions* DwUseOptionParser::Parse(vector<string> words) {	

	// there are 10 keywords we expect to see
	string keys[] = {"variables", "if", "using", "limit",
					 "nulldata", "lowercase", "uppercase", 
					 "label_variable", "label_values", 
					 "username", "password", "database"};
	size_t nkeys(sizeof(keys) / sizeof(string));
	// create parser that accepts these keywords
	OptionParser* parser = new OptionParser( set<string>(keys, keys + nkeys) );

	// prepare another vector where we can search 

	// see if we have a using anywhere, if we do, the first part is the varlist, if not it is the tablename
	bool hasUsing = hasKeyword(words, "using");

	// if it contains using somewhere we can start with variables (if missing it will be an empty string, if the list is there it will be expected)
	if( !hasUsing ) 
		words.insert(words.begin(), "using"); 
	else if( lowerCase(words[0]) != "if" && lowerCase(words[0]) != "using" )
		words.insert(words.begin(), "variables");

	// parse the options
	map<string,string> options = parser->Parse( words );
	delete parser;

	// create a meaningful options object
	DwUseOptions* useOptions = new DwUseOptions( options );	
	return useOptions;
}
Exemplo n.º 7
0
// ****************************************************************************
// Function: GPUSetup
//
// Purpose:
//  do the necessary OpenCL setup for GPU part of the test
//
// Arguments:
//   op: the options parser / parameter database
//   mympirank: for printing errors in case of failure
//   mynoderank: this is typically the device ID (the mapping done in main)
//
// Returns: success/failure
//
// Creation: 2009
//
// Modifications:
//
// ****************************************************************************
//
int GPUSetup(OptionParser &op, int mympirank, int mynoderank)
{
    addBenchmarkSpecOptions(op);
    
    if (op.getOptionBool("infoDevices"))
    {
        OpenCLNodePlatformContainer ndc1;
        ndc1.Print (cout);
        return (0);
    }
    
    // The device option supports specifying more than one device
    int platform = op.getOptionInt("platform");
    int deviceIdx = mynoderank;
    if( deviceIdx >= op.getOptionVecInt( "device" ).size() )
    {
        std::ostringstream estr;
        estr << "Warning: not enough devices specified with --device flag for task "
            << mympirank
            << " ( node rank " << mynoderank
            << ") to claim its own device; forcing to use first device ";
        std::cerr << estr.str() << std::endl;
        deviceIdx = 0;
    }
    int device = op.getOptionVecInt("device")[deviceIdx];

    // Initialization
    _mpicontention_ocldev = new cl::Device( ListDevicesAndGetDevice(platform, device) );
    std::vector<cl::Device> ctxDevices;
    ctxDevices.push_back( *_mpicontention_ocldev );
    _mpicontention_ocldriver_ctx   = new cl::Context( ctxDevices );
    _mpicontention_ocldriver_queue = new cl::CommandQueue( *_mpicontention_ocldriver_ctx, *_mpicontention_ocldev, CL_QUEUE_PROFILING_ENABLE );
    _mpicontention_gpuop = op;
    return 0;
}
Exemplo n.º 8
0
int __cdecl main(int aArgc, char* aArgv[])
{
	InitialisationParams* initParams = InitialisationParams::Create();

    OptionParser parser;
    
    OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test");

    parser.AddOption(&optionDuration);
    
    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    UpnpLibrary::Initialise(initParams);
    
    UpnpLibrary::StartCp();

    //Debug::SetLevel(Debug::kTopology);

	ReceiverManager2Logger* logger = new ReceiverManager2Logger();
	
    Blocker* blocker = new Blocker;
    blocker->Wait(optionDuration.Value());
    delete blocker;
	
	delete (logger);

	UpnpLibrary::Close();
}
Exemplo n.º 9
0
BamHeader PrepareHeader(const OptionParser& parser, int argc, char** argv,
                        const vector<string>& files)
{
    using boost::algorithm::join;

    ProgramInfo program(parser.prog() + "-" + CCS_VERSION);
    program.Name(parser.prog())
    .CommandLine(parser.prog() + " " + join(vector<string>(argv + 1, argv + argc), " "))
    .Description(DESCRIPTION)
    .Version(CCS_VERSION);

    BamHeader header;
    header.PacBioBamVersion("3.0.1").SortOrder("unknown").Version("1.5").AddProgram(program);

    for (const auto& file : files) {
        BamFile bam(file);

        for (const auto& rg : bam.Header().ReadGroups()) {
            if (rg.ReadType() != "SUBREAD")
                parser.error("invalid input file, READTYPE must be SUBREAD");

            ReadGroupInfo readGroup(rg.MovieName(), "CCS");
            readGroup.BindingKit(rg.BindingKit())
            .SequencingKit(rg.SequencingKit())
            .BasecallerVersion(rg.BasecallerVersion())
            .FrameRateHz(rg.FrameRateHz());

            header.AddReadGroup(readGroup);
        }
    }

    return header;
}
Exemplo n.º 10
0
    Options(int argc, char *argv[]) {

        parser = new OptionParser(argc, argv);

        this->init_options();

        // Personnalisation éventuelle du comportement : que faire si l'utilisateur
        // passe une option incorrecte ?  Les valeurs possibles sont :
        //      exit (par défaut), raise, warn, ignore
        // Ici, on veut afficher les clés erronées tout en continuant l'analyse.
        // parser->on_error("warn");
        // Ici, on veut arrêter le programme en cas d'option invalide.
        parser->on_error("exit");  // inutile car c'est "exit" par défaut

        // Permet des post-traitements (vérification de cohérence d'options,...)
        pre_process_options();

        // On peut lancer l'analyse ici ou bien le faire depuis le main() de la
        // du programme principal.
        parser->parse();

        // Permet des post-traitements (vérification de cohérence entre options,...)
        post_process_options();

        // Les attributs options étant affectés, on peut supprimer le parser
        // sauf si on souhaite exploiter quelques-unes de ses méthodes ou attributs
        // e.g parser->print_values() ou parser->params
        //  delete parser;
        //  parser = NULL; // Utile ssi on veut pouvoir tester l'existence de parser !
    }
int CDECL main(int aArgc, char* aArgv[])
{
	InitialisationParams* initParams = InitialisationParams::Create();

    OptionParser parser;
    
    OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test");

    parser.AddOption(&optionDuration);
    
    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    UpnpLibrary::Initialise(initParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    UpnpLibrary::DestroySubnetList(subnetList);
    UpnpLibrary::StartCp(subnet);

    // Debug::SetLevel(Debug::kTopology);

	ReceiverManager2Logger* logger = new ReceiverManager2Logger();
	
    Blocker* blocker = new Blocker;
    blocker->Wait(optionDuration.Value());
    delete blocker;
	
	delete (logger);

	UpnpLibrary::Close();
}
Exemplo n.º 12
0
// ****************************************************************************
// Function: addBenchmarkSpecOptions
//
// Purpose:
//   Add benchmark specific options parsing.  The user is allowed to specify
//   the size of the input data in megabytes.
//
// Arguments:
//   op: the options parser / parameter database
//
// Programmer: Collin McCurdy
// Creation: September 08, 2009
// Returns:  nothing
//
// ****************************************************************************
	void
addBenchmarkSpecOptions(OptionParser &op)
{
	op.addOption("pts", OPT_INT, "0", "data size (in megabytes)");
	op.addOption("pts1", OPT_INT, "0", "data size (in megabytes)");
	op.addOption("pts2", OPT_INT, "0", "data size (in megabytes)");
	op.addOption("2D", OPT_BOOL, "false", "2D FFT");
}
Exemplo n.º 13
0
// ****************************************************************************
// Function: addBenchmarkSpecOptions
//
// Purpose:
//   Add benchmark specific options parsing.  The user is allowed to specify
//   the size of the input data in megabytes.
//
// Arguments:
//   op: the options parser / parameter database
//
// Programmer: Collin McCurdy
// Creation: September 08, 2009
// Returns:  nothing
//
// ****************************************************************************
void 
addBenchmarkSpecOptions(OptionParser &op) 
{
    op.addOption("MB", OPT_INT, "0", "data size (in megabytes)");
    op.addOption("use-native", OPT_BOOL, "false", "call native (HW) versions of sin/cos");
    op.addOption("dump-sp", OPT_BOOL, "false", "dump result after SP fft/ifft");
    op.addOption("dump-dp", OPT_BOOL, "false", "dump result after DP fft/ifft");
}
Exemplo n.º 14
0
// ****************************************************************************
// Function: addBenchmarkSpecOptions
//
// Purpose:
//   Add benchmark specific options parsing.
//
// Arguments:
//   op: the options parser / parameter database
//
// Programmer: Lukasz Wesolowski
// Creation: June 21, 2010
// Returns:  nothing
//
// ****************************************************************************
void addBenchmarkSpecOptions(OptionParser &op)
{
    op.addOption("iterations", OPT_INT, "100", "Number of SpMV iterations "
                 "per pass");
    op.addOption("mm_filename", OPT_STRING, "random", "Name of file "
                 "which stores the matrix in Matrix Market format");
    op.addOption("maxval", OPT_FLOAT, "10", "Maximum value for random "
                 "matrices");
}
Exemplo n.º 15
0
void
StencilFactory<T>::ExtractOptions( const OptionParser& options,
                                T& wCenter,
                                T& wCardinal,
                                T& wDiagonal )
{
    wCenter = options.getOptionFloat( "weight-center" );
    wCardinal = options.getOptionFloat( "weight-cardinal" );
    wDiagonal = options.getOptionFloat( "weight-diagonal" );
}
Exemplo n.º 16
0
void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams)
{
    OptionParser parser;
    OptionBool loopback("-l", "--loopback", "Use the loopback adapter only");
    parser.AddOption(&loopback);
    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }
    if (loopback.Value()) {
        aInitParams->SetUseLoopbackNetworkInterface();
    }
    UpnpLibrary::Initialise(aInitParams);
    UpnpLibrary::StartCombined();
    //Debug::SetLevel(Debug::kDevice/*Debug::kXmlFetch | Debug::kHttp*/);

    Print("TestDviDeviceList - starting\n");

    DvDevices* devices = new DvDevices;
    CpDevices* deviceList = new CpDevices;
    FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &CpDevices::Added);
    FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &CpDevices::Removed);

    Print("Count devices implementing service1\n");
    Brn domainName("a.b.c");
    Brn serviceType("service1");
    TUint ver = 1;
    CpDeviceListUpnpServiceType* list =
                new CpDeviceListUpnpServiceType(domainName, serviceType, ver, added, removed);
    Blocker* blocker = new Blocker;
    blocker->Wait(aInitParams->MsearchTimeSecs());
    std::vector<const char*> udns;
    udns.push_back((const char*)gNameDevice1.Ptr());
    udns.push_back((const char*)gNameDevice2.Ptr());
    deviceList->Validate(udns);
    udns.clear();
    delete list;
    deviceList->Clear();

    Print("Count devices implementing service2\n");
    serviceType.Set("service2");
    list = new CpDeviceListUpnpServiceType(domainName, serviceType, ver, added, removed);
    blocker->Wait(aInitParams->MsearchTimeSecs());
    udns.push_back((const char*)gNameDevice1_1.Ptr());
    udns.push_back((const char*)gNameDevice2.Ptr());
    deviceList->Validate(udns);
    udns.clear();
    delete list;

    delete blocker;
    delete deviceList;
    delete devices;

    Print("TestDviDeviceList - completed\n");
    UpnpLibrary::Close();
}
Exemplo n.º 17
0
Options setupOptions(int theArgc, char * theArgv[]){
    // Create the options
    Options opt;

    // Parse the options
    OptionParser OP;
    OP.setRequired(opt.required);	
    OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option
    OP.readArgv(theArgc, theArgv);

    if (OP.countOptions() == 0){
	cout << "Usage: getConsecutivePhiPsi " << endl;
	cout << endl;
	cout << "\n";
	cout << "pdblist PDB\n";
	cout << "SSE L # L = Loop, S = Strand, H = Helix\n"
	cout << endl;
	exit(0);
    }

    opt.pdblist = OP.getString("pdblist");
    if (OP.fail()){
	cerr << "ERROR 1111 no pdblist specified."<<endl;
	exit(1111);
    }

    opt.SSE = OP.getString("sse");
    if (OP.fail()){
	opt.SSE = "";
    }


    return opt;
}
Exemplo n.º 18
0
Options setupOptions(int theArgc, char * theArgv[]){
    // Create the options
    Options opt;

    // Parse the options
    OptionParser OP;
    OP.setRequired(opt.required);	
    OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option
    OP.readArgv(theArgc, theArgv);

    if (OP.countOptions() == 0){
	cout << "Usage: getTripletCaMeasurements " << endl;
	cout << endl;
	cout << "\n";
	cout << "pdblist PDB\n";
	cout << endl;
	exit(0);
    }

    opt.pdblist = OP.getString("pdblist");
    if (OP.fail()){
	cerr << "ERROR 1111 no pdblist specified."<<endl;
	exit(1111);
    }

    opt.numSamples = OP.getInt("numSamples");
    if (OP.fail()){
      opt.numSamples = 10000;
      cerr << "WARNING numSamples set to "<<opt.numSamples<<endl;
    }
    return opt;
}
Exemplo n.º 19
0
Options setupOptions(int theArgc, char * theArgv[]){
	Options opt;

	OptionParser OP;


	OP.setRequired(opt.required);
	OP.setAllowed(opt.optional);
	OP.readArgv(theArgc, theArgv);

	if (OP.countOptions() == 0){
		cout << "Usage:" << endl;
		cout << endl;
		cout << "createVectorHash --list pdb.list --outfile foo.vh\n";
		exit(0);
	}
	opt.list = OP.getString("list");
	if (OP.fail()){
		cerr << "ERROR 1111 pdb not specified.\n";
		exit(1111);
	}

	opt.outfile = OP.getString("outfile");
	if (OP.fail()){
	  cerr << "WARNING outfile not specified. Using: '"<<opt.list<<".vh'"<<endl;
	  opt.outfile = opt.list+".vh";

	}

	return opt;
}
Exemplo n.º 20
0
int main(int argc, char **argv)
{
    OptionParser cmd;
    cmd.option("-v", "--verbose", "enable verbose stuff", verbose);
    cmd.option("-r", "--required <arg>", "required arg", required);
    cmd.option("-o", "--optional [arg]", "optional arg", optional);
    cmd.parse(argc, argv);
    std::cout << cmd.normalize() << endl;
    //cmd.help();
    return 0;
}
Exemplo n.º 21
0
void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams)
{
    OptionParser parser;
    OptionBool loopback("-l", "--loopback", "Use the loopback adapter only");
    parser.AddOption(&loopback);
    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }
    if (loopback.Value()) {
        aInitParams->SetUseLoopbackNetworkAdapter();
    }
    aInitParams->SetMsearchTime(1);
    aInitParams->SetDvUpnpServerPort(0);
    UpnpLibrary::Initialise(aInitParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    UpnpLibrary::DestroySubnetList(subnetList);
    UpnpLibrary::StartCombined(subnet);
    //Debug::SetLevel(Debug::kEvent | Debug::kDvEvent);

    Print("TestDvDeviceStd - starting\n");

    Semaphore* sem = new Semaphore("SEM1", 0);
    DeviceBasic* device = new DeviceBasic(DeviceBasic::eProtocolUpnp);
    CpDevices* deviceList = new CpDevices(device->Device().Udn(), *sem);
    FunctorCpDeviceCpp added = MakeFunctorCpDeviceCpp(*deviceList, &CpDevices::Added);
    FunctorCpDeviceCpp removed = MakeFunctorCpDeviceCpp(*deviceList, &CpDevices::Removed);
    std::string domainName("openhome.org");
    std::string serviceType("TestBasic");
    TUint ver = 1;
    CpDeviceListCppUpnpServiceType* list =
                new CpDeviceListCppUpnpServiceType(domainName, serviceType, ver, added, removed);
    sem->Wait(30*1000); // allow up to 30s to find our one device
    try {
        deviceList->TestActions();
        Functor cb = MakeFunctor(sem, &DeviceDisabled);
        device->Device().SetDisabled(cb);
        sem->Wait();
        deviceList->TestThrows();
        device->Device().SetEnabled();
        deviceList->TestSubscriptions();
    }
    catch (Exception& e) {
        Print("Exception %s from %s:%u\n", e.Message(), e.File(), e.Line());
        ASSERTS();
    }
    delete sem;
    delete list;
    delete deviceList;
    delete device;

    Print("TestDvDeviceStd - completed\n");
    UpnpLibrary::Close();
}
Exemplo n.º 22
0
    virtual int proceedOpts(OptionParser &op) {
        op.setDescription("Metaprogramming Multi-Staged JavaScript Debugger");

        if (!op.addStringOption('i', "inputfile", "filepath",
                                "Metaprogramming JavaScript input File location")
                || !op.addStringOption('o', "outputfile", "filepath",
                                       "Metaprogramming JavaScript output File location")
                || !op.addStringOption('b', "browser", "browser execution location",
                                       "Metaprogramming JavaScript execution browser")) {
            return EXIT_FAILURE;
        }
        return EXIT_SUCCESS;
    }
Exemplo n.º 23
0
    virtual int handle(JSContext *cx, JSObject *global, OptionParser &op) {

        const char *stgInputfile = op.getStringOption("inputfile");
        if(!stgInputfile) {
            fprintf(stderr, "Unrecognized option for %s: %s\n", "inputfile", stgInputfile);
            return EXIT_FAILURE;
        }
        const char *stgOutputfile = op.getStringOption("outputfile");
        if(!stgOutputfile) {
            fprintf(stderr, "Unrecognized option for %s: %s\n", "outputfile", stgOutputfile);
            return EXIT_FAILURE;
        }
        const char *stgBrowser = op.getStringOption("browser");
        if(!stgBrowser) {
            fprintf(stderr, "Unrecognized option for %s: %s\n", "browser", stgBrowser);
            return EXIT_FAILURE;
        }

        /*		stgInputfile = "Src/examples/test.js";
        			stgOutputfile = "Src/examples/test_staged.js";
        			stgBrowser = "chrome";
        */

        StagingProcess::createSingleton(cx, stgOutputfile, NULL);
        unparse *up = unparse::getSingleton();

        JS_ReportInfo(cx, "opening \"%s\".\n", stgInputfile);

        jschar *chars;
        if (!AutoFile::OpenAndReadAll(cx, stgInputfile, &chars))
            return EXIT_FAILURE;

        uint32_t lineno = 1;
        ScopedJSFreePtr<char> filename;
        jsval rval;

        JS_ReportInfo(cx, "converting src to ast. ");
        if (!reflect_parse_from_string(cx, chars, js_strlen(chars), &rval)) {
            JS_ReportError(cx, "reflection parse error.\n");
            return EXIT_FAILURE;
        }
        JS_ReportInfo(cx, "done.\n");

        RemoteStagedDbg remoteStagedDbg(cx, JSVAL_TO_OBJECT(rval));
        remoteStagedDbg.start(stgBrowser);

        js_free(chars);
        StagingProcess::destroySingleton();
        JS_ReportInfo(cx, "finish.\n");
        return EXIT_SUCCESS;
    }
Exemplo n.º 24
0
void TestSsdpMListen(const std::vector<Brn>& aArgs)
{
    OptionParser parser;
    OptionUint duration("-d", "--duration", 30, "Number of seconds to listen for.  Defaults to 30");
    parser.AddOption(&duration);
    OptionUint adapter("-i", "--interface", 0, "index of network adapter to use");
    parser.AddOption(&adapter);
    if (!parser.Parse(aArgs) || parser.HelpDisplayed()) {
        return;
    }

    Runner runner("SSDP multicast listener\n");
    runner.Add(new SuiteListen(duration.Value(), adapter.Value()));
    runner.Run();
}
Exemplo n.º 25
0
void
RunBenchmark(cl::Device& devcpp,
                  cl::Context& ctxcpp,
                  cl::CommandQueue& queuecpp,
                  ResultDatabase &resultDB,
                  OptionParser &op)
{
    // convert from C++ bindings to C bindings
    // TODO propagate use of C++ bindings
    cl_device_id dev = devcpp();
    cl_context ctx = ctxcpp();
    cl_command_queue queue = queuecpp();

    if (getMaxWorkGroupSize(dev) < 64) {
        cout << "FFT requires MaxWorkGroupSize of at least 64" << endl;
        fillResultDB("SP-FFT", "MaxWorkGroupSize<64", op, resultDB);
        fillResultDB("DP-FFT", "MaxWorkGroupSize<64", op, resultDB);
        return;
    }
    
    bool has_dp = checkExtension(dev, "cl_khr_fp64") ||
        checkExtension(dev, "cl_amd_fp64");

    if (op.getOptionBool("dump-sp")) {
        dump<cplxflt>(op);
    }
    else if (op.getOptionBool("dump-dp")) {
        if (!has_dp) {
            cout << "dump-dp: no double precision support!\n";
            return;
        }
        dump<cplxdbl>(op);
    }
    else {
        // Always run single precision test
        runTest<cplxflt>("SP-FFT", dev, ctx, queue, resultDB, op);

        // If double precision is supported, run the DP test
        if (has_dp) {
            cout << "DP Supported\n";
            runTest<cplxdbl>("DP-FFT", dev, ctx, queue, resultDB, op);
        }
        else {
            cout << "DP Not Supported\n";
            fillResultDB("DP-FFT", "DP_Not_Supported", op, resultDB);
        }
    }
}
Exemplo n.º 26
0
Arquivo: FFT.cpp Projeto: vetter/shoc
void
RunBenchmark(ResultDatabase &resultDB, OptionParser &op)
{
    // Test to see if this device supports double precision
    cudaGetDevice(&fftDevice);
    cudaDeviceProp deviceProp;
    cudaGetDeviceProperties(&deviceProp, fftDevice);
    bool has_dp = (deviceProp.major == 1 && deviceProp.minor >= 3) ||
        (deviceProp.major >= 2);

    cout << "Running single precision test" << endl;
    runTest<float2>("SP-FFT", resultDB, op);
    if (has_dp) {
        cout << "Running double precision test" << endl;
        runTest<double2>("DP-FFT", resultDB, op);
    }
    else
    {
        cout << "Skipping double precision test" << endl;
        char atts[32] = "DP_Not_Supported";
        // resultDB requires neg entry for every possible result
        int passes = op.getOptionInt("passes");
        for (int k=0; k<passes; k++)
        {
            resultDB.AddResult("DP-FFT" , atts, "GB/s", FLT_MAX);
            resultDB.AddResult("DP-FFT_PCIe" , atts, "GB/s", FLT_MAX);
            resultDB.AddResult("DP-FFT_Parity" , atts, "GB/s", FLT_MAX);
            resultDB.AddResult("DP-FFT-INV" , atts, "GB/s", FLT_MAX);
            resultDB.AddResult("DP-FFT-INV_PCIe" , atts, "GB/s", FLT_MAX);
            resultDB.AddResult("DP-FFT-INV_Parity" , atts, "GB/s", FLT_MAX);
        }
    }
}
void 
CommonMICStencilFactory<T>::CheckOptions( const OptionParser& opts ) const
{
    // let base class check its options first
    StencilFactory<T>::CheckOptions( opts );

    // check our options
    std::vector<long long> arrayDims = opts.getOptionVecInt( "customSize" );
    assert( arrayDims.size() == 2 );

    // If both of these are zero, we're using a non-custom size, skip this test
    if (arrayDims[0] == 0 && arrayDims[0] == 0)
    {
        return;
    }

    size_t gRows = (size_t)arrayDims[0];
    size_t gCols = (size_t)arrayDims[1];
    size_t lRows = LROWS;
    size_t lCols = LCOLS;

    // verify that local dimensions evenly divide global dimensions
    if( ((gRows % lRows) != 0) || (lRows > gRows) )
    {
        throw InvalidArgValue( "number of rows must be even multiple of lsize rows" );
    }
    if( ((gCols % lCols) != 0) || (lCols > gCols) )
    {
        throw InvalidArgValue( "number of columns must be even multiple of lsize columns" );
    }

    // TODO ensure local dims are smaller than CUDA implementation limits
}
Exemplo n.º 28
0
int t1only_main(int argc, char *argv[], int nb_pars, OptionParser & options){
  
  if (argc - nb_pars < 4)
    {
      cerr<<"too few arguments"<<endl;
      options.usage(); return -1;
    }
  
  int count_arg = nb_pars;
  
  const string inputt1(argv[count_arg]);
  count_arg++;
  const string mesh(argv[count_arg]);
  count_arg++;
  const string matrix(argv[count_arg]);
  count_arg++;
  const string outputstr(argv[count_arg]);


  //load the mesh
  Mesh m;
  m.load(mesh);

  //load the matrix
  trMatrix M;
  ifstream f(matrix.c_str());
  if (f.is_open())
    {
      f>>M.m11>>M.m12>>M.m13>>M.m14>>M.m21>>M.m22>>M.m23>>M.m24>>M.m31>>M.m32>>M.m33>>M.m34>>M.m41>>M.m42>>M.m43>>M.m44;
      f.close();
    }
Exemplo n.º 29
0
void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams)
{
    OptionParser parser;

    OptionUint duration("-d", "--duration", 30, "Number of seconds to run the test");
    OptionUint adapter("-i", "--interface", 0, "index of network adapter to use");

    parser.AddOption(&duration);
    parser.AddOption(&adapter);

    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }

    UpnpLibrary::Initialise(aInitParams);
    std::vector<NetworkAdapter*>* ifs = Os::NetworkListAdapters(false, "TestTopology3");
    ASSERT(ifs->size() > 0 && adapter.Value() < ifs->size());
    TIpAddress subnet = (*ifs)[adapter.Value()]->Subnet();
    for (TUint i=0; i<ifs->size(); i++) {
        (*ifs)[i]->RemoveRef("TestTopology3");
    }
    delete ifs;
    UpnpLibrary::StartCp(subnet);

    Endpoint endpt(0, subnet);
    Endpoint::AddressBuf buf;
    endpt.AppendAddress(buf);
    Print("Using network interface %s\n\n", buf.Ptr());

    // Debug::SetLevel(Debug::kTopology);
    // Debug::SetLevel(Debug::kAll);

    TopologyLogger logger;

    CpTopology3* topology = new CpTopology3(logger);

    if (topology != NULL) {
        Blocker* blocker = new Blocker;
        blocker->Wait(duration.Value());
        delete blocker;
    }

    delete topology;

    UpnpLibrary::Close();

}
Exemplo n.º 30
0
void dump2D(OptionParser& op)
{
	int i;
	void* work, *temp;
	T2* source, * result;
	unsigned long bytes = 0;

	int probSizes[7] = { 128, 256, 512, 1024, 2048, 4096, 8192};
	int sizeIndex = op.getOptionInt("pts1")-1;
	int sizeIndey = op.getOptionInt("pts2")-1;
	if (sizeIndex < 0 || sizeIndex >= 7) {
		cerr << "Invalid size index specified\n";
		exit(-1);
	}
	if (sizeIndey < 0 || sizeIndey >= 7) {
		cerr << "Invalid size index specified\n";
		exit(-1);
	}

	int FFTN1=probSizes[sizeIndex],FFTN2=probSizes[sizeIndey];
	//int FFTN1=8192,FFTN2=512;
	unsigned long used_bytes = FFTN1*FFTN2*sizeof(T2);

	bool do_dp = dp<T2>();
	init2(op, do_dp, FFTN1, FFTN2);

	int n_ffts = 1;
	double N = FFTN1*FFTN2;


	// allocate host and device memory
	allocHostBuffer((void**)&source, used_bytes);
	allocHostBuffer((void**)&result, used_bytes);

	// init host memory...
	for (i = 0; i < N; i++) {
		source[i].x = (rand()/(float)RAND_MAX)*2-1;
		source[i].y = (rand()/(float)RAND_MAX)*2-1;
	}

	// alloc device memory
	allocDeviceBuffer(&work, used_bytes);
	allocDeviceBuffer(&temp, used_bytes);

	copyToDevice(work, source, used_bytes);

	forward2(work, temp, n_ffts, FFTN1, FFTN2);
	copyFromDevice(result, work, used_bytes);

#ifdef PRINT_RESULT
	for (i = 0; i < N; i++) {
		fprintf(stdout, "data[%d] (%g, %g) \n",i, result[i].x, result[i].y);
	}
#endif
	freeDeviceBuffer(work);
	freeDeviceBuffer(temp);
	freeHostBuffer(source);
	freeHostBuffer(result);
}