Exemplo n.º 1
0
        private unsafe void ContinueWorker(int threadId, Guid guid)
        {
            Native32.AffinitizeThreadRoundRobin((uint)threadId);

            Empty context;

            var success = inputArrays.TryTake(out Input[] inputArray);

            if (!success)
            {
                Console.WriteLine("No input array for {0}", threadId);
                return;
            }

            // Register thread with the store
            var startNum = fht.ContinueSession(guid);

            Interlocked.Increment(ref numActiveThreads);

            Console.WriteLine("Thread {0} starting from {1}", threadId, startNum + 1);

            // Prpcess the batch of input data
            fixed(Input *input = inputArray)
            {
                for (long i = startNum + 1; i < numOps; i++)
                {
                    fht.RMW(&((input + i)->adId), input + i, &context, i);

                    if ((i + 1) % checkpointInterval == 0 && numActiveThreads == threadCount)
                    {
                        if (fht.TakeFullCheckpoint(out Guid token))
                        {
                            Console.WriteLine("Calling TakeCheckpoint");
                        }
                    }

                    if (i % completePendingInterval == 0)
                    {
                        fht.CompletePending(false);
                    }
                    else if (i % refreshInterval == 0)
                    {
                        fht.Refresh();
                    }
                }
            }

            // Make sure operations are completed
            fht.CompletePending(true);

            // Deregister thread from FASTER
            fht.StopSession();

            //Interlocked.Decrement(ref numActiveThreads);

            Console.WriteLine("Populate successful on thread {0}", threadId);
        }
Exemplo n.º 2
0
        private unsafe void PopulateWorker(int threadId)
        {
            Native32.AffinitizeThreadRoundRobin((uint)threadId);

            Empty context;

            var success = inputArrays.TryTake(out Input[] inputArray);

            if (!success)
            {
                Console.WriteLine("No input array for {0}", threadId);
                return;
            }

            // Register thread with the store
            fht.StartSession();

            Interlocked.Increment(ref numActiveThreads);

            // Process the batch of input data
            var random = new Random(threadId + 1);

            threadNumOps[threadId] = (numOps / 2) + random.Next() % (numOps / 4);

            fixed(Input *input = inputArray)
            {
                for (long i = 0; i < threadNumOps[threadId]; i++)
                {
                    fht.RMW(&((input + i)->adId), input + i, &context, i);

                    if (i % completePendingInterval == 0)
                    {
                        fht.CompletePending(false);
                    }
                    else if (i % refreshInterval == 0)
                    {
                        fht.Refresh();
                    }
                }
            }

            // Make sure operations are completed
            fht.CompletePending(true);

            // Deregister thread from FASTER
            fht.StopSession();

            //Interlocked.Decrement(ref numActiveThreads);

            Console.WriteLine("Populate successful on thread {0}", threadId);
        }
Exemplo n.º 3
0
        private void PopulateWorker(int threadId)
        {
            Native32.AffinitizeThreadRoundRobin((uint)threadId);

            var success = inputArrays.TryTake(out Input[] inputArray);

            if (!success)
            {
                Console.WriteLine("No input array for {0}", threadId);
                return;
            }

            // Register thread with the store
            fht.StartSession();

            Interlocked.Increment(ref numActiveThreads);

            // Process the batch of input data
            for (long i = 0; i < numOps; i++)
            {
                fht.RMW(ref inputArray[i].adId, ref inputArray[i], Empty.Default, i);

                if ((i + 1) % checkpointInterval == 0 && numActiveThreads == threadCount)
                {
                    if (fht.TakeFullCheckpoint(out Guid token))
                    {
                        tokens.Add(token);
                    }
                }

                if (i % completePendingInterval == 0)
                {
                    fht.CompletePending(false);
                }
                else if (i % refreshInterval == 0)
                {
                    fht.Refresh();
                }
            }

            // Make sure operations are completed
            fht.CompletePending(true);

            // Deregister thread from FASTER
            fht.StopSession();

            //Interlocked.Decrement(ref numActiveThreads);

            Console.WriteLine("Populate successful on thread {0}", threadId);
        }
Exemplo n.º 4
0
        private void PopulateWorker(int threadId)
        {
            Native32.AffinitizeThreadRoundRobin((uint)threadId);

            var success = inputArrays.TryTake(out Input[] inputArray);

            if (!success)
            {
                Console.WriteLine("No input array for {0}", threadId);
                return;
            }

            // Register thread with the store
            fht.StartSession();

            Interlocked.Increment(ref numActiveThreads);

            // Process the batch of input data
            var random = new Random(threadId + 1);

            threadNumOps[threadId] = (numOps / 2); // + random.Next() % (numOps / 4);

            for (long i = 0; i < threadNumOps[threadId]; i++)
            {
                var status = fht.RMW(ref inputArray[i].adId, ref inputArray[i], Empty.Default, i);

                if (status != Status.OK && status != Status.NOTFOUND)
                {
                    throw new Exception();
                }

                if (i % completePendingInterval == 0)
                {
                    fht.CompletePending(false);
                }
                else if (i % refreshInterval == 0)
                {
                    fht.Refresh();
                }
            }

            // Make sure operations are completed
            fht.CompletePending(true);

            // Deregister thread from FASTER
            fht.StopSession();

            Console.WriteLine("Populate successful on thread {0}", threadId);
        }
Exemplo n.º 5
0
        private void PopulateWorker(int threadId)
        {
            Native32.AffinitizeThreadRoundRobin((uint)threadId);

            var success = inputArrays.TryTake(out Input[] inputArray);

            if (!success)
            {
                Console.WriteLine("No input array for {0}", threadId);
                return;
            }

            // Register thread with the store
            var session = fht.NewSession(new Functions());

            Interlocked.Increment(ref numActiveThreads);

            // Process the batch of input data
            threadNumOps[threadId] = numOps / 2;

            for (long i = 0; i < threadNumOps[threadId]; i++)
            {
                var status = session.RMW(ref inputArray[i].adId, ref inputArray[i], Empty.Default, i);

                if (status != Status.OK && status != Status.NOTFOUND)
                {
                    throw new Exception();
                }

                if (i % completePendingInterval == 0)
                {
                    session.CompletePending(false);
                }
            }

            // Make sure operations are completed
            session.CompletePending(true);

            // Deregister thread from FASTER
            session.Dispose();

            Console.WriteLine("Populate successful on thread {0}", threadId);
        }