Beispiel #1
0
        public OpenClCompiler(Device device, string source)
        {
            _device = device;
            _ctx    = device.CreateContext();


            Source   = source;
            _program = new Program(Cl.CreateProgramWithSource(_ctx, 1, new string[] { source }, null, out ErrorCode error));
            Cl.BuildProgram(_program, 1, new[] { _device }, string.Empty, null, IntPtr.Zero);

            KernelCount = _program.NumKernels;
            Methodes    = _program.KernelNames;

            _kernels = new Kernel[KernelCount];

            if ((error = Cl.CreateKernelsInProgram(_program, KernelCount, _kernels, out _)) != ErrorCode.Success)
            {
                throw new Exception($"{error}");
            }

            _queue = Cl.CreateCommandQueue(_ctx, _device, CommandQueueProperties.None, out _);
        }