Ejemplo n.º 1
0
        public void NewWU(FahLogParser flp, int workUnitSlotNumber, int project, int run, int clone, int gen, string fahcore)
        {
            WorkUnitSlot workUnitSlot = WorkUnitSlots.Find(x => x.WorkUnitSlotNumber == workUnitSlotNumber);

            // If work unit slot exists, remove it and log an error.
            // Very rarely the client ends a wu, but don't give a failed or Final credit.
            if (workUnitSlot != null)
            {
                // Console.WriteLine("LN:{0}:NewWU(): Work Unit Slot exists. wu_slot = {1} f_slot = {2} **********************", LineNumber, wu_slot, f_slot_number);

                if ((workUnitSlot.wu.Project == project) && (workUnitSlot.wu.Run == run) && (workUnitSlot.wu.Clone == clone) && (workUnitSlot.wu.Gen == gen))
                {
                    // Console.WriteLine("LN:{0}:NewWU(): Work Unit Slot exists, but matches. Leaving. wu_slot = {1} {2} {3} {4} {5} f_slot = {6}", LineNumber, wu_slot, project, run, clone, gen, f_slot_number);
                    return;
                }

                Console.WriteLine("LN:{0}:NewWU(): Work Unit Slot exists and doesn't match existing - Removing.wu_slot = {1} {2} {3} {4} {5} f_slot = {6}", flp.LineNumber, workUnitSlotNumber, project, run, clone, gen, FoldingSlotNumber);
                Console.WriteLine("LN:{0}:NewWU(): Work Unit Slot exists and doesn't match existing - Existing info    = {1} {2} {3} {4} {5} f_slot = {6}", flp.LineNumber, workUnitSlotNumber, workUnitSlot.wu.Project, workUnitSlot.wu.Run, workUnitSlot.wu.Clone, workUnitSlot.wu.Gen, FoldingSlotNumber);

                WorkUnitSlots.Remove(workUnitSlot);
            }
            WorkUnitSlots.Add(new WorkUnitSlot()
            {
                WorkUnitSlotNumber = workUnitSlotNumber,
                wu = { Project   = project,        Run              = run, Clone = clone, Gen = gen, Start = flp.CurrentTime, Core = fahcore,
                       StartLine = flp.LineNumber, StartLogFilename = flp.CurentFilename }
            });
        }
Ejemplo n.º 2
0
            override public bool ParseLine(FahLogParser flp, string Line)
            {
                Match m = Regex.Match(Line, time_regx + new_slot);

                if (m.Success)
                {
                    flp.NewSlot(int.Parse(m.Groups["f_slot"].Value), m.Groups["desc"].Value, m.Groups["cuda_slot"].Value);
                }
                return(m.Success);
            }
Ejemplo n.º 3
0
            // Check end of project - only take the integer portion

            override public bool ParseLine(FahLogParser flp, string Line)
            {
                Match m = Regex.Match(Line, time_regx + fsws_regx + cred);

                if (m.Success)
                {
                    flp.EndProject(int.Parse(m.Groups["wu_slot"].Value), int.Parse(m.Groups["f_slot"].Value), m.Groups["credit"].Value);
                }
                return(m.Success);
            }
Ejemplo n.º 4
0
            override public bool ParseLine(FahLogParser flp, string Line)
            {
                Match m = Regex.Match(Line, std_prepend + UnitID);

                if (m.Success)
                {
                    flp.UpdateUnitID(int.Parse(m.Groups["wu_slot"].Value), int.Parse(m.Groups["f_slot"].Value), m.Groups["UnitID"].Value);
                }
                return(m.Success);
            }
Ejemplo n.º 5
0
            override public bool ParseLine(FahLogParser flp, string Line)
            {
                Match m = Regex.Match(Line, std_prepend + new_wu);

                if (m.Success)
                {
                    flp.UpdateProject(int.Parse(m.Groups["wu_slot"].Value), int.Parse(m.Groups["f_slot"].Value), int.Parse(m.Groups["project"].Value),
                                      int.Parse(m.Groups["run"].Value), int.Parse(m.Groups["clone"].Value), int.Parse(m.Groups["gen"].Value), m.Groups["fahcore"].Value);
                }
                return(m.Success);
            }
Ejemplo n.º 6
0
            override public bool ParseLine(FahLogParser flp, string Line)
            {
                Match m = Regex.Match(Line, time_regx + cpu_desc_regex);

                if (m.Success)
                {
                    Console.WriteLine("LN:{0}:cpu_desc = {1}", flp.LineNumber, m.Groups["cpu_desc"].Value);
                    flp.CpuName = m.Groups["cpu_desc"].Value;
                }
                return(m.Success);
            }
Ejemplo n.º 7
0
            override public bool ParseLine(FahLogParser flp, string Line)
            {
                Match m = Regex.Match(Line, time_regx + "WARNING:" + fsws_regx + dumping);

                if (m.Success)
                {
                    Console.WriteLine("LN:{0}:BADWU(): Server did not like results - wu_slot {1} - f_slot {2}.", flp.LineNumber, m.Groups["wu_slot"].Value, m.Groups["f_slot"].Value);
                    flp.EndProject(int.Parse(m.Groups["wu_slot"].Value), int.Parse(m.Groups["f_slot"].Value), "-1");  //TODO: cheesy for now
                }
                return(m.Success);
            }
Ejemplo n.º 8
0
            override public bool ParseLine(FahLogParser flp, string Line)
            {
                Match m = Regex.Match(Line, std_prepend + progress);

                if (m.Success)
                {
                    flp.UpdateProgress(m.Groups["time"].Value, int.Parse(m.Groups["wu_slot"].Value), int.Parse(m.Groups["f_slot"].Value), int.Parse(m.Groups["steps"].Value),
                                       int.Parse(m.Groups["max_steps"].Value));
                }
                return(m.Success);
            }
Ejemplo n.º 9
0
            override public bool ParseLine(FahLogParser flp, string Line)
            {
                Match m = Regex.Match(Line, std_prepend + log_start);

                if (m.Success)
                {
                    DateTime dt;
                    dt = DateTime.ParseExact(m.Groups["date"].Value, "yyyy-MM-ddTHH:mm:ss", null);
                    flp.CurrentTime = dt;
                }
                return(m.Success);
            }
Ejemplo n.º 10
0
        public void UpdateUnitID(FahLogParser flp, int workUnitSlotNumber, string unitID)
        {
            WorkUnitSlot workUnitSlot = WorkUnitSlots.Find(x => x.WorkUnitSlotNumber == workUnitSlotNumber);

            // Work Unit Slot should always exist.
            if (workUnitSlot != null)
            {
                if (workUnitSlot.wu.UnitID != null)
                {
                    if (!workUnitSlot.wu.UnitID.Equals(unitID))
                    {
                        Console.WriteLine("LN:{0}:UpdateUnitID(): Unit ID's don't match. wu_slot = {1}, New UnitID = {2} Old UnitID = {3}", flp.LineNumber, workUnitSlotNumber, unitID, workUnitSlot.wu.UnitID);
                    }
                }
                workUnitSlot.wu.UnitID = unitID;
            }
            else
            {
                Console.WriteLine("LN:{0}:UpdateUnitID(): Work Unit Slot doesn't exist. wu_slot = {1} UnitID = {2}", flp.LineNumber, workUnitSlotNumber, unitID);
            }
        }
Ejemplo n.º 11
0
        public WorkUnitInfo EndWU(FahLogParser flp, int workUnitSlotNumber, int credit)
        {
            WorkUnitSlot workUnitSlot = WorkUnitSlots.Find(x => x.WorkUnitSlotNumber == workUnitSlotNumber);

            if (workUnitSlot != null)
            {
                workUnitSlot.wu.Credit         = credit;
                workUnitSlot.wu.End            = flp.CurrentTime;
                workUnitSlot.wu.EndLine        = flp.LineNumber;
                workUnitSlot.wu.EndLogFilename = flp.CurentFilename;
                workUnitSlot.wu.CpuName        = flp.CpuName;

                if (workUnitSlot.wu.Frames > 1)
                {
                    workUnitSlot.wu.TimePerFrame = TimeSpan.FromTicks(workUnitSlot.wu.TotalComputeTime.Ticks / (workUnitSlot.wu.Frames - 1));
                }

                // Calculate PPD for each WU

                TimeSpan oneDay = new TimeSpan(1, 0, 0, 0, 0);
                TimeSpan delta  = new TimeSpan();
                delta = (workUnitSlot.wu.End - workUnitSlot.wu.Start);
                double ratio = delta.TotalSeconds / oneDay.TotalSeconds;

                workUnitSlot.wu.ElapsedTimePpd = (long)(workUnitSlot.wu.Credit / ratio);

                ratio = workUnitSlot.wu.TotalComputeTime.TotalSeconds / oneDay.TotalSeconds;
                workUnitSlot.wu.ComputeTimePpd = (long)(workUnitSlot.wu.Credit / ratio);

                WorkUnitSlots.Remove(workUnitSlot);
                return(workUnitSlot.wu);
            }
            else
            {
                Console.WriteLine("LN:{0}:EndWU(): Can not find WU. wu_slot = {1} credit = {2}", flp.LineNumber, workUnitSlotNumber, credit);
                return(null);
            }
        }
Ejemplo n.º 12
0
 abstract public bool ParseLine(FahLogParser flp, string Line);
Ejemplo n.º 13
0
        public void UpdateProgress(FahLogParser flp, string time, int workUnitSlotNumber, int step, int maxSteps)
        {
            // Calculate seconds that have passed
            // Add to total WU time
            // Update Total Frames
            // Update TPF

            WorkUnitSlot workUnitSlot = WorkUnitSlots.Find(x => x.WorkUnitSlotNumber == workUnitSlotNumber);

            // If work unit slot exists, remove it and log an error.
            if (workUnitSlot == null)
            {
                Console.WriteLine("LN:{0}:UpdateProgress(): Work Unit Slot doesn't exist wu_slot = {1}", flp.LineNumber, workUnitSlotNumber);
                return;
            }

            // Convert time to time structure incorporating date
            // Cheesy but quick to write
            string DateString = flp.CurrentTime.ToString("yyyy-MM-dd") + "T" + time;

            DateTime dt;

            dt = DateTime.ParseExact(DateString, "yyyy-MM-ddTHH:mm:ss", null);
            //                    Console.Write("LN:{0}:UpdateProgress(): DateString = {1}", LineNumber, DateString);

            if (dt < flp.CurrentTime)
            {
                dt = dt.AddDays(1);
            }
            flp.CurrentTime = dt;

            if (workUnitSlot.wu.LastStep == step)
            {  // Restarting WU.
                workUnitSlot.wu.FrameTime = dt;
                return;
            }

            workUnitSlot.wu.LastStep = step;

            if (workUnitSlot.wu.Frames == 0)
            {
                // Restarting or first update
                workUnitSlot.wu.TotalComputeTime = TimeSpan.Zero;
                workUnitSlot.wu.Frames           = 1;
                workUnitSlot.wu.FrameTime        = dt;
                return;
            }

            if ((workUnitSlot.wu.FrameTime == null) || (workUnitSlot.wu.FrameTime == DateTime.MinValue))
            {
                Console.WriteLine("- SHOULD NEVER HAPPEN!!!!!");
                // Starting the WU so update the frame time
                workUnitSlot.wu.TotalComputeTime = TimeSpan.Zero;
                workUnitSlot.wu.Frames           = 1;
                workUnitSlot.wu.FrameTime        = dt;
                return;
            }

            TimeSpan tpf = dt - workUnitSlot.wu.FrameTime;

            workUnitSlot.wu.TotalComputeTime += tpf;
            workUnitSlot.wu.Frames++;
            double d = workUnitSlot.wu.TotalComputeTime.TotalSeconds;

            workUnitSlot.wu.FrameTime = dt;
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            if ((args.Count() == 1) && (args[0] == "?"))
            {
                Console.WriteLine("");
                Console.WriteLine("Parses all *.txt files in the current directory as if they were FAH log files.");
                Console.WriteLine("They are parsed in filename order which is the correct order for the logs");
                Console.WriteLine("sub-directory. The output file is formatted so it can easily be opened in");
                Console.WriteLine(" a spreadsheet and analyzed.");
                Console.WriteLine("Note: There is minimal error checking and all the console text can be ignored.");
                Console.WriteLine("");
                Console.WriteLine("Usage: FAHLogInfo ? | [outputfilename] | Console");
                Console.WriteLine("   No parameters will create a file called wus.csv with all the WU information.");
                Console.WriteLine("   ? - Gives this help");
                Console.WriteLine("   outputfilename is the name of an optional output file for the WU information.");
                Console.WriteLine("   Console will write the WU information to the Console.");
                return;
            }

            var fpl = new FahLogParser();

            // It's important to sort the filenames, because work units can span log files
            // so they must be processed in chronological order - which is how the files
            // are named.

            var files = Directory.EnumerateFiles(@".", @"*.txt")
                        .OrderBy(filename => filename).ToArray();;

            // Add ability to also process the log.txt in the parent directory.
            // Would need to change the technique used to open the file to be shared read-only.

            //  files.Add(@"../log.txt");

            foreach (string file in files)
            {
                Console.WriteLine("Processing file: {0}\n", file);
                fpl.CurentFilename = file;
                fpl.LineNumber     = 0; // super hack

                foreach (string line in ReadLines(file))
                {
                    fpl.ParseTextLine(line);
                }
            }

            fpl.EndParse();

            StreamWriter sw;

            string outputFilename;

            if (args.Count() != 0 && args[0] == "Console")
            {
                using (sw = new StreamWriter(Console.OpenStandardOutput()))
                {
                    sw.AutoFlush = true;
                    Console.SetOut(sw);
                    Console.WriteLine("Sending results to the console.");
                    fpl.ShowResults(true, true, sw);
                }
            }
            else
            {
                if (args.Count() == 0)
                {
                    outputFilename = "wus.csv";
                }
                else
                {
                    outputFilename = args[0];
                }

                try
                {
                    using (sw = new StreamWriter(outputFilename))
                    {
                        Console.WriteLine("Writing results to {0}", outputFilename);
                        fpl.ShowResults(true, true, sw);
                    }
                }
                catch (IOException ioex)
                {
                    Console.WriteLine("Cannot open output file {0} - it may be in use.", outputFilename);
                    Console.WriteLine("{0}", ioex.Message);
                }
            }
        }