Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROCm environment fixes + workflow updates #117

Merged
merged 11 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ env:

jobs:
omnitrace-ci:
if: github.repository == 'AMDResearch/omnitrace'

runs-on: ubuntu-20.04

strategy:
Expand Down Expand Up @@ -57,6 +59,8 @@ jobs:
popd

omnitrace-release-ubuntu:
if: github.repository == 'AMDResearch/omnitrace'

runs-on: ubuntu-20.04

strategy:
Expand Down Expand Up @@ -98,6 +102,8 @@ jobs:
popd

omnitrace-release-opensuse:
if: github.repository == 'AMDResearch/omnitrace'

runs-on: ubuntu-20.04

strategy:
Expand Down
38 changes: 32 additions & 6 deletions .github/workflows/cpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ env:
GIT_DISCOVERY_ACROSS_FILESYSTEM: 1

jobs:
release:
if: github.repository == 'AMDResearch/omnitrace'
runs-on: ubuntu-20.04
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Generate Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: True
generate_release_notes: True

ubuntu:
runs-on: ubuntu-20.04
strategy:
Expand Down Expand Up @@ -77,7 +93,6 @@ jobs:
# before testing remove any artifacts of the build
- name: Remove Build
timeout-minutes: 10
continue-on-error: true
run: |
mv build-release/stgz/*.sh ./
mv build-release/deb/*.deb ./
Expand All @@ -86,7 +101,6 @@ jobs:

- name: Test STGZ Install
timeout-minutes: 20
continue-on-error: true
run: |
set -v
for i in omnitrace-*.sh
Expand All @@ -96,14 +110,21 @@ jobs:

- name: Test DEB Install
timeout-minutes: 20
continue-on-error: true
run: |
set -v
for i in omnitrace_*.deb
do
./docker/test-docker-release.sh --distro ubuntu --versions ${{ matrix.os }} --rocm-versions ${CI_ROCM_VERSION} -- --deb ${i}
done

- name: Upload Release Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'AMDResearch/omnitrace'
with:
files: |
build-release/stgz/*.sh
build-release/deb/*.deb

opensuse:
runs-on: ubuntu-20.04
strategy:
Expand Down Expand Up @@ -173,7 +194,6 @@ jobs:
# before testing remove any artifacts of the build
- name: Remove Build
timeout-minutes: 10
continue-on-error: true
run: |
mv build-release/stgz/*.sh ./
mv build-release/rpm/*.rpm ./
Expand All @@ -182,7 +202,6 @@ jobs:

- name: Test STGZ Install
timeout-minutes: 20
continue-on-error: true
run: |
set -v
for i in omnitrace-*.sh
Expand All @@ -192,10 +211,17 @@ jobs:

- name: Test RPM Install
timeout-minutes: 20
continue-on-error: true
run: |
set -v
for i in omnitrace-*.rpm
do
./docker/test-docker-release.sh --distro opensuse --versions ${{ matrix.os }} --rocm-versions ${CI_ROCM_VERSION} -- --rpm ${i}
done

- name: Upload Release Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'AMDResearch/omnitrace'
with:
files: |
build-release/stgz/*.sh
build-release/rpm/*.rpm
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.3.1
3 changes: 2 additions & 1 deletion cmake/MacroUtilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ function(OMNITRACE_STRIP_TARGET _TARGET)
--keep-symbol="omnitrace_pop_region" --keep-symbol="omnitrace_set_env"
--keep-symbol="omnitrace_set_mpi" --keep-symbol="omnitrace_user_*"
--keep-symbol="ompt_start_tool" --keep-symbol="kokkosp_*"
--keep-symbol="OnLoad" --keep-symbol="OnUnload" ${ARGN}
--keep-symbol="OnLoad" --keep-symbol="OnUnload"
--keep-symbol="OnLoadToolProp" --keep-symbol="OnUnloadTool" ${ARGN}
$<TARGET_FILE:${_TARGET}>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Stripping ${_TARGET}...")
Expand Down
7 changes: 7 additions & 0 deletions source/bin/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ omnitrace_add_bin_test(
".*\\\[omnitrace-avail\\\] Usage:.*\\\[CATEGORIES\\\].*\\\[VIEW OPTIONS\\\].*\\\[COLUMN OPTIONS\\\].*\\\[WIDTH OPTIONS\\\].*\\\[OUTPUT OPTIONS\\\].*"
)

omnitrace_add_bin_test(
NAME omnitrace-avail-all
TARGET omnitrace-avail
ARGS --all
LABELS "omnitrace-avail"
TIMEOUT 45)

omnitrace_add_bin_test(
NAME omnitrace-avail-all-csv
TARGET omnitrace-avail
Expand Down
11 changes: 9 additions & 2 deletions source/lib/common/setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ setup_environ(int _verbose, const std::string& _search_paths = {},
#endif

#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0
# if OMNITRACE_HIP_VERSION >= 50200
# define ROCPROFILER_METRICS_DIR "lib/rocprofiler"
# else
# define ROCPROFILER_METRICS_DIR "rocprofiler/lib"
# endif
setenv("HSA_TOOLS_LIB", _omnilib.c_str(), 0);
setenv("ROCP_TOOL_LIB", _omnilib.c_str(), 0);
setenv("ROCPROFILER_LOG", "1", 0);
Expand All @@ -142,7 +147,8 @@ setup_environ(int _verbose, const std::string& _search_paths = {},
if(getenv(itr))
{
setenv("ROCP_METRICS",
common::join('/', getenv(itr), "rocprofiler/lib/metrics.xml").c_str(),
common::join('/', getenv(itr), ROCPROFILER_METRICS_DIR, "metrics.xml")
.c_str(),
0);
setenv("OMNITRACE_ROCPROFILER_LIBRARY",
common::join('/', getenv(itr), "rocprofiler/lib/librocprofiler64.so")
Expand All @@ -153,7 +159,8 @@ setup_environ(int _verbose, const std::string& _search_paths = {},
}
// default path
setenv("ROCP_METRICS",
common::join('/', OMNITRACE_DEFAULT_ROCM_PATH, "rocprofiler/lib/metrics.xml")
common::join('/', OMNITRACE_DEFAULT_ROCM_PATH, ROCPROFILER_METRICS_DIR,
"metrics.xml")
.c_str(),
0);
#endif
Expand Down
13 changes: 10 additions & 3 deletions source/lib/omnitrace/library/components/roctracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,18 @@ roctracer::setup()

OMNITRACE_VERBOSE_F(1, "setting up roctracer...\n");

dynamic_library _amdhip64{ "OMNITRACE_ROCTRACER_LIBAMDHIP64", "libamdhip64.so" };
dynamic_library _amdhip64{ "OMNITRACE_ROCTRACER_LIBAMDHIP64",
find_library_path("libamdhip64.so",
{ "OMNITRACE_ROCM_PATH", "ROCM_PATH" },
{ OMNITRACE_DEFAULT_ROCM_PATH }) };

#if OMNITRACE_HIP_VERSION_MAJOR == 4 && OMNITRACE_HIP_VERSION_MINOR < 4
dynamic_library _kfdwrapper{ "OMNITRACE_ROCTRACER_LIBKFDWRAPPER",
OMNITRACE_ROCTRACER_LIBKFDWRAPPER };
dynamic_library _kfdwrapper{
"OMNITRACE_ROCTRACER_LIBKFDWRAPPER",
find_library_path("libkfdwrapper64.so", { "OMNITRACE_ROCM_PATH", "ROCM_PATH" },
{ OMNITRACE_DEFAULT_ROCM_PATH },
{ "roctracer/lib", "roctracer/lib64", "lib", "lib64" })
};
#endif

ROCTRACER_CALL(roctracer_set_properties(ACTIVITY_DOMAIN_HIP_API, nullptr));
Expand Down
8 changes: 0 additions & 8 deletions source/lib/omnitrace/library/defines.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@

#include "common/defines.h"

// clang-format off
#if defined(OMNITRACE_USE_ROCTRACER)
# define OMNITRACE_ROCTRACER_LIBKFDWRAPPER "@roctracer_kfdwrapper_LIBRARY@"
#else
# define OMNITRACE_ROCTRACER_LIBKFDWRAPPER "/opt/rocm/roctracer/lib/libkfdwrapper64.so"
#endif
// clang-format on

#define TIMEMORY_USER_COMPONENT_ENUM \
OMNITRACE_COMPONENT_idx, OMNITRACE_USER_REGION_idx, OMNITRACE_ROCTRACER_idx, \
OMNITRACE_ROCPROFILER_idx, OMNITRACE_SAMPLING_WALL_CLOCK_idx, \
Expand Down
90 changes: 83 additions & 7 deletions source/lib/omnitrace/library/dynamic_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,90 @@
// SOFTWARE.

#include "library/dynamic_library.hpp"
#include "common/defines.h"
#include "library/common.hpp"
#include "library/debug.hpp"
#include "library/defines.hpp"

#include <timemory/environment.hpp>
#include <timemory/utility/delimit.hpp>
#include <timemory/utility/filepath.hpp>

#include <string>
#include <utility>

namespace omnitrace
{
dynamic_library::dynamic_library(const char* _env, const char* _fname, int _flags,
bool _store)
: envname{ _env }
, filename{ tim::get_env<std::string>(_env, _fname, _store) }
std::string
find_library_path(const std::string& _name, const std::vector<std::string>& _env_vars,
const std::vector<std::string>& _hints,
const std::vector<std::string>& _path_suffixes)
{
if(_name.find('/') == 0) return _name;

auto _paths = std::vector<std::string>{};
for(const std::string& itr : _env_vars)
{
auto _env_val = get_env(itr, std::string{});
for(auto vitr : tim::delimit(_env_val, ":"))
if(!vitr.empty()) _paths.emplace_back(vitr);
}

for(const std::string& itr : _hints)
{
if(!itr.empty()) _paths.emplace_back(itr);
}

for(auto& itr : _paths)
{
auto _v = JOIN('/', itr, _name);
if(filepath::exists(_v)) return _v;
for(const auto& litr : _path_suffixes)
{
_v = JOIN('/', itr, litr, _name);
if(filepath::exists(_v)) return _v;
}
}

return _name;
}

dynamic_library::dynamic_library(std::string _env, std::string _fname, int _flags,
bool _open, bool _query_env, bool _store)
: envname{ std::move(_env) }
, filename{ std::move(_fname) }
, flags{ _flags }
{
open();
if(_query_env)
{
auto _env_val = get_env(envname, std::string{}, _store);
// if the environment variable is set to an absolute path that exists,
// override with value
if(!_env_val.empty())
{
if(_env_val.find('/') == 0 && filepath::exists(_env_val))
{
filename = _env_val;
}
else if(_env_val.find('/') == 0)
{
OMNITRACE_VERBOSE_F(1,
"Ignoring environment variable %s=\"%s\" because the "
"filepath does not exist. Using \"%s\" instead...\n",
envname.c_str(), _env_val.c_str(), filename.c_str())
}
else if(_env_val.find('/') != 0 && filename.find('/') == 0)
{
OMNITRACE_VERBOSE_F(
1,
"Ignoring environment variable %s=\"%s\" because the "
"filepath is relative. Using absolute path \"%s\" instead...\n",
envname.c_str(), _env_val.c_str(), filename.c_str())
}
}
}

if(_open) open();
}

dynamic_library::~dynamic_library() { close(); }
Expand All @@ -47,8 +117,8 @@ dynamic_library::open()
handle = dlopen(filename.c_str(), flags);
if(!handle)
{
OMNITRACE_VERBOSE(2, "[dynamic_library][%s][%s] %s\n", envname.c_str(),
filename.c_str(), dlerror());
OMNITRACE_VERBOSE(2, "[dynamic_library] Error opening %s=\"%s\" :: %s.\n",
envname.c_str(), filename.c_str(), dlerror());
}
dlerror(); // Clear any existing error
}
Expand All @@ -61,4 +131,10 @@ dynamic_library::close() const
if(handle) return dlclose(handle);
return -1;
}

bool
dynamic_library::is_open() const
{
return (handle != nullptr);
}
} // namespace omnitrace
Loading