예제 #1
0
파일: Form1.cs 프로젝트: ctapang/GPUCyclops
        private unsafe void TestVecKernel(Context c, CommandQueue cq, Kernel k)
        {
            Float2 f2 = new Float2(0.0f,1.0f);
            float[] memory = new float[2];

            fixed (float* pMemory = memory)
            {
                Mem mem = c.CreateBuffer((MemFlags)((ulong)MemFlags.READ_WRITE | (ulong)MemFlags.USE_HOST_PTR), 4 * 2, pMemory);

                k.SetArg(0, f2);
                k.SetArg(1, mem);
                cq.EnqueueTask(k);
                cq.EnqueueBarrier();
                IntPtr pMap = cq.EnqueueMapBuffer(mem, true, MapFlags.READ, 0, 2 * 4);
                cq.EnqueueUnmapMemObject(mem, pMap);
            }
        }
예제 #2
0
        public void SetArg(int argIndex, Float2 c)
        {
            ErrorCode result;

            result = OpenCL.SetKernelArg(KernelID, (uint)argIndex, (IntPtr)sizeof(Float2), &c);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("SetArg failed with error code " + result, result);
        }