Exemple #1
0
        private static void executeEvenDistributed(int fromInclusive, int toExclusive, Action <int> action)
        {
            List <ExecuteInfo> executeInfos = new List <ExecuteInfo>();

            int count = toExclusive - fromInclusive;
            int computeDeviceCount = Platform.ComputeDevices.Count;
            int workshare          = count / computeDeviceCount;
            int moreWorkCount      = count - workshare * computeDeviceCount;

            AlgorithmCharacteristics algorithmCharacteristics = new AlgorithmCharacteristics(action);

            // TODO: do something clever with algochars

            for (int i = 0; i < moreWorkCount; i++)
            {
                int from = fromInclusive + i * (workshare + 1);
                int to   = from + (workshare + 1);
                executeInfos.Add(new ExecuteInfo(from, to, action, Platform.ComputeDevices[i]));
            }

            fromInclusive = fromInclusive + moreWorkCount * (workshare + 1);

            for (int i = 0; i < computeDeviceCount - moreWorkCount; i++)
            {
                int from = fromInclusive + i * workshare;
                int to   = from + workshare;
                executeInfos.Add(new ExecuteInfo(from, to, action, Platform.ComputeDevices[i]));
            }

            System.Threading.Tasks.Parallel.ForEach(executeInfos, delegate(ExecuteInfo executeInfo) { executeInfo.Execute(); });
        }
Exemple #2
0
        public double PredictPerformance(AlgorithmCharacteristics algorithmCharacteristics)
        {
            double result = 0.0;

            foreach (ComputeDevice computeDevice in ComputeDevices)
            {
                result += computeDevice.PredictPerformance(algorithmCharacteristics);
            }

            return(result);
        }
Exemple #3
0
        public double PredictPerformance(AlgorithmCharacteristics algorithmCharacteristics)
        {
            double result = 0.0;

            foreach (ComputeUnit computeUnit in ComputeUnits)
            {
                result += computeUnit.PredictPerformance(algorithmCharacteristics);
            }

            // TODO: consider DeviceTypes
            // TODO: consider Memory

            return(result);
        }
Exemple #4
0
        public double PredictPerformance(AlgorithmCharacteristics algorithmCharacteristics)
        {
            double result = 0.0;

            foreach (ProcessingElement processingElement in ProcessingElements)
            {
                result += processingElement.ClockSpeed;
            }

            if (algorithmCharacteristics.UsesDoublePrecisionFloatingPoint && !DoublePrecisionFloatingPointSupported)
            {
                result /= 8; // TODO: check heuristics
            }
            if (algorithmCharacteristics.UsesAtomics && !AtomicsSupported)
            {
                result = 0;
            }

            // TODO: consider memory as well

            return(result);
        }