• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ComputeCommandQueue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: VoxelGrid

        public VoxelGrid(ComputeCommandQueue commandQueue, float gridWidth, int gridResolution)
        {
            _commandQueue = commandQueue;

            _gridWidth = gridWidth;
            GridResolution = gridResolution;
            CellSize = gridWidth / gridResolution;

            Vector3 halfGridWidth = new Vector3(gridWidth/2.0f, gridWidth/2.0f, gridWidth/2.0f);
            _gridOrigin = -halfGridWidth;

            // Create voxel grid. gridResolution^3 cells
            int cellCount = gridResolution * gridResolution * gridResolution;
            _voxelArray = new Voxel[cellCount];

            unsafe
            {
                fixed (Voxel* gridData = _voxelArray)
                {
                    _grid = new ComputeImage3D(_commandQueue.Context,
                        ComputeMemoryFlags.CopyHostPointer | ComputeMemoryFlags.ReadOnly,
                        _imageFormat,
                        GridResolution, GridResolution, GridResolution,
                        0, 0,
                        (IntPtr)gridData);
                }
            }

            // Create array to hold primitives.
            VectorsPerVoxel = 16;	// Low value for testing;
            _geometryArray = new Triangle[cellCount * VectorsPerVoxel];
            Geometry = new ComputeBuffer<Triangle>(_commandQueue.Context, ComputeMemoryFlags.ReadWrite | ComputeMemoryFlags.UseHostPointer, _geometryArray);

            // Create array for lights
            _pointLightArray = new SimplePointLight[InitialPointLightArraySize];
            PointLightCount = 0;
            _pointLightBuffer = new ComputeBuffer<SimplePointLight>(_commandQueue.Context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.UseHostPointer, _pointLightArray);

            syncBuffers();
        }
开发者ID:kwaegel,项目名称:muTracer,代码行数:40,代码来源:VoxelGrid.cs


示例17: GraphicsInterop

        public GraphicsInterop()
        {
            var glHandle = ((IGraphicsContextInternal)GraphicsContext.CurrentContext).Context.Handle;
            var wglHandle = wglGetCurrentDC();
            _device = ComputePlatform.Platforms[0].Devices[0];
            var p1 = new ComputeContextProperty(ComputeContextPropertyName.Platform, Device.Platform.Handle.Value);
            var p2 = new ComputeContextProperty(ComputeContextPropertyName.CL_GL_CONTEXT_KHR, glHandle);
            var p3 = new ComputeContextProperty(ComputeContextPropertyName.CL_WGL_HDC_KHR, wglHandle);
            var cpl = new ComputeContextPropertyList(new[] { p1, p2, p3 });
            _context = new ComputeContext(ComputeDeviceTypes.Gpu, cpl, null, IntPtr.Zero);
            _queue = new ComputeCommandQueue(Context, Device, ComputeCommandQueueFlags.None);

            GL.ClearColor(0f, 0f, 1f, 1f);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, 1.0f, 0, 1.0f, -1.0f, 1.0f);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.GenBuffers(1, out _pub);
            GL.Enable(EnableCap.Texture2D);
            _texture = GL.GenTexture();
        }
开发者ID:khyperia,项目名称:Scatterlight,代码行数:22,代码来源:GraphicsInterop.cs


示例18: RunInternal

        protected override void RunInternal()
        {
            int count = 10;
            float[] arrA = new float[count];
            float[] arrB = new float[count];
            float[] arrC = new float[count];

            Random rand = new Random();

            for (int i = 0; i < count; i++)
            {
                arrA[i] = (float)(rand.NextDouble() * 100);
                arrB[i] = (float)(rand.NextDouble() * 100);
            }

            ComputeBuffer<float> a = new ComputeBuffer<float>(context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.CopyHostPointer, arrA);
            ComputeBuffer<float> b = new ComputeBuffer<float>(context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.CopyHostPointer, arrB);
            ComputeBuffer<float> c = new ComputeBuffer<float>(context, ComputeMemoryFlags.WriteOnly, arrC.Length);

            ComputeProgram program = new ComputeProgram(context, new string[] { kernelSource });
            program.Build(null, null, null, IntPtr.Zero);

            ComputeKernel kernel = program.CreateKernel("VectorAdd");
            kernel.SetMemoryArgument(0, a);
            kernel.SetMemoryArgument(1, b);
            kernel.SetMemoryArgument(2, c);

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

            ComputeEventList events = new ComputeEventList();

            commands.Execute(kernel, null, new long[] { count }, null, events);

            arrC = new float[count];
            GCHandle arrCHandle = GCHandle.Alloc(arrC, GCHandleType.Pinned);

            commands.Read(c, false, 0, count, arrCHandle.AddrOfPinnedObject(), events);
            commands.Finish();

            arrCHandle.Free();

            for (int i = 0; i < count; i++)
                Console.WriteLine("{0} + {1} = {2}", arrA[i], arrB[i], arrC[i]);
        }
开发者ID:yeerkkiller1,项目名称:Go-AI,代码行数:44,代码来源:VectorAddTest.cs


示例19: Run

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

            try
            {
                int count = 10;
                float[] arrA = new float[count];
                float[] arrB = new float[count];
                float[] arrC = new float[count];

                Random rand = new Random();

                for (int i = 0; i < count; i++)
                {
                    arrA[i] = (float)(rand.NextDouble() * 100);
                    arrB[i] = (float)(rand.NextDouble() * 100);
                }

                ComputeBuffer<float> a = new ComputeBuffer<float>(context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.CopyHostPointer, arrA);
                ComputeBuffer<float> b = new ComputeBuffer<float>(context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.CopyHostPointer, arrB);
                ComputeBuffer<float> c = new ComputeBuffer<float>(context, ComputeMemoryFlags.WriteOnly, arrC.Length);

                ComputeProgram program = new ComputeProgram(context, kernelSource);
                program.Build(null, null, null, IntPtr.Zero);
                ComputeKernel kernel = program.CreateKernel("VectorAdd");
                kernel.SetMemoryArgument(0, a);
                kernel.SetMemoryArgument(1, b);
                kernel.SetMemoryArgument(2, c);

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

                ICollection<ComputeEventBase> events = new Collection<ComputeEventBase>();

                // BUG: ATI Stream v2.2 crash if event list not null.
                commands.Execute(kernel, null, new long[] { count }, null, events);
                //commands.Execute(kernel, null, new long[] { count }, null, null);

                arrC = new float[count];
                GCHandle arrCHandle = GCHandle.Alloc(arrC, GCHandleType.Pinned);

                commands.Read(c, true, 0, count, arrCHandle.AddrOfPinnedObject(), events);

                arrCHandle.Free();

                for (int i = 0; i < count; i++)
                    log.WriteLine("{0} + {1} = {2}", arrA[i], arrB[i], arrC[i]);
            }
            catch (Exception e)
            {
                log.WriteLine(e.ToString());
            }

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


示例20: InitializeOpenCL

        /// <summary>
        /// Attempts to initialize OpenCL for the selected GPU.
        /// </summary>
        private void InitializeOpenCL()
        {
            // only initialize once
            if (clKernel != null)
                return;

            // select the device we've been instructed to use
            clDevice = ComputePlatform.Platforms
                .SelectMany(i => i.Devices)
                .SingleOrDefault(i => i.Handle.Value == Gpu.CLDeviceHandle.Value);

            // context we'll be working underneath
            clContext = new ComputeContext(new ComputeDevice[] { clDevice }, new ComputeContextPropertyList(clDevice.Platform), null, IntPtr.Zero);

            // queue to control device
            clQueue = new ComputeCommandQueue(clContext, clDevice, ComputeCommandQueueFlags.None);

            // buffers to store kernel output
            clBuffer0 = new ComputeBuffer<uint>(clContext, ComputeMemoryFlags.ReadOnly, 16);
            clBuffer1 = new ComputeBuffer<uint>(clContext, ComputeMemoryFlags.ReadOnly, 16);

            // kernel code
            string kernelCode;
            using (var rdr = new StreamReader(GetType().Assembly.GetManifestResourceStream("BitMaker.Miner.Gpu.DiabloMiner.cl")))
                kernelCode = rdr.ReadToEnd();

            clProgram = new ComputeProgram(clContext, kernelCode);

            try
            {
                // build kernel for device
                clProgram.Build(new ComputeDevice[] { clDevice }, "-D WORKSIZE=" + clDevice.MaxWorkGroupSize, null, IntPtr.Zero);
            }
            catch (ComputeException)
            {
                throw new Exception(clProgram.GetBuildLog(clDevice));
            }

            clKernel = clProgram.CreateKernel("search");
        }
开发者ID:furyan,项目名称:MatriXMiner,代码行数:43,代码来源:GpuMiner.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ComputeErrorCode类代码示例发布时间:2022-05-24
下一篇:
C# CompressionType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap