Example #1
0
        public MyParallelKernel(MyNode owner, int nGPU, ParallelKernelDescriptor descriptor, int bufferSize)
        {
            m_owner = owner;
            m_nGPU  = nGPU;

            m_threadCount = ThreadCount.T32;

            m_outTypeSize = descriptor.outTypeSize;
            m_inTypeSize  = descriptor.inTypeSize;

            m_TSize = Marshal.SizeOf(typeof(T));
            if (m_TSize > m_inTypeSize || m_TSize > m_outTypeSize || m_inTypeSize % m_TSize != 0 ||
                m_outTypeSize % m_TSize != 0 || m_inTypeSize == 0 || m_outTypeSize == 0)
            {
                MyLog.Writer.WriteLine(MyLogLevel.WARNING, "MyReduction.cs: MemoryBlock type can be incompatible with reduction in/out types.");
            }

            Array threadCountValues = Enum.GetValues(typeof(ThreadCount));

            m_kernels = new Dictionary <ThreadCount, MyCudaKernel>();
            foreach (ThreadCount threadCount in Enum.GetValues(typeof(ThreadCount)))
            {
                string kernelName = descriptor.GetKernelName(threadCount);
                m_kernels.Add(threadCount, MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\Reduction\Reduction", kernelName));
            }

            m_buffer       = MyMemoryManager.Instance.CreateMemoryBlock <float>(owner);
            m_buffer.Name  = "Buffer(" + descriptor.modeName + ")";
            m_buffer.Count = bufferSize;

            m_blockDims = new dim3((int)m_threadCount, 1, 1);
            m_gridDims  = new dim3(1, 1, 1);
        }
Example #2
0
        public static ParallelKernelDescriptor GetDescriptor(Type type, string name)
        {
            MemberInfo[] memInfo    = type.GetMember(name);
            object[]     attributes = memInfo[0].GetCustomAttributes(typeof(ParallelKernelDescriptor), false);
            if (attributes.Length == 0)
            {
                throw new Exception("Kernel descriptor is missing for " + name + ".");
            }
            ParallelKernelDescriptor descriptor = attributes[0] as ParallelKernelDescriptor;

            descriptor.modeName = name;
            return(descriptor);
        }
Example #3
0
 public MyProductKernel(MyNode owner, int nGPU, ProductMode mode, int bufferSize = BUFFER_SIZE)
     : base(owner, nGPU, ParallelKernelDescriptor.GetDescriptor(typeof(ProductMode), mode.ToString()), bufferSize)
 {
     ResetParameters();
 }