Esempio n. 1
0
        public LayerCfg(int neuronsCount, string activationType, float layerLearnRate = 1f, ThreadingMode threadingMode = ThreadingMode.Default)
        {
            this.NeuronsCount       = neuronsCount;
            this.NeuronsWeightsSize = 0;             //Must be setted further
            string actType = (activationType == null) ? string.Empty : activationType.ToLower();

            switch (actType)
            {
            case "":
            case "default":
            case "sigmoid":
            case "logistic":
                this.ActivationType = ActivationType.Sigmoid;
                break;

            case "tanh":
                this.ActivationType = ActivationType.Tanh;
                break;

            case "relu":
                this.ActivationType = ActivationType.ReLU;
                break;

            case "lrelu":
            case "leakyrelu":
                this.ActivationType = ActivationType.LReLU;
                break;

            default:
                throw new ArgumentException($"\"{activationType}\" - invalid activation type!");
            }
            this.LayerLearnRate     = layerLearnRate;
            this.LayerThreadingMode = threadingMode;
        }
Esempio n. 2
0
        public void Launch(ThreadingMode threadingMode, bool deleteDirectoryOnLaunch)
        {
            DirectoryName           = Path.Combine(Path.GetTempPath(), $"aeron-{Environment.UserName}");
            ThreadingMode           = threadingMode;
            DeleteDirectoryOnLaunch = deleteDirectoryOnLaunch;

            LaunchInternal();
        }
Esempio n. 3
0
        public void LaunchEmbedded(ThreadingMode threadingMode)
        {
            DirectoryName           = Path.Combine(Path.GetTempPath(), $"aeron-embed-{Guid.NewGuid()}");
            ThreadingMode           = threadingMode;
            DeleteDirectoryOnLaunch = true;

            LaunchInternal();
        }
Esempio n. 4
0
 public LayerCfg(int neuronsCount, ActivationType activationType, float layerLearnRate = 1f, ThreadingMode threadingMode = ThreadingMode.Default)
 {
     this.NeuronsCount       = neuronsCount;
     this.NeuronsWeightsSize = 0;             //Must be setted further
     this.ActivationType     = activationType;
     this.LayerLearnRate     = layerLearnRate;
     this.LayerThreadingMode = threadingMode;
 }
Esempio n. 5
0
 internal LayerCfg(int neuronsCount, int neuronsWeightsSize, ActivationType activationType, float layerLearnRate, ThreadingMode threadingMode)
 {
     this.NeuronsCount       = neuronsCount;
     this.NeuronsWeightsSize = neuronsWeightsSize;
     this.ActivationType     = activationType;
     this.LayerLearnRate     = layerLearnRate;
     this.LayerThreadingMode = threadingMode;
 }
Esempio n. 6
0
        /// <summary>
        /// Set desired threading mode to all neural network layers
        /// </summary>
        /// <param name="layersThreadingMode">Layers threading mode</param>
        public void SetAllLayersThreadingMode(ThreadingMode layersThreadingMode)
        {
            var layersPtr   = LayersPtr;
            var layersCount = LayersCount;

            for (int l = 0; l < layersCount; l++)
            {
                layersPtr[l]->ThreadingMode = layersThreadingMode;
            }
        }
Esempio n. 7
0
        public static async Task Main(string[] args)
        {
            if (args.Length > 0)
            {
                for (var ii = 0; ii < args.Length; ++ii)
                {
                    var arg = args[ii];
                    string nextArg()
                    {
                        var next = ii < args.Length - 1 && args[ii + 1][0] != '-' ? args[++ii] : string.Empty;

                        if (next.Length == 0)
                        {
                            throw new ApplicationException($"Need arg value for {arg}");
                        }
                        return(next);
                    }

                    if (arg == "-u")
                    {
                        upsertThreadingMode = Enum.Parse <ThreadingMode>(nextArg(), ignoreCase: true);
                    }
                    else if (arg == "-r")
                    {
                        readThreadingMode = Enum.Parse <ThreadingMode>(nextArg(), ignoreCase: true);
                    }
                    else if (arg == "-t")
                    {
                        numTasks = int.Parse(nextArg());
                    }
                    else if (arg == "-n")
                    {
                        numOperations = int.Parse(nextArg());
                    }
                    else if (arg == "-b")
                    {
                        FasterWrapper <int, int> .useOsReadBuffering = true;
                    }
                    else if (arg == "-?" || arg == "/?" || arg == "--help")
                    {
                        Usage();
                        return;
                    }
                    else
                    {
                        throw new ApplicationException($"Unknown switch: {arg}");
                    }
                }
            }
            await ProfileStore(new FasterWrapper <int, int>());
        }
Esempio n. 8
0
        public static D2D1MetaResource <IDxgi1_2ContainerWithSwapChain> CreateForSwapChain(
            ThreadingMode threadingMode         = ThreadingMode.SingleThreaded,
            DeviceContextOptions contextOptions = DeviceContextOptions.EnableMultithreadedOptimizations,
            DebugLevel debugLevel = DebugLevel.None)
        {
            var props = new CreationProperties
            {
                DebugLevel    = debugLevel,
                ThreadingMode = threadingMode,
                Options       = contextOptions
            };

            return(CreateForSwapChainCore(ref props));
        }
Esempio n. 9
0
        /// <summary>
        /// Starts the watching
        /// </summary>
        public void Start(ThreadingMode mode = ThreadingMode.ThreadPool)
        {
            if (m_started)
            {
                return;
            }
            m_started = true;

            Log.Publish(MessageLevel.Debug, "EventTimer Started");

            m_timer          = new ScheduledTask(mode);
            m_timer.Running += TimerRunning;
            RestartTimer();
        }
Esempio n. 10
0
 /// <summary>
 /// The Constructor of the KeyInputHandler
 /// </summary>
 /// <param name="form">The Form where the KeyInputHandler should handle the Keys</param>
 /// <param name="allowHold">If it's true the KeyInputHandler will allow the holding of a Key</param>
 /// <param name="mode">It's for the Delay between the Activations of the KeyInput Methods</param>
 public KeyInputHandler(Form form, bool allowHold, ThreadingMode mode)
 {
     pressedKeys       = new List <Keys>();
     this.mode         = mode;
     this.allowHold    = allowHold;
     handlingKeyInputs = new List <IKeyInput>();
     Form           = form;
     keyInputThread = new Thread(() =>
     {
         KeyHandle();
     });
     form.KeyDown += Form_KeyDown;
     form.KeyUp   += Form_KeyUp;
 }
Esempio n. 11
0
        void TestConcurrent(ThreadingMode mode)
        {
            int workCount;

            const int Count = 100000000;
            Stopwatch sw    = new Stopwatch();

            m_doWorkCount = 0;
            using (ScheduledTask work = new ScheduledTask(mode))
            {
                work.Running += work_DoWork;

                sw.Start();
                for (int x = 0; x < 1000; x++)
                {
                    work.Start();
                }

                sw.Stop();
            }
            m_doWorkCount = 0;
            sw.Reset();

            using (ScheduledTask work = new ScheduledTask(mode))
            {
                work.Running += work_DoWork;


                sw.Start();
                ThreadPool.QueueUserWorkItem(BlastStartMethod, work);
                ThreadPool.QueueUserWorkItem(BlastStartMethod, work);

                for (int x = 0; x < Count; x++)
                {
                    work.Start();
                }
                workCount = m_doWorkCount;
                sw.Stop();
                Thread.Sleep(100);
            }

            Console.WriteLine(mode.ToString());
            Console.WriteLine(" Fire Event Count: " + workCount.ToString());
            Console.WriteLine("  Fire Event Rate: " + (workCount / sw.Elapsed.TotalSeconds / 1000000).ToString("0.00"));
            Console.WriteLine(" Total Calls Time: " + sw.Elapsed.TotalMilliseconds.ToString("0.0") + "ms");
            Console.WriteLine(" Total Calls Rate: " + (Count / sw.Elapsed.TotalSeconds / 1000000).ToString("0.00"));
            Console.WriteLine();
        }
Esempio n. 12
0
        void CheckThreadingModeProxy(List <ITestRunner> list, ITestRunner runner, ThreadingMode mode)
        {
            bool found = false;

            if ((Attribute.ThreadingMode & mode) != 0)
            {
                found = true;
            }
            else
            {
                found = tests.Any(test => (test.Attribute.ThreadingMode & mode) != 0);
            }
            if (found)
            {
                list.Add(new ThreadingModeProxyRunner(runner, mode));
            }
        }
        void TestTimed(ThreadingMode mode)
        {

            const int Count = 1000000000;
            Stopwatch sw = new Stopwatch();
            m_doWorkCount = 0;
            using (ScheduledTask work = new ScheduledTask(mode))
            {
                work.Running += work_DoWork;

                sw.Start();
                for (int x = 0; x < 1000; x++)
                {
                    work.Start(1);
                    work.Start();
                }

                sw.Stop();
            }
            m_doWorkCount = 0;
            sw.Reset();

            using (ScheduledTask work = new ScheduledTask(mode))
            {
                work.Running += work_DoWork;

                sw.Start();
                for (int x = 0; x < Count; x++)
                {
                    work.Start(1000);
                    work.Start();
                }

                sw.Stop();
            }

            Console.WriteLine(mode.ToString());
            Console.WriteLine(" Fire Event Count: " + m_doWorkCount.ToString());
            Console.WriteLine("  Fire Event Rate: " + (m_doWorkCount / sw.Elapsed.TotalSeconds / 1000000).ToString("0.00"));
            Console.WriteLine(" Total Calls Time: " + sw.Elapsed.TotalMilliseconds.ToString("0.0") + "ms");
            Console.WriteLine(" Total Calls Rate: " + (Count / sw.Elapsed.TotalSeconds / 1000000).ToString("0.00"));
            Console.WriteLine();
        }
Esempio n. 14
0
        void TestTimed(ThreadingMode mode)
        {
            const int Count = 1000000000;
            Stopwatch sw    = new Stopwatch();

            m_doWorkCount = 0;
            using (ScheduledTask work = new ScheduledTask(mode))
            {
                work.Running += work_DoWork;

                sw.Start();
                for (int x = 0; x < 1000; x++)
                {
                    work.Start(1);
                    work.Start();
                }

                sw.Stop();
            }
            m_doWorkCount = 0;
            sw.Reset();

            using (ScheduledTask work = new ScheduledTask(mode))
            {
                work.Running += work_DoWork;

                sw.Start();
                for (int x = 0; x < Count; x++)
                {
                    work.Start(1000);
                    work.Start();
                }

                sw.Stop();
            }

            Console.WriteLine(mode.ToString());
            Console.WriteLine(" Fire Event Count: " + m_doWorkCount.ToString());
            Console.WriteLine("  Fire Event Rate: " + (m_doWorkCount / sw.Elapsed.TotalSeconds / 1000000).ToString("0.00"));
            Console.WriteLine(" Total Calls Time: " + sw.Elapsed.TotalMilliseconds.ToString("0.0") + "ms");
            Console.WriteLine(" Total Calls Rate: " + (Count / sw.Elapsed.TotalSeconds / 1000000).ToString("0.00"));
            Console.WriteLine();
        }
Esempio n. 15
0
        /// <summary>
        /// Creates a <see cref="ScheduledTask"/>.
        /// </summary>
        /// <param name="threadMode">The manner in which the scheduled task executes.</param>
        /// <param name="priority">The thread priority to assign if a dedicated thread is used. This is ignored if using the thread-pool.</param>
        /// <param name="disposeOnShutdown">Adds a handler to <see cref="ShutdownHandler"/> that requires this class to be disposed
        /// when the application is shutdown. Note: If this object has been garbage collected, this will have no effect.</param>
        public ScheduledTask(ThreadingMode threadMode = ThreadingMode.ThreadPool, ThreadPriority priority = ThreadPriority.Normal, bool disposeOnShutdown = false)
        {
            m_workerThreadID = -1;
            m_waitForDispose = new ManualResetEvent(false);
            m_disposeSync    = new object();

            switch (threadMode)
            {
            case ThreadingMode.DedicatedForeground:
                m_thread = new ThreadContainerDedicated(OnRunningCallback, Dispose, false, priority, disposeOnShutdown);
                break;

            case ThreadingMode.DedicatedBackground:
                m_thread = new ThreadContainerDedicated(OnRunningCallback, Dispose, true, priority, disposeOnShutdown);
                break;

            case ThreadingMode.ThreadPool:
                m_thread = new ThreadContainerThreadpool(OnRunningCallback, Dispose, disposeOnShutdown);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(threadMode));
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Creates a <see cref="ScheduledTask"/>.
        /// </summary>
        /// <param name="threadMode">The manner in which the scheduled task executes.</param>
        /// <param name="priority">The thread priority to assign if a dedicated thread is used. This is ignored if using the thread-pool.</param>
        public ScheduledTask(ThreadingMode threadMode = ThreadingMode.ThreadPool, ThreadPriority priority = ThreadPriority.Normal)
        {
            m_workerThreadID = -1;
            m_waitForDispose = new ManualResetEvent(false);
            m_disposeSync    = new object();

            switch (threadMode)
            {
            case ThreadingMode.DedicatedForeground:
                m_thread = new ThreadContainerDedicated(new WeakAction <ThreadContainerBase.CallbackArgs>(OnRunningCallback, out m_weakCallbackToken), false, priority);
                break;

            case ThreadingMode.DedicatedBackground:
                m_thread = new ThreadContainerDedicated(new WeakAction <ThreadContainerBase.CallbackArgs>(OnRunningCallback, out m_weakCallbackToken), true, priority);
                break;

            case ThreadingMode.ThreadPool:
                m_thread = new ThreadContainerThreadpool(new WeakAction <ThreadContainerBase.CallbackArgs>(OnRunningCallback, out m_weakCallbackToken));
                break;

            default:
                throw new ArgumentOutOfRangeException("threadMode");
            }
        }
Esempio n. 17
0
        public static async Task Main(string[] args)
        {
            bool useOsReadBuffering = false;
            bool useLargeLog        = false;

            if (args.Length > 0)
            {
                for (var ii = 0; ii < args.Length; ++ii)
                {
                    var arg = args[ii];
                    string nextArg()
                    {
                        var next = ii < args.Length - 1 && args[ii + 1][0] != '-' ? args[++ii] : string.Empty;

                        if (next.Length == 0)
                        {
                            throw new ApplicationException($"Need arg value for {arg}");
                        }
                        return(next);
                    }

                    if (arg == "-u")
                    {
                        insertThreadingMode = Enum.Parse <ThreadingMode>(nextArg(), ignoreCase: true);
                    }
                    else if (arg == "-r")
                    {
                        operationThreadingMode = Enum.Parse <ThreadingMode>(nextArg(), ignoreCase: true);
                    }
                    else if (arg == "-s")
                    {
                        storageType = Enum.Parse <StorageType>(nextArg(), ignoreCase: true);
                    }
                    else if (arg == "-c")
                    {
                        numChunks = int.Parse(nextArg());
                    }
                    else if (arg == "-n")
                    {
                        numOperations = int.Parse(nextArg());
                    }
                    else if (arg == "-b")
                    {
                        useOsReadBuffering = true;
                    }
                    else if (arg == "--rmw")
                    {
                        useRmw = true;
                    }
                    else if (arg == "--upsert")
                    {
                        useUpsert = true;
                    }
                    else if (arg == "--large")
                    {
                        useLargeLog = true;
                    }
                    else if (arg == "-?" || arg == "/?" || arg == "--help")
                    {
                        Usage();
                        return;
                    }
                    else
                    {
                        throw new ApplicationException($"Unknown switch: {arg}");
                    }
                }
                if (useRmw && useUpsert)
                {
                    throw new ApplicationException("Cannot specify both RMW-only and Upsert-only");
                }
            }

            await(storageType switch
            {
                StorageType.Value => ProfileStore(new FasterWrapper <long, long>(isRefType: false, useLargeLog, useOsReadBuffering), e => (long)e, e => (long)e),
                StorageType.Reference => ProfileStore(new FasterWrapper <string, string>(isRefType: true, useLargeLog, useOsReadBuffering), e => $"key {e}", e => $"value {e}"),
                StorageType.Span => ProfileStore(new SerializedFasterWrapper <string, string>(useLargeLog, useOsReadBuffering), e => $"key {e}", e => $"value {e}"),
                _ => throw new ApplicationException($"Unknown storageType {storageType}")
            });
 /// <summary>
 ///     Sets the threading mode for the resultant <see cref="IConnectionHandler"/>.
 /// </summary>
 /// <param name="mode">The desired threading mode.</param>
 /// <returns>Itself</returns>
 public SpatialOSConnectionHandlerBuilder SetThreadingMode(ThreadingMode mode)
 {
     threadingMode = mode;
     return(this);
 }
Esempio n. 19
0
 public LayerCfg(int neuronsCount, float layerLearnRate = 1f, ThreadingMode threadingMode = ThreadingMode.Default) : this(neuronsCount, ActivationType.Sigmoid, layerLearnRate, threadingMode)
 {
 }
Esempio n. 20
0
 public static unsafe float CalcRootMeanSquaredError(float[] etalon, float[] predicted, ThreadingMode threadingMode = ThreadingMode.Default)
 {
     return((float)Math.Sqrt(CalcMeanSquaredError(etalon, predicted, threadingMode)));
 }
 public ThreadingModeProxyRunner(ITestRunner inner, ThreadingMode mode)
     : base(inner)
 {
     this.Mode = mode;
 }
        void TestConcurrent(ThreadingMode mode)
        {
            int workCount;

            const int Count = 100000000;
            Stopwatch sw = new Stopwatch();
            m_doWorkCount = 0;
            using (ScheduledTask work = new ScheduledTask(mode))
            {
                work.Running += work_DoWork;

                sw.Start();
                for (int x = 0; x < 1000; x++)
                    work.Start();

                sw.Stop();
            }
            m_doWorkCount = 0;
            sw.Reset();

            using (ScheduledTask work = new ScheduledTask(mode))
            {
                work.Running += work_DoWork;


                sw.Start();
                ThreadPool.QueueUserWorkItem(BlastStartMethod, work);
                ThreadPool.QueueUserWorkItem(BlastStartMethod, work);

                for (int x = 0; x < Count; x++)
                    work.Start();
                workCount = m_doWorkCount;
                sw.Stop();
                Thread.Sleep(100);
            }

            Console.WriteLine(mode.ToString());
            Console.WriteLine(" Fire Event Count: " + workCount.ToString());
            Console.WriteLine("  Fire Event Rate: " + (workCount / sw.Elapsed.TotalSeconds / 1000000).ToString("0.00"));
            Console.WriteLine(" Total Calls Time: " + sw.Elapsed.TotalMilliseconds.ToString("0.0") + "ms");
            Console.WriteLine(" Total Calls Rate: " + (Count / sw.Elapsed.TotalSeconds / 1000000).ToString("0.00"));
            Console.WriteLine();
        }
Esempio n. 23
0
        /// <summary>
        /// Creates a <see cref="ScheduledTask"/>.
        /// </summary>
        /// <param name="threadMode">The manner in which the scheduled task executes.</param>
        /// <param name="priority">The thread priority to assign if a dedicated thread is used. This is ignored if using the thread-pool.</param>
        /// <param name="disposeOnShutdown">Adds a handler to <see cref="ShutdownHandler"/> that requires this class to be disposed
        /// when the application is shutdown. Note: If this object has been garbage collected, this will have no effect.</param>
        public ScheduledTask(ThreadingMode threadMode = ThreadingMode.ThreadPool, ThreadPriority priority = ThreadPriority.Normal, bool disposeOnShutdown = false)
        {
            m_workerThreadID = -1;
            m_waitForDispose = new ManualResetEvent(false);
            m_disposeSync = new object();

            switch (threadMode)
            {
                case ThreadingMode.DedicatedForeground:
                    m_thread = new ThreadContainerDedicated(OnRunningCallback, Dispose, false, priority, disposeOnShutdown);
                    break;
                case ThreadingMode.DedicatedBackground:
                    m_thread = new ThreadContainerDedicated(OnRunningCallback, Dispose, true, priority, disposeOnShutdown);
                    break;
                case ThreadingMode.ThreadPool:
                    m_thread = new ThreadContainerThreadpool(OnRunningCallback, Dispose, disposeOnShutdown);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(threadMode));
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Starts the watching
        /// </summary>
        public void Start(ThreadingMode mode = ThreadingMode.ThreadPool)
        {
            if (m_started)
                return;
            m_started = true;

            Log.Publish(MessageLevel.Debug, "EventTimer Started");

            m_timer = new ScheduledTask(mode);
            m_timer.Running += TimerRunning;
            RestartTimer();
        }
Esempio n. 25
0
		void CheckThreadingModeProxy (List<ITestRunner> list, ITestRunner runner, ThreadingMode mode)
		{
			bool found = false;
			if ((Attribute.ThreadingMode & mode) != 0)
				found = true;
			else
				found = tests.Any (test => (test.Attribute.ThreadingMode & mode) != 0);
			if (found)
				list.Add (new ThreadingModeProxyRunner (runner, mode));
		}
Esempio n. 26
0
 public static unsafe float CalcMeanSquaredError(float[] etalon, float *predictedPtr, ThreadingMode threadingMode = ThreadingMode.Default)
 {
     fixed(float *etalonPtr = etalon)
     return(Native.MeanSquaredError(etalonPtr, predictedPtr, etalon.Length, threadingMode));
 }
Esempio n. 27
0
 static string threadingModeString(ThreadingMode threadingMode)
 => threadingMode switch
 {
Esempio n. 28
0
 public static unsafe float CalcRootMeanSquaredError(float *etalonPtr, float *predictedPtr, int size, ThreadingMode threadingMode = ThreadingMode.Default)
 {
     return((float)Math.Sqrt(CalcMeanSquaredError(etalonPtr, predictedPtr, size, threadingMode)));
 }
Esempio n. 29
0
        public static unsafe float CalcMeanSquaredError(float[] etalon, float[] predicted, ThreadingMode threadingMode = ThreadingMode.Default)
        {
            fixed(float *etalonPtr = etalon)
            fixed(float *predictedPtr = predicted)
            {
                int size = Math.Min(etalon.Length, predicted.Length);                 //Get size from smallest array

                return(Native.MeanSquaredError(etalonPtr, predictedPtr, size, threadingMode));
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Creates a <see cref="ScheduledTask"/>.
        /// </summary>
        /// <param name="threadMode">The manner in which the scheduled task executes.</param>
        /// <param name="priority">The thread priority to assign if a dedicated thread is used. This is ignored if using the thread-pool.</param>
        public ScheduledTask(ThreadingMode threadMode = ThreadingMode.ThreadPool, ThreadPriority priority = ThreadPriority.Normal)
        {
            m_workerThreadID = -1;
            m_waitForDispose = new ManualResetEvent(false);
            m_disposeSync = new object();

            switch (threadMode)
            {
                case ThreadingMode.DedicatedForeground:
                    m_thread = new ThreadContainerDedicated(new WeakAction<ThreadContainerBase.CallbackArgs>(OnRunningCallback, out m_weakCallbackToken), false, priority);
                    break;
                case ThreadingMode.DedicatedBackground:
                    m_thread = new ThreadContainerDedicated(new WeakAction<ThreadContainerBase.CallbackArgs>(OnRunningCallback, out m_weakCallbackToken), true, priority);
                    break;
                case ThreadingMode.ThreadPool:
                    m_thread = new ThreadContainerThreadpool(new WeakAction<ThreadContainerBase.CallbackArgs>(OnRunningCallback, out m_weakCallbackToken));
                    break;
                default:
                    throw new ArgumentOutOfRangeException("threadMode");
            }
        }
Esempio n. 31
0
 /// <summary>
 /// Add noise to float array (USE OF "SEED" IS USELESS IF YOU USE MULTITHREADING MODE!!!)
 /// </summary>
 /// <param name="array">Float array</param>
 /// <param name="noiseCoeff">Coefficient of noise. For example: 0.1f with Negative=true will generate -0.1 to 0.1</param>
 /// <param name="negative">Generate negative side of float value.</param>
 /// <param name="limit">Limit value after adding into array?</param>
 /// <param name="seed">Seed for random, 0 for random seed. (USELESS IN MULTITHREADING MODE!!!)</param>
 /// <param name="threadingMode">Threading mode. Using multithreading not recommended for small arrays (~4k or smaller)</param>
 public static unsafe void FloatArrayRandomAdd(float[] array, float noiseCoeff, bool negative, bool limit, int seed = 0, ThreadingMode threadingMode = ThreadingMode.Default)
 {
     if (seed == 0)
     {
         seed = Environment.TickCount;
         fixed(float *arrayPtr = array)
         Native.FloatArrayRandomAdd(arrayPtr, array.Length, noiseCoeff, negative, limit, seed, threadingMode);
 }
		public ThreadingModeProxyRunner (ITestRunner inner, ThreadingMode mode)
			: base (inner)
		{
			this.Mode = mode;
		}
Esempio n. 33
0
        public static async Task Main(string[] args)
        {
            bool useOsReadBuffering = false;

            if (args.Length > 0)
            {
                for (var ii = 0; ii < args.Length; ++ii)
                {
                    var arg = args[ii];
                    string nextArg()
                    {
                        var next = ii < args.Length - 1 && args[ii + 1][0] != '-' ? args[++ii] : string.Empty;

                        if (next.Length == 0)
                        {
                            throw new ApplicationException($"Need arg value for {arg}");
                        }
                        return(next);
                    }

                    if (arg == "-u")
                    {
                        upsertThreadingMode = Enum.Parse <ThreadingMode>(nextArg(), ignoreCase: true);
                    }
                    else if (arg == "-r")
                    {
                        readThreadingMode = Enum.Parse <ThreadingMode>(nextArg(), ignoreCase: true);
                    }
                    else if (arg == "-c")
                    {
                        numChunks = int.Parse(nextArg());
                    }
                    else if (arg == "-n")
                    {
                        numOperations = int.Parse(nextArg());
                    }
                    else if (arg == "-b")
                    {
                        useOsReadBuffering = true;
                    }
                    else if (arg == "-?" || arg == "/?" || arg == "--help")
                    {
                        Usage();
                        return;
                    }
                    else
                    {
                        throw new ApplicationException($"Unknown switch: {arg}");
                    }
                }
            }

            // Store with value types, no object log
            // await ProfileStore(new FasterWrapper<long, long>(useOsReadBuffering), e => (long)e, e => (long)e);

            // Store with reference types, using object log
            // await ProfileStore(new FasterWrapper<string, string>(useOsReadBuffering), e => $"key {e}", e => $"value {e}");

            // Store with reference or value types, no object log (store serialized bytes)
            await ProfileStore(new SerializedFasterWrapper <string, string>(useOsReadBuffering), e => $"key {e}", e => $"value {e}");
        }
Esempio n. 34
0
 /// <summary>
 /// Fill randomly the float array (USE OF "SEED" IS USELESS IF YOU USE MULTITHREADING MODE!!!)
 /// </summary>
 /// <param name="arrayPtr">Array pointer</param>
 /// <param name="arraySize">Array size</param>
 /// <param name="noiseCoeff">Coefficient of noise. For example: 0.1f with Negative=true will generate -0.1 to 0.1</param>
 /// <param name="negative">Generate negative side of float value.</param>
 /// <param name="seed">Seed for random, 0 for random seed. (USELESS IN MULTITHREADING MODE!!!)</param>
 /// <param name="threadingMode">Threading mode. Using multithreading not recommended for small arrays (~4k or smaller)</param>
 public static unsafe void FloatArrayRandomFill(float *arrayPtr, int arraySize, float noiseCoeff, bool negative, int seed = 0, ThreadingMode threadingMode = ThreadingMode.Default)
 {
     if (seed == 0)
     {
         seed = Environment.TickCount;
     }
     Native.FloatArrayRandomFill(arrayPtr, arraySize, noiseCoeff, negative, seed, threadingMode);
 }