示例#1
0
        public IntPtr clCreateProgramWithSource(IntPtr context, uint count, string[] strings, uint[] lengths,
                                                out OpenClErrorCode errorCodeRet)
        {
            errorCodeRet = clCreateProgramWithSourceErrorCode ?? OpenClErrorCode.Success;
            IntPtr id;

            if (errorCodeRet == OpenClErrorCode.Success)
            {
                id = clCreateProgramWithSourceReturn ?? new IntPtr(1);
                FakePrograms[id] = new FakeProgram(context, strings);
            }
            else
            {
                id = IntPtr.Zero;
            }

            return(id);
        }
示例#2
0
        public IntPtr clCreateProgramWithBinary(IntPtr context, uint numDevices, IntPtr[] deviceList, uint[] lengths,
                                                IntPtr[] binaries, OpenClErrorCode[] binaryStatus, out OpenClErrorCode errorCodeRet)
        {
            binaryStatus = clCreateProgramWithBinaryBinaryStatus ?? new OpenClErrorCode[deviceList.Length];
            errorCodeRet = clCreateProgramWithBinaryErrorCodeRet ?? OpenClErrorCode.Success;
            var id = clCreateProgramWithBinaryResult ?? new IntPtr(1);

            if (errorCodeRet != OpenClErrorCode.Success)
            {
                return(IntPtr.Zero);
            }

            var deviceBinaries = binaries.Zip(deviceList, (binary, device) => new { binary, device })
                                 .Zip(lengths, (binDev, length) => new { binDev.binary, binDev.device, length })
                                 .Zip(binaryStatus, (binDevLength, status) => new { binDevLength.binary, binDevLength.device, binDevLength.length, status })
                                 .Where(f => f.status == OpenClErrorCode.Success)
                                 .Select(b => Tuple.Create(b.device, new byte[b.length]));

            FakePrograms[id] = new FakeProgram(context, deviceBinaries);
            return(id);
        }