当前位置: 首页>>代码示例>>C#>>正文


C# ComputeCommandQueue.Unmap方法代码示例

本文整理汇总了C#中ComputeCommandQueue.Unmap方法的典型用法代码示例。如果您正苦于以下问题:C# ComputeCommandQueue.Unmap方法的具体用法?C# ComputeCommandQueue.Unmap怎么用?C# ComputeCommandQueue.Unmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ComputeCommandQueue的用法示例。


在下文中一共展示了ComputeCommandQueue.Unmap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunInternal

        protected override void RunInternal()
        {
            ComputeCommandQueue commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.Profiling);

            Console.WriteLine("Original content:");

            Random rand = new Random();
            int count = 6;
            long[] bufferContent = new long[count];
            for (int i = 0; i < count; i++)
            {
                bufferContent[i] = (long)(rand.NextDouble() * long.MaxValue);
                Console.WriteLine("\t" + bufferContent[i]);
            }

            ComputeBuffer<long> buffer = new ComputeBuffer<long>(context, ComputeMemoryFlags.CopyHostPointer, bufferContent);
            IntPtr mappedPtr = commands.Map(buffer, false, ComputeMemoryMappingFlags.Read, 0, bufferContent.Length, null);
            commands.Finish();

            Console.WriteLine("Mapped content:");

            for (int i = 0; i < bufferContent.Length; i++)
            {
                IntPtr ptr = new IntPtr(mappedPtr.ToInt64() + i * sizeof(long));
                Console.WriteLine("\t" + Marshal.ReadInt64(ptr));
            }

            commands.Unmap(buffer, ref mappedPtr, null);
        }
开发者ID:yeerkkiller1,项目名称:Go-AI,代码行数:29,代码来源:MappingTest.cs

示例2: Run

        public void Run(ComputeContext context, TextWriter log)
        {
            try
            {
                ComputeCommandQueue commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.None);

                log.WriteLine("Original content:");

                Random rand = new Random();
                int count = 6;
                long[] bufferContent = new long[count];
                for (int i = 0; i < count; i++)
                {
                    bufferContent[i] = (long)(rand.NextDouble() * long.MaxValue);
                    log.WriteLine("\t" + bufferContent[i]);
                }

                ComputeBuffer<long> buffer = new ComputeBuffer<long>(context, ComputeMemoryFlags.CopyHostPointer, bufferContent);
                
                IntPtr mappedPtr = commands.Map(buffer, true, ComputeMemoryMappingFlags.Read, 0, bufferContent.Length, null);

                log.WriteLine("Mapped content:");

                for (int i = 0; i < bufferContent.Length; i++)
                {
                    IntPtr ptr = new IntPtr(mappedPtr.ToInt64() + i * sizeof(long));
                    log.WriteLine("\t" + Marshal.ReadInt64(ptr));
                }

                commands.Unmap(buffer, ref mappedPtr, null);

                // wait for the unmap to happen
                commands.Finish();
                // cleanup buffer
                buffer.Dispose();
                // cleanup commands
                commands.Dispose();
            }
            catch (Exception e)
            {
                log.WriteLine(e.ToString());
            }
        }
开发者ID:RokkiGH,项目名称:cloo-unity,代码行数:43,代码来源:MappingExample.cs

示例3: Run

        public static void Run(TextWriter log, ComputeContext context)
        {
            StartTest(log, "Dummy test");

            try
            {
                ComputeCommandQueue commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.None);

                log.WriteLine("Original content:");

                Random rand = new Random();
                int count = 6;
                long[] bufferContent = new long[count];
                for (int i = 0; i < count; i++)
                {
                    bufferContent[i] = (long)(rand.NextDouble() * long.MaxValue);
                    log.WriteLine("\t" + bufferContent[i]);
                }

                ComputeBuffer<long> buffer = new ComputeBuffer<long>(context, ComputeMemoryFlags.CopyHostPointer, bufferContent);
                IntPtr mappedPtr = commands.Map(buffer, false, ComputeMemoryMappingFlags.Read, 0, bufferContent.Length, null);
                commands.Finish();

                log.WriteLine("Mapped content:");

                for (int i = 0; i < bufferContent.Length; i++)
                {
                    IntPtr ptr = new IntPtr(mappedPtr.ToInt64() + i * sizeof(long));
                    log.WriteLine("\t" + Marshal.ReadInt64(ptr));
                }

                commands.Unmap(buffer, ref mappedPtr, null);
            }
            catch (Exception e)
            {
                log.WriteLine(e.ToString());
            }

            EndTest(log, "Dummy test");
        }
开发者ID:kwaegel,项目名称:Cloox2,代码行数:40,代码来源:MappingTest.cs


注:本文中的ComputeCommandQueue.Unmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。