コード例 #1
0
        public node(int numOfCPUS, int numOfMems, int numOfGPUS, cpu cpuUsed, gpu gpuUsed, mem memUsed)
        {
            this.numOfCPUS = numOfCPUS;
            this.numOfMems = numOfMems;
            this.numOfGPUS = numOfGPUS;

            this.cpuUsed = cpuUsed;
            this.memUsed = memUsed;
            this.gpuUsed = gpuUsed;

            for (int k = 0; k < numOfCPUS; k++)
                cpus.Add(cpuUsed);

            for (int k = 0; k < numOfGPUS; k++)
                gpus.Add(gpuUsed);

            for (int k = 0; k < numOfMems; k++)
                mems.Add(memUsed);
        }
コード例 #2
0
        private string getBestComponents()
        {
            string msg = "-----------Best Performing Components:-----------" + Environment.NewLine;
            double fastestCPUd = 0; cpu fastestcpu = new cpu();
            double fastestGPUd = 0; gpu fastestgpu = new gpu();
            double fastestMemoryd = 0; mem fastestmem = new mem();

            foreach (cpu c in theCPUS)
            {
                if (c.calculateGFLOPS() > fastestCPUd)
                {
                    fastestCPUd = c.calculateGFLOPS();
                    fastestcpu = c;
                }
            }

            foreach (gpu g in theGPUS)
            {
                if (g.getDpTFLOPS() > fastestGPUd)
                {
                    fastestGPUd = g.getDpTFLOPS();
                    fastestgpu = g;
                }
            }

            foreach (mem m in theMems)
            {
                double measure = m.getCapacityGB() * m.getFrequencyMhz();

                if (measure > fastestMemoryd)
                {
                    fastestMemoryd = measure;
                    fastestmem = m;
                }
            }

            msg += Environment.NewLine + "CPU:\t" + fastestcpu.toString()+ Environment.NewLine;
            msg += Environment.NewLine + "GPU:\t" + fastestgpu.toString() + Environment.NewLine;
            msg += Environment.NewLine + "MEM:\t" + fastestmem.toString() + Environment.NewLine;

            msg += Environment.NewLine + "-----------Most Cost Effective Components:-----------" + Environment.NewLine;

            double costEffectiveCPUd = 0; cpu costEffectivecpu = new cpu();
            double costEffectiveGPUd = 0; gpu costEffectivegpu = new gpu();
            double costEffectiveMemoryd = 0; mem costEffectivemem = new mem();

            foreach (cpu c in theCPUS)
            {
                double measure = c.calculateGFLOPS()/c.getComponentCost();

                if (measure > costEffectiveCPUd)
                {
                    costEffectiveCPUd = measure;
                    costEffectivecpu = c;
                }
            }

            foreach (gpu g in theGPUS)
            {
                double measure = g.getSpTFLOPS()/ g.getComponentCost();

                if (measure > costEffectiveGPUd)
                {
                    costEffectiveGPUd = measure;
                    costEffectivegpu = g;
                }
            }

            foreach (mem m in theMems)
            {
                double measure = (m.getCapacityGB() * m.getFrequencyMhz())/m.getComponentCost();

                if (measure > costEffectiveMemoryd)
                {
                    costEffectiveMemoryd = measure;
                    costEffectivemem = m;
                }
            }

            msg += Environment.NewLine + "CPU:\t" + costEffectivecpu.toString() + Environment.NewLine;
            msg += Environment.NewLine + "GPU:\t" + costEffectivegpu.toString() + Environment.NewLine;
            msg += Environment.NewLine + "MEM:\t" + costEffectivemem.toString() + Environment.NewLine;

            msg += Environment.NewLine + "-----------Most Power Efficient Components:-----------" + Environment.NewLine;

            double powerEfficientCPUd = 0; cpu powerEfficientcpu = new cpu();
            double powerEfficientGPUd = 0; gpu powerEfficientgpu = new gpu();
            double powerEfficientMemoryd = 0; mem powerEfficientmem = new mem();

            foreach (cpu c in theCPUS)
            {
                double measure = c.calculateGFLOPS() / c.getComponentTDP();

                if (measure > powerEfficientCPUd)
                {
                    powerEfficientCPUd = measure;
                    powerEfficientcpu = c;
                }
            }

            foreach (gpu g in theGPUS)
            {
                double measure = g.getSpTFLOPS() / g.getComponentTDP();

                if (measure > powerEfficientGPUd)
                {
                    powerEfficientGPUd = measure;
                    powerEfficientgpu = g;
                }
            }

            foreach (mem m in theMems)
            {
                double measure = (m.getCapacityGB() * m.getFrequencyMhz()) / m.getComponentTDP();

                if (measure > powerEfficientMemoryd)
                {
                    powerEfficientMemoryd = measure;
                    powerEfficientmem = m;
                }
            }

            msg += Environment.NewLine + "CPU:\t" + powerEfficientcpu.toString() + Environment.NewLine;
            msg += Environment.NewLine + "GPU:\t" + powerEfficientgpu.toString() + Environment.NewLine;
            msg += Environment.NewLine + "MEM:\t" + powerEfficientmem.toString() + Environment.NewLine;

            return msg;
        }
コード例 #3
0
        public void initializeLists()
        {
            string cpuLines, memLines, gpuLines;

            try
            {

                cpuLines = Properties.Resources.cpus;
                memLines = Properties.Resources.mems;
                gpuLines = Properties.Resources.gpus;

                string[] lines;
                //cpus

                lines = cpuLines.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                foreach (string s in lines)
                {
                    if (!s.StartsWith("#"))
                    {
                        string[] partsC = s.Split(':');

                        String componentName = partsC[0];
                        double componentCost = double.Parse(partsC[1]);
                        double componentTDP = double.Parse(partsC[2]);
                        int frequencyMhz = int.Parse(partsC[3]);
                        int instructionsPerCycle = int.Parse(partsC[4]);
                        int numOfCores = int.Parse(partsC[5]);
                        string hyperthreaded = partsC[6];

                        bool ht = false;
                        if (hyperthreaded == "Y")
                            ht = true;

                        cpu tmp = new cpu(frequencyMhz, instructionsPerCycle, numOfCores, componentName, componentCost, componentTDP,ht);
                        theCPUS.Add(tmp);
                    }

                }
                //mems
                lines = memLines.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                foreach (string s in lines)
                {
                    if (!s.StartsWith("#"))
                    {
                        //#componentName:componentCost:componentTDP:capacityGB:frequencyMhz
                        string[] partsM = s.Split(':');

                        String componentName = partsM[0];
                        double componentCost = double.Parse(partsM[1]);
                        double componentTDP = double.Parse(partsM[2]);
                        int capacityGB = int.Parse(partsM[3]);
                        int frequencyMhz = int.Parse(partsM[4]);

                        mem tmp = new mem(capacityGB, frequencyMhz, componentName, componentCost, componentTDP);
                        theMems.Add(tmp);
                    }
                }
                //gpus

                lines = gpuLines.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                foreach (string s in lines)
                {
                    if (!s.StartsWith("#"))
                    {
                        //#componentName:componentCost:componentTDP:vramGB,sfpTFLOPS,dfpTFLOPS
                        //gpu1:117,65:200,00:2,00:2,00:1,18
                        string[] partsG = s.Split(':');

                        String componentName = partsG[0];
                        double componentCost = double.Parse(partsG[1]);
                        double componentTDP = double.Parse(partsG[2]);
                        Double vramGB = double.Parse(partsG[3]);
                        Double sfpTFLOPS = double.Parse(partsG[4]);
                        Double dfpTFLOPS = double.Parse(partsG[5]);

                        gpu tmp = new gpu(vramGB, sfpTFLOPS, dfpTFLOPS, componentName, componentCost, componentTDP);
                        theGPUS.Add(tmp);
                    }
                }

                txt_log.BeginInvoke((Action)(() =>
                                    {
                                        txt_log.AppendText("Done initializing lists: " + Environment.NewLine + Environment.NewLine + "Processors:\t\t" + theCPUS.Count + Environment.NewLine + "Graphics Processors:\t" + theGPUS.Count + Environment.NewLine + "Memory Sticks:\t\t" + theMems.Count);
                                    }));

            }
            catch (Exception ex)
            {
                txt_log.BeginInvoke((Action)(() =>
                       {
                           txt_log.Text = "ERROR LOADING INPUT DATA!";
                       }));
                Console.WriteLine("\nError loading data files.\n\n" + ex.Message);
            }
        }