Buffering: initial implementation and tests (#20)

* Update source/lib/common

- CMakeLists.txt
  - less verbose
  - rocprofiler-common-library uses rocprofiler-headers target
- mpl.hpp
  - metaprogramming header with type_list, size_of, index_of, and is_one_of
- record_header_buffer.{hpp,cpp}
  - wrapper class around atomic_ring_buffer and vector of rocprofiler_record_header_t
- atomic_ring_buffer.{hpp,cpp}
  - request function accepts wrap param when overwritting is not desirable
  - can_clear member function
  - clear member function for rewinding write pointer to start of buffer
- containers/CMakeLists.txt
  - include record_header_buffer.{hpp,cpp} in build target

* Update source/lib/tests: Buffering tests

- Added buffering tests. See comments in code for description

* atomic_ring_buffer -> ring_buffer

- remove ring_buffer implementation
- rename atomic_ring_buffer to ring_buffer

* atomic_ring_buffer -> ring_buffer

- remove ring_buffer implementation
- rename atomic_ring_buffer to ring_buffer

* Update record_header_buffer

- lock, unlock, is_locked, clear, save, and load member functions

* Buffering tests

- add buffer test for save/load capability

* Update rocprofiler_memcheck.cmake

- fix erroneous spaces causing incorrect string evaluation

* Update ring_buffer

- fix exception message

* undef HIP_PROF_API

- make sure HIP_PROF_API is undefined before including hip_runtime.h
- avoid directly including hip/hip_runtime.h

* Update rocprofiler_config_interfaces

- remove stale preprocessor defines that are from old rocprofiler/roctracer
  - HIP_PROF_HIP_API_STRING=1
  - PROF_API_IMPL=1

* Update run-ci.py

- fix paths to suppression files
- improve printing logs to console in github actions

* Update buffering implementation

- remove support for using malloc instead of mmap in ring_buffer
- provide some info functions in record_header_buffer
- improve the testing of the save-load buffer test

* Update run-ci.py

- fix CTEST_CUSTOM_COVERAGE_EXCLUDE

* Update hip/api_args.h

- remove undef HIP_PROF_API

* Update buffering-save-load.cpp

- updated comments

* Update record_header_buffer

- default ctor
- allocate member function
- is_allocated member function

* Update buffering-save-load.cpp

- tweaked usage of record_header_buffer to delay allocation

[ROCm/rocprofiler-sdk commit: b12ef4a75e]
This commit is contained in:
Jonathan R. Madsen
2023-08-30 11:34:03 -05:00
gecommit door GitHub
bovenliggende d4a977349c
commit ccd154b74c
20 gewijzigde bestanden met toevoegingen van 1525 en 1063 verwijderingen
@@ -62,9 +62,13 @@ def generate_custom(args, cmake_args, ctest_args):
if MEMCHECK_TYPE == "AddressSanitizer":
MEMCHECK_SANITIZER_OPTIONS = "detect_leaks=0 use_sigaltstack=0"
MEMCHECK_SUPPRESSION_FILE = f"{SOURCE_DIR}/script/address-sanitizer-suppr.txt"
MEMCHECK_SUPPRESSION_FILE = (
f"{SOURCE_DIR}/source/scripts/address-sanitizer-suppr.txt"
)
elif MEMCHECK_TYPE == "LeakSanitizer":
MEMCHECK_SUPPRESSION_FILE = f"{SOURCE_DIR}/script/leak-sanitizer-suppr.txt"
MEMCHECK_SUPPRESSION_FILE = (
f"{SOURCE_DIR}/source/scripts/leak-sanitizer-suppr.txt"
)
elif MEMCHECK_TYPE == "ThreadSanitizer":
external_symbolizer_path = ""
for version in range(8, 20):
@@ -75,7 +79,7 @@ def generate_custom(args, cmake_args, ctest_args):
[
"history_size=5",
"second_deadlock_stack=1",
f"suppressions={SOURCE_DIR}/script/thread-sanitizer-suppr.txt",
f"suppressions={SOURCE_DIR}/source/scripts/thread-sanitizer-suppr.txt",
external_symbolizer_path,
os.environ.get("TSAN_OPTIONS", ""),
]
@@ -101,7 +105,7 @@ def generate_custom(args, cmake_args, ctest_args):
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS "100")
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS "100")
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "51200")
set(CTEST_CUSTOM_COVERAGE_EXCLUDE "/usr/.*;/opt/.*;.*external/.*;.*samples/.*;.*test/.*;.*tests-v2/.*;.*perfetto/perfetto_sdk/.*;.*ctf/barectf.*")
set(CTEST_CUSTOM_COVERAGE_EXCLUDE "/usr/.*;/opt/.*;.*external/.*;.*samples/.*;.*tests/.*")
set(CTEST_MEMORYCHECK_TYPE "{MEMCHECK_TYPE}")
set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "{MEMCHECK_SUPPRESSION_FILE}")
@@ -426,29 +430,31 @@ if __name__ == "__main__":
)
finally:
if "-VV" not in ctest_args and not args.quiet:
tag = None
tagfpath = os.path.join(args.binary_dir, "Testing/TAG")
with open(tagfpath, "r") as f:
tag = f.readline().strip()
for file in glob.glob(
os.path.join(args.binary_dir, "Testing/Temporary/**"),
os.path.join(args.binary_dir, "Testing", tag, "**"),
recursive=True,
):
if not os.path.isfile(file):
continue
if (
re.match(
r"Last(Start|Update|Configure|Build|Test).*\.log$",
os.path.basename(file),
)
is None
):
if "CoverageLog-" in os.path.basename(file):
continue
print(f"\n\n###### Reading {file}... ######\n\n")
with open(file, "r") as inpf:
fdata = inpf.read()
print(fdata)
# print out memory checker files
for file in glob.glob(
os.path.join(args.binary_dir, "Testing/Temporary/MemoryChecker.*"),
recursive=True,
):
if not os.path.isfile(file):
continue
print(f"\n\n\n###### Reading {file}... ######\n\n\n")
with open(file, "r") as inpf:
fdata = inpf.read()
if "LastTest" not in file and "Coverage" not in file:
print(fdata)
oname = os.path.basename(file)
if 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")
outf.write(fdata)
print(fdata)