예제 #1
0
        private static IEnumerable <T> StoreDate <T>(string directory,
                                                     string filename, IEnumerable <T> records)
        {
            string generated = directory + Path.DirectorySeparatorChar + "analysis" + Path.DirectorySeparatorChar + filename;

            CsvWrapper.Write(records, generated);

            return(records);
        }
예제 #2
0
        private static IEnumerable <T> ParseSource <T>(
            string directory, string folder, string filename, Func <string, IEnumerable <T> > method)
        {
            string source    = directory + Path.DirectorySeparatorChar + folder;
            string generated = directory + Path.DirectorySeparatorChar + "generated" + Path.DirectorySeparatorChar + filename;

            IEnumerable <T> records = method(source);

            CsvWrapper.Write(records, generated);

            return(records);
        }
예제 #3
0
        private static IEnumerable <GPURepairRecord> GetGPURepairRecords(string directory)
        {
            if (!Directory.Exists(directory))
            {
                return(new List <GPURepairRecord>());
            }

            IEnumerable <string>   files   = Directory.EnumerateFiles(directory, "*.metrics.csv", SearchOption.AllDirectories);
            List <GPURepairRecord> records = new List <GPURepairRecord>();

            // consolidate records from all the files in a single list

            foreach (string file in files)
            {
                IEnumerable <GPURepairRecord> list = CsvWrapper.Read <GPURepairRecord>(file);
                records.AddRange(list);
            }

            // standardize the kernel name
            records.ForEach(x => x.Kernel = Common.StandardizeKernelName(x.Kernel));

            List <GPURepairRecord> summary = new List <GPURepairRecord>();

            foreach (GPURepairRecord record in records)
            {
                // already visited this record
                if (summary.Any(x => x.Kernel == record.Kernel))
                {
                    continue;
                }

                IEnumerable <GPURepairRecord> matches = records.Where(x => x.Kernel == record.Kernel);
                summary.Add(GetGPURepairRecord(matches));
            }

            return(summary.OrderBy(x => x.Kernel));
        }
예제 #4
0
        private static IEnumerable <AutoSyncOutRecord> GetAutoSyncRecords(string directory)
        {
            if (!Directory.Exists(directory))
            {
                return(new List <AutoSyncOutRecord>());
            }

            IEnumerable <string>  files   = Directory.EnumerateFiles(directory, "*.csv", SearchOption.TopDirectoryOnly);
            List <AutoSyncRecord> records = new List <AutoSyncRecord>();

            // consolidate records from all the files in a single list
            foreach (string file in files)
            {
                IEnumerable <AutoSyncRecord> list = CsvWrapper.Read <AutoSyncRecord>(file, false);
                records.AddRange(list);
            }

            // standardize the kernel name
            records.ForEach(x => x.Kernel = Common.StandardizeKernelName(x.Kernel));

            directory = directory + Path.DirectorySeparatorChar + "gpuverify";
            IEnumerable <GPUVerifyRecord> gv_records = GetGPUVerifyRecords(directory);

            foreach (AutoSyncRecord record in records)
            {
                // AutoSync repaired but GPUVerify identified errors
                GPUVerifyRecord gv_record = gv_records.FirstOrDefault(x => x.Kernel == record.Kernel);
                if (record.Result == AutoSyncRecord.Status.Repaired)
                {
                    if (gv_record == null || gv_record.ResultEnum != GPUVerifyRecord.Status.Success)
                    {
                        record.Result = AutoSyncRecord.Status.FalsePositive;
                    }
                }

                // AutoSync did not change anything but GPUVerify identified errors
                // AutoSync should have returned a repair error in these cases
                gv_record = GPUVerify.FirstOrDefault(x => x.Kernel == record.Kernel);
                if (record.Result == AutoSyncRecord.Status.Unchanged)
                {
                    if (gv_record == null || gv_record.ResultEnum != GPUVerifyRecord.Status.Success)
                    {
                        record.Result = AutoSyncRecord.Status.FalsePositive;
                    }
                }
            }

            List <AutoSyncOutRecord> summary = new List <AutoSyncOutRecord>();

            foreach (AutoSyncRecord record in records)
            {
                // already visited this record
                if (summary.Any(x => x.Kernel == record.Kernel))
                {
                    continue;
                }

                IEnumerable <AutoSyncRecord> matches = records.Where(x => x.Kernel == record.Kernel);
                summary.Add(GetAutoSyncRecord(matches));
            }

            return(summary.OrderBy(x => x.Kernel));
        }
예제 #5
0
        public async Task Generate()
        {
            List <GPURepairTimeRecord> timings = CsvWrapper.Read <GPURepairTimeRecord>(timeFile);
            List <GPURepairRecord>     records = new List <GPURepairRecord>();

            foreach (GPURepairTimeRecord timing in timings)
            {
                timing.Kernel = Common.StandardizeKernelName(timing.Kernel);
                records.Add(new GPURepairRecord
                {
                    Kernel          = timing.Kernel,
                    Result          = timing.Result,
                    Clang           = timing.Clang,
                    Opt             = timing.Opt,
                    Bugle           = timing.Bugle,
                    Instrumentation = timing.Instrumentation,
                    VCGen           = timing.VCGen,
                    Cruncher        = timing.Cruncher,
                    Repair          = timing.Repair,
                    Total           = timing.Total,
                });
            }

            IEnumerable <string> directories = Directory.EnumerateDirectories(directory, "*", SearchOption.AllDirectories);

            foreach (string directory in directories)
            {
                GPURepairRecord record = records.FirstOrDefault(x => x.Kernel == Common.StandardizeKernelName(directory));
                if (record == null)
                {
                    continue;
                }

                foreach (string file in Directory.GetFiles(directory))
                {
                    if (file.Contains("metrics.log"))
                    {
                        string[] lines = File.ReadAllLines(file);
                        foreach (string line in lines)
                        {
                            string[] array = line.Split(new char[] { ';' });

                            if (array[0] == "Blocks")
                            {
                                record.Blocks = int.Parse(array[1]);
                            }
                            else if (array[0] == "Commands")
                            {
                                record.Commands = int.Parse(array[1]);
                            }
                            else if (array[0] == "CallCommands")
                            {
                                record.CallCommands = int.Parse(array[1]);
                            }
                            else if (array[0] == "Barriers")
                            {
                                record.Barriers = int.Parse(array[1]);
                            }
                            else if (array[0] == "GridLevelBarriers")
                            {
                                record.GridLevelBarriers = int.Parse(array[1]);
                            }
                            else if (array[0] == "LoopBarriers")
                            {
                                record.LoopBarriers = int.Parse(array[1]);
                            }
                            else if (array[0] == "Changes")
                            {
                                record.Changes = int.Parse(array[1]);
                            }
                            else if (array[0] == "SolutionCalls")
                            {
                                record.SolutionCalls = int.Parse(array[1]);
                            }
                            else if (array[0] == "SolutionGrid")
                            {
                                record.SolutionGrid = int.Parse(array[1]);
                            }
                            else if (array[0] == "SolutionLoop")
                            {
                                record.SolutionLoop = int.Parse(array[1]);
                            }
                            else if (array[0] == "RunsAfterOpt")
                            {
                                record.RunsAfterOpt = record.RunsAfterOpt + 1;
                            }
                            else if (array[0] == "FailsAfterOpt")
                            {
                                record.FailsAfterOpt = record.FailsAfterOpt + 1;
                            }
                            else if (array[0] == "ExceptionMessage")
                            {
                                record.ExceptionMessage = array[1];
                            }
                            else if (array[0] == "SourceWeight")
                            {
                                record.SourceWeight = int.Parse(array[1]);
                            }
                            else if (array[0] == "RepairedWeight")
                            {
                                record.RepairedWeight = int.Parse(array[1]);
                            }
                            else if (array[0] == "Watch")
                            {
                                if (array[1] == "MaxSAT")
                                {
                                    record.MaxSATCount = record.MaxSATCount + 1;
                                    record.MaxSATTime  = record.MaxSATTime + int.Parse(array[2]);
                                }
                                else if (array[1] == "mhs")
                                {
                                    record.mhsCount = record.mhsCount + 1;
                                    record.mhsTime  = record.mhsTime + int.Parse(array[2]);
                                }
                                else if (array[1] == "Verification")
                                {
                                    record.VerCount = record.VerCount + 1;
                                    record.VerTime  = record.VerTime + int.Parse(array[2]);
                                }
                                else if (array[1] == "Optimization")
                                {
                                    record.OptCount = record.OptCount + 1;
                                    record.OptTime  = record.OptTime + int.Parse(array[2]);
                                }
                                else if (array[1] == "SAT")
                                {
                                    record.SATCount = record.SATCount + 1;
                                    record.SATTime  = record.SATTime + int.Parse(array[2]);
                                }
                            }
                        }
                    }
                    else if (file.Contains(".cu") || file.Contains(".cl") || file.Contains(".h"))
                    {
                        record.Lines += await GetLines(file);
                    }
                }
            }

            CsvWrapper.Write(records.OrderBy(x => x.Kernel), summaryFile);
        }