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


C# ComputeCommandQueue类代码示例

本文整理汇总了C#中ComputeCommandQueue的典型用法代码示例。如果您正苦于以下问题:C# ComputeCommandQueue类的具体用法?C# ComputeCommandQueue怎么用?C# ComputeCommandQueue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: MaterialCache

        public MaterialCache(ComputeCommandQueue commandQueue)
        {
            _commandQueue = commandQueue;

            _materialArray = new Material[DefaultCacheSize];
            Buffer = new ComputeBuffer<Material>(commandQueue.Context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.UseHostPointer, _materialArray);
        }
开发者ID:kwaegel,项目名称:muTracer,代码行数:7,代码来源:MaterialCache.cs

示例2: 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

示例3: OpenCLProxy

        public OpenCLProxy(bool useSoftware = false)
        {
            HardwareAccelerationEnabled = ComputePlatform.Platforms.Count != 0 && !useSoftware;

            if (HardwareAccelerationEnabled)
            {
                ComputePlatform platform = ComputePlatform.Platforms[0];
                var devices = new List<ComputeDevice> { platform.Devices[0] };
                var properties = new ComputeContextPropertyList(platform);

                _context = new ComputeContext(devices, properties, null, IntPtr.Zero);
                _commands = new ComputeCommandQueue(_context, _context.Devices[0], ComputeCommandQueueFlags.None);

                _intComputeBuffers = new Dictionary<string, ComputeBuffer<int>>();
                _floatComputeBuffers = new Dictionary<string, ComputeBuffer<float>>();

                AcceleratorName = platform.Name;
            }
            else
            {
                AcceleratorName = "CPU";
            }

            _intArguments = new Dictionary<string, int>();
            _intBuffers = new Dictionary<string, int[]>();

            _floatArguments = new Dictionary<string, float>();
            _floatBuffers = new Dictionary<string, float[]>();

            _doubleArguments = new Dictionary<string, double>();
        }
开发者ID:rdancer,项目名称:SpaceSim,代码行数:31,代码来源:OpenCLProxy.cs

示例4: OpenCLQueue

        internal OpenCLQueue(OpenCLContext context, ComputeCommandQueue computeCommandQueue)
        {
            Contract.Requires(context != null);
            Contract.Requires(computeCommandQueue != null);

            Context = context;
            ComputeCommandQueue = computeCommandQueue;
        } 
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:8,代码来源:OpenCLQueue.cs

示例5: GpuBvhTree

        public GpuBvhTree(ComputeCommandQueue commandQueue,
			List<Triangle> prims, List<SimplePointLight> lights, int maxPrimsPerNode)
            : base(prims, maxPrimsPerNode)
        {
            _commandQueue = commandQueue;
            _lights = lights;
            initBuffers();
        }
开发者ID:kwaegel,项目名称:muTracer,代码行数:8,代码来源:GpuBvhTree.cs

示例6: ComputeEvent

 internal ComputeEvent(IntPtr handle, ComputeCommandQueue queue)
 {
     unsafe
     {
         Handle = handle;
         commandQueue = queue;
         commandType = (ComputeCommandType)GetInfo<ComputeEventInfo, uint>(
             ComputeEventInfo.CommandType, CL10.GetEventInfo);
     }
 }
开发者ID:yeerkkiller1,项目名称:Go-AI,代码行数:10,代码来源:ComputeEvent.cs

示例7: ComputeEvent

        internal ComputeEvent(CLEventHandle handle, ComputeCommandQueue queue)
        {
            Handle = handle;
            SetID(Handle.Value);

            CommandQueue = queue;
            Type = (ComputeCommandType)GetInfo<CLEventHandle, ComputeEventInfo, int>(Handle, ComputeEventInfo.CommandType, CLInterface.CL10.GetEventInfo);
            Context = queue.Context;

            if (ComputeTools.ParseVersionString(CommandQueue.Device.Platform.Version, 1) > new Version(1, 0))
                HookNotifier();
        }
开发者ID:nathanpackard,项目名称:openCLoo,代码行数:12,代码来源:ComputeEvent.cs

示例8: ComputeEvent

        internal ComputeEvent(CLEventHandle handle, ComputeCommandQueue queue)
        {
            Handle = handle;
            SetID(Handle.Value);

            CommandQueue = queue;
            Type = (ComputeCommandType)GetInfo<CLEventHandle, ComputeEventInfo, int>(Handle, ComputeEventInfo.CommandType, CL10.GetEventInfo);
            Context = queue.Context;

            if (ComputeTools.ParseVersionString(CommandQueue.Device.Platform.Version, 1) > new Version(1, 0))
                HookNotifier();

            Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
开发者ID:JustasB,项目名称:cudafy,代码行数:14,代码来源:ComputeEvent.cs

示例9: Run

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

            try
            {
                log.Write("Creating command queue... ");
                ComputeCommandQueue commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.None);
                log.WriteLine("done.");

                int width = 16;
                int height = 16;

                log.Write("Creating first bitmap and drawing shapes... ");
                Bitmap firstBitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                Graphics graphics = Graphics.FromImage(firstBitmap);
                graphics.FillEllipse(Brushes.Red, 0, 0, width / 2, height / 2);
                graphics.FillRectangle(Brushes.Green, width / 2 + 1, 0, width / 2, height / 2);
                graphics.FillRectangle(Brushes.Blue, width / 2 + 1, height / 2 + 1, width / 2, height / 2);
                log.WriteLine("done.");

                log.Write("Creating OpenCL image object from first bitmap... ");
                ComputeImage2D clImage = new ComputeImage2D(context, ComputeMemoryFlags.ReadWrite | ComputeMemoryFlags.CopyHostPointer, firstBitmap);
                log.WriteLine("done.");

                log.Write("Creating second bitmap... ");
                Bitmap secondBitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                BitmapData bmpData = secondBitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, secondBitmap.PixelFormat);
                log.WriteLine("done.");

                log.Write("Reading from OpenCL image object... ");
                commands.ReadFromImage(clImage, bmpData.Scan0, true, null);
                log.WriteLine("done.");

                secondBitmap.UnlockBits(bmpData);

                log.Write("Comparing bitmaps... ");
                for (int i = 0; i < width; i++)
                    for (int j = 0; j < height; j++)
                        if (firstBitmap.GetPixel(i, j) != secondBitmap.GetPixel(i, j))
                            throw new Exception("Image data mismatch!");
                log.WriteLine("passed.");
            }
            catch (Exception e)
            {
                log.WriteLine(e.ToString());
            }

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

示例10: ComputeEvent

        internal ComputeEvent(IntPtr handle, ComputeCommandQueue queue)
        {
            unsafe
            {
                Handle = handle;
                CommandQueue = queue;
                Type = (ComputeCommandType)GetInfo<ComputeEventInfo, uint>(
                    ComputeEventInfo.CommandType, CL10.GetEventInfo);
                Context = queue.Context;

                if (CommandQueue.Device.Version == new Version(1, 1))
                    HookNotifier();

                Completed += new ComputeCommandStatusChanged(ComputeEvent_Fired);
                Aborted += new ComputeCommandStatusChanged(ComputeEvent_Fired);
            }
        }
开发者ID:yeerkkiller1,项目名称:Go-AI,代码行数:17,代码来源:ComputeEvent.cs

示例11: SetupDevice

 public void SetupDevice(params string[] kernelNames) {
     try {
         this.program.Build(new[] { device }, string.Empty, null, IntPtr.Zero);
     }
     catch (Exception) {
         Tracer.TraceLine(this.program.GetBuildLog(ComputePlatform.Platforms[0].Devices[0]));
         throw;
     }
     if (kernelNames.Length > 1)
     {
         kernels = program.CreateAllKernels().ToDictionary(item => item.FunctionName);
     }
     else
     {
         kernel = program.CreateKernel(kernelNames[0]);                
     }
     commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.None);
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:18,代码来源:ClDeviceContext.cs

示例12: ConductSearch

        private static void ConductSearch(ComputeContext context, ComputeKernel kernel)
        {
            var todos = GetQueenTaskPartition(NumQueens, 4);
            var done = new List<QueenTask>();

            ComputeEventList eventList = new ComputeEventList();

            var commands = new ComputeCommandQueue(context, context.Devices[1], ComputeCommandQueueFlags.None);

            Console.WriteLine("Starting {0} tasks, and working {1} at a time.", todos.Count, Spread);

            QueenTask[] inProgress = GetNextAssignment(new QueenTask[] {}, todos, done);

            var sw = new Stopwatch();
            sw.Start();

            while (inProgress.Any())
            {
                var taskBuffer =
                    new ComputeBuffer<QueenTask>(context,
                        ComputeMemoryFlags.ReadWrite | ComputeMemoryFlags.CopyHostPointer,
                        inProgress);

                kernel.SetMemoryArgument(0, taskBuffer);
                commands.WriteToBuffer(inProgress, taskBuffer, false, null);

                for (int i = 0; i < 12; i++)
                    commands.Execute(kernel, null, new long[] { inProgress.Length }, null, eventList);

                commands.ReadFromBuffer(taskBuffer, ref inProgress, false, eventList);
                commands.Finish();

                inProgress = GetNextAssignment(inProgress, todos, done);
            }

            sw.Stop();

            Console.WriteLine(sw.ElapsedMilliseconds / 1000.0);

            ulong sum = done.Select(state => state.solutions)
                            .Aggregate((total, next) => total + next);

            Console.WriteLine("Q({0})={1}", NumQueens, sum);
        }
开发者ID:peterallenwebb,项目名称:GpuQueens,代码行数:44,代码来源:Program.cs

示例13: 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

示例14: ComputeEvent

        internal ComputeEvent(IntPtr handle, ComputeCommandQueue queue)
        {
            unsafe
            {
                Handle = handle;
                CommandQueue = queue;
                Type = (ComputeCommandType)GetInfo<ComputeEventInfo, uint>(
                    ComputeEventInfo.CommandType, CL10.GetEventInfo);
                Context = queue.Context;

                if (CommandQueue.Device.Version == new Version(1, 1))
                    HookNotifier();

                Completed += new ComputeCommandStatusChanged(ComputeEvent_Fired);
                Aborted += new ComputeCommandStatusChanged(ComputeEvent_Fired);
            }

            Trace.WriteLine("Created " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").");
        }
开发者ID:JacindaChen,项目名称:TronCell,代码行数:19,代码来源:ComputeEvent.cs

示例15: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。