void generate(OutputIterator first,
                  OutputIterator last,
                  Generator &generator,
                  command_queue &queue)
    {
        size_t size = std::distance(first, last);
        typedef typename Generator::result_type g_result_type;

        vector<g_result_type> tmp(size, queue.get_context());
        vector<g_result_type> tmp2(size, queue.get_context());

        uint_ bound = ((uint_(-1))/(m_b-m_a+1))*(m_b-m_a+1);

        buffer_iterator<g_result_type> tmp2_iter;

        while(size>0)
        {
            generator.generate(tmp.begin(), tmp.begin() + size, queue);
            tmp2_iter = copy_if(tmp.begin(), tmp.begin() + size, tmp2.begin(),
                                _1 <= bound, queue);
            size = std::distance(tmp2_iter, tmp2.end());
        }

        BOOST_COMPUTE_FUNCTION(IntType, scale_random, (const g_result_type x),
        {
            return LO + (x % (HI-LO+1));
        });
예제 #2
0
  void startGraphConstruction() {
		while (opts.freeze_after_graph_creation) {}
		CkPrintf("PageRank running...\n");
		CkPrintf("\tnumber of mpi processes is %d\n", CkNumPes());
		CkPrintf("\tgraph (s=%d, k=%d), scaling: %s\n", opts.scale, opts.K, (opts.strongscale) ? "strong" : "weak");
		CkPrintf("Start graph construction:........\n");
    starttime = CkWallTimer();

		generator->generate();

		CkStartQD(CkIndex_TestDriver::doPageRank(), &thishandle);
	}
예제 #3
0
    void generate(OutputIterator first,
                  OutputIterator last,
                  Generator &generator,
                  command_queue &queue)
    {
        size_t count = detail::iterator_range_size(first, last);

        vector<uint_> tmp(count, queue.get_context());
        generator.generate(tmp.begin(), tmp.end(), queue);

        BOOST_COMPUTE_FUNCTION(bool, scale_random, (const uint_ x),
        {
            return (convert_RealType(x) / MAX_RANDOM) < PARAM;
        });
예제 #4
0
void EncoderGenerator::generate(Context* pCtx, Strategy* pWhere)
{
     Generator* pNext = next();

     int p2 = pow2(_preparations);
     
     for (int preparation = 0; preparation < p2; ++preparation)
     {
        StrategyPtr pPreparation = new Strategy(pCtx, this, preparation, _preparations);
        pWhere->pushBack(pPreparation);

        
        if (pNext)
            pNext->generate(pCtx, pPreparation);  

     }
}
예제 #5
0
int main(int argc, char *argv[])
{
   CommandLine cmdline(argc, argv);

   std::cout << "Gen tool - Copyright 2014 - Jeroen Broekhuizen" << std::endl;

   if ( cmdline.size() == 0 )
   {
      // print help information
      std::cout << "Invalid arguments.";
   }
   else
   {
      const CommandLineArgument& argument = cmdline[0];
      ASSERT(argument.getType() == CommandLineArgument::eCommand);

      Generator* pgenerator = NULL;
      if ( argument.getName() == UTEXT("project") )
      {
         pgenerator = new ProjectGenerator();
      }
      else if ( argument.getName() == UTEXT("mod") )
      {
         pgenerator = new ModuleGenerator();
      }
      else if ( argument.getName() == UTEXT("class") )
      {
         pgenerator = new ClassGenerator();
      }
      else
      {
         std::cerr << argument.getName().toUtf8() << " is not a valid target.";
         return -1;
      }

      if ( !pgenerator->generate(cmdline) )
      {
         return -2;
      }
   }

   return 0;
}
예제 #6
0
QString GeneratorSetD::generate() {

    // Ui conversion...
    if (do_ui_convert) {
        UiConverter converter;
        converter.setClasses(builder.classes());
        converter.convertToJui(ui_file_name, custom_widgets);
        return 0;
    } else if (!custom_widgets.isEmpty()) {
        fprintf(stderr, "NOTE: The --custom-widgets option only has an effect when used with --convert-to-jui");
    }

    // Code generation
    QList<Generator *> generators;
    PriGenerator *priGenerator = new PriGenerator;
    ContainerGenerator *cointainerGenerator;
    DGenerator *d_generator = 0;
    CppHeaderGenerator *cpp_header_generator = 0;
    CppImplGenerator *cpp_impl_generator = 0;
    MetaInfoGenerator *metainfo = 0;
    JumpTablePreprocessor *jumpTablePreprocessor = 0;
    JumpTableGenerator *jumpTableGenerator = 0;

    ClassFromEntry::construct(builder.classes());

    QStringList contexts;
    if (build_qdoc_japi) {
        generators << new QDocGenerator;
        contexts << "QDocGenerator";
    }

    if (native_jump_table) {
        jumpTablePreprocessor = new JumpTablePreprocessor();
        generators << jumpTablePreprocessor;
        contexts << "JumpTablePreprocessor";
    }

    if (!no_d) {
        d_generator = new DGenerator;
        d_generator->setDocumentationDirectory(doc_dir);
        d_generator->setDocumentationEnabled(docs_enabled);
        d_generator->setNativeJumpTable(native_jump_table);
        generators << d_generator;

        contexts << "JavaGenerator";
    }

    if (!no_cpp_h) {
        cpp_header_generator = new CppHeaderGenerator(priGenerator);
        generators << cpp_header_generator;
        contexts << "CppHeaderGenerator";
    }

    if (!no_cpp_impl) {
        cpp_impl_generator = new CppImplGenerator(priGenerator);
        cpp_impl_generator->setNativeJumpTable(native_jump_table);
        generators << cpp_impl_generator;
        contexts << "CppImplGenerator";
    }

    if (native_jump_table) {
        jumpTableGenerator = new JumpTableGenerator(jumpTablePreprocessor, priGenerator);
        generators << jumpTableGenerator;
        contexts << "JumpTableGenerator";
    }

    if (!no_metainfo) {
        metainfo = new MetaInfoGenerator(priGenerator);
        generators << metainfo;
        contexts << "MetaInfoGenerator";
    }

    if (build_class_list) {
        generators << new ClassListGenerator;
        contexts << "ClassListGenerator";
    }

    cointainerGenerator = new ContainerGenerator(cpp_impl_generator);


    generators << priGenerator;
    contexts << "PriGenerator";

    generators << cointainerGenerator;
    contexts << "cointainerGenerator";

    for (int i=0; i<generators.size(); ++i) {
        Generator *generator = generators.at(i);
        ReportHandler::setContext(contexts.at(i));

        generator->setOutputDirectory(outDir);
        generator->setClasses(builder.classes());
        if (printStdout)
            generator->printClasses();
        else
            generator->generate();
    }

    QString res;
    res = QString("Classes in typesystem: %1\n"
                  "Generated:\n"
                  "  - d.........: %2 (%3)\n"
                  "  - cpp-impl..: %4 (%5)\n"
                  "  - cpp-h.....: %6 (%7)\n"
                  "  - meta-info.: %8 (%9)\n"
                  "  - pri.......: %10 (%11)\n"
                  )
        .arg(builder.classes().size())
        .arg(d_generator ? d_generator->numGenerated() : 0)
        .arg(d_generator ? d_generator->numGeneratedAndWritten() : 0)
        .arg(cpp_impl_generator ? cpp_impl_generator->numGenerated() : 0)
        .arg(cpp_impl_generator ? cpp_impl_generator->numGeneratedAndWritten() : 0)
        .arg(cpp_header_generator ? cpp_header_generator->numGenerated() : 0)
        .arg(cpp_header_generator ? cpp_header_generator->numGeneratedAndWritten() : 0)
        .arg(metainfo ? metainfo->numGenerated() : 0)
        .arg(metainfo ? metainfo->numGeneratedAndWritten() : 0)
        .arg(priGenerator->numGenerated())
        .arg(priGenerator->numGeneratedAndWritten());

    return res;
}
예제 #7
0
int main(int argc, char ** argv, char** envp) {

    // Global return code
    int returnCode = 0;

    string st;
    string s;
    bool c1;
    bool c2;
    bool c3;

    if (argc < 7) {
        cmdsyntaxerror();
        return -1;
    } else {

        // Determine arguments
        //-----------------------
        QStringList includeArgs;
        string projectFile;
        string vhdlDestination;
        string vplanDestination;
        string fsmToGenerate;
        bool generateMap = false;
        bool useVerilogGenerator2 = false;
        bool genverilog1RemoveIntersections = false;
        bool errorForce = false;
        bool noChecks = false;

        for (int i = 1; i < argc; i++) {

            // Project file
            if (strcmp(argv[i], "-p") == 0) {
                projectFile.append(argv[++i]);
            } else if (strcmp(argv[i], "-vhdl") == 0) {
                vhdlDestination.append(argv[++i]);
            } else if (strcmp(argv[i], "-vplan") == 0) {
                vplanDestination.append(argv[++i]);
            } else if (strcmp(argv[i], "-fsm") == 0) {
                fsmToGenerate.append(argv[++i]);
            } else if (strcmp(argv[i], "-fmap") == 0) {
                generateMap = true;
            }  else if (strcmp(argv[i], "-force") == 0) {

                errorForce = true;
            } else if (strcmp(argv[i], "-noChecks") == 0) {

                noChecks = true;
            }


        }

        // Verify all arguments where provided
        //------------
        if (projectFile.size() == 0 || fsmToGenerate.size() == 0) {
            cmdsyntaxerror();
            return -1;
        }

        // OK Proceed to generation
        //----------------------------

        //-- Load FSMs
        LoadFactory::getLoad_I().load(projectFile);

        //-- Find the right one
        Core& core = *(Core::getInstance());
        Fsm * fsm = core.getProject()->findFSM(fsmToGenerate);

        // Not found -> fail
        if (fsm == NULL) {
            cerr << "FSM to generate " << fsmToGenerate
                    << " doesn't exist in the project file" << endl;
            cmdsyntaxerror();
            return -1;
        }

        //-- Register Verilog Generator
        GeneratorFactory::getInstance()->registerGenerator("VHDL",
                new VHDLGenerator());
        GeneratorFactory::getInstance()->registerGenerator("Simvision_Mmap",new SimvisionMmapGenerator());
        GeneratorFactory::getInstance()->registerGenerator("VPlan",new VerificationPlanGenerator());

        //-- Generate Verilog
        //------------
        if (vhdlDestination.size() > 0) {

            //-- Create Generator and generate
            Generator * generator = GeneratorFactory::getInstance()->newGenerator("VHDL");
            if (generator == NULL) {
                cerr
                        << "There are no Generator registered under the 'VHDL' name. No VHDL can generated"
                        << endl;
                return -1;
            }

            //-- Set Parameters

            //-- Open File
            QFile vhdlFile(QString::fromStdString(vhdlDestination));
            if (!vhdlFile.open(
                    QFile::Text | QFile::WriteOnly | QIODevice::Truncate)) {

                cerr
                        << "The provided file to generate verilog to cannot be opened for writing"
                        << endl;
                return -1;

            }

            //-- Error Check
            //--------------------------
            Verificator * verificator = new Verificator();
            verificator->addRule(new StateOutputsRule());
            verificator->addRule(new StateTransitions());
            verificator->addRule(new OverlappingTransitionsRule());

            //-- Start
            StdoutVerificationListener verificationListener;
            bool verifyResult = true;
            if (noChecks==false) {
                verifyResult = verificator->verify(fsm,&verificationListener);
            }

            //-- Generate only if no error and not force
            //--------------------------
            if (verifyResult==true || errorForce==true) {
                QDataStream outputStream(&vhdlFile);
                generator->generate(fsm, &outputStream);

                //---- Generate MMap If necessary
                //-----------------------
                if (generateMap == true) {

                    //-- Create Generator and generate
                    Generator * mmapGenerator =
                            GeneratorFactory::getInstance()->newGenerator(
                                    "Simvision_Mmap");
                    if (mmapGenerator == NULL) {
                        cerr
                                << "There are no Generator registered under the 'Simvision_Mmap' name. No Simvision Mmap can generated"
                                << endl;
                        return -1;
                    }

                    //-- Open File
                    QFile mmapFile(QString::fromStdString(vhdlDestination).replace(".vhdl",".svcf"));
                    if (!mmapFile.open(
                            QFile::Text | QFile::WriteOnly | QIODevice::Truncate)) {

                        cerr
                                << "The provided file to generate a simvision mmap to cannot be opened for writing"
                                << endl;
                        return -1;

                    }

                    //-- Generate
                    QDataStream mmapOutputStream(&mmapFile);
                    mmapGenerator->generate(fsm, &mmapOutputStream);

                    //-- Close
                    delete mmapGenerator;
                    mmapFile.close();

                }
                // EOF MMap

                //-- Generate Verification Plan if necessary
                //-------------
                if (vplanDestination.size() > 0) {

                    cout << "Generating VPlan to " << vplanDestination << endl;

                    //-- Generate
                    Generator * vplanGenerator =
                                            GeneratorFactory::getInstance()->newGenerator(
                                                    "VPlan");

                    //-- Open File
                    QFile vplanFile(QString::fromStdString(vplanDestination.c_str()));
                    if (!vplanFile.open(
                            QFile::Text | QFile::WriteOnly | QIODevice::Truncate)) {
                        cerr
                                << "The provided file to generate a vplan to cannot be opened for writing"
                                << endl;
                        return -1;

                    }

                    //-- Generate
                    QDataStream vplanOutputStream(&vplanFile);
                    vplanGenerator->generate(fsm, &vplanOutputStream);

                    //-- Close
                    delete vplanGenerator;
                    vplanFile.close();

                }
                // EOF VPlan

            } else {
                cerr << "An error occured while verifying FSM, so nothing was generated" << endl;
                returnCode = -1;
            }

            //-- Close
            delete generator;
            vhdlFile.close();

        }



        return returnCode;

    }
}
QString GeneratorSetDylan::generate() {

    // Code generation
    QList<Generator *> generators;
    LibraryGenerator *libraryGenerator = new LibraryGenerator;
    LidGenerator *lidGenerator = new LidGenerator;
    DylanGenerator *dylan_generator = 0;
    PlainCppHeaderGenerator *cpp_header_generator = 0;
    PlainCppImplGenerator *cpp_impl_generator = 0;

    QStringList contexts;

    dylan_generator = new DylanGenerator(libraryGenerator, lidGenerator);
    if (!javaOutDir.isNull())
        dylan_generator->setDylanOutputDirectory(javaOutDir);
    if (!outDir.isNull())
        dylan_generator->setLogOutputDirectory(outDir);
    generators << dylan_generator;

    contexts << "DylanGenerator";

    cpp_header_generator = new PlainCppHeaderGenerator(lidGenerator);
    if (!cppOutDir.isNull())
        cpp_header_generator->setCppOutputDirectory(cppOutDir);
    generators << cpp_header_generator;
    contexts << "PlainCppHeaderGenerator";

    cpp_impl_generator = new PlainCppImplGenerator(lidGenerator);
    if (!cppOutDir.isNull())
        cpp_impl_generator->setCppOutputDirectory(cppOutDir);
    generators << cpp_impl_generator;
    contexts << "PlainCppImplGenerator";

    if (!cppOutDir.isNull())
        lidGenerator->setCppOutputDirectory(cppOutDir);
    generators << lidGenerator;
    contexts << "LidGenerator";

    if (!cppOutDir.isNull())
        libraryGenerator->setOutputDirectory(cppOutDir);
    generators << libraryGenerator;
    contexts << "LibraryGenerator";

    for (int i = 0; i < generators.size(); ++i) {
        Generator *generator = generators.at(i);
        ReportHandler::setContext(contexts.at(i));

        if (generator->outputDirectory().isNull())
            generator->setOutputDirectory(outDir);
        generator->setClasses(builder.classes());
        if (printStdout)
            generator->printClasses();
        else
            generator->generate();
    }

    QString res;
    res = QString("Classes in typesystem: %1\n"
                  "Generated:\n"
                  "  - dylan.....: %2 (%3)\n"
                  "  - cpp-impl..: %4 (%5)\n"
                  "  - cpp-h.....: %6 (%7)\n"
                  "  - library...: %8 (%9)\n"
                  "  - lid.......: %10 (%11)\n"
                 )
          .arg(builder.classes().size())
          .arg(dylan_generator ? dylan_generator->numGenerated() : 0)
          .arg(dylan_generator ? dylan_generator->numGeneratedAndWritten() : 0)
          .arg(cpp_impl_generator ? cpp_impl_generator->numGenerated() : 0)
          .arg(cpp_impl_generator ? cpp_impl_generator->numGeneratedAndWritten() : 0)
          .arg(cpp_header_generator ? cpp_header_generator->numGenerated() : 0)
          .arg(cpp_header_generator ? cpp_header_generator->numGeneratedAndWritten() : 0)
          .arg(libraryGenerator->numGenerated())
          .arg(libraryGenerator->numGeneratedAndWritten())
          .arg(lidGenerator->numGenerated())
          .arg(lidGenerator->numGeneratedAndWritten());

    return res;
}