Commit 80db3825 authored by Brewer, Wes's avatar Brewer, Wes
Browse files

Merge branch 'fixes-to-config' into 'main'

Fix some errors caused by the recent changes to ConfigManager

See merge request !64
parents ebb5e8d5 d4eed429
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ if args.seed:
    np.random.seed(SEED)

if args.cooling:
    cooling_model = ThermoFluidsModel(FMU_PATH)
    cooling_model = ThermoFluidsModel(**config)
    cooling_model.initialize()
    args.layout = "layout2"

@@ -99,7 +99,11 @@ else:
flops_manager = FLOPSManager(**config)
layout_manager = LayoutManager(args.layout, args.debug, **config)
args_dict['config'] = config
sc = Scheduler(power_manager, flops_manager, layout_manager, cooling_model, **args_dict)
sc = Scheduler(
    power_manager = power_manager, flops_manager = flops_manager, layout_manager = layout_manager,
    cooling_model = cooling_model,
    **args_dict,
)

if args.replay:

+13 −13
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ class ThermoFluidsModel:
    cleanup():
        Cleans up the extracted FMU directory, ensuring no temporary files are left behind.
    """
    def __init__(self, FMU_PATH):
    def __init__(self, **config):
        """
        Constructs all the necessary attributes for the ThermoFluidsModel object.

@@ -82,7 +82,7 @@ class ThermoFluidsModel:
        FMU_PATH : str
            The file path to the FMU file.
        """
        self.FMU_PATH = FMU_PATH
        self.config = config
        self.fmu_history = []
        self.inputs = None
        self.outputs = None
@@ -102,8 +102,8 @@ class ThermoFluidsModel:
        print('Initializing FMU...')

        # Unzip the FMU file and get the unzip directory
        self.unzipdir = extract(self.FMU_PATH)
        model_description = read_model_description(self.FMU_PATH)
        self.unzipdir = extract(self.config['FMU_PATH'])
        model_description = read_model_description(self.config['FMU_PATH'])

        # Add to list of variable names
        var_model = []
@@ -139,12 +139,12 @@ class ThermoFluidsModel:
        """
        # Dynamically generate the power inputs
        runtime_values = {
        f"simulator_1_datacenter_1_computeBlock_{i+1}_cabinet_1_sources_Q_flow_total": cdu_power[i] * COOLING_EFFICIENCY / RACKS_PER_CDU
        for i in range(NUM_CDUS)
        f"simulator_1_datacenter_1_computeBlock_{i+1}_cabinet_1_sources_Q_flow_total": cdu_power[i] * self.config['COOLING_EFFICIENCY'] / self.config['RACKS_PER_CDU']
        for i in range(self.config['NUM_CDUS'])
        }

        # Default temperature is from the config
        temperature = WET_BULB_TEMP
        temperature = self.config['WET_BULB_TEMP']

        # If replay mode is on and weather data is available
        if sc.replay and self.weather and self.weather.start is not None and self.weather.has_coords:
@@ -153,10 +153,10 @@ class ThermoFluidsModel:
            target_datetime = self.weather.start + delta

            # Get temperature from weather data
            temperature = self.weather.get_temperature(target_datetime) or WET_BULB_TEMP
            temperature = self.weather.get_temperature(target_datetime) or self.config['WET_BULB_TEMP']

        # Set the temperature value
        runtime_values[TEMPERATURE_KEY] = temperature
        runtime_values[self.config['TEMPERATURE_KEY']] = temperature

        return runtime_values
    
@@ -226,14 +226,14 @@ class ThermoFluidsModel:
            return np.array(value_in_kw) * 1e3 if value_in_kw is not None else 0.0

        # Convert values from kW to Watts using the utility function
        W_HTWPs = convert_to_watts(cooling_output.get(W_HTWPs_KEY))
        W_CTWPs = convert_to_watts(cooling_output.get(W_CTWPs_KEY))
        W_CTs = convert_to_watts(cooling_output.get(W_CTs_KEY))
        W_HTWPs = convert_to_watts(cooling_output.get(self.config['W_HTWPs_KEY']))
        W_CTWPs = convert_to_watts(cooling_output.get(self.config['W_CTWPs_KEY']))
        W_CTs = convert_to_watts(cooling_output.get(self.config['W_CTs_KEY']))

        # Get the sum of the work done by all CDU pumps
        W_CDUPs = sum(
            convert_to_watts(cooling_output.get(f'simulator[1].datacenter[1].computeBlock[{idx+1}].cdu[1].summary.W_flow_CDUP_kW'))
            for idx in range(NUM_CDUS)
            for idx in range(self.config['NUM_CDUS'])
        )

        # Sum all values in the cooling_input dictionary
+10 −10
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ def load_data_from_df(jobs_df: pd.DataFrame, jobprofile_df: pd.DataFrame, **kwar
    return jobs


def xname_to_index(xname: str):
def xname_to_index(xname: str, config: dict):
    """
    Converts an xname string to an index value based on system configuration.

@@ -167,11 +167,11 @@ def xname_to_index(xname: str):
    if row == 6:
        col -= 9
    rack_index = row * 12 + col
    node_index = chassis * BLADES_PER_CHASSIS * NODES_PER_BLADE + slot * NODES_PER_BLADE + node
    return rack_index * SC_SHAPE[2] + node_index
    node_index = chassis * config['BLADES_PER_CHASSIS'] * config['NODES_PER_BLADE'] + slot * config['NODES_PER_BLADE'] + node
    return rack_index * config['SC_SHAPE'][2] + node_index


def index_to_xname(index: int):
def index_to_xname(index: int, config: dict):
    """
    Converts an index value back to an xname string based on system configuration.

@@ -185,17 +185,17 @@ def index_to_xname(index: int):
    str
        The xname string corresponding to the index.
    """
    rack_index = index // SC_SHAPE[2]
    node_index = index % SC_SHAPE[2]
    rack_index = index // config['SC_SHAPE'][2]
    node_index = index % config['SC_SHAPE'][2]

    row = rack_index // 12
    col = rack_index % 12
    if row == 6:
        col += 9

    chassis = node_index // (BLADES_PER_CHASSIS * NODES_PER_BLADE)
    remaining = node_index % (BLADES_PER_CHASSIS * NODES_PER_BLADE)
    slot = remaining // NODES_PER_BLADE
    node = remaining % NODES_PER_BLADE
    chassis = node_index // (config['BLADES_PER_CHASSIS'] * config['NODES_PER_BLADE'])
    remaining = node_index % (config['BLADES_PER_CHASSIS'] * config['NODES_PER_BLADE'])
    slot = remaining // config['NODES_PER_BLADE']
    node = remaining % config['NODES_PER_BLADE']

    return f"x2{row}{col:02}c{chassis}s{slot}b{node}"
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ class PowerManager:
    - down_nodes: Nodes that are currently down.
    - down_rack: Rack number of down nodes.
    """
    def __init__(self, power_func, **config):
    def __init__(self, power_func=compute_node_power, **config):
        """
        Initialize the PowerManager object.

+2 −2
Original line number Diff line number Diff line
@@ -77,8 +77,8 @@ def get_utilization(trace, time_quanta_index):

class Scheduler:
    """Job scheduler and simulation manager."""
    def __init__(self, power_manager, flops_manager, layout_manager, cooling_model=None, **kwargs):
        self.config = kwargs.get('config')
    def __init__(self, *, power_manager, flops_manager, layout_manager, cooling_model=None, config, **kwargs):
        self.config = config
        self.down_nodes = summarize_ranges(self.config['DOWN_NODES'])
        self.available_nodes = list(set(range(self.config['TOTAL_NODES'])) - set(self.config['DOWN_NODES']))
        self.num_free_nodes = len(self.available_nodes)