示例#1
0
        /// <summary>
        /// Constructor (uses default values for the class unless overridden in settings file).
        /// </summary>
        public ParamsSearch()
        {
            if (CeresUserSettingsManager.Settings.SmartPruningFactor.HasValue)
            {
                float pruningFactorValue = CeresUserSettingsManager.Settings.SmartPruningFactor.Value;
                if (pruningFactorValue == 0)
                {
                    FutilityPruningStopSearchEnabled  = false;
                    MoveFutilityPruningAggressiveness = 0;
                }
                else if (pruningFactorValue == LC0_DEFAULT_SMART_PRUNING_FACTOR)
                {
                    FutilityPruningStopSearchEnabled  = new ParamsSearch().FutilityPruningStopSearchEnabled;
                    MoveFutilityPruningAggressiveness = new ParamsSearch().MoveFutilityPruningAggressiveness;
                }
                else
                {
                    throw new Exception("SmartPruningFactor in Ceres.json must either have value 0, 1.33 or be absent.");
                }
            }

            // Check user settings to see if tablebases are configured.
            EnableTablebases = CeresUserSettingsManager.Settings.TablebaseDirectory is not null;

            // Start with default execution params,
            // but these may be updated dynamicaly during search
            // based on search state.
            Execution = new ParamsSearchExecution();
        }
示例#2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public ParamsSearch()
        {
            // Check user settings to see if tablebases are configured.
            EnableTablebases = CeresUserSettingsManager.Settings.DirTablebases != "";

            // Start with default execution params,
            // but these may be updated dynamicaly during search
            // based on search state.
            Execution = new ParamsSearchExecution();
        }
        /// <summary>
        /// Internal worker method to that actually computes and updates the optimal parameters.
        /// </summary>
        /// <param name="estNumNodes"></param>
        void DoChooseOptimal(int estNumNodes)
        {
            // TODO: lift restriction that SMART_SIZE only works with single device
            bool defaultUseSmartSizeBatches = new ParamsSearchExecution().SmartSizeBatches;

            ParamsSearch.Execution.SmartSizeBatches = defaultUseSmartSizeBatches &&
                                                      estNumNodes > 1000 &&
                                                      NNEvaluatorDef.NumDevices == 1;

            if (NNEvaluatorDef.DeviceCombo == NNEvaluatorDeviceComboType.Pooled)
            {
                AdjustForPooled();
            }


            // Turn off some features if search is very small (overhead of initializing them not worth it)
            const int CUTOVER_NUM_NODES_TINY   = 200;
            const int CUTOVER_NUM_NODES_SMALL  = 20_000;
            const int CUTOVER_NUM_NODES_MEDIUM = 100_000;

            if (estNumNodes < CUTOVER_NUM_NODES_SMALL)
            {
                if (estNumNodes < 10)
                {
                    ParamsSearch.Execution.RootPreloadDepth = 0;
                    ParamsSearch.Execution.RootPreloadWidth = 0;
                }

                else if (estNumNodes < CUTOVER_NUM_NODES_TINY)
                {
                    ParamsSearch.Execution.RootPreloadDepth = 2;
                    ParamsSearch.Execution.RootPreloadWidth = 2;
                }

                ParamsSearch.Execution.SelectParallelEnabled      = false;
                ParamsSearch.Execution.SetPoliciesParallelEnabled = false;
            }
            else if (estNumNodes < CUTOVER_NUM_NODES_MEDIUM)
            {
                ParamsSearch.Execution.SelectParallelEnabled      = true;
                ParamsSearch.Execution.SetPoliciesParallelEnabled = true;
            }
            else
            {
                ParamsSearch.Execution.SelectParallelEnabled      = true;
                ParamsSearch.Execution.SetPoliciesParallelEnabled = true;
            }

            ParamsSearch.Execution.FlowDirectOverlapped = estNumNodes > 5000;
            ParamsSearch.Execution.FlowDualSelectors    = estNumNodes > 5000;

            // TODO: set the GPU fractions if multiple
        }