Beispiel #1
0
        public void RunExperiment(Grammar grm, bool nvrtc = true, bool remote = false)
        {
            Initialize(grm);  ///                                      ---  (1)  gp, grammar, population, individual


            // Evolution of generations
            for (int gen = 0; gen < GENCOUNT; gen++)
            {
                CreateSourceCodes(PARALLELISM_LEVEL); ///    ---  (2)  create source

                PTXcompile(nvrtc, remote);            ///                     ---  (3) ptx compile

                JITcompile();                         ///                     ---  (4) JIT compile

                tic();

                CreateKernelObjects();      ///                     ---

                LaunchKernels();            ///                     ---  (5)  launch kernel

                WaitCompleteAndReadBack();  ///                     ---



                GPoperations();             ///                     ---  (6) gp operations: selection, XO, mutation

                SampleCollector.Collect("other", toc());
            }
            ctx.Dispose();
        }
Beispiel #2
0
        public void WaitCompleteAndReadBack()
        {
            ctx.Synchronize();                                          // wait all to finish

            grm.ReadBackFromGPUBuffersAndComputeFitness(gp.population); //  read back from GPU memory


            Individual e = gp.getElite();

            e.elite = true;             // mark the new elite
            SampleCollector.Collect("fitness", e.fitness);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            testCaseUpDown.Value = 1024;

            var exp = new ExperimentV2();
            exp.GENCOUNT = (int)genCountUpDown.Value;
            exp.NUMTESTCASE = (int)testCaseUpDown.Value;
            exp.PARALLELISM_LEVEL = (int)parallelismUpDown.Value;
            exp.GENOME_SIZE = GENOME_SIZE;
            exp.XORATE = XORATE;
            exp.MUTATION_RATE = MUTATION_RATE;


            for (int pop = (int)popSizeUpDown.Value; pop <= popSizeMaxUpDown.Value; pop += (int)popSizeStepUpDown.Value)
            {
                exp.POPSIZE = pop;

                for (int rep = 0; rep < repeatUpDown.Value; rep++)
                {
                    textBox1.Text = string.Format("pop: {0} , rep: {1}", pop, rep);  
                    Application.DoEvents();

                    switch (comboBox1.SelectedIndex)  
                    {
                        case 0: // Multiple NVCC launch
                            exp.RunExperiment(new MulGrammar(exp.NUMTESTCASE), false, false);
                            break;
                        case 1: // Multiple remote NVRTC
                            exp.RunExperiment(new MulGrammar(exp.NUMTESTCASE), true, true);
                            break;

                        case 2: // Single thread, NVRTC
                            exp.PARALLELISM_LEVEL = 1;
                            exp.RunExperiment(new MulGrammar(exp.NUMTESTCASE), true, false);
                            break;
                    }



                    SampleCollector.SaveAsTableRow("data", "other", comboBox1.SelectedIndex, exp.POPSIZE, 1, (double)parallelismUpDown.Value);
                    SampleCollector.SaveAsTableRow("data", "JIT", comboBox1.SelectedIndex, exp.POPSIZE, 3, (double)parallelismUpDown.Value);
                    SampleCollector.SaveAsTableRow("data", "PTX", comboBox1.SelectedIndex, exp.POPSIZE, 2, (double)parallelismUpDown.Value);
                    SampleCollector.SaveAsTableRow("data", "fitness", comboBox1.SelectedIndex, exp.POPSIZE, 4, (double)parallelismUpDown.Value);
                    SampleCollector.Reset("other");
                    SampleCollector.Reset("JIT");
                    SampleCollector.Reset("PTX");
                    SampleCollector.Reset("fitness");
                }
            }
            SampleCollector.Tables["data"].SaveAsCsv("data-MUL.csv", "CompileType,PopulationSize,Total1Ptx2Jit3Fitness4,ParallelismLevel");
        }
Beispiel #4
0
        public void JITcompile()
        {
            tic();
            foreach (var sc in sourceCodes)
            {
                if (sc.ptx == null)
                {
                    sc.mod = ctx.LoadModulePTX(sc.cubin, null, null);  // no jit, just upload
                }
                else
                {
                    sc.mod = ctx.LoadModulePTX(sc.ptx); //jit
                }
            }

            SampleCollector.Collect("JIT", toc());
        }
Beispiel #5
0
 public void PTXcompile(bool nvrtc, bool remote)
 {
     tic();
     if (nvrtc)
     {
         if (remote)
         {
             // Multiple remote NVRTC
             PtxCompileRemoteMultiprocess();
         }
         else
         {
             // Single thread, NVRTC
             srcToPtx(sourceCodes[0]);
         }
     }
     else
     {
         // Multiple NVCC launch
         PtxCompileNVCCMultiprocess();
     }
     SampleCollector.Collect("PTX", toc());
 }