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


C# OpenCLNet.Mem类代码示例

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


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

示例1: NativeKernelCallbackData

 internal NativeKernelCallbackData(NativeKernel nk,CommandQueue cq, object o, Mem[] buffers)
 {
     NativeKernel = nk;
     CQ = cq;
     O = o;
     Buffers = buffers;
 }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:7,代码来源:CommandQueue.cs

示例2: CreateSubBuffer

 /// <summary>
 /// OpenCL 1.1
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="flags"></param>
 /// <param name="buffer_create_info"></param>
 /// <param name="errcode_ret"></param>
 /// <returns></returns>
 public Mem CreateSubBuffer(Mem buffer, MemFlags flags, BufferRegion buffer_create_info, out ErrorCode errcode_ret)
 {
     IntPtr memID = OpenCL.CreateSubBuffer(buffer.MemID, flags, buffer_create_info, out errcode_ret);
     return new Mem(buffer.Context, memID);
 }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:13,代码来源:Mem.cs

示例3: CopyOCLBitmapToBitmap

        public unsafe void CopyOCLBitmapToBitmap(Mem oclBitmap, Bitmap bitmap)
        {
            IntPtr[] origin = new IntPtr[3];
            IntPtr[] region = new IntPtr[3];
            Mem buffer;

            BitmapData bd = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
            buffer = oclContext.CreateBuffer((MemFlags)((long)MemFlags.WRITE_ONLY | (long)MemFlags.USE_HOST_PTR), bd.Height * bd.Stride, bd.Scan0);
            origin[0] = (IntPtr)0;
            origin[1] = (IntPtr)0;
            origin[2] = (IntPtr)0;
            region[0] = (IntPtr)bd.Width;
            region[1] = (IntPtr)bd.Height;
            region[2] = (IntPtr)1;
            oclCQ.EnqueueCopyImageToBuffer(oclBitmap, buffer, origin, region, IntPtr.Zero);
            oclCQ.EnqueueBarrier();
            IntPtr p = oclCQ.EnqueueMapBuffer(buffer, true, MapFlags.READ, IntPtr.Zero, (IntPtr)(bd.Height * bd.Stride));
            oclCQ.EnqueueUnmapMemObject(buffer, p);
            oclCQ.Finish();
            buffer.Dispose();
            bitmap.UnlockBits(bd);
        }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:22,代码来源:Form1.cs

示例4: GetCounter

        /*
        private unsafe Mem GetCounter()
        {
            fixed (ulong* dataptr = &voxelctr)
            {
                counter = manager.Context.CreateBuffer(MemFlags.READ_WRITE, 8, new IntPtr(dataptr));
            }
            return counter;
        }*/
        private unsafe void DoRayCasting(BitmapData output)
        {
            try
            {
                int deviceIndex = 0;
                outputBuffer = manager.Context.CreateBuffer(MemFlags.USE_HOST_PTR, output.Stride * output.Height, output.Scan0);

                if (first || changeDistance)
                {

                    // модель камеры UVN
                    camPos = new Float4()
                    {
                        S0 =
                        vol.GetSize() / 2 - (float)Math.Cos(camAngle * Math.PI / 180) * camDist,
                        S1 = vol.GetSize() / 2,
                        S2 = vol.GetSize() / 2 - (float)Math.Sin(camAngle * Math.PI / 180) * camDist,
                        S3 = 0
                    };

                    first = false;
                    changeDistance = false;
                    camPosOld = camPos;
                }

                else
                {
                    // поворот вокруг оси куба визуализации
                    if (angleChange && leftChange)
                    {
                        camPosOld.S0 -= camLookAt.S0;
                        camPosOld.S2 -= camLookAt.S2;

                        camPos.S0 = (float)Math.Cos(camAngle * Math.PI / 180) * camPosOld.S0 + (float)Math.Sin(camAngle * Math.PI / 180) * camPosOld.S2;
                        camPos.S1 = vol.GetSize() / 2;
                        camPos.S2 = -(float)Math.Sin(camAngle * Math.PI / 180) * camPosOld.S0 + (float)Math.Cos(camAngle * Math.PI / 180) * camPosOld.S2;
                        camPos.S3 = 0;

                        camPos.S0 += camLookAt.S0;
                        camPos.S2 += camLookAt.S2;

                        camPosOld = camPos;
                        angleChange = false;
                        leftChange = false;
                    }
                    if (angleChange && rightChange)
                    {
                        camPosOld.S0 -= camLookAt.S0;
                        camPosOld.S2 -= camLookAt.S2;

                        camPos.S0 = (float)Math.Cos(camAngle * Math.PI / 180) * camPosOld.S0 - (float)Math.Sin(camAngle * Math.PI / 180) * camPosOld.S2;
                        camPos.S1 = vol.GetSize() / 2;
                        camPos.S2 = (float)Math.Sin(camAngle * Math.PI / 180) * camPosOld.S0 + (float)Math.Cos(camAngle * Math.PI / 180) * camPosOld.S2;
                        camPos.S3 = 0;

                        camPos.S0 += camLookAt.S0;
                        camPos.S2 += camLookAt.S2;

                        camPosOld = camPos;
                        angleChange = false;
                        leftChange = false;

                    }

                }

                camLookAt = new Float4()
                {
                    S0 = vol.GetSize() / camfactorX,
                    S1 = vol.GetSize() / camfactorX,
                    S2 = vol.GetSize() / camfactorZ,
                    S3 = 0
                };

                //light = camPos;

                // направление камеры, UVN модель
                camForward = camLookAt.Sub(camPos).Normalize(); // направление просмотра
                var up = new Float4(0.0f, 1.0f, 0.0f, 0.0f);
                var right = MathClass.Cross(up, camForward).Normalize().Times(1.5f);
                up = MathClass.Cross(camForward, right).Normalize().Times(-1.5f);

                /*  обработка выходного изображения BitmapData в OpenCl устройстве */
                for (var x = 0; x < output.Width; x += blocksize)
                {
                    for (var y = 0; y < output.Height; y += blocksize)
                    {
                        var rayTracingGlobalWorkSize = new IntPtr[2]; // work_dim = 2
                        rayTracingGlobalWorkSize[0] = (IntPtr)(output.Width - x > blocksize ? blocksize : output.Width - x);
                        rayTracingGlobalWorkSize[1] = (IntPtr)(output.Height - y > blocksize ? blocksize : output.Height - y);

//.........这里部分代码省略.........
开发者ID:Shahdee,项目名称:tsvme,代码行数:101,代码来源:VoxelImage.cs

示例5: GetOpacity

 private unsafe Mem GetOpacity()
 {
     fixed (float* dataptr = form_this.opacity)
     {
         opacity = manager.Context.CreateBuffer(MemFlags.COPY_HOST_PTR, form_this.opacity.Count(), new IntPtr(dataptr));
     }
     return opacity;
 }
开发者ID:Shahdee,项目名称:tsvme,代码行数:8,代码来源:VoxelImage.cs

示例6: CreateBuffer

 /* возвращает буфер */
 public unsafe Mem CreateBuffer()
 {
     if (buffer == null)
     {
         /* указатели в C# используются с fixed (противодействие для GC) */
         fixed (short* dataptr = data)
         {
             buffer = manager_this.Context.CreateBuffer(MemFlags.COPY_HOST_PTR, data.Count() * 2, new IntPtr(dataptr));
         }
     }
     return buffer;
 }
开发者ID:AlexAksentyev,项目名称:tsvme,代码行数:13,代码来源:SystemClasses.cs

示例7: SetArg

 /// <summary>
 /// Set argument argIndex to mem
 /// </summary>
 /// <param name="argIndex"></param>
 /// <param name="mem"></param>
 public void SetArg(int argIndex, Mem mem)
 {
     SetArg(argIndex, mem.MemID);
 }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:9,代码来源:Kernel.cs

示例8: EnqueueCopyImage

        public void EnqueueCopyImage(Mem src_image, Mem dst_image, long[] src_origin, long[] dst_origin, long[] region, int num_events_in_wait_list, Event[] event_wait_list, out Event _event)
        {
            ErrorCode result;
            IntPtr tmpEvent;
            IntPtr* repackedSrcOrigin = stackalloc IntPtr[3];
            IntPtr* repackedDstOrigin = stackalloc IntPtr[3];
            IntPtr* repackedRegion = stackalloc IntPtr[3];
            IntPtr* repackedEvents = stackalloc IntPtr[num_events_in_wait_list];

            if (num_events_in_wait_list == 0)
                repackedEvents = null;
            InteropTools.A3ToIntPtr3(src_origin, repackedSrcOrigin);
            InteropTools.A3ToIntPtr3(dst_origin, repackedDstOrigin);
            InteropTools.A3ToIntPtr3(region, repackedRegion);
            InteropTools.ConvertEventsToEventIDs(num_events_in_wait_list, event_wait_list, repackedEvents);

            result = OpenCL.EnqueueCopyImage(CommandQueueID, src_image, dst_image, repackedSrcOrigin, repackedDstOrigin, repackedRegion, num_events_in_wait_list, repackedEvents, &tmpEvent);
            _event = new Event(Context, this, tmpEvent);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueCopyImage failed with error code " + result, result);
        }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:21,代码来源:CommandQueue.cs

示例9: EnqueueCopyBufferRect

        public void EnqueueCopyBufferRect(Mem src_buffer, Mem dst_buffer, long[] src_origin, long[] dst_origin, long[] region, long src_row_pitch, long src_slice_pitch, long dst_row_pitch, long dst_slice_pitch)
        {
            ErrorCode result;
            IntPtr* pSrcOrigin = stackalloc IntPtr[3];
            IntPtr* pDstOrigin = stackalloc IntPtr[3];
            IntPtr* pRegion = stackalloc IntPtr[3];

            InteropTools.A3ToIntPtr3(src_origin, pSrcOrigin);
            InteropTools.A3ToIntPtr3(dst_origin, pDstOrigin);
            InteropTools.A3ToIntPtr3(region, pRegion);

            result = OpenCL.EnqueueCopyBufferRect(CommandQueueID,
                src_buffer.MemID,
                dst_buffer.MemID,
                pSrcOrigin,
                pDstOrigin,
                pRegion,
                src_row_pitch,
                src_slice_pitch,
                dst_row_pitch,
                dst_slice_pitch,
                0,
                null,
                null);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueCopyBufferRect failed with error code " + result, result);
        }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:27,代码来源:CommandQueue.cs

示例10: Core

        public Core(int Nxp,int Nyp, int Nzp, int Ntm, double Bbeta, double Flux)
        {
            Nx = Nxp; Ny = Nyp; Nz = Nzp; Nt = Ntm; betagauge = (floattype)Bbeta; flux = (floattype)Flux;
            N = Nx * Ny * Nz * Nt; Nspace = Nx * Ny * Nz;

            string strforcompiler =  "-D Nt=" + Nt.ToString() + " -D Nxyz=" + (Nx * Ny * Nz).ToString() + " -D Nxy=" + (Nx*Ny).ToString() +
                                            " -D Nx="+(Nx).ToString()+" -D Ny="+(Ny).ToString()+" -D Nz="+(Nz).ToString();
            strforcompiler += typeof(floattype) == typeof(double) ? " -D floattype=double -D floattype2=double2 -D floattype4=double4" :
                                                                " -D floattype=float -D floattype2=float2 -D floattype4=float4";
            strforcompiler += " -D phi=" + flux.ToString().Replace(',', '.') + " -D KAPPA=" + kappa.ToString().Replace(',', '.');
            string fp64support = "#pragma OPENCL EXTENSION  cl_khr_fp64 : enable\n";

            Plocalsize = AdjustLocalSize(Nspace);
            Slocalsize = AdjustLocalSize(N / 2);
            XhermYlocalsize = AdjustLocalSize(4 * N);

               // Plocalsize = 16; Slocalsize = 16;

            PNumGroups = Nx * Ny * Nz / Plocalsize;
            SNumGroups = N/2 / Slocalsize;
            XhermYNumGroups = 4*4*N / XhermYlocalsize;
            BufferLength = N * 4 * 9 * 2 * sizeof(floattype);
            SeedBufLen = N * sizeof(Int32)/2 * 4;

            AllocBuffers();

            openCLPlatform = OpenCL.GetPlatform(0);
            openCLDevices = openCLPlatform.QueryDevices(DeviceType.ALL);
            openCLContext = openCLPlatform.CreateDefaultContext();
            openCLCQ = openCLContext.CreateCommandQueue(openCLDevices[0], CommandQueueProperties.PROFILING_ENABLE);
            MyKernelProgram = openCLContext.CreateProgramWithSource(
                (typeof(floattype)==typeof(double)?fp64support:"") + File.ReadAllText("MyKernel.cl")+File.ReadAllText("dirak_mul.cl"));
            try
            {
                MyKernelProgram.Build(openCLDevices, strforcompiler, null, IntPtr.Zero);
            }
            catch (OpenCLException)
            {
                string buildLog = MyKernelProgram.GetBuildLog(openCLDevices[0]);
                MessageBox.Show(buildLog, "Build error(64 bit debug sessions in vs2008 always fail like this - debug in 32 bit or use vs2010)");
                //  Application.Exit();
            }
            MyKernelKernel = MyKernelProgram.CreateKernel("MyKernel");
            PReductionKernel = MyKernelProgram.CreateKernel("PLoop");
            SReductionKernel = MyKernelProgram.CreateKernel("CalcS");
            DiralMulKernel = MyKernelProgram.CreateKernel("dirakMatrMul");
            FillWithKernel = MyKernelProgram.CreateKernel("FillWith");
            FillLinkWithKernel = MyKernelProgram.CreateKernel("FillLinkWith");
            FillWithRandomKernel = MyKernelProgram.CreateKernel("FillWithRandom");
            AXPYKernel = MyKernelProgram.CreateKernel("AXPY");
            XhermYKernel = MyKernelProgram.CreateKernel("XhermY");
            BackupLinkKernel = MyKernelProgram.CreateKernel("BackupLink");
            RestoreLinkKernel = MyKernelProgram.CreateKernel("RestoreLink");

            SeedMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), SeedBufLen, IntPtr.Zero);
            LinkMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), BufferLength, IntPtr.Zero);
            PGroupMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), floatsize * PNumGroups, IntPtr.Zero);
            PResMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), floatsize, IntPtr.Zero);
            SGroupMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), floatsize * SNumGroups, IntPtr.Zero);
            SResMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), floatsize, IntPtr.Zero);

            XhermYGroupMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), floatsize * 2*XhermYNumGroups, IntPtr.Zero);
            XhermYresMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), floatsize * 2, IntPtr.Zero);
            XhermYrespointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(floatsize * 2);

            SeedVectorMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), SeedVectorBuf.Length * sizeof(int), IntPtr.Zero);
            StorageMem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), linksize, IntPtr.Zero);
            dSmem = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.READ_WRITE), floatsize, IntPtr.Zero);
            dSpointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(floatsize);

            MyKernelKernel.SetArg(0, (byte)EvenOdd);
            MyKernelKernel.SetArg(1, (floattype)betagauge);
            MyKernelKernel.SetArg(2, (floattype)flux);
            MyKernelKernel.SetArg(3, SeedMem);
            MyKernelKernel.SetArg(4, LinkMem);

            PReductionKernel.SetArg(0, LinkMem);
            PReductionKernel.SetArg(1, PGroupMem);
            PReductionKernel.SetArg(2, PResMem);
            IntPtr ptr = new IntPtr(Plocalsize * floatsize);
            PReductionKernel.SetArg(3, ptr, IntPtr.Zero);

            SReductionKernel.SetArg(0, LinkMem);
            SReductionKernel.SetArg(1, SGroupMem);
            SReductionKernel.SetArg(2, SResMem);
            IntPtr ptr1 = new IntPtr(Slocalsize * floatsize);
            SReductionKernel.SetArg(3, ptr1, IntPtr.Zero);

            XhermYKernel.SetArg(2, XhermYresMem);
            XhermYKernel.SetArg(3, XhermYGroupMem);
            XhermYKernel.SetArg(4, new IntPtr(XhermYlocalsize*floatsize*2),IntPtr.Zero);

            openCLCQ.EnqueueWriteBuffer(SeedMem, true, 0, SeedBufLen, ipseed);
            openCLCQ.EnqueueWriteBuffer(LinkMem, true, 0, BufferLength, ip);
            openCLCQ.EnqueueWriteBuffer(SeedVectorMem, true, 0, SeedVectorBuf.Length*sizeof(int), ipseedvector);
            rhat0 = new Vector();
            //init BICGStab vectors
            phi = new Vector();

            r0 = new Vector();
//.........这里部分代码省略.........
开发者ID:dptph,项目名称:lat-qcd,代码行数:101,代码来源:KernelClass.cs

示例11: Mandelbrot

        public Mandelbrot( Platform platform, int width, int height )
        {
            openCLPlatform = platform;
            openCLDevices = openCLPlatform.QueryDevices(DeviceType.ALL);
            openCLContext = openCLPlatform.CreateDefaultContext();
            openCLCQ = openCLContext.CreateCommandQueue(openCLDevices[0], CommandQueueProperties.PROFILING_ENABLE);
            mandelBrotProgram = openCLContext.CreateProgramWithSource(File.ReadAllText("Mandelbrot.cl"));
            try
            {
                mandelBrotProgram.Build();
            }
            catch (OpenCLException)
            {
                string buildLog = mandelBrotProgram.GetBuildLog(openCLDevices[0]);
                MessageBox.Show(buildLog,"Build error(64 bit debug sessions in vs2008 always fail like this - debug in 32 bit or use vs2010)");
                Application.Exit();
            }
            mandelbrotKernel = mandelBrotProgram.CreateKernel("Mandelbrot");

            Left = -2.0f;
            Top = 2.0f;
            Right = 2.0f;
            Bottom = -2.0f;
            BitmapWidth = width;
            BitmapHeight = height;

            mandelbrotMemBuffer = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.WRITE_ONLY), width*height*4, IntPtr.Zero);
        }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:28,代码来源:Mandelbrot.cs

示例12: EnqueueCopyImageToBuffer

        public void EnqueueCopyImageToBuffer(Mem src_image, Mem dst_buffer, IntPtr[] src_origin, IntPtr[] region, IntPtr dst_offset, int num_events_in_wait_list, Event[] event_wait_list)
        {
            ErrorCode result;

            result = OpenCL.EnqueueCopyImageToBuffer(CommandQueueID,
                src_image.MemID,
                dst_buffer.MemID,
                src_origin,
                region,
                dst_offset,
                (uint)num_events_in_wait_list,
                InteropTools.ConvertEventsToEventIDs(event_wait_list),
                null);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("EnqueueCopyImageToBuffer failed with error code " + result, result);
        }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:16,代码来源:CommandQueue.cs

示例13: FLACCLTask

		unsafe public FLACCLTask(Program _openCLProgram, int channelsCount, int channels, uint bits_per_sample, int max_frame_size, FLACCLWriter writer, int groupSize, bool gpuOnly, bool gpuRice)
		{
			this.UseGPUOnly = gpuOnly;
			this.UseGPURice = gpuOnly && gpuRice;
			this.UseMappedMemory = writer._settings.MappedMemory || writer._settings.DeviceType == OpenCLDeviceType.CPU;
			this.groupSize = groupSize;
			this.channels = channels;
			this.channelsCount = channelsCount;
			this.writer = writer;
			openCLProgram = _openCLProgram;
#if DEBUG
			var prop = CommandQueueProperties.PROFILING_ENABLE;
#else
			var prop = CommandQueueProperties.NONE;
#endif
			openCLCQ = openCLProgram.Context.CreateCommandQueue(openCLProgram.Context.Devices[0], prop);

            int MAX_ORDER = this.writer.eparams.max_prediction_order;
			int MAX_FRAMES = this.writer.framesPerTask;
			int MAX_CHANNELSIZE = MAX_FRAMES * ((writer.eparams.block_size + 3) & ~3);
			residualTasksLen = sizeof(FLACCLSubframeTask) * 32 * channelsCount * MAX_FRAMES;
			bestResidualTasksLen = sizeof(FLACCLSubframeTask) * channels * MAX_FRAMES;
			int samplesBufferLen = writer.PCM.BlockAlign * MAX_CHANNELSIZE * channelsCount;
			int residualBufferLen = sizeof(int) * MAX_CHANNELSIZE * channels; // need to adjust residualOffset?
			int partitionsLen = sizeof(int) * ((writer.PCM.BitsPerSample > 16 ? 31 : 15) * 2 << 8) * channels * MAX_FRAMES;
			int riceParamsLen = sizeof(int) * (4 << 8) * channels * MAX_FRAMES;
			int autocorLen = sizeof(float) * (MAX_ORDER + 1) * lpc.MAX_LPC_WINDOWS * channelsCount * MAX_FRAMES;
            int lpcDataLen = autocorLen * 32;
			int resOutLen = sizeof(int) * channelsCount * (lpc.MAX_LPC_WINDOWS * lpc.MAX_LPC_ORDER + 8) * MAX_FRAMES;
			int wndLen = sizeof(float) * MAX_CHANNELSIZE /** 2*/ * lpc.MAX_LPC_WINDOWS;
			int selectedLen = sizeof(int) * 32 * channelsCount * MAX_FRAMES;
			int riceLen = sizeof(int) * channels * MAX_CHANNELSIZE;

            if (!this.UseMappedMemory)
            {
                clSamplesBytes = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, samplesBufferLen / 2);
				clResidual = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, residualBufferLen);
                clBestRiceParams = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, riceParamsLen / 4);
                clResidualTasks = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, residualTasksLen);
                clBestResidualTasks = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, bestResidualTasksLen);
                clWindowFunctions = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, wndLen);
				clSelectedTasks = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, selectedLen);
				clRiceOutput = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, riceLen);

                clSamplesBytesPinned = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, samplesBufferLen / 2);
				clResidualPinned = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, residualBufferLen);
                clBestRiceParamsPinned = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, riceParamsLen / 4);
                clResidualTasksPinned = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, residualTasksLen);
                clBestResidualTasksPinned = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, bestResidualTasksLen);
                clWindowFunctionsPinned = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, wndLen);
				clSelectedTasksPinned = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, selectedLen);
				clRiceOutputPinned = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, riceLen);

                clSamplesBytesPtr = openCLCQ.EnqueueMapBuffer(clSamplesBytesPinned, true, MapFlags.READ_WRITE, 0, samplesBufferLen / 2);
				clResidualPtr = openCLCQ.EnqueueMapBuffer(clResidualPinned, true, MapFlags.READ_WRITE, 0, residualBufferLen);
				clBestRiceParamsPtr = openCLCQ.EnqueueMapBuffer(clBestRiceParamsPinned, true, MapFlags.READ_WRITE, 0, riceParamsLen / 4);
				clResidualTasksPtr = openCLCQ.EnqueueMapBuffer(clResidualTasksPinned, true, MapFlags.READ_WRITE, 0, residualTasksLen);
				clBestResidualTasksPtr = openCLCQ.EnqueueMapBuffer(clBestResidualTasksPinned, true, MapFlags.READ_WRITE, 0, bestResidualTasksLen);
				clWindowFunctionsPtr = openCLCQ.EnqueueMapBuffer(clWindowFunctionsPinned, true, MapFlags.READ_WRITE, 0, wndLen);
				clSelectedTasksPtr = openCLCQ.EnqueueMapBuffer(clSelectedTasksPinned, true, MapFlags.READ_WRITE, 0, selectedLen);
				clRiceOutputPtr = openCLCQ.EnqueueMapBuffer(clRiceOutputPinned, true, MapFlags.READ_WRITE, 0, riceLen);
			}
            else
            {
                clSamplesBytes = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, (uint)samplesBufferLen / 2);
				clResidual = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, residualBufferLen);
                clBestRiceParams = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, riceParamsLen / 4);
                clResidualTasks = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, residualTasksLen);
                clBestResidualTasks = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, bestResidualTasksLen);
                clWindowFunctions = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, wndLen);
				clSelectedTasks = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, selectedLen);
				clRiceOutput = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE | MemFlags.ALLOC_HOST_PTR, riceLen);

				clSamplesBytesPtr = openCLCQ.EnqueueMapBuffer(clSamplesBytes, true, MapFlags.READ_WRITE, 0, samplesBufferLen / 2);
				clResidualPtr = openCLCQ.EnqueueMapBuffer(clResidual, true, MapFlags.READ_WRITE, 0, residualBufferLen);
				clBestRiceParamsPtr = openCLCQ.EnqueueMapBuffer(clBestRiceParams, true, MapFlags.READ_WRITE, 0, riceParamsLen / 4);
				clResidualTasksPtr = openCLCQ.EnqueueMapBuffer(clResidualTasks, true, MapFlags.READ_WRITE, 0, residualTasksLen);
				clBestResidualTasksPtr = openCLCQ.EnqueueMapBuffer(clBestResidualTasks, true, MapFlags.READ_WRITE, 0, bestResidualTasksLen);
				clWindowFunctionsPtr = openCLCQ.EnqueueMapBuffer(clWindowFunctions, true, MapFlags.READ_WRITE, 0, wndLen);
				clSelectedTasksPtr = openCLCQ.EnqueueMapBuffer(clSelectedTasks, true, MapFlags.READ_WRITE, 0, selectedLen);
				clRiceOutputPtr = openCLCQ.EnqueueMapBuffer(clRiceOutput, true, MapFlags.READ_WRITE, 0, riceLen);

                //clSamplesBytesPtr = clSamplesBytes.HostPtr;
                //clResidualPtr = clResidual.HostPtr;
                //clBestRiceParamsPtr = clBestRiceParams.HostPtr;
                //clResidualTasksPtr = clResidualTasks.HostPtr;
                //clBestResidualTasksPtr = clBestResidualTasks.HostPtr;
                //clWindowFunctionsPtr = clWindowFunctions.HostPtr;
            }

            clSamples = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, samplesBufferLen);
            clLPCData = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, lpcDataLen);
            clAutocorOutput = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, autocorLen);
			clSelectedTasksSecondEstimate = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, selectedLen);
			clSelectedTasksBestMethod = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, selectedLen);
			if (UseGPUOnly)
            {
                clPartitions = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, partitionsLen);
                clRiceParams = openCLProgram.Context.CreateBuffer(MemFlags.READ_WRITE, riceParamsLen);
            }
//.........这里部分代码省略.........
开发者ID:androidhacker,项目名称:DotNetProjs,代码行数:101,代码来源:FLACCLWriter.cs

示例14: SetMemArg

 public void SetMemArg(int argIndex, Mem mem)
 {
     SetIntPtrArg(argIndex, mem.MemID);
 }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:4,代码来源:Kernel.cs

示例15: SetupBitmaps

        /// <summary>
        /// Loads two bitmaps and locks them for the duration of the program.
        /// Also creates two OpenCL buffers that map to the locked images
        /// </summary>
        private void SetupBitmaps()
        {
            InputBitmap0 = (Bitmap)Bitmap.FromFile(@"Input0.png");
            InputBitmap1 = (Bitmap)Bitmap.FromFile(@"Input1.png");
            if (InputBitmap1.Size != InputBitmap0.Size)
                InputBitmap1 = new Bitmap(InputBitmap1, InputBitmap0.Size);
            OutputBitmap = new Bitmap(InputBitmap0);

            InputBitmapData0 = InputBitmap0.LockBits(new Rectangle(0, 0, InputBitmap0.Width, InputBitmap0.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            InputBitmapData1 = InputBitmap1.LockBits(new Rectangle(0, 0, InputBitmap1.Width, InputBitmap1.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);

            InputBuffer0 = OCLMan.Context.CreateBuffer(MemFlags.USE_HOST_PTR, InputBitmapData0.Stride * InputBitmapData0.Height, InputBitmapData0.Scan0);
            InputBuffer1 = OCLMan.Context.CreateBuffer(MemFlags.USE_HOST_PTR, InputBitmapData1.Stride * InputBitmapData1.Height, InputBitmapData1.Scan0);
        }
开发者ID:ctapang,项目名称:GPUCyclops,代码行数:18,代码来源:Form1.cs


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