/// <summary> /// Cloo compute command queue /// </summary> /// <param name="context">command context</param> /// <param name="device">command device</param> /// <param name="flags">command queue flags</param> public ClooCommandQueue(ClooContext context, ClooDevice device, ComputeCommandQueueFlags flags) : base(context, device, flags) { _context = context; _device = device; _flags = flags; }
/// <summary> /// Constructor /// </summary> /// <param name="context">compute context</param> /// <param name="binaries">program binaries</param> /// <param name="devices">devices</param> public ClooProgram(ClooContext context, IList<byte[]> binaries, IEnumerable<ClooDevice> devices) : base(context, binaries, devices.Cast<ComputeDevice>().ToList()) { _context = context; _devices.AddRange(devices); }
/// <summary> /// Constructor /// </summary> /// <param name="context">compute context</param> /// <param name="source">OpenCL source code</param> public ClooProgram(ClooContext context, string[] source) : base(context, source) { _context = context; _devices.AddRange(context.Devices); }
/// <summary> /// Constructor /// </summary> /// <param name="context">compute context</param> /// <param name="source">OpenCL source code</param> public ClooProgram(ClooContext context, string source) : base(context, source) { _context = context; }
/// <summary> /// Constructor /// </summary> /// <param name="context">compute context</param> /// <param name="lines">lines of source code</param> protected ClooProgramImaging(ClooContext context, IList<byte[]> binaries, IEnumerable<ClooDevice> devices) : base(context, binaries, devices) { }
/// <summary> /// Constructor /// </summary> /// <param name="context">compute context</param> /// <param name="lines">lines of source code</param> protected ClooProgramImaging(ClooContext context, string[] lines) : base(context, lines) { }
/// <summary> /// Constructor /// </summary> /// <param name="context">compute context</param> /// <param name="useBinaryCache">use cache for binaries</param> public static new ClooProgramImaging Create(ClooContext context, bool useBinaryCache = false) { var dict = GetEmbeddedSourceLines(typeof(ClooProgramImaging)); string header = null; if (dict.TryGetValue("Header", out header)) dict.Remove("Header"); else header = ""; List<string> lines = dict.Values.ToList(); string source = header + "\r\n" + String.Join("\r\n\r\n", lines.ToArray()); ClooProgramImaging res = null; if (useBinaryCache) { // check if we already have binaries int hashCode = lines.GetArrayHashCode(); foreach (ClooDevice device in context.Devices) hashCode ^= device.GetHashCode(); IList<byte[]> binaries; if (ClooProgram.BinariesCache.TryGetValue(hashCode, out binaries)) { // create from cached binaries res = new ClooProgramImaging(context, binaries, context.Devices); } } #if DEBUG try { #endif if (res == null) { // ok not in cache, so rebuilt from source res = new ClooProgramImaging(context, new string[] { source }); res.Build(context.Devices, null, useBinaryCache); } #if DEBUG } catch (Exception exception) { StringBuilder sb = new StringBuilder(); foreach (ComputeDevice device in context.Devices) { string info = "DEVICE: " + device.Name; sb.AppendLine(info); StringReader reader = new StringReader(res.GetBuildLog(device)); string line = reader.ReadLine(); while (line != null) { sb.AppendLine(line); line = reader.ReadLine(); } sb.AppendLine(""); sb.AppendLine(exception.Message); } throw new ApplicationException(sb.ToString()); } #endif res.InitializeKernels(typeof(ClooProgramImaging)); return res; }