/// <summary> /// Enables a CPU device of the given kind. /// </summary> /// <param name="builder">The builder instance.</param> /// <param name="device">The custom CPU device.</param> /// <returns>The updated builder instance.</returns> public static Context.Builder CPU( this Context.Builder builder, CPUDevice device) { builder.DeviceRegistry.Register(device); return(builder); }
/// <summary> /// Enables a CPU device of the given kind. /// </summary> /// <param name="builder">The builder instance.</param> /// <param name="kind">The CPU device kind.</param> /// <returns>The updated builder instance.</returns> public static Context.Builder CPU( this Context.Builder builder, CPUDeviceKind kind) { builder.DeviceRegistry.Register(CPUDevice.GetDevice(kind)); return(builder); }
/// <summary> /// Constructs a new CPU runtime. /// </summary> /// <param name="context">The ILGPU context.</param> /// <param name="description">The accelerator description.</param> /// <param name="mode">The current accelerator mode.</param> /// <param name="threadPriority"> /// The thread priority of the execution threads. /// </param> internal CPUAccelerator( Context context, CPUDevice description, CPUAcceleratorMode mode, ThreadPriority threadPriority) : base(context, description) { NativePtr = new IntPtr(1); DefaultStream = CreateStream(); NumThreads = description.NumThreads; Mode = mode; ThreadPriority = threadPriority; UsesSequentialExecution = Mode == CPUAcceleratorMode.Sequential || Mode == CPUAcceleratorMode.Auto && Debugger.IsAttached; finishedEventPerMultiprocessor = new Barrier(NumMultiprocessors + 1); multiprocessors = new CPUMultiprocessor[NumMultiprocessors]; for (int i = 0, e = NumMultiprocessors; i < e; ++i) { multiprocessors[i] = CPUMultiprocessor.Create( this, i, UsesSequentialExecution); } Bind(); Init(context.DefautltILBackend); }
/// <summary> /// Enables all CPU devices. /// </summary> /// <param name="builder">The builder instance.</param> /// <param name="predicate"> /// The predicate to include a given device. /// </param> /// <returns>The updated builder instance.</returns> public static Context.Builder CPU( this Context.Builder builder, Predicate <CPUDevice> predicate) { CPUDevice.GetDevices( predicate, builder.DeviceRegistry); return(builder); }
/// <summary> /// Constructs a new CPU runtime. /// </summary> /// <param name="context">The ILGPU context.</param> /// <param name="description">The accelerator description.</param> /// <param name="mode">The current accelerator mode.</param> /// <param name="threadPriority"> /// The thread priority of the execution threads. /// </param> internal CPUAccelerator( Context context, CPUDevice description, CPUAcceleratorMode mode, ThreadPriority threadPriority) : base(context, description) { NativePtr = new IntPtr(1); DefaultStream = CreateStream(); NumThreads = description.NumThreads; Mode = mode; UsesSequentialExecution = Mode == CPUAcceleratorMode.Sequential || Mode == CPUAcceleratorMode.Auto && Debugger.IsAttached; Bind(); InitExecutionEngine(threadPriority); Init(context.DefautltILBackend); }