TensileCreateLibrary#
- Tensile.TensileCreateLibrary.addFallback(masterLibraries: Dict[str, MasterSolutionLibrary]) None #
Adds fallback library.
Given a master solution library, add a fallback and if the corresponding architecture is unsupported, replace the library altogether with a fallback.
- Parameters:
masterLibraries – A dictionary containing the master solution libraries.
- Tensile.TensileCreateLibrary.addNewLibrary(masterLibraries: Dict[str, MasterSolutionLibrary], newLibrary: MasterSolutionLibrary, architectureName: str) int #
Adds new master solution library to a master solution libraries dict.
For a given architecture, add the new library to a dictionary containing libraries for all architectures, compute the starting index for the new library, then remap the indexes for all of the solutions associated with the library.
- Parameters:
masterLibraries – A dictionary containing all master solution libraries for all architectures.
newLibrary – A master solution library to add to the dictionary.
architectureName – The name of the architecture (or key) associated with the library.
- Returns:
Index to the last solution of the library associated with current architecture.
- Tensile.TensileCreateLibrary.applyNaming(masterLibraries: Dict[str, MasterSolutionLibrary]) None #
Assigns the solution code object file name for lazy libraries.
Given a master solution library with lazy libraries, assigns the key associated with the lazy library (or name) as the value assiciated with the corresponding solution’s code object file.
- Parameters:
masterLibraries – A dictionary containing the master solution libraries.
- Tensile.TensileCreateLibrary.filterProcessingErrors(kernels: List[Solution], solutions: List[Solution], results: List[Tuple[int, str, str, str, str | None]], errorTolerant: bool)#
Filters out processing errors from lists of kernels, solutions, and results.
This function iterates through the results of processKernelSource and identifies any errors encountered during processing. If an error is found (-2 error code), the corresponding kernel, solution, and result are appended to separate lists for removal. After processing, items identified for removal are deleted from the original lists of kernels, solutions, and results.
- Parameters:
kernels – List of Solution objects representing kernels.
solutions – List of Solution objects associated with kernels.
results – List of tuples representing processing results.
printLevel – Print level indicator.
- Returns:
Tuple containing filtered lists of kernels, solutions, and results after removing items with processing errors.
- Return type:
Tuple[List[Solution], List[Solution], List[Any]]
- Raises:
KeyError – If ‘PrintLevel’ key is not found in the params dictionary.
- Tensile.TensileCreateLibrary.findLogicFiles(path: Path, logicArchs: Set[str], lazyLoading: bool, experimentalDir: str, extraMatchers: Set[str] = {'hip'}) List[str] #
Recursively searches the provided path for logic files.
- Parameters:
path – The path to the directory to search.
logicArchs – Target logic archiectures. These are interepreted as filename substrings for which logic files are to be included.
extraMatchers – Additional directories to include for logic files.
- Returns:
A list of Path objects representing the found YAML files.
- Tensile.TensileCreateLibrary.generateClientConfig(outputPath: Path, masterFile: Path, codeObjectFiles: List[str], configFile: str = 'best-solution.ini') None #
Generates a client config file.
Generates a client config file corresponding to a master library file and code-object parameters created by a TensileCreateLibrary invocation. Also sets best-solution-mode to True.
- Parameters:
outputPath – The path to the tensile output directory where output files are written.
masterFile – Path to the master library file (.dat or .yaml).
codeObjectFiles – List of code object files created by TensileCreateLibrary.
configFile – Name of config file written to the output directory.
- Tensile.TensileCreateLibrary.generateLogicData(logicFiles: List[str], version: str, printLevel: int, separate: bool) Dict[str, MasterSolutionLibrary] #
Generates a dictionary of master solution libraries.
- Parameters:
logicFiles – List of paths to logic files.
version – User provided version for the library.
printLevel – Level of debug printing requested.
separate – Separate libraries by architecture.
- Returns:
For separate architectures, a dictionary of architecture separated master solution libraries; otherwise, a single master solution library for all architectures.
- Tensile.TensileCreateLibrary.generateLazyMasterFileList(masterFileList: List[Tuple[str, MasterSolutionLibrary]]) List[Tuple[str, MasterSolutionLibrary]] #
Generates a list of tuples that represent the name and the state associated with the lazy master libraries.
This function takes a list of MasterSolutionLibraries and traverses each lazy libraries. It collects the items (i.e. the name and corresponding master file) and adds them to list of master files.
- Parameters:
masterLibraries – A list of name / master solution library pairs.
- Returns:
List of pairs of master solutions libraries and the corresponding name.
- Tensile.TensileCreateLibrary.generateMasterFileList(masterLibraries: dict, archs: List[str], lazy: bool) List[Tuple[str, MasterSolutionLibrary]] #
Generates a list of tuples that represent the name and the state associated with the master libraries.
This function takes a dictionary with keys corresponding to a target architecture and values corresponding to the master solution library for that architecture. The function generates a tuple consisting of a MasterSolutionLibrary and the associated name. When not separating architectures, the key full will appear in masterLibraries indicating that all libraries are combinded into a single master library.
- Parameters:
masterLibraries – A dictionary of architecture name / master solution library pairs.
archs – A list of supported architectures.
lazy – If True, add lazy library master files.
- Returns:
List of pairs of master solutions libraries and the corresponding name.
- Tensile.TensileCreateLibrary.makeMasterLibraries(logicList: List[LibraryLogic], separate: bool) Dict[str, MasterSolutionLibrary] #
Creates a dictionary of master solution libraries.
Iterates through a list of LibraryLogic objects creating master solution libraries and modifying the solution indexing as required.
- Parameters:
logicFiles – List of LibraryLogic objects.
separate – Separate libraries by architecture.
- Returns:
An architecture separated master solution libraries or a single master solution library for all architectures.
- Tensile.TensileCreateLibrary.makeSolutions(masterLibraries: dict, separate: bool)#
Extracts the solutions from the master solution library.
Given a master solution library, forms a flattened generator that yields solutions by iterating over all of the solutions contained in the master solution libraries. If using separate architectures but not using lazy loading, lazyLibraries should be an empty dict.
- Parameters:
masterLibraries – A dictionary containing the master solution libraries.
- Returns:
Generator representing a sequence of library logic tuples.
- Tensile.TensileCreateLibrary.markDuplicateKernels(kernels: List[Solution], kernelWriterAssembly: KernelWriterAssembly) List[Solution] #
Marks duplicate assembly kernels based on their generated base file names.
Kernels written in Assembly language may generate duplicate output file names, leading to potential race conditions. This function identifies such duplicates within the provided list of Solution objects and marks them to prevent issues.
- Parameters:
kernels – A list of Solution objects representing kernels to be processed.
- Returns:
A modified list of Solution objects where kernels identified as duplicates are marked with a duplicate attribute indicating their duplication status.
Notes
This function sets the “duplicate” attribute on Solution objects, and thereby prepares kernels for processKernelSource, which requires “duplicate” to be set.
- Tensile.TensileCreateLibrary.parseLibraryLogicFiles(logicFiles: List[str]) List[LibraryLogic] #
Load and parse logic (yaml) files.
Given a list of paths to yaml files containing library logic, load the files into memory and parse the data into a named tuple (i.e. LibraryLogic). This operation is parallelized over N processes.
- Parameters:
logicFiles – List of paths to logic files.
- Returns:
List of library logic tuples.
- Tensile.TensileCreateLibrary.prepAsm(kernelWriterAssembly: KernelWriterAssembly, isLinux: bool, buildPath: Path, isa: Tuple[int, int, int], printLevel: int)#
Create and prepare the assembly directory; called ONCE per output directory.
This function is called once per output directory. It creates a directory “assembly” under the provided buildPath, and generates a bash script for compiling object files into code object files.
- Parameters:
kernelWriterAssembly – Assembly writer object.
buildPath – Path to directory where assembly files will be written.
- Tensile.TensileCreateLibrary.sanityCheck(srcLibPaths: List[str], asmLibPaths: List[str], codeObjectPaths: List[str], genSourcesAndExit: bool)#
Verifies that generated code object paths match associated library paths.
- Parameters:
srcLibPaths – Source library paths (.hsaco).
asmLibPaths – Assembly library paths (.co).
coPaths – Code object paths containing generated kernels; should contain all assembly and source library paths.
genSourcesAndExit – Flag identifying whether only source file should be generated.
- Raises:
ValueError – If code object paths do not match library paths.
- Tensile.TensileCreateLibrary.verifyManifest(manifest: Path) bool #
Verifies whether the files listed in the manifest exist on disk.
- Parameters:
manifest – Path to the manifest file.
- Returns:
True if all files exist on disk, otherwise False.
- Tensile.TensileCreateLibrary.writeMasterFile(libraryPath: Path, format: str, naming: dict, name: str, lib: MasterSolutionLibrary) None #
Writes a master file to disk as a .yaml or .dat file.
- Parameters:
libraryPath – Path to library subdirectory located in the tensile output directory.
format – Output format of written file (.dat or .yaml).
naming – Kernel minimum naming.
name – Name of the masterfile.
lib – Master solution library data.