Esempio n. 1
0
        public static Report BuildReport([ActivityTrigger] ReportContext ctx, ILogger log)
        {
            var repo = new InMemoryMatrixMulRepository();

            repo.StoreCalculation("an_id", ctx.Calculation);
            repo.StoreResultMatrix("an_id", ctx.Result);
            var hndlr = new FunctionHandler(repo);

            log.LogInformation($"Building Report");
            return(hndlr.GenerateReport(ctx.CallbackURL, ctx.StartTime, "an_id", ctx.WorkerCount));
        }
Esempio n. 2
0
        public static Matrix SerialMultiply([ActivityTrigger] MatrixCalculation calculation, ILogger log)
        {
            var repo = new InMemoryMatrixMulRepository();

            repo.StoreCalculation("an_id", calculation);
            var hndlr = new FunctionHandler(repo);

            log.LogInformation("Serially multiplying two matrices");
            hndlr.SerialMultiply("an_id");

            return(repo.GetResultMatrix("an_id"));
        }
Esempio n. 3
0
        public static MatrixCalculation GenerateMatrix([ActivityTrigger] CalculationConfiguration cfg, ILogger log)
        {
            var s = cfg.MatrixSize;

            log.LogInformation($"Creating Two {s}x{s} matrices");
            var repo  = new InMemoryMatrixMulRepository();
            var hndlr = new FunctionHandler(repo);
            var id    = hndlr.CreateMatrix(s, cfg.MaxValue, cfg.Seed);

            log.LogInformation($"Created MatrixCalculations with ID {id}");

            return(repo.GetCalculation(id));
        }
Esempio n. 4
0
        public static Matrix BuildResultMatrix([ActivityTrigger] BuildResultContext ctx, ILogger log)
        {
            var repo = new InMemoryMatrixMulRepository();

            repo.StoreCalculation("an_id", ctx.Calculation);
            repo.WorkerResults.Add("an_id", ctx.Results);
            var hndlr = new FunctionHandler(repo);

            log.LogInformation($"Building Result Matrix");
            hndlr.BuildResultMatrix("an_id", ctx.Results.Count);

            return(repo.GetResultMatrix("an_id"));
        }
Esempio n. 5
0
        public static ComputationResult[] ParallelMultiply([ActivityTrigger] ParallelWorkerContext ctx, ILogger log)
        {
            var repo = new InMemoryMatrixMulRepository();

            repo.StoreCalculation("an_id", ctx.Calculation);
            repo.StoreComputationTasksForWorker("an_id", ctx.WorkerID, ctx.Tasks);
            var hndlr = new FunctionHandler(repo);

            log.LogInformation($"Worker #{ctx.WorkerID} Running parallel Multiplication tasks");
            hndlr.ParallelMultiplyWorker("an_id", ctx.WorkerID);

            return(repo.GetComputationResults("an_id", ctx.WorkerID));
        }
Esempio n. 6
0
        public static Dictionary <int, ComputationTask[]> DistributeWork([ActivityTrigger] WorkDistributionContext ctx,
                                                                         ILogger log)
        {
            var repo = new InMemoryMatrixMulRepository();

            repo.StoreCalculation("an_id", ctx.Calculation);
            var hndlr = new FunctionHandler(repo);

            log.LogInformation("Scheduling Tasks");
            hndlr.ScheduleMultiplicationTasks("an_id", ctx.WorkerCount);

            return(repo.Tasks["an_id"]);
        }