Skip to content

Commit

Permalink
Rename omnitrace-python binary, python module, and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dgaliffiAMD committed Sep 20, 2024
1 parent 13d1a3a commit 1296bb2
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-focal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ jobs:
module use /opt/omnitrace/share/modulefiles
module avail
module load omnitrace
./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,rewrite,runtime}=1 --test-omnitrace-python=${{ matrix.python }}
./scripts/test-install.sh --test-rocprof-sys-{instrument,avail,sample,rewrite,runtime}=1 --test-rocprof-sys-python=${{ matrix.python }}
- name: Test User API
timeout-minutes: 10
Expand Down
8 changes: 4 additions & 4 deletions examples/python/fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import os
import sys
import time
import omnitrace
from omnitrace.user import region as omni_user_region
from omnitrace.profiler import config as omni_config
import rocprofsys
from rocprofsys.user import region as omni_user_region
from rocprofsys.profiler import config as omni_config

_prefix = ""

Expand All @@ -14,7 +14,7 @@ def loop(n):
pass


@omnitrace.profile()
@rocprofsys.profile()
def run(i, n, v):
for l in range(n * n):
loop(v + l)
Expand Down
8 changes: 4 additions & 4 deletions examples/python/source-numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import os
import sys
import time
import omnitrace
from omnitrace.user import region as omni_user_region
import rocprofsys
from rocprofsys.user import region as omni_user_region

_prefix = ""

Expand Down Expand Up @@ -50,7 +50,7 @@ def inefficient(n):
return _ret


@omnitrace.profile()
@rocprofsys.profile()
def run(n):
_ret = 0
_ret += fib(n)
Expand Down Expand Up @@ -78,6 +78,6 @@ def run(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:
omnitrace.user.stop_trace()
rocprofsys.user.stop_trace()
ans = run(args.value)
print(f"[{_prefix}] [{i}] result of run({args.value}) = {ans}\n")
8 changes: 4 additions & 4 deletions examples/python/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import os
import sys
import time
import omnitrace
from omnitrace.user import region as omni_user_region
import rocprofsys
from rocprofsys.user import region as omni_user_region
import random

_prefix = ""
Expand Down Expand Up @@ -33,7 +33,7 @@ def inefficient(n):
return _ret


@omnitrace.profile()
@rocprofsys.profile()
def run(n):
_ret = 0
_ret += fib(n)
Expand Down Expand Up @@ -61,6 +61,6 @@ def run(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:
omnitrace.user.stop_trace()
rocprofsys.user.stop_trace()
ans = run(args.value)
print(f"[{_prefix}] [{i}] result of run({args.value}) = {ans}\n")
20 changes: 10 additions & 10 deletions scripts/test-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ usage()
print_option() { printf " --%-10s %-30s %s (default: %s)\n" "${1}" "${2}" "${3}" "${4}"; }
echo "Options:"
print_option source-dir "<PATH>" "Location of source directory" "${SOURCE_DIR}"
print_option test-rocprof-sys-instrument "0|1" "Enable testing rocprof-sys-instrument exe" "${ENABLE_OMNITRACE_INSTRUMENT}"
print_option test-rocprof-sys-instrument "0|1" "Enable testing rocprof-sys-instrument" "${ENABLE_OMNITRACE_INSTRUMENT}"
print_option test-rocprof-sys-avail "0|1" "Enable testing rocprof-sys-avail" "${ENABLE_OMNITRACE_AVAIL}"
print_option test-rocprof-sys-sample "0|1" "Enable testing rocprof-sys-sample" "${ENABLE_OMNITRACE_SAMPLE}"
print_option test-rocprof-sys-python "0|1" "Enable testing rocprof-sys-python" "${ENABLE_OMNITRACE_PYTHON}"
Expand Down Expand Up @@ -136,10 +136,10 @@ do
esac
done

test-omnitrace()
test-rocprof-sys-instrument()
{
verbose-run which omnitrace
verbose-run ldd $(which omnitrace)
verbose-run which rocprof-sys-instrument
verbose-run ldd $(which rocprof-sys-instrument)
verbose-run rocprof-sys-instrument --help
}

Expand All @@ -161,11 +161,11 @@ test-rocprof-sys-sample()

test-rocprof-sys-python()
{
verbose-run which omnitrace-python
verbose-run omnitrace-python --help
verbose-run omnitrace-python -b -- ${SOURCE_DIR}/examples/python/builtin.py -n 5 -v 5
verbose-run omnitrace-python -b -- ${SOURCE_DIR}/examples/python/noprofile.py -n 5 -v 5
verbose-run omnitrace-python -- ${SOURCE_DIR}/examples/python/external.py -n 5 -v 5
verbose-run which rocprof-sys-python
verbose-run rocprof-sys-python --help
verbose-run rocprof-sys-python -b -- ${SOURCE_DIR}/examples/python/builtin.py -n 5 -v 5
verbose-run rocprof-sys-python -b -- ${SOURCE_DIR}/examples/python/noprofile.py -n 5 -v 5
verbose-run rocprof-sys-python -- ${SOURCE_DIR}/examples/python/external.py -n 5 -v 5
verbose-run python3 ${SOURCE_DIR}/examples/python/source.py -n 5 -v 5
}

Expand Down Expand Up @@ -198,7 +198,7 @@ test-rocprof-sys-runtime()
verbose-run rocprof-sys-instrument -e -v 1 -- ${LS_NAME} ${LS_ARGS}
}

if [ "${ENABLE_OMNITRACE_INSTRUMENT}" -ne 0 ]; then verbose-run test-omnitrace; fi
if [ "${ENABLE_OMNITRACE_INSTRUMENT}" -ne 0 ]; then verbose-run test-rocprof-sys-instrument; fi
if [ "${ENABLE_OMNITRACE_AVAIL}" -ne 0 ]; then verbose-run test-rocprof-sys-avail; fi
if [ "${ENABLE_OMNITRACE_SAMPLE}" -ne 0 ]; then verbose-run test-rocprof-sys-sample; fi
if [ "${ENABLE_OMNITRACE_PYTHON}" -ne 0 ]; then verbose-run test-rocprof-sys-python; fi
Expand Down
40 changes: 20 additions & 20 deletions source/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ function(OMNITRACE_CONFIGURE_PYTARGET _TARGET _VERSION)

add_library(omnitrace::${_TARGET} ALIAS ${_TARGET})
target_link_libraries(${_TARGET} PRIVATE libpyomnitrace-interface)
add_dependencies(libpyomnitrace ${_TARGET})
add_dependencies(libpyrocprofsys ${_TARGET})

set_target_properties(
${_TARGET}
PROPERTIES PREFIX ""
OUTPUT_NAME libpyomnitrace
OUTPUT_NAME libpyrocprofsys
LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
PDB_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
${EXTRA_PROPERTIES})

set(_PYLIB ${CMAKE_INSTALL_PYTHONDIR}/omnitrace)
set(_PYLIB ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys)
if(NOT IS_ABSOLUTE "${_PYLIB}")
set(_PYLIB ${CMAKE_INSTALL_PREFIX}/${_PYLIB})
endif()
Expand All @@ -54,7 +54,7 @@ function(OMNITRACE_CONFIGURE_PYTARGET _TARGET _VERSION)

install(
TARGETS ${_TARGET}
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/omnitrace
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
OPTIONAL)
endfunction()

Expand All @@ -68,8 +68,8 @@ add_target_cxx_flag_if_avail(
"-Wno-deprecated-declarations" "-Wno-unused-but-set-parameter"
"-ftls-model=global-dynamic")

file(GLOB pyheaders ${CMAKE_CURRENT_LIST_DIR}/libpyomnitrace*.hpp)
set(pysources ${CMAKE_CURRENT_LIST_DIR}/libpyomnitrace.cpp)
file(GLOB pyheaders ${CMAKE_CURRENT_LIST_DIR}/libpyrocprofsys*.hpp)
set(pysources ${CMAKE_CURRENT_LIST_DIR}/libpyrocprofsys.cpp)

set(pybind_libs pybind11::module)

Expand All @@ -90,35 +90,35 @@ target_link_libraries(
omnitrace_target_compile_definitions(libpyomnitrace-interface
INTERFACE OMNITRACE_PYBIND11_SOURCE)

add_custom_target(libpyomnitrace)
add_custom_target(libpyrocprofsys)

file(GLOB_RECURSE PYTHON_FILES ${CMAKE_CURRENT_SOURCE_DIR}/omnitrace/*.py)
file(GLOB_RECURSE PYTHON_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys/*.py)
foreach(_IN ${PYTHON_FILES})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/omnitrace"
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/omnitrace" _OUT
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys"
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys" _OUT
"${_IN}")
configure_file(${_IN} ${_OUT} @ONLY)
install(
FILES ${_OUT}
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/omnitrace
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
OPTIONAL)
endforeach()

omnitrace_python_console_script("omnitrace-python" "omnitrace")
omnitrace_python_console_script("rocprof-sys-python" "rocprofsys")

set(_INDEX 0)
foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS})
# add_library(libpyomnitrace MODULE ${pysources} ${pyheaders})
# add_library(libpyrocprofsys MODULE ${pysources} ${pyheaders})
list(GET OMNITRACE_PYTHON_ROOT_DIRS ${_INDEX} Python3_ROOT_DIR)
omnitrace_pybind11_add_module(
libpyomnitrace-${_VERSION} MODULE
libpyrocprofsys-${_VERSION} MODULE
PYTHON_VERSION ${_VERSION}
VISIBILITY "hidden" ${pysources} ${pyheaders})
omnitrace_configure_pytarget(libpyomnitrace-${_VERSION} ${_VERSION})
omnitrace_configure_pytarget(libpyrocprofsys-${_VERSION} ${_VERSION})

if(OMNITRACE_USE_PYTHON)
omnitrace_python_console_script(
"omnitrace-python" "omnitrace"
"rocprof-sys-python" "rocprofsys"
VERSION ${_VERSION}
ROOT_DIR "${Python3_ROOT_DIR}")
endif()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
// Copyright (c) 2024 Advanced Micro Devices, 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
Expand All @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include "libpyomnitrace.hpp"
#include "libpyrocprofsys.hpp"
#include "dl/dl.hpp"
#include "library/coverage.hpp"
#include "library/coverage/impl.hpp"
Expand Down Expand Up @@ -56,7 +56,7 @@
#define OMNITRACE_PYTHON_VERSION \
((10000 * PY_MAJOR_VERSION) + (100 * PY_MINOR_VERSION) + PY_MICRO_VERSION)

namespace pyomnitrace
namespace pyrocprofsys
{
namespace pyprofile
{
Expand All @@ -73,14 +73,14 @@ namespace pyuser
py::module
generate(py::module& _pymod);
}
} // namespace pyomnitrace
} // namespace pyrocprofsys

template <typename... Tp>
using uomap_t = std::unordered_map<Tp...>;

PYBIND11_MODULE(libpyomnitrace, omni)
PYBIND11_MODULE(libpyrocprofsys, omni)
{
using namespace pyomnitrace;
using namespace pyrocprofsys;

py::doc("Omnitrace Python bindings for profiling, user API, and code coverage "
"post-processing");
Expand Down Expand Up @@ -110,18 +110,18 @@ PYBIND11_MODULE(libpyomnitrace, omni)
"initialize",
[](const std::string& _v) {
if(_is_initialized)
throw std::runtime_error("Error! omnitrace is already initialized");
throw std::runtime_error("Error! rocprofsys is already initialized");
_is_initialized = true;
omnitrace_set_mpi(_get_use_mpi(), false);
omnitrace_init("trace", false, _v.c_str());
},
"Initialize omnitrace");
"Initialize rocprofsys");

omni.def(
"initialize",
[](const py::list& _v) {
if(_is_initialized)
throw std::runtime_error("Error! omnitrace is already initialized");
throw std::runtime_error("Error! rocprofsys is already initialized");
_is_initialized = true;
omnitrace_set_instrumented(
static_cast<int>(omnitrace::dl::InstrumentMode::PythonProfile));
Expand All @@ -140,17 +140,17 @@ PYBIND11_MODULE(libpyomnitrace, omni)
}
omnitrace_init("trace", false, _cmd.c_str());
},
"Initialize omnitrace");
"Initialize rocprofsys");

omni.def(
"finalize",
[]() {
if(_is_finalized)
throw std::runtime_error("Error! omnitrace is already finalized");
throw std::runtime_error("Error! rocprofsys is already finalized");
_is_finalized = true;
omnitrace_finalize();
},
"Finalize omnitrace");
"Finalize rocprofsys");

pyprofile::generate(omni);
pycoverage::generate(omni);
Expand All @@ -168,14 +168,14 @@ PYBIND11_MODULE(libpyomnitrace, omni)
auto _msg =
TIMEMORY_JOIN("", "dlopen(\"", _libpath, "\", RTLD_NOW | RTLD_GLOBAL)");
perror(_msg.c_str());
fprintf(stderr, "[omnitrace][dl][pid=%i] %s :: %s\n", getpid(), _msg.c_str(),
fprintf(stderr, "[rocprofsys][dl][pid=%i] %s :: %s\n", getpid(), _msg.c_str(),
dlerror());
}
}

//======================================================================================//
//
namespace pyomnitrace
namespace pyrocprofsys
{
namespace pyprofile
{
Expand Down Expand Up @@ -556,7 +556,7 @@ generate(py::module& _pymod)
try
{
auto _file =
py::module::import("omnitrace").attr("__file__").cast<std::string>();
py::module::import("rocprofsys").attr("__file__").cast<std::string>();
if(_file.find('/') != std::string::npos)
_file = _file.substr(0, _file.find_last_of('/'));
get_config().base_module_path = _file;
Expand Down Expand Up @@ -774,7 +774,7 @@ generate(py::module& _pymod)

try
{
ar->setNextName("omnitrace");
ar->setNextName("rocprofsys");
ar->startNode();
ar->setNextName("coverage");
ar->startNode();
Expand All @@ -798,7 +798,7 @@ generate(py::module& _pymod)
auto ar =
tim::policy::output_archive<cereal::PrettyJSONOutputArchive>::get(oss);

ar->setNextName("omnitrace");
ar->setNextName("rocprofsys");
ar->startNode();
ar->setNextName("coverage");
ar->startNode();
Expand Down Expand Up @@ -949,6 +949,6 @@ generate(py::module& _pymod)
return _pyuser;
}
} // namespace pyuser
} // namespace pyomnitrace
} // namespace pyrocprofsys
//
//======================================================================================//
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
// Copyright (c) 2024 Advanced Micro Devices, 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
Expand Down Expand Up @@ -48,9 +48,9 @@
#include <thread>
#include <vector>

namespace pyomnitrace
namespace pyrocprofsys
{
namespace py = pybind11;
using namespace std::placeholders; // for _1, _2, _3...
using namespace py::literals;
} // namespace pyomnitrace
} // namespace pyrocprofsys
Loading

0 comments on commit 1296bb2

Please sign in to comment.