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

Fix miopen package dependency roctracer etc #2508

Merged
merged 11 commits into from
Dec 24, 2023
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ if(MIOPEN_USE_MLIR)
math(EXPR rocMLIR_VERSION_FLAT "(${rocMLIR_VERSION_MAJOR} * 1000 + ${rocMLIR_VERSION_MINOR}) * 100000 + ${rocMLIR_VERSION_PATCH}")
endif()

set(MIOPEN_PACKAGE_REQS "hip-rocclr")

# Online assembler
find_program(MIOPEN_AMDGCN_ASSEMBLER
Expand All @@ -378,6 +379,7 @@ message(STATUS "AMDGCN assembler: ${MIOPEN_AMDGCN_ASSEMBLER}")
if(MIOPEN_USE_COMGR)
find_package(amd_comgr REQUIRED CONFIG)
message(STATUS "Build with comgr ${amd_comgr_VERSION}")
set(MIOPEN_PACKAGE_REQS "${MIOPEN_PACKAGE_REQS}, amd_comgr")
endif()

if(MIOPEN_USE_HIPRTC)
Expand Down Expand Up @@ -419,7 +421,23 @@ else()
endif()
set(MIOPEN_SYSTEM_FIND_DB_SUFFIX "${MIOPEN_BACKEND}" CACHE PATH "Filename suffix for the system find-db files")

set(MIOPEN_PACKAGE_REQS "hip-rocclr")
# PR-2391 Add the ability to log function calls to roctx.
# This allows attached profilers to see which MIOpen calls are being called by application and which kernels are being invoked by MIOpen.
# Enabled via the MIOPEN_ENABLE_LOGGING_ROCTX env var.
set(MIOPEN_USE_ROCTRACER ON CACHE BOOL "")
if(NOT WIN32 AND MIOPEN_USE_ROCTRACER)
find_library(rocTracer roctx64)
if(rocTracer)
MESSAGE(STATUS "Build with rocTracer: " ${rocTracer})
set(MIOPEN_PACKAGE_REQS "${MIOPEN_PACKAGE_REQS}, roctracer")
else()
message(WARNING "rocTracer cannot be found! Build without rocTracer")
set(MIOPEN_USE_ROCTRACER OFF)
endif()
else()
message(STATUS "Build without rocTracer")
set(MIOPEN_USE_ROCTRACER OFF)
endif()

junliume marked this conversation as resolved.
Show resolved Hide resolved
if(MIOPEN_USE_ROCBLAS)
set(MIOPEN_PACKAGE_REQS "${MIOPEN_PACKAGE_REQS}, rocblas")
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
python3-pip \
python3-venv \
rocblas \
rocm-developer-tools \
rpm \
software-properties-common && \
apt-get clean && \
Expand Down
1 change: 1 addition & 0 deletions include/miopen/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#cmakedefine01 MIOPEN_USE_MIOPENTENSILE
#cmakedefine01 MIOPEN_USE_MIOPENGEMM
#cmakedefine01 MIOPEN_USE_ROCBLAS
#cmakedefine01 MIOPEN_USE_ROCTRACER
#cmakedefine01 MIOPEN_BUILD_DEV
#cmakedefine01 MIOPEN_GPU_SYNC

Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ set( MIOpen_Source
conv/invokers/impl_gemm_dynamic.cpp
conv/invokers/ocl_wrw_rdc.cpp
conv/problem_description.cpp
conv/solver_finders.cpp
conv/solver_finders.cpp
conv_algo_name.cpp
convolution.cpp
convolution_api.cpp
Expand Down Expand Up @@ -835,7 +835,7 @@ if(NOT WIN32 AND NOT APPLE)
endif()
endif()

if(NOT WIN32)
if(MIOPEN_USE_ROCTRACER)
target_link_libraries(MIOpen PRIVATE roctx64)
endif()

Expand Down
31 changes: 21 additions & 10 deletions src/include/miopen/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <miopen/object.hpp>
#include <miopen/config.h>

#ifndef _WIN32
#if MIOPEN_USE_ROCTRACER
#include <roctracer/roctx.h>
#endif

Expand Down Expand Up @@ -224,7 +224,9 @@ std::string LoggingPrefix();
bool IsLogging(LoggingLevel level, bool disableQuieting = false);
bool IsLoggingCmd();
bool IsLoggingFunctionCalls();
#if MIOPEN_USE_ROCTRACER
bool IsLoggingToRoctx();
#endif

namespace logger {

Expand Down Expand Up @@ -307,8 +309,23 @@ LogParam(std::ostream& os, std::string name, const std::vector<T>& vec, bool ind
miopen::LogParam(miopen_log_func_ostream, #param, param, false) << " | "; \
} while(false);

#if MIOPEN_USE_ROCTRACER
#define MIOPEN_LOG_ROCTX_DEFINE_OBJECT miopen::LogScopeRoctx logtx;
#define MIOPEN_LOG_ROCTX_DO_LOGGING(...) \
if(miopen::IsLoggingToRoctx()) \
{ \
std::ostringstream miopen_log_func_ss; \
miopen_log_func_ss << "s_api = " << __FUNCTION__ << " | "; \
MIOPEN_PP_EACH_ARGS(MIOPEN_LOG_FUNCTION_EACH_ROCTX, __VA_ARGS__) \
logtx.logRange(miopen_log_func_ss.str()); \
}
#else
#define MIOPEN_LOG_ROCTX_DEFINE_OBJECT
#define MIOPEN_LOG_ROCTX_DO_LOGGING(...)
#endif

#define MIOPEN_LOG_FUNCTION(...) \
miopen::LogScopeRoctx logtx; \
MIOPEN_LOG_ROCTX_DEFINE_OBJECT \
do \
{ \
if(miopen::IsLoggingFunctionCalls()) \
Expand All @@ -322,13 +339,7 @@ LogParam(std::ostream& os, std::string name, const std::vector<T>& vec, bool ind
miopen_log_func_ss << miopen::LoggingPrefix() << "}" << std::endl; \
std::cerr << miopen_log_func_ss.str(); \
} \
if(miopen::IsLoggingToRoctx()) \
{ \
std::ostringstream miopen_log_func_ss; \
miopen_log_func_ss << "s_api = " << __FUNCTION__ << " | "; \
MIOPEN_PP_EACH_ARGS(MIOPEN_LOG_FUNCTION_EACH_ROCTX, __VA_ARGS__) \
logtx.logRange(miopen_log_func_ss.str()); \
} \
MIOPEN_LOG_ROCTX_DO_LOGGING(__VA_ARGS__) \
} while(false)
#else
#define MIOPEN_LOG_FUNCTION(...)
Expand Down Expand Up @@ -412,7 +423,7 @@ class LogScopeTime
#define MIOPEN_LOG_SCOPE_TIME
#endif

#ifndef _WIN32
#if MIOPEN_USE_ROCTRACER
class LogScopeRoctx
{
public:
Expand Down
5 changes: 1 addition & 4 deletions src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ bool IsLoggingFunctionCalls()
return miopen::IsEnabled(MIOPEN_ENABLE_LOGGING{}) && !IsLoggingDebugQuiet();
}

bool IsLoggingToRoctx()
{
return miopen::IsEnabled(MIOPEN_ENABLE_LOGGING_ROCTX{}) && !IsLoggingDebugQuiet();
}
bool IsLoggingToRoctx() { return miopen::IsEnabled(MIOPEN_ENABLE_LOGGING_ROCTX{}); }

bool IsLogging(const LoggingLevel level, const bool disableQuieting)
{
Expand Down
6 changes: 4 additions & 2 deletions test/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
find_package(GTest CONFIG REQUIRED)
find_package(GTest CONFIG)
if(GTest_FOUND)
MESSAGE(STATUS "GoogleTest: " ${GTest})
enable_testing()
include(GoogleTest)
else()
message(WARNING "GoogleTest is not found! Skip GTests ... try install GTest or preferably follow instructions to install MIOpen dependencies.")
return()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related to the PR?

Copy link
Collaborator Author

@junliume junliume Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly, a byproduct of the review I believe.
Update: updated from develop and make GTest a required package

endif()

find_package(rocblas)
Expand Down