Classes | |
class | bcolors |
class | disablefuncmode |
class | InputError |
class | Trie |
Functions | |
def | openf (filename, mode) |
def | matched_files_iter (root_path, includes=('*',), ignores=(), extensions=(), out_of_place_only=False) |
def | preprocess (output_directory, all_files, show_detailed=False, show_progress=True, hip_clang_launch=False) |
def | compute_stats (stats) |
def | add_dim3 (kernel_string, cuda_kernel) |
def | processKernelLaunches (string, stats) |
def | find_closure_group (input_string, start, group) |
def | find_bracket_group (input_string, start) |
def | find_parentheses_group (input_string, start) |
def | disable_asserts (input_string) |
def | replace_math_functions (input_string) |
def | hip_header_magic (input_string) |
def | replace_extern_shared (input_string) |
def | disable_function (input_string, function, replace_style) |
def | get_hip_file_path (filepath) |
def | is_out_of_place (filepath) |
def | is_pytorch_file (filepath) |
def | is_caffe2_gpu_file (filepath) |
def | preprocessor (output_directory, filepath, stats, hip_clang_launch) |
def | file_specific_replacement (filepath, search_string, replace_string, strict=False) |
def | file_add_header (filepath, header) |
def | fix_static_global_kernels (in_txt) |
def | disable_unsupported_function_call (function, input_string, replacement) |
def | disable_module (input_file) |
def | extract_arguments (start, string) |
def | str2bool (v) |
def | hipify (project_directory, show_detailed=False, extensions=(".cu",".cuh",".c",".cc",".cpp",".h",".in",".hpp"), output_directory="", includes=(), json_settings="", out_of_place_only=False, ignores=(), show_progress=True, hip_clang_launch=False) |
The Python Hipify script. ## # Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. # 2017-2018 Advanced Micro Devices, Inc. and # Facebook Inc. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE.
def pyHIPIFY.hipify_python.add_dim3 | ( | kernel_string, | |
cuda_kernel | |||
) |
adds dim3() to the second and third arguments in the kernel launch
Definition at line 289 of file hipify_python.py.
def pyHIPIFY.hipify_python.disable_asserts | ( | input_string | ) |
Disables regular assert statements e.g. "assert(....)" -> "/*assert(....)*/"
Definition at line 496 of file hipify_python.py.
def pyHIPIFY.hipify_python.disable_function | ( | input_string, | |
function, | |||
replace_style | |||
) |
Finds and disables a function in a particular file. If type(function) == List function - The signature of the function to disable. e.g. ["bool", "overlappingIndices", "(const Tensor& t)"] disables function -> "bool overlappingIndices(const Tensor& t)" If type(function) == String function - Disables the function by name only. e.g. "overlappingIndices" replace_style - The style to use when stubbing functions.
Definition at line 570 of file hipify_python.py.
def pyHIPIFY.hipify_python.disable_module | ( | input_file | ) |
Disable a module entirely except for header includes.
Definition at line 1013 of file hipify_python.py.
def pyHIPIFY.hipify_python.disable_unsupported_function_call | ( | function, | |
input_string, | |||
replacement | |||
) |
Disables calls to an unsupported HIP function
Definition at line 973 of file hipify_python.py.
def pyHIPIFY.hipify_python.extract_arguments | ( | start, | |
string | |||
) |
Return the list of arguments in the upcoming function parameter closure. Example: string (input): '(blocks, threads, 0, THCState_getCurrentStream(state))' arguments (output): '[{'start': 1, 'end': 7}, {'start': 8, 'end': 16}, {'start': 17, 'end': 19}, {'start': 20, 'end': 53}]'
Definition at line 1027 of file hipify_python.py.
def pyHIPIFY.hipify_python.find_bracket_group | ( | input_string, | |
start | |||
) |
Finds the first balanced parantheses.
Definition at line 483 of file hipify_python.py.
def pyHIPIFY.hipify_python.find_closure_group | ( | input_string, | |
start, | |||
group | |||
) |
Generalization for finding a balancing closure group if group = ["(", ")"], then finds the first balanced parantheses. if group = ["{", "}"], then finds the first balanced bracket. Given an input string, a starting position in the input string, and the group type, find_closure_group returns the positions of group[0] and group[1] as a tuple. Example: find_closure_group("(hi)", 0, ["(", ")"]) Returns: 0, 3
Definition at line 443 of file hipify_python.py.
def pyHIPIFY.hipify_python.find_parentheses_group | ( | input_string, | |
start | |||
) |
Finds the first balanced bracket.
Definition at line 488 of file hipify_python.py.
def pyHIPIFY.hipify_python.fix_static_global_kernels | ( | in_txt | ) |
Static global kernels in HIP results in a compilation error.
Definition at line 967 of file hipify_python.py.
def pyHIPIFY.hipify_python.get_hip_file_path | ( | filepath | ) |
Returns the new name of the hipified file
Definition at line 709 of file hipify_python.py.
def pyHIPIFY.hipify_python.hip_header_magic | ( | input_string | ) |
If the file makes kernel builtin calls and does not include the cuda_runtime.h header, then automatically add an #include to match the "magic" includes provided by NVCC. TODO: Update logic to ignore cases where the cuda_runtime.h is included by another file.
Definition at line 524 of file hipify_python.py.
def pyHIPIFY.hipify_python.preprocess | ( | output_directory, | |
all_files, | |||
show_detailed = False , |
|||
show_progress = True , |
|||
hip_clang_launch = False |
|||
) |
Call preprocessor on selected files. Arguments) show_detailed - Show a detailed summary of the transpilation process.
Definition at line 250 of file hipify_python.py.
def pyHIPIFY.hipify_python.preprocessor | ( | output_directory, | |
filepath, | |||
stats, | |||
hip_clang_launch | |||
) |
Executes the CUDA -> HIP conversion on the specified file.
Definition at line 884 of file hipify_python.py.
def pyHIPIFY.hipify_python.processKernelLaunches | ( | string, | |
stats | |||
) |
Replace the CUDA style Kernel launches with the HIP style kernel launches.
Definition at line 327 of file hipify_python.py.
def pyHIPIFY.hipify_python.replace_extern_shared | ( | input_string | ) |
Match extern __shared__ type foo[]; syntax and use HIP_DYNAMIC_SHARED() MACRO instead. https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md#__shared__ Example: "extern __shared__ char smemChar[];" => "HIP_DYNAMIC_SHARED( char, smemChar)" "extern __shared__ unsigned char smem[];" => "HIP_DYNAMIC_SHARED( unsigned char, my_smem)"
Definition at line 555 of file hipify_python.py.
def pyHIPIFY.hipify_python.replace_math_functions | ( | input_string | ) |
FIXME: Temporarily replace std:: invocations of math functions with non-std:: versions to prevent linker errors NOTE: This can lead to correctness issues when running tests, since the correct version of the math function (exp/expf) might not get called. Plan is to remove this function once HIP supports std:: math function calls inside device code
Definition at line 509 of file hipify_python.py.
def pyHIPIFY.hipify_python.str2bool | ( | v | ) |
ArgumentParser doesn't support type=bool. Thus, this helper method will convert from possible string types to True / False.
Definition at line 1073 of file hipify_python.py.