diff --git a/hipamd/CMakeLists.txt b/hipamd/CMakeLists.txt index 65a920f4ad..71901da4a4 100644 --- a/hipamd/CMakeLists.txt +++ b/hipamd/CMakeLists.txt @@ -98,6 +98,15 @@ if(NOT DEFINED BUILD_CLANG_HIPIFY) endif() endif() +# Check if we need to enable ATP marker +if(NOT DEFINED COMPILE_HIP_ATP_MARKER) + if(NOT DEFINED ENV{COMPILE_HIP_ATP_MARKER}) + set(COMPILE_HIP_ATP_MARKER 0) + else() + set(COMPILE_HIP_ATP_MARKER $ENV{COMPILE_HIP_ATP_MARKER}) + endif() +endif() + ############################# # Build steps ############################# @@ -109,13 +118,18 @@ endif() # Build hip_hcc if platform is hcc if(HIP_PLATFORM STREQUAL "hcc") include_directories(${PROJECT_SOURCE_DIR}/include) + if(COMPILE_HIP_ATP_MARKER) + include_directories(/opt/rocm/profiler/CXLActivityLogger/include) + set(CMAKE_CXX_FLAGS " -DCOMPILE_HIP_ATP_MARKER=1 ${CMAKE_CXX_FLAGS}") + set(CMAKE_C_FLAGS " -DCOMPILE_HIP_ATP_MARKER=1 ${CMAKE_C_FLAGS}") + endif() set(CMAKE_CXX_COMPILER "${HCC_HOME}/bin/hcc") set(CMAKE_C_COMPILER "${HCC_HOME}/bin/hcc") # Set HIP_HCC so we know this is HIP compile, some files are shared with HCC (staging_buffer). - set(CMAKE_CXX_FLAGS " -hc -I${HCC_HOME}/include -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include/libhsakmt -stdlib=libc++ -DHIP_HCC") - set(CMAKE_C_FLAGS " -hc -I${HCC_HOME}/include -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include/libhsakmt -stdlib=libc++ -DHIP_HCC") + set(CMAKE_CXX_FLAGS " -hc -I${HCC_HOME}/include -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include/libhsakmt -stdlib=libc++ -DHIP_HCC ${CMAKE_CXX_FLAGS}") + set(CMAKE_C_FLAGS " -hc -I${HCC_HOME}/include -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include/libhsakmt -stdlib=libc++ -DHIP_HCC ${CMAKE_C_FLAGS}") set(SOURCE_FILES src/device_util.cpp src/hip_hcc.cpp diff --git a/hipamd/bin/hipcc b/hipamd/bin/hipcc index 7c894af53e..ce888fea8f 100755 --- a/hipamd/bin/hipcc +++ b/hipamd/bin/hipcc @@ -31,10 +31,6 @@ $verbose = 0 unless defined $verbose; $HIP_PATH=$ENV{'HIP_PATH'}; $HIP_PATH=dirname (dirname $0) unless defined $HIP_PATH; # use parent directory of hipcc -$CODEXL_PATH = $ENV{'CODEXL_PATH'}; -$CODEXL_PATH = "/opt/AMD/CodeXL" unless defined $CODEXL_PATH; -$marker_path = "$CODEXL_PATH/SDK/AMDTActivityLogger"; - #--- #HIP_PLATFORM controls whether to use NVCC or HCC for compilation: $HIP_PLATFORM= `$HIP_PATH/bin/hipconfig --platform`; @@ -60,6 +56,11 @@ if ($HIP_PLATFORM eq "hcc") { $ROCM_PATH=$ENV{'ROCM_PATH'}; $ROCM_PATH="/opt/rocm" unless defined $ROCM_PATH; + $HIP_ATP_MARKER=$ENV{'HIP_ATP_MARKER'}; + if ($HIP_ATP_MARKER) { + $marker_path = "$ROCM_PATH/profiler/CXLActivityLogger"; + } + $ROCM_TARGET=$ENV{'ROCM_TARGET'}; $ROCM_TARGET="fiji" unless defined $ROCM_TARGET; @@ -97,14 +98,16 @@ if ($HIP_PLATFORM eq "hcc") { # Add trace marker library: # TODO - once we cleanly separate the HIP API headers from HIP library headers this logic should move to CMakebuild option - apps do not need to see the marker library. - $marker_inc_path = "$marker_path/include"; - if (-e $marker_inc_path) { - $HIPCXXFLAGS .= " -I$marker_inc_path"; - } + if ($HIP_ATP_MARKER) { + $marker_inc_path = "$marker_path/include"; + if (-e $marker_inc_path) { + $HIPCXXFLAGS .= " -I$marker_inc_path"; + } - $marker_lib_path = "$marker_path/bin/x86_64"; - if (-e $marker_lib_path) { - $HIPLDFLAGS .= " -L$marker_lib_path -lAMDTActivityLogger"; + $marker_lib_path = "$marker_path/bin/x86_64"; + if (-e $marker_lib_path) { + $HIPLDFLAGS .= " -L$marker_lib_path -lCXLActivityLogger -Wl,--rpath=$marker_lib_path"; + } } # Add C++ libs for GCC. diff --git a/hipamd/include/hcc_detail/hip_hcc.h b/hipamd/include/hcc_detail/hip_hcc.h index 7c47d1b2a9..e79ba9e1dc 100644 --- a/hipamd/include/hcc_detail/hip_hcc.h +++ b/hipamd/include/hcc_detail/hip_hcc.h @@ -130,7 +130,7 @@ class ihipDevice_t; // TODO - currently we print the trace message at the beginning. if we waited, we could also include return codes, and any values returned // through ptr-to-args (ie the pointers allocated by hipMalloc). #if COMPILE_HIP_ATP_MARKER -#include "AMDTActivityLogger.h" +#include "CXLActivityLogger.h" #define SCOPED_MARKER(markerName,group,userString) amdtScopedMarker(markerName, group, userString) #else // Swallow scoped markers: diff --git a/hipamd/src/hip_hcc.cpp b/hipamd/src/hip_hcc.cpp index c70c35f23b..6334b6004d 100644 --- a/hipamd/src/hip_hcc.cpp +++ b/hipamd/src/hip_hcc.cpp @@ -934,7 +934,7 @@ static hsa_status_t findCpuAgent(hsa_agent_t agent, void *data) void ihipInit() { -#if COMPILE_TRACE_MARKER +#if COMPILE_HIP_ATP_MARKER amdtInitializeActivityLogger(); amdtScopedMarker("ihipInit", "HIP", NULL); #endif