Exemple #1
0
def test_integration(useGlobalParameters, builddir, getLogicFileDir,
                     testYamls, mergeFiles, libraryFormat, shortNames, legacyComponents):
  mergeFiles, shortNames, legacyComponents = str2bool(mergeFiles, shortNames, legacyComponents)

  if isSkippedTest(testYamls, mergeFiles, libraryFormat, shortNames, legacyComponents):
    pytest.skip("only run pre_checkin test in certain combo")

  logicFileDir = os.path.join(getLogicFileDir, testYamls)
  outputDir    = os.path.join(builddir, "lib")

  with useGlobalParameters(OutputPath=outputDir,
                           WorkingPath=outputDir,
                           MergeFiles=mergeFiles,
                           LibraryFormat=libraryFormat,
                           LegacyComponents=legacyComponents,
                           ShortNames=shortNames,
                           GenerateManifestAndExit=False
                           ):
    Common.ensurePath(outputDir)

    createLibraryScript = ClientWriter.getBuildClientLibraryScript(outputDir, logicFileDir)
    subprocess.run(shlex.split(createLibraryScript), cwd=outputDir, check=True)

    coList = []
    libList = []
    coExt = "co"
    libExt = "yaml" if libraryFormat == "yaml" else "dat"
    with open(os.path.join(outputDir,"library","TensileManifest.txt"), "r") as f:
      lines = f.read().split("\n")
      coList = [line for line in lines if coExt in line]
      libList = [line for line in lines if libExt in line]

    logicFiles = [os.path.join(logicFileDir, f) for f in os.listdir(logicFileDir) \
      if (os.path.isfile(os.path.join(logicFileDir, f)) and os.path.splitext(f)[1]==".yaml")]

    clientParametersPaths = []
    isaStr = "".join([str(e) for e in Common.globalParameters["CurrentISA"]])
    for logicFileName in logicFiles:
      (scheduleName, _, problemType, _, _, exactLogic, _, newLibrary, archName) = LibraryIO.parseLibraryLogicFile(logicFileName)
      problemSizes = ProblemSizesMock(random.sample(exactLogic, min(len(exactLogic), 16))) # sample at most 16 problems
      if isaStr in archName:
        clientParametersPaths.append(ClientWriter.writeClientConfig(
                                      forBenchmark=False,
                                      solutions=None,
                                      problemSizes=problemSizes,
                                      stepName=str(ProblemType(problemType)),
                                      stepBaseDir=outputDir,
                                      newLibrary=newLibrary,
                                      configBase="ClientParameters_%s_%s"%(scheduleName, str(ProblemType(problemType))),
                                      codeObjectFiles=coList,
                                      tileAwareSelection=False,
                                      libraryFile=libList[0]))

    forBenchmark = False
    enableTileSelection = False
    returncode = ClientWriter.runClient(logicFileDir, forBenchmark, enableTileSelection, clientParametersPaths)

    assert(returncode == 0)
Exemple #2
0
def downloadLogicFiles(logicDir):
  prefix = "library/src/blas3/Tensile/Logic/asm_full"
  testData = {
    "pre_checkin" : [
      "arcturus_Cijk_Ailk_Bjlk_SB.yaml",
      "vega20_Cijk_Ailk_Bjlk_SB.yaml",
      "vega10_Cijk_Ailk_Bjlk_SB.yaml",
      "arcturus_Cijk_Ailk_Bjlk_BBH.yaml",
      "arcturus_Cijk_Ailk_Bjlk_HBH.yaml",
      "vega20_Cijk_Ailk_Bjlk_HBH.yaml",
      "vega10_Cijk_Ailk_Bjlk_HBH.yaml",
      "hip_Cijk_Ailk_Bjlk_CB.yaml"
    ],
    "quick" : [
      "arcturus_Cijk_Ailk_Bjlk_SB.yaml",
      "vega20_Cijk_Ailk_Bjlk_SB.yaml",
      "vega10_Cijk_Ailk_Bjlk_SB.yaml"
    ]
  }

  parentDir = os.path.dirname(logicDir)
  shutil.rmtree(logicDir, ignore_errors=True)

  # basically to query the latest zip release weblink, download it and unzip
  # selected files to destination folder
  cmd = """#!/bin/bash
  set -x
  wget -nc https://api.github.com/repos/ROCmSoftwarePlatform/rocBLAS/releases/latest
  weblink=$(grep -oP '(?<="zipball_url": ")[a-zA-Z:/\.\-0-9]*' latest)
  wget -nc $weblink
  archive=$(basename $weblink)
  rootDir=$(zipinfo -1 $archive | head -n 1)
  """
  for schedule in list(testData.keys()):
    for f in testData[schedule]:
      dir = os.path.join(logicDir, schedule)
      Common.ensurePath(dir)
      cmd += "unzip -j -d %s -x $archive ${rootDir}%s\n"%(dir, os.path.join(prefix,f))

  scriptFile = os.path.join(parentDir,"get_logic.sh")
  with open(scriptFile, "w") as file:
    file.write(cmd)
  os.chmod(scriptFile, 0o777)

  subprocess.run(scriptFile, cwd=parentDir, check=True)
Exemple #3
0
        def __enter__(self):
            argParser = argparse.ArgumentParser()
            Tensile.addCommonArguments(argParser)
            args = argParser.parse_args(tensile_args)

            Common.restoreDefaultGlobalParameters()
            if args.CxxCompiler:
                Common.globalParameters["CxxCompiler"] = args.CxxCompiler

            Common.assignGlobalParameters({})

            overrideParameters = Tensile.argUpdatedGlobalParameters(args)
            for key, value in overrideParameters.items():
                Common.globalParameters[key] = value

            for key, value in self.additionalParams.items():
                Common.globalParameters[key] = value

            return Common.globalParameters
def test_WriteClientLibraryFromSolutions(tmpdir):
    Common.globalParameters["MergeFiles"] = True
    Common.globalParameters["CodeObjectVersion"] = "V3"
    Common.globalParameters["YAML"] = True
    Common.globalParameters["CxxCompiler"] = "hipcc"
    Common.assignGlobalParameters({})

    libraryWorkingPath = tmpdir.mkdir("lib")
    buildWorkingPath = tmpdir.mkdir("build")

    scriptDir = os.path.dirname(os.path.realpath(__file__))
    dataDir = os.path.realpath(
        os.path.join(scriptDir, "..", "test_data", "unit"))
    solutionsFilePath = os.path.join(dataDir, "solutions",
                                     "solutions_nn_3.yaml")

    fileSolutions = LibraryIO.parseSolutionsFile(solutionsFilePath)
    solutions = fileSolutions[1]

    Common.setWorkingPath(buildWorkingPath)
    TensileCreateLibrary.WriteClientLibraryFromSolutions(
        solutions, libraryWorkingPath)
    Common.popWorkingPath()

    tensileLibraryPath = os.path.join(libraryWorkingPath, "library")

    hsacoFiles = glob.glob(tensileLibraryPath + "/*hsaco")
    assert (len(hsacoFiles) > 0)

    coFiles = glob.glob(tensileLibraryPath + "/*TensileLibrary*co")
    assert (len(coFiles) > 0)

    tensileYamlFilePath = os.path.join(tensileLibraryPath,
                                       "TensileLibrary.yaml")
    assert os.path.exists(tensileYamlFilePath) == 1

    config = None
    try:
        stream = open(tensileYamlFilePath, "r")
    except IOError:
        mylogger.error("Cannot open file: %s" % tensileYamlFilePath)
    config = yaml.load(stream, yaml.SafeLoader)
    stream.close()
    actualSolutions = config["solutions"]

    assert (len(actualSolutions) == 3)

    metadataYamlFilePath = os.path.join(tensileLibraryPath, "metadata.yaml")
    assert os.path.exists(metadataYamlFilePath) == 1

    metadata = None
    try:
        stream = open(metadataYamlFilePath, "r")
    except IOError:
        mylogger.error("Cannot open file: %s" % metadataYamlFilePath)
    metadata = yaml.load(stream, yaml.SafeLoader)
    stream.close()
    actualProblemType = metadata["ProblemType"]

    assert (len(actualProblemType) > 0)
Exemple #5
0
def test_gfxArch():
    assert Common.gfxArch('gfx9') is None

    assert Common.gfxArch('gfx803') == (8, 0, 3)
    assert Common.gfxArch('gfx900') == (9, 0, 0)
    assert Common.gfxArch('gfx906') == (9, 0, 6)

    assert Common.gfxArch('gfx1010') == (10, 1, 0)

    assert Common.gfxArch('gfx90015') == (900, 1, 5)

    assert Common.gfxArch('blah gfx900 stuff') == (9, 0, 0)
Exemple #6
0
def test_paths():
    workingPathName = "working/path"
    Common.globalParameters["WorkingPath"] = workingPathName
    expectedWorkingPath = "working/path"
    assert Common.globalParameters["WorkingPath"] == expectedWorkingPath

    recursiveWorkingPath = "next1"
    expectedRecurrsiveWorkingPath = "working/path/next1"
    Common.pushWorkingPath(recursiveWorkingPath)
    assert Common.globalParameters[
        "WorkingPath"] == expectedRecurrsiveWorkingPath
    Common.popWorkingPath()
    assert Common.globalParameters["WorkingPath"] == expectedWorkingPath

    set1WorkingPath = "working/path/set1"
    expectedSet1WorkingPath = "working/path/set1"
    Common.setWorkingPath(set1WorkingPath)
    assert Common.globalParameters["WorkingPath"] == expectedSet1WorkingPath
    Common.popWorkingPath()
    assert Common.globalParameters["WorkingPath"] == expectedWorkingPath
Exemple #7
0
 def __exit__(self, exc_type, exc_value, traceback):
     Common.restoreDefaultGlobalParameters()