public BuildStatus GetBuildStatus(Device device) { BuildInfo buildInfo; buildInfo = new BuildInfo(this, device); return((BuildStatus)InteropTools.ReadInt(buildInfo, (uint)ProgramBuildInfo.STATUS)); }
public string GetBuildLog(Device device) { BuildInfo buildInfo; buildInfo = new BuildInfo(this, device); return(InteropTools.ReadString(buildInfo, (uint)ProgramBuildInfo.LOG)); }
public Platform(IntPtr platformID) { this.PlatformID = platformID; // Create a local representation of all devices this.DeviceIDs = this.QueryDeviceIntPtr(DeviceType.ALL); for (var i = 0; i < this.DeviceIDs.Length; i++) { this._Devices[this.DeviceIDs[i]] = new Device(this, this.DeviceIDs[i]); } this.DeviceList = InteropTools.ConvertDeviceIDsToDevices(this, this.DeviceIDs); this.InitializeExtensionHashSet(); var m = this.VersionStringRegex.Match(this.Version); if (m.Success) { this.OpenCLMajorVersion = Int32.Parse(m.Groups["Major"].Value); this.OpenCLMinorVersion = Int32.Parse(m.Groups["Minor"].Value); } else { this.OpenCLMajorVersion = 1; this.OpenCLMinorVersion = 0; } }
public static void HexDump(String filename, Byte[] array, Int32 width) { var sw = new StreamWriter(filename); InteropTools.HexDump(sw, array, width); sw.Close(); }
public Platform(IntPtr platformID) { PlatformID = platformID; // Create a local representation of all devices DeviceIDs = QueryDeviceIntPtr(DeviceType.ALL); for (int i = 0; i < DeviceIDs.Length; i++) { _Devices[DeviceIDs[i]] = new Device(this, DeviceIDs[i]); } DeviceList = InteropTools.ConvertDeviceIDsToDevices(this, DeviceIDs); InitializeExtensionHashSet(); Match m = VersionStringRegex.Match(Version); if (m.Success) { OpenCLMajorVersion = int.Parse(m.Groups["Major"].Value); OpenCLMinorVersion = int.Parse(m.Groups["Minor"].Value); } else { OpenCLMajorVersion = 1; OpenCLMinorVersion = 0; } if (VersionCheck(1, 2)) { AddExtensionSupport(new DirectX9Extension(this)); AddExtensionSupport(new DirectX10Extension(this)); AddExtensionSupport(new DirectX11Extension(this)); } }
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(); }
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)); }
/// <summary> /// Block until the event fires /// </summary> /// <param name="_event"></param> public void WaitForEvent(Event _event) { Event[] event_list = new Event[1]; event_list[0] = _event; OpenCL.WaitForEvents(1, InteropTools.ConvertEventsToEventIDs(event_list)); }
public string GetBuildOptions(Device device) { BuildInfo buildInfo; buildInfo = new BuildInfo(this, device); return(InteropTools.ReadString(buildInfo, (uint)ProgramBuildInfo.OPTIONS)); }
/// <summary> /// Find all devices of a specififc type /// </summary> /// <param name="deviceType"></param> /// <returns>Array containing the devices</returns> public Device[] QueryDevices(DeviceType deviceType) { IntPtr[] deviceIDs; deviceIDs = QueryDeviceIntPtr(deviceType); return(InteropTools.ConvertDeviceIDsToDevices(this, deviceIDs)); }
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)); }
public static unsafe IntPtr[] ReadIntPtrArray(IPropertyContainer propertyContainer, UInt32 key) { var size = propertyContainer.GetPropertySize(key); var numElements = (Int64)size / sizeof(IntPtr); var ptrs = new IntPtr[numElements]; var data = InteropTools.ReadBytes(propertyContainer, key); fixed(Byte *pData = data) { var pBS = (void **)pData; for (var i = 0; i < numElements; i++) { ptrs[i] = new IntPtr(pBS[i]); } } return(ptrs); }
public unsafe Device[] GetDeviceIDsFromD3D11(Platform platform, D3D11DeviceSource d3d_device_source, IntPtr d3d_object, D3D11DeviceSet d3d_device_set) { ErrorCode status; uint numDevices; status = GetDeviceIDsFromD3D11(platform, d3d_device_source, d3d_object, d3d_device_set, 0, null, &numDevices); if (status != ErrorCode.SUCCESS) { return(null); } IntPtr[] deviceArray = new IntPtr[numDevices]; status = GetDeviceIDsFromD3D11(platform, d3d_device_source, d3d_object, d3d_device_set, numDevices, deviceArray, &numDevices); if (status != ErrorCode.SUCCESS) { return(null); } return(InteropTools.ConvertDeviceIDsToDevices(platform, deviceArray)); }
unsafe public static ulong[] ReadULongArray(IPropertyContainer propertyContainer, uint key) { IntPtr size = propertyContainer.GetPropertySize(key); long numElements = (long)size / sizeof(ulong); ulong[] ulongs = new ulong[numElements]; byte[] data = InteropTools.ReadBytes(propertyContainer, key); fixed(byte *pData = data) { ulong *pBS = (ulong *)pData; for (int i = 0; i < numElements; i++) { ulongs[i] = pBS[i]; } } return(ulongs); }
unsafe public static IntPtr[] ReadIntPtrArray(IPropertyContainer propertyContainer, uint key) { IntPtr size = propertyContainer.GetPropertySize(key); long numElements = (long)size / sizeof(IntPtr); IntPtr[] ptrs = new IntPtr[numElements]; byte[] data = InteropTools.ReadBytes(propertyContainer, key); fixed(byte *pData = data) { void **pBS = (void **)pData; for (int i = 0; i < numElements; i++) { ptrs[i] = new IntPtr(pBS[i]); } } return(ptrs); }
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); } }
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); } }
public String GetBuildOptions(Device device) { var buildInfo = new BuildInfo(this, device); return(InteropTools.ReadString(buildInfo, (UInt32)ProgramBuildInfo.OPTIONS)); }
public static Boolean ReadBool(IPropertyContainer propertyContainer, UInt32 key) { return(InteropTools.ReadUInt(propertyContainer, key) == (UInt32)Bool.TRUE ? true : false); }
/// <summary> /// Block until all events in the array have fired /// </summary> /// <param name="num_events"></param> /// <param name="event_list"></param> public void WaitForEvents(int num_events, Event[] event_list) { OpenCL.WaitForEvents((uint)num_events, InteropTools.ConvertEventsToEventIDs(event_list)); }
public String GetBuildLog(Device device) { var buildInfo = new BuildInfo(this, device); return(InteropTools.ReadString(buildInfo, (UInt32)ProgramBuildInfo.LOG)); }