Skip to content

Commit

Permalink
rocprofv3: stabilize rocprofv3 summary tests (#1161)
Browse files Browse the repository at this point in the history
* Update tests/bin/transpose/transpose.cpp

- add hipMemGetInfo call to display the available vs. total memory on the GPU

* Update tests/rocprofv3/summary/validate.py

- Updated test_summary_display_data after addition of hipMemGetInfo to transpose test exe

* Tweak code coverage comment uploading

- create unique orphan branch per PR
- reduce quality of PNG files (85 -> 70)

* Revert some of code coverage comment uploading

- remove creation of unique orphan branch per PR

* Tweak code coverage comment uploading

- create unique orphan branch per PR
  • Loading branch information
jrmadsen authored Oct 25, 2024
1 parent 74facf8 commit 5e1643c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ jobs:
ls -la
for i in "all" "tests" "samples"; do
wkhtmltoimage --enable-local-file-access --quality 85 .codecov/${i}.html .codecov/${i}.png
wkhtmltoimage --enable-local-file-access --quality 70 .codecov/${i}.html .codecov/${i}.png
done
ls -la .codecov
which -a git
Expand Down
19 changes: 10 additions & 9 deletions source/scripts/upload-image-to-github.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,16 @@ def run(*args, **kwargs):
check=True,
)

_branch = f"images-{args.name}"
_ref_branch = f"refs/{_branch}/image-ref"

run(["pwd"])
run([git_cmd, "switch", "--orphan", "images"], check=True)
run([git_cmd, "switch", "--orphan", _branch], check=True)
run([git_cmd, "commit", "--allow-empty", "-m", "Empty commit"], check=True)
run([git_cmd, "fetch", "origin", "refs/images/image-ref"], check=True)
run([git_cmd, "pull", "--rebase", "origin", "refs/images/image-ref"], check=True)
run([git_cmd, "reset", "--hard", "HEAD^"], check=True)
run([git_cmd, "push", "origin", f"HEAD:{_ref_branch}"], check=False)
run([git_cmd, "fetch", "origin", _ref_branch], check=True)
run([git_cmd, "pull", "--rebase", "origin", _ref_branch], check=True)
run([git_cmd, "reset", "--hard", "HEAD^"], check=False)

if not os.path.exists(args.name):
os.makedirs(args.name)
Expand All @@ -142,11 +146,8 @@ def run(*args, **kwargs):

run([git_cmd, "add", args.name])
run([git_cmd, "status"])
run([git_cmd, "commit", "-m", "code coverage files"])
run(
[git_cmd, "push", "--force", "origin", "HEAD:refs/images/image-ref"],
check=True,
)
run([git_cmd, "commit", "-m", f"{args.name} code coverage files"])
run([git_cmd, "push", "--force", "origin", f"HEAD:{_ref_branch}"], check=True)

log = run([git_cmd, "log", "-n", "1", "--format=%H"], capture_output=True)
hash = log.stdout.decode("utf-8").strip()
Expand Down
38 changes: 29 additions & 9 deletions tests/bin/transpose/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,28 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include <hip/hip_runtime.h>
#include <sstream>

#if defined(USE_ROCTRACER_ROCTX)
# include <roctracer/roctx.h>
#else
# include <rocprofiler-sdk-roctx/roctx.h>
#endif

#include <hip/hip_runtime.h>

#if defined(USE_MPI)
# include <mpi.h>
#endif

#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <mutex>
#include <random>
#include <sstream>
#include <stdexcept>

#if defined(USE_MPI)
# include <mpi.h>
#endif

#define HIP_API_CALL(CALL) \
{ \
hipError_t error_ = (CALL); \
Expand Down Expand Up @@ -229,8 +230,27 @@ run(int rank, int tid, int devid, int argc, char** argv)
int* in = nullptr;
int* out = nullptr;

HIP_API_CALL(hipMallocAsync(&in, size, stream));
HIP_API_CALL(hipMallocAsync(&out, size, stream));
// lock during malloc to get more accurate memory info
{
_lk.lock();
constexpr auto MiB = (1024UL * 1024UL);
size_t free_gpu_mem = 0;
size_t total_gpu_mem = 0;

HIP_API_CALL(hipMemGetInfo(&free_gpu_mem, &total_gpu_mem));
free_gpu_mem /= MiB;
total_gpu_mem /= MiB;

std::cout << "[transpose][" << rank << "][" << tid
<< "] Available GPU memory (MiB): " << std::setw(6) << free_gpu_mem << " / "
<< std::setw(6) << total_gpu_mem << std::endl;

HIP_API_CALL(hipMallocAsync(&in, size, stream));
HIP_API_CALL(hipMallocAsync(&out, size, stream));

_lk.unlock();
}

HIP_API_CALL(hipMemsetAsync(in, 0, size, stream));
HIP_API_CALL(hipMemsetAsync(out, 0, size, stream));
HIP_API_CALL(hipMemcpyAsync(in, inp_matrix, size, hipMemcpyHostToDevice, stream));
Expand Down
6 changes: 3 additions & 3 deletions tests/rocprofv3/summary/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ def get_dims(df):
hip_and_marker = get_df("HIP_API + MARKER_API") if num_summary_grps > 1 else None
total = get_df("SUMMARY")

expected_hip_and_marker_dims = [20, 9] if hip_and_marker is not None else [0, 0]
expected_hip_and_marker_dims = [21, 9] if hip_and_marker is not None else [0, 0]

assert get_dims(marker) == [7, 9], f"{marker}"
assert get_dims(memcpy) == [2, 9], f"{memcpy}"
assert get_dims(dispatch) == [3, 9], f"{dispatch}"
assert get_dims(dispatch_and_copy) == [5, 9], f"{dispatch_and_copy}"
assert get_dims(hip) == [13, 9], f"{hip}"
assert get_dims(hip) == [14, 9], f"{hip}"
assert get_dims(hip_and_marker) == expected_hip_and_marker_dims, f"{hip_and_marker}"
assert get_dims(total) == [22, 9], f"{total}"
assert get_dims(total) == [23, 9], f"{total}"


def test_perfetto_data(pftrace_data, json_data):
Expand Down

0 comments on commit 5e1643c

Please sign in to comment.