def get_utilization(self): """ Get any utilization information for this Platform Worker's Configurations The returned Report contains a data-point (dict) for each Configuration, stored in the Report instance's data_points array. Each data-point maps dimension/header to value for that configuration. """ # Add to the default list of reportable synthesis items to report on ordered_headers = [ "Configuration" ] + hdltargets.HdlReportableToolSet.get_ordered_items() sort_priority = hdltargets.HdlReportableToolSet.get_sort_priority() + [ "Configuration" ] # Initialize an empty data-set with these default headers util_report = ocpiutil.Report(ordered_headers=ordered_headers, sort_priority=sort_priority) # Sort based on configuration name for cfg_name in sorted(self.configs): # Get the dictionaries of utilization report items for this Platform Worker. # Each dictionary returned corresponds to one implementation of this # container, and serves as a single data-point/row. # Add all data-points for this container to the running list sub_report = self.configs[cfg_name].get_utilization() if sub_report: # We want to add the container name as a report element # Add this dataset to the list of utilization dictionaries. It will serve # as a single data-point/row in the report sub_report.assign_for_all_points(key="Configuration", value=cfg_name) util_report += sub_report return util_report
def get_utilization(self): """ Get the utilization Report for this Container. It will be combination of reports for each container implementation with a leading "Container" column The returned Report contains a data-point (dict) for each container implementation, stored in the Report instance's data_points array. Each data-point maps dimension/header to value for that implementation. """ # Add to the default list of reportable synthesis items to report on ordered_headers = ["Container"] + hdltargets.HdlReportableToolSet.get_ordered_items("impl") sort_priority = hdltargets.HdlReportableToolSet.get_sort_priority() + ["Container"] # Initialize an empty data-set with these default headers util_report = ocpiutil.Report(ordered_headers=ordered_headers, sort_priority=sort_priority) for impl in self.implementations.values(): # Get the dictionary that maps utilization report "headers" to discovered "values" # Do this for the current container implementation sub_report = impl.get_utilization() # If the container implementation returns a dict of utilization information, # add it to the list if sub_report: # We want to add the container name as a report element sub_report.assign_for_all_points(key="Container", value=self.name) # Add this dataset to the list of utilization dictionaries. It will serve # as a single data-point/row in the report util_report += sub_report return util_report
def construct_report_item(self, directory, target=None, platform=None, mode="synth", init_report=None): """ For a single directory and single target OR platform, construct (or add to) a Report with a new data-point for the directory and target/platform provided. The data-point will contain a key/value pair for each ReportableItem of this toolset. """ if mode != "synth" and mode != "impl": raise ocpiutil.OCPIException( "Valid modes for reporting utilization are \"synth\" " + "and \"impl\". Mode specified was \"" + mode + "\".") # pylint:disable=bad-continuation target_plat_not_none = target is not None and platform is not None if ((mode == "synth" and target is None) or (mode == "impl" and platform is None) or target_plat_not_none): raise ocpiutil.OCPIException( "Synthesis reporting operates only on HDL targets.\n" + "Implementation reporting operates only on HDL platforms.") # pylint:enable=bad-continuation # Initialize a report object with the default ordered headers for this mode if init_report is None: init_report = ocpiutil.Report( ordered_headers=self.get_ordered_items(mode)) # Determine the toolset to collect these report items if mode == "synth": toolset = target.toolset elif mode == "impl": toolset = platform.target.toolset # For the tool in question, get the files for reporting on this directory/mode files = toolset.get_files(directory, mode) # Collect the actual report items dict of itemkey=>value and add as a data-point to the # report for returning new_report = toolset.collect_report_items(files, target=target, platform=platform, mode=mode) # If the new_report is non-empty, add it to the initial one if new_report: init_report.append(new_report) return init_report
def get_utilization(self): """ Get any utilization information for this instance The returned Report contains a single data-point (dict) for this Configuration, stored in the Report instance's data_points array. The data-point maps dimension/header to value for that configuration. Since a Platform Configuration is a synthesis asset, the utilization report will be generated with mode=synth """ # We report for this Config's HDL Platform's toolset toolset = self.platform.target.toolset if isinstance(toolset, hdltargets.HdlReportableToolSet): return toolset.construct_report_item(self.subdir_prefix, target=self.platform.target, mode="synth") else: return ocpiutil.Report()
def get_utilization(self): """ Get utilization report for this ApplicationAssembly. Get the utilization for each of container this assembly references. The returned Report contains a data-point (dict) for each Container, stored in the Report instance's data_points array. Each data-point maps dimension/header to value for that container. """ self.init_containers(self.hdl_platforms) # Sort based on container name util_report = ocpiutil.Report() for cname in sorted(self.containers): # Get the dictionaries of utilization report items for this container. # Each dictionary returned corresponds to one implementation of this # container, and serves as a single data-point/row. # Add all data-points for this container to the running list util_report += self.containers[cname].get_utilization() return util_report
def get_config_params_report(self): """ Create a Report instance containing an entry for each configuration of this worker. Return that report. The Report's data_points member is an array that will hold a data-point (stored as a dictionary) for each configuration. The keys of each data-point/dict will be "Configuration" or parameter name, and the values are configuration index or parameter values. """ # Initialize a report with headers matching "Configuration" and the parameter names report = ocpiutil.Report(ordered_headers=["Configuration"] + list(self.configs[0].param_dict.keys())) # For each configuration, construct a data-point with Configuration=index # and entries for each parameter key/value (just copy param_dict) for idx, config in self.configs.items(): params = config.param_dict.copy() params["Configuration"] = idx # Append this data-point to the report report.append(params) return report
def get_utilization(self): """ Get the utilization Report instance for this worker configuration Do so for each target provided all within a single Report Since a Worker Configuration is a synthesis asset, the utilization report will be generated with mode=synth """ # Get the default list of reportable synthesis items to report on ordered_headers = hdltargets.HdlReportableToolSet.get_ordered_items() sort_priority = hdltargets.HdlReportableToolSet.get_sort_priority() # Initialize an empty data-set with these default headers util_report = ocpiutil.Report(ordered_headers=ordered_headers, sort_priority=sort_priority) # Add data-points to this report/set for each target for tgt in self.hdl_targets: tgtdir = self.subdir_prefix + tgt.name if isinstance(tgt.toolset, hdltargets.HdlReportableToolSet): util_report += tgt.toolset.construct_report_item( directory=tgtdir, target=tgt, mode="synth") return util_report