Beispiel #1
0
    def __init__(self, problemTypeConfig, problemSizeGroupConfig):
        # read problem type
        #if "ProblemType" in config:
        #  problemTypeConfig = config["ProblemType"]
        #else:
        #  problemTypeConfig = {}
        #  print2("No ProblemType in config: %s; using defaults." % str(config) )
        self.problemType = ProblemType(problemTypeConfig)
        self.isBatched = True \
            if "Batched" in problemTypeConfig and problemTypeConfig["Batched"] \
            else False
        print2("# BenchmarkProcess beginning %s" % str(self.problemType))

        # read initial solution parameters
        self.initialSolutionParameters = {"ProblemType": problemTypeConfig}
        self.initialSolutionParameters.update(defaultSolution)
        if "InitialSolutionParameters" not in problemSizeGroupConfig:
            print2("No InitialSolutionParameters; using defaults.")
        else:
            if problemSizeGroupConfig["InitialSolutionParameters"] != None:
                for paramDict in problemSizeGroupConfig[
                        "InitialSolutionParameters"]:
                    for paramName in paramDict:
                        paramValueList = paramDict[paramName]
                        if isinstance(paramValueList, list):
                            if len(paramValueList) != 1:
                                printWarning(
                                    "InitialSolutionParameters must have length=1: %s:%s"
                                    % (paramName, paramValueList))
                            self.initialSolutionParameters[
                                paramName] = paramValueList[0]
                        else:
                            self.initialSolutionParameters[
                                paramName] = paramValueList
        print2("# InitialSolutionParameters: %s" %
               str(self.initialSolutionParameters))

        # fill in missing steps using defaults
        self.benchmarkCommonParameters = []
        self.forkParameters = []
        self.benchmarkForkParameters = []
        self.joinParameters = []
        self.benchmarkJoinParameters = []
        self.benchmarkFinalParameters = []
        self.benchmarkSteps = []
        self.hardcodedParameters = [{}]
        self.singleValueParameters = {}

        # (I)
        self.fillInMissingStepsWithDefaults(self.isBatched,
                                            problemSizeGroupConfig)

        # convert list of parameters to list of steps
        self.currentProblemSizes = []
        self.benchmarkStepIdx = 0

        # (II)
        self.convertParametersToSteps()
Beispiel #2
0
def main(config):
    dataPath = os.path.join(globalParameters["WorkingPath"], \
        globalParameters["BenchmarkDataPath"])
    pushWorkingPath(globalParameters["BenchmarkProblemsPath"])
    ensurePath(dataPath)
    totalTestFails = 0
    for benchmarkProblemTypeConfig in config:
        problemTypeConfig = benchmarkProblemTypeConfig[0]
        if len(benchmarkProblemTypeConfig) < 2:
            problemSizeGroupConfigs = [{}]
        else:
            problemSizeGroupConfigs = benchmarkProblemTypeConfig[1:]
        for problemSizeGroupIdx in range(0, len(problemSizeGroupConfigs)):
            problemSizeGroupConfig = problemSizeGroupConfigs[
                problemSizeGroupIdx]
            print2("ProblemTypeConfig: %s" % problemTypeConfig)
            problemTypeObj = ProblemType(problemTypeConfig)
            globalParameters["EnableHalf"] = problemTypeObj["DataType"].isHalf(
            )

            # results files will be named
            newResultsFileName = os.path.join(dataPath, "%s_%02u.csv" \
                % (str(problemTypeObj), problemSizeGroupIdx) )
            newSolutionsFileName = os.path.join(dataPath, "%s_%02u.yaml" \
                % (str(problemTypeObj), problemSizeGroupIdx) )

            # skip if possible
            if globalParameters["ForceRedoBenchmarkProblems"] or \
                not os.path.exists(newResultsFileName):

                # Benchmark Problem Size Group
                (resultsFileBaseFinal, benchmarkErrors) = benchmarkProblemType(problemTypeConfig, \
                    problemSizeGroupConfig, problemSizeGroupIdx)
                totalTestFails += benchmarkErrors
                print "clientExit=%u %s for %s" %\
                        (totalTestFails, "(ERROR)" if totalTestFails else "(PASS)", \
                        globalParameters["ConfigPath"])

                # Copy Data
                resultsFileBase = resultsFileBaseFinal
                resultsFileName = "%s.csv" % (resultsFileBase)
                solutionsFileName = "%s.yaml" % (resultsFileBase)
                shutil_copy(resultsFileName, newResultsFileName)
                shutil_copy(solutionsFileName, newSolutionsFileName)
            else:
                print1("# %s_%02u already benchmarked; skipping." %
                       (str(problemTypeObj), problemSizeGroupIdx))

    popWorkingPath()

    if globalParameters["ExitOnFails"] and totalTestFails:
        sys.exit(1)
Beispiel #3
0
def readLibraryLogicForSchedule(filename):
    print1("# Reading Library Logic: %s" % (filename))
    try:
        stream = open(filename, "r")
    except IOError:
        printExit("Cannot open file: %s" % filename)
    data = yaml.load(stream, yaml.SafeLoader)
    stream.close()

    # verify
    if len(data) < 6:
        printExit("len(%s) %u < 7" % (filename, len(data)))

    # parse out objects
    versionString = data[0]["MinimumRequiredVersion"]
    scheduleName = data[1]
    architectureName = data[2]
    deviceNames = data[3]
    problemTypeState = data[4]
    solutionStates = data[5]
    indexOrder = data[6]
    exactLogic = data[7]
    rangeLogic = data[8]

    # does version match
    if not versionIsCompatible(versionString):
        printWarning("File \"%s\" version=%s does not match Tensile version=%s" \
            % (filename, versionString, __version__) )

    # unpack problemType
    problemType = ProblemType(problemTypeState)
    # unpack solutions
    solutions = []
    for i in range(0, len(solutionStates)):
        solutionState = solutionStates[i]
        if solutionState["KernelLanguage"] == "Assembly":
            isa0 = int(architectureName[3])
            isa1 = int(architectureName[4])
            isa2 = int(architectureName[5])
            solutionState["ISA"] = (isa0, isa1, isa2)
        else:
            solutionState["ISA"] = (0, 0, 0)
        solutionObject = Solution(solutionState)
        if solutionObject["ProblemType"] != problemType:
            printExit("ProblemType of file doesn't match solution: %s != %s" \
                % (problemType, solutionObject["ProblemType"]))
        solutions.append(solutionObject)

    return (scheduleName, deviceNames, problemType, solutions, indexOrder, \
        exactLogic, rangeLogic )