コード例 #1
0
        public void GlobalSetup()
        {
            intPool   = new AlignedArrayPool <int>();
            shortPool = new AlignedArrayPool <short>();
            longPool  = new AlignedArrayPool <long>();

            intData    = intPool.Rent(NumberOfItems);
            intStore   = intPool.Rent(NumberOfItems);
            bmpData    = intPool.Rent(bmpWidth * bmpHeight * 4);
            bmpStore   = intPool.Rent(bmpWidth * bmpHeight * 4);
            shortData  = shortPool.Rent(NumberOfItems);
            shortStore = shortPool.Rent(NumberOfItems);
            longData   = longPool.Rent(NumberOfItems);
            longStore  = longPool.Rent(NumberOfItems);

            var r = new Random(1);

            for (int i = 0; i < NumberOfItems; i++)
            {
                intData.Memory.Span[i]    = i * 2 + r.Next(-1000, 1000);
                intStore.Memory.Span[i]   = i + r.Next(-1000, 1000);
                shortData.Memory.Span[i]  = (short)intData.Memory.Span[i];
                shortStore.Memory.Span[i] = (short)intStore.Memory.Span[i];
                longData.Memory.Span[i]   = intData.Memory.Span[i];
                longStore.Memory.Span[i]  = intStore.Memory.Span[i];
            }
            for (int i = 0; i < bmpData.Memory.Span.Length; i++)
            {
                bmpData.Memory.Span[i] = i;
            }
        }
コード例 #2
0
        public unsafe void GlobalSetup()
        {
            vectorFloatStep     = Vector256 <float> .Count;
            numberOfFloatItems  = NumberOfBytes / sizeof(float);
            vectorNumberOfItems = numberOfFloatItems / vectorFloatStep;

            dataMemory    = alignedArrayPool.Rent(numberOfFloatItems);
            storeMemory   = alignedArrayPool.Rent(numberOfFloatItems);
            data16Memory  = alignedArrayPool.Rent(numberOfFloatItems, 16);
            store16Memory = alignedArrayPool.Rent(numberOfFloatItems, 16);

            for (int i = 0; i < numberOfFloatItems; i++)
            {
                dataMemory.Memory.Span[i]   = i;
                data16Memory.Memory.Span[i] = i;
            }
        }
コード例 #3
0
        public unsafe void GlobalSetup()
        {
            numberOfItems      = l1CacheSize / sizeof(double) / 2 - 8;
            floatPool          = new AlignedArrayPool <float>();
            doublePool         = new AlignedArrayPool <double>();
            dataMemory         = floatPool.Rent(numberOfItems);
            resultMemory       = floatPool.Rent(numberOfItems);
            dataDoubleMemory   = doublePool.Rent(numberOfItems);
            resultDoubleMemory = doublePool.Rent(numberOfItems);
            Span <float>  dataSpan         = new Span <float>(dataMemory.MemoryHandle.Pointer, numberOfItems);
            Span <float>  resultSpan       = new Span <float>(resultMemory.MemoryHandle.Pointer, numberOfItems);
            Span <double> dataDoubleSpan   = new Span <double>(dataDoubleMemory.MemoryHandle.Pointer, numberOfItems);
            Span <double> resultDoubleSpan = new Span <double>(resultDoubleMemory.MemoryHandle.Pointer, numberOfItems);

            for (int i = 0; i < numberOfItems; i++)
            {
                dataSpan[i]         = i + 0.01f;
                resultSpan[i]       = 0.0f;
                dataDoubleSpan[i]   = i + 0.01;
                resultDoubleSpan[i] = 0.0;
            }
        }