diff --git a/.github/workflows/rocprofiler-register-formatting.yml b/.github/workflows/rocprofiler-register-formatting.yml new file mode 100644 index 00000000000..8ca7b4902e7 --- /dev/null +++ b/.github/workflows/rocprofiler-register-formatting.yml @@ -0,0 +1,174 @@ + +name: rocprofiler-register Formatting + +on: + workflow_dispatch: + pull_request: + paths: + - 'projects/rocprofiler-register/**' + - '!**/*.md' + - '!**/*.rtf' + - '!**/*.rst' + - '!**/.markdownlint-ci2.yaml' + - '!**/.readthedocs.yaml' + - '!**/.spellcheck.local.yaml' + - '!**/.wordlist.txt' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + cmake: + runs-on: ubuntu-22.04 + env: + ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: projects/rocprofiler-register + + - name: Extract branch name + shell: bash + run: | + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_HEAD_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Install dependencies + working-directory: projects/rocprofiler-register + run: | + sudo apt-get update + sudo apt-get install -y python3-pip + python3 -m pip install -r requirements.txt + + - name: Run cmake-format + working-directory: projects/rocprofiler-register + run: | + FORMAT_FILES=$(find . -type f | egrep 'CMakeLists.txt|\.cmake$') + command -v cmake-format + cmake-format --version + set +e + cmake-format -i ${FORMAT_FILES} + if [ $(git diff | wc -l) -ne 0 ]; then + echo -e "\nError! CMake code not formatted. Run cmake-format...\n" + echo -e "\nFiles:\n" + git diff --name-only + echo -e "\nFull diff:\n" + git diff + exit 1 + fi + + source: + runs-on: ubuntu-22.04 + env: + ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: projects/rocprofiler-register + + - name: Extract branch name + shell: bash + run: | + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_HEAD_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Install dependencies + working-directory: projects/rocprofiler-register + run: | + DISTRIB_CODENAME=$(cat /etc/lsb-release | grep DISTRIB_CODENAME | awk -F '=' '{print $NF}') + sudo apt-get update + sudo apt-get install -y software-properties-common python3 python3-pip + python3 -m pip install -r requirements.txt + + - name: Run clang-format + working-directory: projects/rocprofiler-register + run: | + FORMAT_FILES=$(find samples source tests benchmark -type f | egrep '\.(h|hpp|hh|c|cc|cpp)(|\.in)$') + command -v git + command -v clang-format + git --version + clang-format --version + set +e + FORMAT_OUT=$(clang-format -i ${FORMAT_FILES}) + git status + if [ $(git diff | wc -l) -ne 0 ]; then + echo -e "\nError! Code not formatted. Run clang-format (version 11)...\n" + echo -e "\nFiles:\n" + git diff --name-only + echo -e "\nFull diff:\n" + git diff + exit 1 + fi + + python: + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: ['3.10'] + env: + ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: projects/rocprofiler-register + + - name: Extract branch name + shell: bash + run: | + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_HEAD_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + working-directory: projects/rocprofiler-register + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + + - name: black format + working-directory: projects/rocprofiler-register + run: | + black . + if [ $(git diff | wc -l) -ne 0 ]; then + echo -e "\nError! Python code not formatted. Run black...\n" + echo -e "\nFiles:\n" + git diff --name-only + echo -e "\nFull diff:\n" + git diff + exit 1 + fi + + missing-new-line: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: projects/rocprofiler-register + + - name: Extract branch name + shell: bash + run: | + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_HEAD_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Find missing new line + shell: bash + working-directory: projects/rocprofiler-register + run: | + OUTFILE=missing_newline.txt + for i in $(find source tests samples benchmark docker cmake -type f | egrep -v '\.(bin|png|csv)$|source/docs/_(build|doxygen)'); do VAL=$(tail -c 1 ${i}); if [ -n "${VAL}" ]; then echo "- ${i}" >> ${OUTFILE}; fi; done + if [[ -f ${OUTFILE} && $(cat ${OUTFILE} | wc -l) -gt 0 ]]; then + echo -e "\nError! Source code missing new line at end of file...\n" + echo -e "\nFiles:\n" + cat ${OUTFILE} + exit 1 + fi diff --git a/projects/rocprofiler-register/samples/library-implementation/demo.cpp b/projects/rocprofiler-register/samples/library-implementation/demo.cpp index 0ccbaf559fd..5a28dc61c8b 100644 --- a/projects/rocprofiler-register/samples/library-implementation/demo.cpp +++ b/projects/rocprofiler-register/samples/library-implementation/demo.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #include "demo.hpp" #include diff --git a/projects/rocprofiler-register/scripts/run-ci.py b/projects/rocprofiler-register/scripts/run-ci.py index e6e01c1c89f..f7ea61f302c 100755 --- a/projects/rocprofiler-register/scripts/run-ci.py +++ b/projects/rocprofiler-register/scripts/run-ci.py @@ -439,7 +439,7 @@ def run(*args, **kwargs): ) finally: echo_files = [] - if "-VV" not in ctest_args and not args.quiet: + if not args.quiet: for file in glob.glob( os.path.join(args.binary_dir, "Testing/Temporary/**"), recursive=True, @@ -472,14 +472,14 @@ def run(*args, **kwargs): echo_files_sorted.append(file) echo_files_sorted += [x for x in echo_files if x not in echo_files_sorted] for file in echo_files_sorted: - print(f"\n\n\n###### Reading {file}... ######\n\n\n") + print(f"###### Reading {file}... ######") with open(file, "r") as inpf: fdata = inpf.read() oname = os.path.basename(file) if "LastTest" not in oname and "Coverage" not in oname: print(fdata) - if oname.endswith(".log"): + if not oname.endswith(".log"): oname += ".log" with open(os.path.join(args.binary_dir, oname), "w") as outf: - print(f"\n\n###### Writing {oname}... ######\n\n") + print(f"###### Writing {oname}... ######") outf.write(fdata) diff --git a/projects/rocprofiler-register/source/lib/rocprofiler-register/rocprofiler_register.cpp b/projects/rocprofiler-register/source/lib/rocprofiler-register/rocprofiler_register.cpp index 8990e118205..1833921180c 100644 --- a/projects/rocprofiler-register/source/lib/rocprofiler-register/rocprofiler_register.cpp +++ b/projects/rocprofiler-register/source/lib/rocprofiler-register/rocprofiler_register.cpp @@ -366,12 +366,6 @@ rocp_reg_scan_for_tools() << rocprofiler_lib_register_entrypoint << " not found. Tried to dlopen " << _rocp_reg_lib; } - else if(_found_tool && rocprofiler_set_api_table) - { - rocprofiler_lib_config_fn = &rocprofiler_set_api_table; - rocprofiler_lib_attach_fn = &rocprofiler_attach; - rocprofiler_lib_detach_fn = &rocprofiler_detach; - } return rocp_scan_data{ rocprofiler_lib_handle, rocprofiler_lib_config_fn, diff --git a/projects/rocprofiler-register/tests/CMakeLists.txt b/projects/rocprofiler-register/tests/CMakeLists.txt index 988bdcf74a2..0578592ede5 100644 --- a/projects/rocprofiler-register/tests/CMakeLists.txt +++ b/projects/rocprofiler-register/tests/CMakeLists.txt @@ -170,9 +170,8 @@ function(rocp_register_test_executable _NAME) set(_BASE_PRELOAD "${ROCPROFILER_REGISTER_MEMCHECK_PRELOAD_ENV}") endif() - rocp_register_add_test( - ${_NAME} ${_NAME} "${_BASE_PRELOAD}" - "${RRTE_CORE_PASS_REGEX}" "${RRTE_CORE_FAIL_REGEX}") + rocp_register_add_test(${_NAME} ${_NAME} "${_BASE_PRELOAD}" "${RRTE_CORE_PASS_REGEX}" + "${RRTE_CORE_FAIL_REGEX}") # Build LD_PRELOAD list for -preload tests set(_PRELOAD_LIBS "librocprofiler-register.so" "libgeneric-tool.so") @@ -181,10 +180,8 @@ function(rocp_register_test_executable _NAME) endif() list(JOIN _PRELOAD_LIBS ":" _PRELOAD_STRING) - rocp_register_add_test( - ${_NAME}-preload ${_NAME} - "LD_PRELOAD=${_PRELOAD_STRING}" - "${RRTE_PRELOAD_PASS_REGEX}" "${RRTE_PRELOAD_FAIL_REGEX}") + rocp_register_add_test(${_NAME}-preload ${_NAME} "LD_PRELOAD=${_PRELOAD_STRING}" + "${RRTE_PRELOAD_PASS_REGEX}" "${RRTE_PRELOAD_FAIL_REGEX}") rocp_register_add_test( ${_NAME}-env @@ -194,16 +191,16 @@ function(rocp_register_test_executable _NAME) "${RRTE_PRELOAD_FAIL_REGEX}") rocp_register_add_test( - ${_NAME}-wrap ${_NAME} + ${_NAME}-wrap + ${_NAME} "LD_PRELOAD=librocprofiler-register.so;ROCP_REG_TEST_WRAP=1;${ROCPROFILER_REGISTER_MEMCHECK_PRELOAD_ENV}" - "${RRTE_WRAP_PASS_REGEX}" "${RRTE_WRAP_FAIL_REGEX}") + "${RRTE_WRAP_PASS_REGEX}" + "${RRTE_WRAP_FAIL_REGEX}") rocp_register_add_test( - ${_NAME}-preload-wrap - ${_NAME} + ${_NAME}-preload-wrap ${_NAME} "LD_PRELOAD=${_PRELOAD_STRING};ROCP_REG_TEST_WRAP=1" - "${RRTE_PRELOAD_WRAP_PASS_REGEX}" - "${RRTE_PRELOAD_WRAP_FAIL_REGEX}") + "${RRTE_PRELOAD_WRAP_PASS_REGEX}" "${RRTE_PRELOAD_WRAP_FAIL_REGEX}") rocp_register_add_test( ${_NAME}-env-wrap diff --git a/projects/rocprofiler-register/tests/bin/simple-hip.cpp b/projects/rocprofiler-register/tests/bin/simple-hip.cpp index 99ebe7cca24..218a36f0437 100644 --- a/projects/rocprofiler-register/tests/bin/simple-hip.cpp +++ b/projects/rocprofiler-register/tests/bin/simple-hip.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -59,8 +60,8 @@ namespace { using auto_lock_t = std::unique_lock; auto print_lock = std::mutex{}; -size_t xdim = 4960 * 2; -size_t ydim = 4960 * 2; +size_t xdim = 4096 * 2; +size_t ydim = 4096 * 2; size_t nthreads = 2; size_t nitr = 1; } // namespace @@ -112,6 +113,12 @@ main(int argc, char** argv) itr.join(); } + std::ifstream maps_file("/proc/self/maps"); + std::string line; + while (std::getline(maps_file, line)) { + std::cout << line << std::endl; + } + return 0; } diff --git a/projects/rocprofiler-register/tests/generic-tool/generic-tool.cpp b/projects/rocprofiler-register/tests/generic-tool/generic-tool.cpp index 654d2a7ac2f..df60effae7b 100644 --- a/projects/rocprofiler-register/tests/generic-tool/generic-tool.cpp +++ b/projects/rocprofiler-register/tests/generic-tool/generic-tool.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #include #include #include diff --git a/projects/rocprofiler-register/tests/rccl/rccl.hpp b/projects/rocprofiler-register/tests/rccl/rccl.hpp index ae33a34103f..cbc7b42e51b 100644 --- a/projects/rocprofiler-register/tests/rccl/rccl.hpp +++ b/projects/rocprofiler-register/tests/rccl/rccl.hpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #pragma once #define RCCL_API_TRACE_VERSION_MAJOR 0 diff --git a/projects/rocprofiler-register/tests/rocprofiler/rocprofiler.cpp b/projects/rocprofiler-register/tests/rocprofiler/rocprofiler.cpp index 2a7e944b968..07398c58672 100644 --- a/projects/rocprofiler-register/tests/rocprofiler/rocprofiler.cpp +++ b/projects/rocprofiler-register/tests/rocprofiler/rocprofiler.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #include #include #include diff --git a/projects/rocprofiler-register/tests/roctx/roctx.cpp b/projects/rocprofiler-register/tests/roctx/roctx.cpp index b3e2536bc94..6d7821dcf60 100644 --- a/projects/rocprofiler-register/tests/roctx/roctx.cpp +++ b/projects/rocprofiler-register/tests/roctx/roctx.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #ifdef NDEBUG # undef NDEBUG #endif diff --git a/projects/rocprofiler-register/tests/roctx/roctx.hpp b/projects/rocprofiler-register/tests/roctx/roctx.hpp index be7eeec0b14..90b944a47b2 100644 --- a/projects/rocprofiler-register/tests/roctx/roctx.hpp +++ b/projects/rocprofiler-register/tests/roctx/roctx.hpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #pragma once #define ROCTX_VERSION_MAJOR 4 diff --git a/projects/rocprofiler-register/tests/test-amdhip-ctor-mt.cpp b/projects/rocprofiler-register/tests/test-amdhip-ctor-mt.cpp index a7486e0153f..bfeb3303810 100644 --- a/projects/rocprofiler-register/tests/test-amdhip-ctor-mt.cpp +++ b/projects/rocprofiler-register/tests/test-amdhip-ctor-mt.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #include #include #include diff --git a/projects/rocprofiler-register/tests/test-amdhip-ctor.cpp b/projects/rocprofiler-register/tests/test-amdhip-ctor.cpp index 40535cbecc5..32102100747 100644 --- a/projects/rocprofiler-register/tests/test-amdhip-ctor.cpp +++ b/projects/rocprofiler-register/tests/test-amdhip-ctor.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #include #include #include diff --git a/projects/rocprofiler-register/tests/test-amdhip-hsart-roctx.cpp b/projects/rocprofiler-register/tests/test-amdhip-hsart-roctx.cpp index efb43727dc6..253a3c638e3 100644 --- a/projects/rocprofiler-register/tests/test-amdhip-hsart-roctx.cpp +++ b/projects/rocprofiler-register/tests/test-amdhip-hsart-roctx.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #include #include diff --git a/projects/rocprofiler-register/tests/test-amdhip-roctx-mt.cpp b/projects/rocprofiler-register/tests/test-amdhip-roctx-mt.cpp index c9461f9ecc9..264f9369aa3 100644 --- a/projects/rocprofiler-register/tests/test-amdhip-roctx-mt.cpp +++ b/projects/rocprofiler-register/tests/test-amdhip-roctx-mt.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #include #include #include diff --git a/projects/rocprofiler-register/tests/test-amdhip-roctx.cpp b/projects/rocprofiler-register/tests/test-amdhip-roctx.cpp index 18ee198a5e9..0debd049836 100644 --- a/projects/rocprofiler-register/tests/test-amdhip-roctx.cpp +++ b/projects/rocprofiler-register/tests/test-amdhip-roctx.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - #include #include