public GreenScalars Calculate(ScalarPlan plan, IEnumerable <Transceiver> transceivers, IProfiler profiler)
        {
            if (plan == null)
            {
                throw new ArgumentNullException(nameof(plan));
            }
            var trans = transceivers.ToArray();

            var notCombined = new InnerResult[trans.Length][]; //new Dictionary<Transceiver, List<InnerResult>>();

            using (profiler?.StartAuto(ProfilerEvent.GreenScalarAtoACalcCalc))
            {
                IterateParallel(trans, i =>
                {
                    notCombined[i] = CalculateByPlan(plan, trans[i].Transmitter, trans[i].Receiver);
                });
            }

            using (profiler?.StartAuto(ProfilerEvent.GreenScalarAtoAUnion))
            {
                var rho      = plan.GetSortedRho();
                var combined = notCombined.Length == 0
                    ? new SingleGreenScalar[0]
                    : InnerResultsCombiner.CreateFromSample(plan, notCombined[0])
                               .CombineSeparatedScalars(trans, notCombined);

                return(new GreenScalars(rho, combined));
            }
        }
Exemple #2
0
        private void Compute(CustomFftPlan data, Direction direction)
        {
            var buff1 = direction == Direction.Forward ? data.Input : data.Output;
            var buff2 = direction == Direction.Forward ? data.Output : data.Input;

            using (_profiler?.StartAuto(ProfilerEvent.CustomFft))
            {
                if (data.Dimension == 3)
                {
                    WithProfiler(ProfilerEvent.CustomFftFourierZ, () => FourierZ(data, direction, buff2, buff1));
                }

                WithProfiler(ProfilerEvent.CustomFftInitialTranspose, () => InitialTranspose(data, buff1, buff2));
                WithProfiler(ProfilerEvent.CustomFftFourierY, () => FourierY(data, direction, buff2, buff1));
                WithProfiler(ProfilerEvent.CustomFftBlockTransposeYtoX, () => BlockTransposeYtoX(data, buff1, buff2));
                WithProfiler(ProfilerEvent.CustomFftDistributedTranspose, () => DistributedTranspose(data, buff2, buff1));
                WithProfiler(ProfilerEvent.CustomFftFourierX, () => FourierX(data, direction, buff1, buff2));
                WithProfiler(ProfilerEvent.CustomFftDistributedTranspose, () => DistributedTranspose(data, buff2, buff1));
                WithProfiler(ProfilerEvent.CustomFftBlockTransposeXtoY, () => BlockTransposeXtoY(data, buff1, buff2));
                WithProfiler(ProfilerEvent.CustomFftFinalTranspose, () => FinalTranspose(data, buff2, buff1));
            }
        }
Exemple #3
0
        private static void PrepareBuffersForModel(ModelSize ms, INativeMemoryProvider memoryProvider, Mpi mpi, IProfiler profiler)
        {
            if (Buffers.ContainsKey(ms))
            {
                throw new InvalidOperationException("Buffer for such model size is already created");
            }

            using (profiler?.StartAuto(ProfilerEvent.FftwPlanCalculation))
            {
                var buffer = new FftBuffer(memoryProvider, profiler);

                if (IsParallel(mpi))
                {
                    buffer.AllocateBuffersAndCreatePlansParallel(ms.Nx, ms.Ny, ms.Nz, mpi);
                }
                else
                {
                    buffer.AllocateBuffersAndCreatePlansLocal(ms.Nx, ms.Ny, ms.Nz);
                }

                Buffers.Add(ms, buffer);
            }
        }