コード例 #1
0
 def getMinNaming(objs):
   # early return
   if len(objs) == 0:
     return {}
   # determine keys
   requiredParameters = {}
   if isinstance(objs[0], Solution):
     keys = list(objs[0].state.keys())
   else:
     keys = list(objs[0].keys())
   # only 1, rather than name being nothing, it'll be everything
   if len(objs) == 1:
     for key in keys:
       if key in validParameters.keys():
         requiredParameters[key] = False
   else:
     for key in keys:
       required = False
       if key in validParameters.keys():
         for i in range(1, len(objs)):
           if objs[0][key] != objs[i][key]:
             required = True
             break
       if required:
         requiredParameters[key] = True
       else:
         requiredParameters[key] = False
   requiredParameters["ProblemType"] = False # always prepended
   requiredParameters["MacroTile0"] = False # always prepended
   requiredParameters["MacroTile1"] = False # always prepended
   requiredParameters["DepthU"] = False # always prepended
   requiredParameters["Kernel"] = True # distinguish kernels from solutions
                                       # for single-source compilation
   return requiredParameters
コード例 #2
0
  def getNameSerial(state, serialNaming):
    data = serialNaming[0]
    numDigits = serialNaming[1]

    serial = 0
    multiplier = 1
    for paramName in sorted(state.keys()):
      if paramName in validParameters.keys():
        paramValue = state[paramName]
        paramData = data[paramName]
        paramNameMultiplier = len(paramData)
        if paramValue in paramData:
          paramValueIdx = paramData.index(paramValue)
        serial += paramValueIdx * multiplier
        multiplier *= paramNameMultiplier
    name = "%s%0*u" % ("S" if isinstance(state, Solution) else "K", \
        numDigits, serial)
    return name
コード例 #3
0
 def getSerialNaming(objs):
   data = {}
   for objIdx in range(0, len(objs)):
     obj = objs[objIdx]
     for paramName in sorted(obj.keys()):
       if paramName in validParameters.keys():
         paramValue = obj[paramName]
         if paramName in data:
           if paramValue not in data[paramName]:
             data[paramName].append(paramValue)
         else:
           data[paramName] = [ paramValue ]
   maxObjs = 1
   for paramName in data:
     data[paramName] = sorted(data[paramName])
     maxObjs *= len(data[paramName])
   numDigits = len(str(maxObjs))
   return [ data, numDigits ]
コード例 #4
0
    def fillInMissingStepsWithDefaults(self, config):
        print2("")
        print2(
            "####################################################################"
        )
        print1("# Filling in Parameters With Defaults")
        print2(
            "####################################################################"
        )
        print2("")

        ############################################################################
        # (I-0) get 6 phases from config
        configBenchmarkCommonParameters = config["BenchmarkCommonParameters"] \
            if "BenchmarkCommonParameters" in config \
            else [{"ProblemSizes": defaultProblemSizes}]
        configForkParameters = config["ForkParameters"] \
            if "ForkParameters" in config else []
        configBenchmarkForkParameters = config["BenchmarkForkParameters"] \
            if "BenchmarkForkParameters" in config \
            else []
        configJoinParameters = config["JoinParameters"] \
            if "JoinParameters" in config else []
        configBenchmarkJoinParameters = config["BenchmarkJoinParameters"] \
            if "BenchmarkJoinParameters" in config \
            else []
        configBenchmarkFinalParameters = config["BenchmarkFinalParameters"] \
            if "BenchmarkFinalParameters" in config and config["BenchmarkFinalParameters"] != None \
            and len(config["BenchmarkFinalParameters"]) > 0 \
            else [{"ProblemSizes": defaultBenchmarkFinalProblemSizes}]

        ############################################################################
        # Ensure only valid solution parameters were requested
        validParameterNames = validParameters.keys()
        for paramDictList in [configBenchmarkCommonParameters, \
            configForkParameters, configBenchmarkForkParameters, \
            configBenchmarkJoinParameters]:
            if paramDictList != None:
                for paramDict in paramDictList:
                    for paramName in paramDict:
                        if paramName in ["ProblemSizes"]:
                            continue
                        else:
                            if paramName not in validParameterNames:
                                printExit("Invalid parameter name: %s\nValid parameters are %s." \
                                    % (paramName, validParameterNames))
                            paramValues = paramDict[paramName]
                            for paramValue in paramValues:
                                if paramValue not in validParameters[
                                        paramName]:
                                    printExit("Invalid parameter value: %s = %s\nValid values for %s are %s." \
                                        % (paramName, paramValue, paramName, validParameters[paramName]))

        ############################################################################
        # (I-1) get current problem sizes
        currentProblemSizes = defaultProblemSizes
        if configBenchmarkCommonParameters != None:
            if len(configBenchmarkCommonParameters) > 0:
                if "ProblemSizes" in configBenchmarkCommonParameters[0]:
                    # user specified, so use it, remove it from config and insert later
                    currentProblemSizes = \
                      configBenchmarkCommonParameters[0]["ProblemSizes"]
                    del configBenchmarkCommonParameters[0]
        # into common we put in all Dcommon that
        # don't show up in Ccommon/Cfork/CBfork/Cjoin/CBjoin
        # followed by Ccommon
        self.benchmarkCommonParameters = [{
            "ProblemSizes": currentProblemSizes
        }]
        for paramDict in defaultBenchmarkCommonParameters:
            for paramName in paramDict:
                if not hasParam( paramName, [ configBenchmarkCommonParameters, \
                    configForkParameters, configBenchmarkForkParameters, \
                    configJoinParameters, configBenchmarkJoinParameters]) \
                    or paramName == "ProblemSizes":
                    self.benchmarkCommonParameters.append(paramDict)
        if configBenchmarkCommonParameters != None:
            for paramDict in configBenchmarkCommonParameters:
                self.benchmarkCommonParameters.append(paramDict)
        else:  # make empty
            self.benchmarkCommonParameters = [{
                "ProblemSizes":
                currentProblemSizes
            }]

        ############################################################################
        # (I-2) into fork we put in all Dfork that
        # don't show up in Bcommon/Cfork/CBfork/Cjoin/CBjoin
        # followed by Cfork
        self.forkParameters = []
        for paramDict in defaultForkParameters:
            for paramName in paramDict:
                if not hasParam( paramName, [ self.benchmarkCommonParameters, \
                    configForkParameters, configBenchmarkForkParameters, \
                    configJoinParameters, configBenchmarkJoinParameters]) \
                    or paramName == "ProblemSizes":
                    self.forkParameters.append(paramDict)
        if configForkParameters != None:
            for paramDict in configForkParameters:
                self.forkParameters.append(paramDict)
        else:  # make empty
            self.forkParameters = []

        ############################################################################
        # (I-3) get current problem sizes
        if configBenchmarkForkParameters != None:
            if len(configBenchmarkForkParameters) > 0:
                if "ProblemSizes" in configBenchmarkForkParameters[0]:
                    # user specified, so use it, remove it from config and insert later
                    currentProblemSizes = configBenchmarkForkParameters[0][
                        "ProblemSizes"]
                    del configBenchmarkForkParameters[0]
        # into Bfork we put in all DBfork that
        # don't show up in Bcommon/Bfork/CBfork/Cjoin/CBjoin
        # followed by CBforked
        self.benchmarkForkParameters = [{"ProblemSizes": currentProblemSizes}]
        for paramDict in defaultBenchmarkForkParameters:
            for paramName in paramDict:
                if not hasParam( paramName, [ self.benchmarkCommonParameters, \
                    self.forkParameters, configBenchmarkForkParameters, \
                    configJoinParameters, configBenchmarkJoinParameters]) \
                    or paramName == "ProblemSizes":
                    self.benchmarkForkParameters.append(paramDict)
        if configBenchmarkForkParameters != None:
            for paramDict in configBenchmarkForkParameters:
                self.benchmarkForkParameters.append(paramDict)
        else:  # make empty
            self.benchmarkForkParameters = [{
                "ProblemSizes": currentProblemSizes
            }]

        ############################################################################
        # (I-4) into join we put in all non-derrived Djoin that
        # don't show up in Bcommon/Bfork/CBfork/Cjoin/CBjoin
        # followed by CBforked
        self.joinParameters = []
        for paramName in defaultJoinParameters:
            if not hasParam( paramName, [ self.benchmarkCommonParameters, \
                self.forkParameters, self.benchmarkForkParameters, \
                configJoinParameters, configBenchmarkJoinParameters]) \
                or paramName == "ProblemSizes":
                if "JoinParameters" not in config \
                    or (paramName != "MacroTile"):
                    self.joinParameters.append(paramName)
        if configJoinParameters != None:
            for paramName in configJoinParameters:
                self.joinParameters.append(paramName)
        else:  # make empty
            self.joinParameters = []

        ############################################################################
        # (I-5) benchmark join
        if configBenchmarkJoinParameters != None:
            if len(configBenchmarkJoinParameters) > 0:
                if "ProblemSizes" in configBenchmarkJoinParameters[0]:
                    # user specified, so use it, remove it from config and insert later
                    currentProblemSizes = configBenchmarkJoinParameters[0][
                        "ProblemSizes"]
                    del configBenchmarkJoinParameters[0]
        # into Bjoin we put in all DBjoin that
        # don't show up in Bcommon/Bfork/BBfork/Bjoin/CBjoin
        # followed by CBjoin
        self.benchmarkJoinParameters = [{"ProblemSizes": currentProblemSizes}]
        for paramDict in defaultBenchmarkJoinParameters:
            for paramName in paramDict:
                if not hasParam( paramName, [ self.benchmarkCommonParameters, \
                    self.forkParameters, self.benchmarkForkParameters, \
                    self.joinParameters, configBenchmarkJoinParameters]) \
                    or paramName == "ProblemSizes":
                    self.benchmarkJoinParameters.append(paramDict)
        if configBenchmarkJoinParameters != None:
            for paramDict in configBenchmarkJoinParameters:
                self.benchmarkJoinParameters.append(paramDict)
        else:  # make empty
            self.benchmarkJoinParameters = [{
                "ProblemSizes": currentProblemSizes
            }]

        ############################################################################
        # (I-6) benchmark final sizes
        self.benchmarkFinalParameters = configBenchmarkFinalParameters
        # no other parameters besides problem sizes

        ############################################################################
        # (I-7) any default param with 1 value will be hardcoded; move to beginning
        for stepList in [self.benchmarkCommonParameters, \
            self.forkParameters, self.benchmarkForkParameters, \
            self.benchmarkJoinParameters]:
            for paramDict in copy(stepList):
                for paramName in copy(paramDict):
                    paramValues = paramDict[paramName]
                    if paramValues == None:
                        printExit(
                            "You must specify value for parameters \"%s\"" %
                            paramName)
                    if len(paramValues) < 2 and paramName != "ProblemSizes":
                        paramDict.pop(paramName)
                        #self.benchmarkCommonParameters.insert(0, {paramName: paramValues })
                        self.hardcodedParameters[0][paramName] = paramValues[0]
                        self.singleValueParameters[paramName] = [
                            paramValues[0]
                        ]
                        self.initialSolutionParameters[
                            paramName] = paramValues[0]
                        if len(paramDict) == 0:
                            stepList.remove(paramDict)

        ############################################################################
        # (I-8) if fork and join, but no benchmark fork, append dummy benchmarkFork
        if len(self.forkParameters) > 0 and len(self.joinParameters) > 0 \
            and (len(self.benchmarkForkParameters) == 0 \
            or (len(self.benchmarkForkParameters) == 1 \
            and hasParam("ProblemSizes", self.benchmarkForkParameters)) ):
            self.benchmarkForkParameters.append({"BenchmarkFork": [0]})

        ############################################################################
        # (I-9) if join, but no benchmark join, append dummy benchmarkJoin
        #if len(self.joinParameters) > 0 \
        #    and (len(self.benchmarkJoinParameters) == 0 \
        #    or (len(self.benchmarkJoinParameters) == 1 \
        #    and hasParam("ProblemSizes", self.benchmarkJoinParameters)) ):
        #  self.benchmarkJoinParameters.append({"BenchmarkJoin": [0]})
        # No, this is handles by Final Benchmark

        ############################################################################
        # (I-10) Parameter Lists
        # benchmarkCommonParameters
        print2("HardcodedParameters:")
        for paramName in self.hardcodedParameters[0]:
            paramValues = self.hardcodedParameters[0][paramName]
            print2("    %s: %s" % (paramName, paramValues))
        print2("BenchmarkCommonParameters:")
        for step in self.benchmarkCommonParameters:
            print2("    %s" % step)
        # forkParameters
        print2("ForkParameters:")
        for param in self.forkParameters:
            print2("    %s" % param)
        # benchmarkForkParameters
        print2("BenchmarkForkParameters:")
        for step in self.benchmarkForkParameters:
            print2("    %s" % step)
        # joinParameters
        print2("JoinParameters:")
        for param in self.joinParameters:
            print2("    %s" % param)
        # benchmarkJoinParameters
        print2("BenchmarkJoinParameters:")
        for step in self.benchmarkJoinParameters:
            print2("    %s" % step)
        # benchmarkJoinParameters
        print2("BenchmarkFinalParameters:")
        for step in self.benchmarkFinalParameters:
            print2("    %s" % step)
コード例 #5
0
 def getNameFull(state):
   requiredParameters = {}
   for key in state:
     if key in validParameters.keys():
       requiredParameters[key] = True
   return Solution.getNameMin(state, requiredParameters)