Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

87 lines
2.2 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
import os
import sys
import time
import rocprofsys
from rocprofsys.user import region as omni_user_region
_prefix = ""
def fib(n):
return n if n < 2 else (fib(n - 1) + fib(n - 2))
try:
import numpy as np
def inefficient(n):
print(f"[{_prefix}] ... running inefficient({n}) (1)")
a = 0
for i in range(n):
a += i
for j in range(n):
a += j
_len = a * n * n
_ret = np.random.rand(_len).sum()
print(f"[{_prefix}] ... sum of {_len} random elements: {_ret}")
return _ret
except ImportError as e:
print(f"ImportError: {e}")
import random
def _sum(arr):
print(f"---- in _sum")
return sum(arr)
def inefficient(n):
print(f"[{_prefix}] ... running inefficient({n})")
a = 0
for i in range(n):
a += i
for j in range(n):
a += j
_len = a * n * n
_arr = [random.random() for _ in range(_len)]
_ret = _sum(_arr)
print(f"[{_prefix}] ... sum of {_len} random elements: {_ret}")
return _ret
@rocprofsys.profile()
def run(n):
_ret = 0
_ret += fib(n)
_ret += inefficient(n)
return _ret
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-n", "--num-iterations", help="Number", type=int, default=3)
parser.add_argument("-v", "--value", help="Starting value", type=int, default=20)
parser.add_argument(
"-s",
"--stop-profile",
help="Stop tracing after given iterations",
type=int,
default=0,
)
args = parser.parse_args()
_prefix = os.path.basename(__file__)
print(f"[{_prefix}] Executing {args.num_iterations} iterations...\n")
for i in range(args.num_iterations):
with omni_user_region(f"main_loop"):
if args.stop_profile > 0 and i == args.stop_profile:
rocprofsys.user.stop_trace()
ans = run(args.value)
print(f"[{_prefix}] [{i}] result of run({args.value}) = {ans}\n")