Weaver

The weaver is a critical component of Kelp.Net and is the first object call you will make when running a test. This object houses a variety of OpenCL objects such as:

  • ComputeContext
  • An array of ComputeDevices
  • ComputeCommandQueue
  • A Boolean flag indicating if the GPU is enabled
  • ComputePlatform
  • A dictionary of KernelSources

The weaver is the place to tell your program whether you will be using a CPU or GPU, and which device (if your system is capable of multiple devices) you will be using. You only need to make a single call to the weaver, at the beginning of your program, similar to what you see here:

Weaver.Initialize(ComputeDeviceTypes.Gpu);

You also can avoid using the initialization call of the weaver and allow it to determine what needs to happen automatically.

Here are the basic contents of the weaver. Its purpose is to build (compile dynamically at runtime) the program that will be executed:

 /// <summary>   The context. </summary>
internal static ComputeContext Context;
/// <summary> The devices. </summary>
private static ComputeDevice[] Devices;
/// <summary> Queue of commands. </summary>
internal static ComputeCommandQueue CommandQueue;
/// <summary> Zero-based index of the device. </summary>
private static int DeviceIndex;
/// <summary> True to enable, false to disable. </summary>
internal static bool Enable;
/// <summary> The platform. </summary>
private static ComputePlatform Platform;
/// <summary> The kernel sources. </summary>
private static readonly Dictionary<string, string> KernelSources = new Dictionary<string, string>();
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.246.148