Beispiel #1
0
        public Matrix <string, string, double> Normalize(Matrix <string, string, double> input, ParallelOptions parallelOptions)
        {
            Matrix <string, string, double> output = null;

            using (ParallelOptionsScope.Create(parallelOptions))
            {
                output = Normalize(input);
            }
            return(input);
        }
Beispiel #2
0
        public void NormalizeInPlace(ref ShoMatrix matrix, ParallelOptions parallelOptions)
        {
            var matrix2 = matrix;

            using (ParallelOptionsScope.Create(parallelOptions))
            {
                NormalizeInPlace(ref matrix2);
            }
            matrix = matrix2;
        }
Beispiel #3
0
        public Matrix <string, string, double> ToKernel(Matrix <string, string, double> unnormalizedInput, ParallelOptions parallelOptions, int?cidInBatchCountOrNull = null)
        {
            Matrix <string, string, double> kernel = null;

            using (ParallelOptionsScope.Create(parallelOptions))
            {
                kernel = ToKernel(unnormalizedInput, cidInBatchCountOrNull);
            }
            return(kernel);
        }
 public void ValidateCreateForThreadCount()
 {
     using (ParallelOptionsScope parallel = ParallelOptionsScope.Create(Constants.ParallelProcess))
     {
         Assert.IsNotNull(parallel);
         Assert.AreEqual(Constants.ParallelProcess, ParallelOptionsScope.Current.MaxDegreeOfParallelism);
         Assert.IsTrue(ParallelOptionsScope.Exists);
     }
     ApplicationLog.WriteLine(string.Concat(
                                  "ParallelOptionsScope BVT: Validation of Create method for thread count completed successfully."));
 }
Beispiel #5
0
        /// <summary>
        /// Runs Tasks locally on distributableObject.
        /// </summary>
        /// <param name="distributableObject">The object that will run the tasks.</param>
        public void Distribute(IDistributable distributableObject)
        {
            using (ParallelOptionsScope.Create(ParallelOptions))
            {
                distributableObject.RunTasks(Tasks, TaskCount);

                if (Cleanup)
                {
                    distributableObject.Cleanup(TaskCount);
                }
            }
        }
        public void ValidateCDispose()
        {
            ParallelOptionsScope scope = ParallelOptionsScope.Create(Constants.ParallelProcess);

            Assert.IsNotNull(scope);
            Assert.AreEqual(Constants.ParallelProcess, ParallelOptionsScope.Current.MaxDegreeOfParallelism);
            Assert.IsTrue(ParallelOptionsScope.Exists);

            scope.Dispose();
            Assert.IsFalse(ParallelOptionsScope.Exists);

            ApplicationLog.WriteLine(string.Concat(
                                         "ParallelOptionsScope BVT: Validation of Dispose method completed successfully."));
        }
        public void ValidateCreateForParallelOptions()
        {
            ParallelOptions parallel = new ParallelOptions();

            parallel.MaxDegreeOfParallelism = Constants.SerialProcess;

            ParallelOptionsScope scope = ParallelOptionsScope.Create(parallel);

            Assert.IsNotNull(scope);
            Assert.AreEqual(Constants.SerialProcess, ParallelOptionsScope.Current.MaxDegreeOfParallelism);
            Assert.IsTrue(ParallelOptionsScope.Exists);

            ApplicationLog.WriteLine(string.Concat(
                                         "ParallelOptionsScope BVT: Validation of Create method for ParallelOptions completed successfully."));
        }
 public void ValidateParallelOptionsScopeProperties()
 {
     using (ParallelOptionsScope.Create(Environment.ProcessorCount))
     {
         Assert.IsTrue(ParallelOptionsScope.Exists);
         ParallelOptions parallel = ParallelOptionsScope.Current;
         Assert.IsNotNull(parallel);
         Assert.IsNotNull(parallel.CancellationToken);
         Assert.AreEqual(Constants.SerialProcess, parallel.TaskScheduler.Id);
         Assert.AreEqual(Environment.ProcessorCount, parallel.MaxDegreeOfParallelism);
         Assert.AreEqual(1, ParallelOptionsScope.SingleThreadedOptions.MaxDegreeOfParallelism);
         Assert.AreEqual(
             Environment.ProcessorCount,
             ParallelOptionsScope.FullyParallelOptions.MaxDegreeOfParallelism);
     }
     ApplicationLog.WriteLine("Trace BVT: Validation of all ParallelOptionsScope properties completed successfully.");
 }
Beispiel #9
0
        /// <summary>
        /// Runs Tasks locally on distributableObject.
        /// </summary>
        /// <param name="distributableObject">The object that will run the tasks.</param>
        public void Distribute(IDistributable distributableObject)
        {
            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                distributableObject.Cancel();
                Environment.ExitCode = -1073741510; // exit by control break
            };

            using (ParallelOptionsScope.Create(ParallelOptions))
            {
                distributableObject.RunTasks(Tasks, TaskCount);

                if (Cleanup)
                {
                    distributableObject.Cleanup(TaskCount);
                }
            }
        }