Beispiel #1
0
        public void Allocate1D <T>(T _)
            where T : unmanaged
        {
            using var buffer = new MemoryBufferCache(Accelerator);

            // Allocate several elements one after another
            for (int i = 1; i <= 1024; i <<= 1)
            {
                var view = buffer.Allocate <T>(i);

                Assert.Equal(view.Length, i);
                Assert.Equal(view.LengthInBytes, Interop.SizeOf <T>() * i);

                Assert.True(buffer.CacheSizeInBytes >= Interop.SizeOf <T>() * i);
                Assert.True(buffer.GetCacheSize <T>() == i);
            }

            // "Allocate" the same elements in reverse order
            for (int i = 1024; i >= 1; i >>= 1)
            {
                var view = buffer.Allocate <T>(i);

                Assert.Equal(view.Length, i);
                Assert.Equal(view.LengthInBytes, Interop.SizeOf <T>() * i);

                Assert.True(buffer.CacheSizeInBytes >= Interop.SizeOf <T>() * i);
                Assert.True(buffer.GetCacheSize <T>() >= i);
            }
        }
 /// <summary>
 /// Constructs a new CPU-based runtime context for parallel processing.
 /// </summary>
 /// <param name="accelerator">The target CPU accelerator.</param>
 public CPURuntimeGroupContext(CPUAccelerator accelerator)
 {
     Debug.Assert(accelerator != null, "Invalid accelerator");
     Accelerator        = accelerator;
     groupBarrier       = new Barrier(0);
     sharedMemoryBuffer = new MemoryBufferCache(accelerator);
     broadcastBuffer    = accelerator.Allocate <byte>(BroadcastBufferSize);
 }
 internal RadixSortPairsProvider(
     Accelerator accelerator,
     RadixSortPairsProviderImplementation implementation)
     : base(accelerator)
 {
     bufferCache         = new MemoryBufferCache(Accelerator);
     this.implementation = implementation;
 }
Beispiel #4
0
        /// <summary>
        /// Constructs a new CPU-based runtime context for parallel processing.
        /// </summary>
        /// <param name="multiprocessor">The target CPU multiprocessor.</param>
        protected CPURuntimeContext(CPUMultiprocessor multiprocessor)
        {
            Multiprocessor = multiprocessor
                             ?? throw new ArgumentNullException(nameof(multiprocessor));

            broadcastBuffer = new MemoryBufferCache(multiprocessor.Accelerator);
            broadcastBuffer.Allocate <int>(16);
        }
Beispiel #5
0
        /// <summary>
        /// Constructs a new CPU-based runtime context for parallel processing.
        /// </summary>
        /// <param name="accelerator">The target CPU accelerator.</param>
        /// <param name="numThreadsPerWarp">The number of threads per warp.</param>
        public CPURuntimeWarpContext(CPUAccelerator accelerator, int numThreadsPerWarp)
            : base(accelerator)
        {
            WarpSize = numThreadsPerWarp;

            shuffleBuffer = new MemoryBufferCache(accelerator);
            shuffleBuffer.Allocate <int>(2 * sizeof(int) * numThreadsPerWarp);
        }
Beispiel #6
0
        /// <summary>
        /// Constructs a new CPU-based runtime context for parallel processing.
        /// </summary>
        /// <param name="accelerator">The target CPU accelerator.</param>
        protected CPURuntimeContext(CPUAccelerator accelerator)
        {
            Accelerator = accelerator
                          ?? throw new ArgumentNullException(nameof(accelerator));
            barrier = new Barrier(0);

            broadcastBuffer = new MemoryBufferCache(accelerator);
            broadcastBuffer.Allocate <int>(16);
        }
Beispiel #7
0
 /// <summary>
 /// Constructs a new allocation operation.
 /// </summary>
 public GetShuffleMemory(MemoryBufferCache shuffleBuffer, int warpSize)
 {
     ShuffleBuffer = shuffleBuffer;
     WarpSize      = warpSize;
 }
Beispiel #8
0
 internal ScanProvider(Accelerator accelerator)
     : base(accelerator)
 {
     bufferCache = new MemoryBufferCache(Accelerator);
 }
 internal RadixSortProvider(Accelerator accelerator)
     : base(accelerator)
 {
     bufferCache = new MemoryBufferCache(accelerator);
 }
 /// <summary>
 /// Constructs a new CPU-based runtime context for parallel processing.
 /// </summary>
 /// <param name="accelerator">The target CPU accelerator.</param>
 public CPURuntimeGroupContext(CPUAccelerator accelerator)
 {
     Debug.Assert(accelerator != null, "Invalid accelerator");
     groupBarrier       = new Barrier(0);
     sharedMemoryBuffer = new MemoryBufferCache(accelerator);
 }
 internal ScanProvider(Accelerator accelerator, ScanProviderImplementation implementation)
     : base(accelerator)
 {
     bufferCache         = new MemoryBufferCache(Accelerator);
     this.implementation = implementation;
 }