示例#1
0
        private ExampleBase.RunResult executeGpu(ExampleBase example, double sizeFactor)
        {
            const bool CpuViaOpenCL = true;

            ExampleBase.RunResult runResultGPU = null;
            if (!SystemCharacteristics.Platform.ContainsAGpu && !CpuViaOpenCL)
            {
                logWriteLine("[GPU]       No GPUs available!");
            }
            else
            {
                logWrite("[GPU]       ");
                runResultGPU = runExample(example, Execute.OnSingleGpu, sizeFactor);
                Parallel.ReInitialize();
            }

            if (runResultGPU == null)
            {
                runResultGPU = new ExampleBase.RunResult();
                {
                    runResultGPU.Valid = false;
                    runResultGPU.ElapsedTotalSeconds = -1;
                };
            }
            return(runResultGPU);
        }
示例#2
0
        private void runExample(ExampleBase example, double sizeFactor)
        {
            ExampleBase.RunResult runResultSerial    = executeSerial(example, sizeFactor);
            ExampleBase.RunResult runResultParallel  = executeParallel(example, sizeFactor);
            ExampleBase.RunResult runResultGPU       = executeGpu(example, sizeFactor);
            ExampleBase.RunResult runResultAutomatic = executeAutomatic(example, sizeFactor);

            logWriteLine();

            writeOutputs(example, runResultSerial, runResultParallel, runResultGPU, runResultAutomatic);
            //writeOutputs(example, runResultGPU, runResultGPU, runResultGPU, runResultGPU);
        }
示例#3
0
        private ExampleBase.RunResult executeSerial(ExampleBase example, double sizeFactor)
        {
            logWrite("[Serial]    ");
            ExampleBase.RunResult runResultSerial = runExample(example, Execute.OnSingleCpu, sizeFactor);

            if (runResultSerial == null)
            {
                runResultSerial = new ExampleBase.RunResult();
                {
                    runResultSerial.Valid = false;
                    runResultSerial.ElapsedTotalSeconds = -1;
                };
            }
            return(runResultSerial);
        }
示例#4
0
        private ExampleBase.RunResult executeParallel(ExampleBase example, double sizeFactor)
        {
            logWrite("[Parallel]  ");
            ExampleBase.RunResult runResultParallel = runExample(example, Execute.OnAllCpus, sizeFactor);

            if (runResultParallel == null)
            {
                runResultParallel = new ExampleBase.RunResult();
                {
                    runResultParallel.Valid = false;
                    runResultParallel.ElapsedTotalSeconds = -1;
                };
            }
            return(runResultParallel);
        }
示例#5
0
        private void writeOutputs(ExampleBase example, ExampleBase.RunResult runResultSerial, ExampleBase.RunResult runResultParallel, ExampleBase.RunResult runResultGPU, ExampleBase.RunResult runResultAutomatic)
        {
            reasonablyEqual(runResultSerial, runResultParallel);
            reasonablyEqual(runResultSerial, runResultGPU);
            reasonablyEqual(runResultSerial, runResultAutomatic);

            double relSerial = runResultSerial.RelativeExecutionTime(runResultSerial.ElapsedTotalSeconds);
            double relCPUs   = runResultParallel.RelativeExecutionTime(runResultSerial.ElapsedTotalSeconds);
            double relGPU    = runResultGPU.RelativeExecutionTime(runResultSerial.ElapsedTotalSeconds);
            double relAll    = runResultAutomatic.RelativeExecutionTime(runResultSerial.ElapsedTotalSeconds);

            csv.WriteLine(example.Name + ";" + runResultSerial.SizeX + ";" + runResultSerial.SizeY + ";" + runResultSerial.SizeZ + ";"
                          + runResultSerial.ElapsedTotalSeconds + ";" + runResultParallel.ElapsedTotalSeconds + ";" + runResultGPU.ElapsedTotalSeconds + ";" + runResultAutomatic.ElapsedTotalSeconds + ";"
                          + relSerial + ";" + relCPUs + ";" + relGPU + ";" + relAll + ";");
            csv.Flush();
        }
示例#6
0
        private ExampleBase.RunResult executeAutomatic(ExampleBase example, double sizeFactor)
        {
            logWrite("[Automatic] ");
            ExampleBase.RunResult runResultAutomatic = runExample(example, Execute.OnEverythingAvailable, sizeFactor);
            Parallel.ReInitialize();

            if (runResultAutomatic == null)
            {
                runResultAutomatic = new ExampleBase.RunResult();
                {
                    runResultAutomatic.Valid = false;
                    runResultAutomatic.ElapsedTotalSeconds = -1;
                };
            }
            return(runResultAutomatic);
        }
示例#7
0
        private void reasonablyEqual(ExampleBase.RunResult one, ExampleBase.RunResult other)
        {
            if (!other.Valid)
            {
                return;
            }

            if (!one.Valid)
            {
                logWriteLine("!!!!!!!!!!!!!!!!!!!!!!");
                logWriteLine("!!!!ONE IS INVALID!!!!");
                logWriteLine("!!!!!!!!!!!!!!!!!!!!!!");
            }

            if (one.SizeX != other.SizeX || one.SizeY != other.SizeY || one.SizeZ != other.SizeZ || one.Name != other.Name)
            {
                logWriteLine("!!!!!!!!!!!!!!!!!!!!!");
                logWriteLine("!!!!INVALID STATE!!!!");
                logWriteLine("!!!!!!!!!!!!!!!!!!!!!");
                throw new Exception("Invalid state!!");
            }
        }
示例#8
0
        private void runExampleGpuAndAutomaticOnly(ExampleBase example, double sizeFactor)
        {
            ExampleBase.RunResult runResultSerial = new ExampleBase.RunResult();
            {
                runResultSerial.Valid = true;
                runResultSerial.ElapsedTotalSeconds = 1;
                runResultSerial.SizeX = sizeFactor;
                runResultSerial.SizeY = sizeFactor;
                runResultSerial.SizeZ = sizeFactor;
                runResultSerial.Name  = example.Name;
            }; //executeSerial(example, sizeFactor);
            ExampleBase.RunResult runResultParallel  = executeParallel(example, sizeFactor);
            ExampleBase.RunResult runResultGPU       = executeGpu(example, sizeFactor);
            ExampleBase.RunResult runResultAutomatic = new ExampleBase.RunResult();
            {
                runResultAutomatic.Valid = false;
                runResultAutomatic.ElapsedTotalSeconds = -1;
            }; //executeAutomatic(example, sizeFactor);

            logWriteLine();

            writeOutputs(example, runResultSerial, runResultParallel, runResultGPU, runResultAutomatic);
        }