Пример #1
0
        internal Context(Platform platform, ContextProperties[] properties, Device[] devices)
        {
            IntPtr[]  intPtrProperties;
            IntPtr[]  deviceIDs;
            ErrorCode result;

            Platform  = platform;
            deviceIDs = InteropTools.ConvertDevicesToDeviceIDs(devices);

            intPtrProperties = new IntPtr[properties.Length];
            for (int i = 0; i < properties.Length; i++)
            {
                intPtrProperties[i] = new IntPtr((long)properties[i]);
            }

            ContextID = (IntPtr)OpenCL.CreateContext(intPtrProperties,
                                                     (uint)devices.Length,
                                                     deviceIDs,
                                                     null,
                                                     IntPtr.Zero,
                                                     out result);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("CreateContext failed: " + result, result);
            }
            Is64BitContext = ContainsA64BitDevice();
        }
Пример #2
0
        public CLProgram CreateProgramWithBinary(Device[] devices, byte[][] binaries, ErrorCode[] binaryStatus)
        {
            IntPtr    programID;
            ErrorCode result;

            IntPtr[] lengths;
            int[]    binStatus = new int[binaryStatus.Length];

            lengths = new IntPtr[devices.Length];
            for (int i = 0; i < lengths.Length; i++)
            {
                lengths[i] = (IntPtr)binaries[i].Length;
            }
            programID = OpenCL.CreateProgramWithBinary(ContextID,
                                                       (uint)devices.Length,
                                                       InteropTools.ConvertDevicesToDeviceIDs(devices),
                                                       lengths,
                                                       binaries,
                                                       binStatus,
                                                       out result);
            for (int i = 0; i < binaryStatus.Length; i++)
            {
                binaryStatus[i] = (ErrorCode)binStatus[i];
            }
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("CreateProgramWithBinary failed with error code " + result, result);
            }
            return(new CLProgram(this, programID));
        }
Пример #3
0
        public Context CreateContext(IntPtr[] contextProperties, Device[] devices, ContextNotify notify, IntPtr userData)
        {
            IntPtr    contextID;
            ErrorCode result;

            IntPtr[] deviceIDs = InteropTools.ConvertDevicesToDeviceIDs(devices);
            contextID = (IntPtr)OpenCL.CreateContext(contextProperties,
                                                     (uint)deviceIDs.Length,
                                                     deviceIDs,
                                                     notify,
                                                     userData,
                                                     out result);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("CreateContext failed with error code: " + result, result);
            }
            return(new Context(this, contextID));
        }
Пример #4
0
        public void Build(Device[] devices, String options, ProgramNotify notify, IntPtr userData)
        {
            var deviceLength = 0;

            if (devices != null)
            {
                deviceLength = devices.Length;
            }

            var deviceIDs = InteropTools.ConvertDevicesToDeviceIDs(devices);
            var result    = OpenCL.BuildProgram(this.ProgramID,
                                                (UInt32)deviceLength,
                                                deviceIDs,
                                                options,
                                                notify,
                                                userData);

            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLBuildException(this, result);
            }
        }
Пример #5
0
        public void Build(Device[] devices, string options, ProgramNotify notify, IntPtr userData)
        {
            ErrorCode result;

            IntPtr[] deviceIDs;
            int      deviceLength = 0;

            if (devices != null)
            {
                deviceLength = devices.Length;
            }

            deviceIDs = InteropTools.ConvertDevicesToDeviceIDs(devices);
            result    = (ErrorCode)OpenCL.BuildProgram(ProgramID,
                                                       (uint)deviceLength,
                                                       deviceIDs,
                                                       options,
                                                       notify,
                                                       userData);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLBuildException(this, result);
            }
        }