Add configure and CMake options to enable DTL logging and tracing (#86)

Instead of editing a header file, add options to build systems to allow
DTL tracing and/or logging output to be generated. For most users
logging is recommended, producing a line of output per application
thread of every BLAS call made. Tracing provides more detailed info
of internal BLIS calls, and is aimed more at expert users and BLIS
developers. Different tracing levels from 1 to 10 provide control of
the granularity of information produced. The default level is 5. Note
that tracing, especially at higher tracing levels, will impose a
significant runtime cost overhead.

Example usage:

Using configure:

  ./configure ... --enable-aocl-dtl=log amdzen

  ./configure ... --enable-aocl-dtl=trace --aocl-dtl-trace-level=6 amdzen

  ./configure ... --enable-aocl-dtl=all amdzen

Using CMake:

  cmake ... -DENABLE_AOCL_DTL=LOG

  cmake ... -DENABLE_AOCL_DTL=TRACE -DAOCL_DTL_TRACE_LEVEL=6

  cmake ... -DENABLE_AOCL_DTL=ALL

Also, modify function AOCL_get_requested_threads_count to correct
reported thread count in cases where internal value is recorded as -1

AMD-Internal: [CPUPL-7010]
This commit is contained in:
Smyth, Edward
2025-07-28 15:24:10 +01:00
committed by GitHub
parent 46aac600ec
commit e3dcc15a80
6 changed files with 134 additions and 25 deletions

View File

@@ -198,7 +198,7 @@ if(NOT MSVC)
set_property(CACHE ENABLE_DEBUG PROPERTY STRINGS "off" "noopt" "opt")
if( NOT ((ENABLE_DEBUG STREQUAL "off") OR (ENABLE_DEBUG STREQUAL "noopt") OR (ENABLE_DEBUG STREQUAL "opt")) )
message(FATAL_ERROR "ENABLE_DEBUG option '${ENABLE_DEBUG}' is not supported. Please use one of the following options \
during CMake invokation: off, noopt, opt")
during CMake invocation: off, noopt, opt")
endif()
# Check if user provided CMAKE_BUILD_TYPE. If that's the case, map it to the internal ENABLE_DEBUG type
# and clean cache from CMAKE_BUILD_TYPE. We do this because CMake will add some flags depending on the
@@ -234,20 +234,20 @@ if(WIN32)
set_property(CACHE ENABLE_THREADING PROPERTY STRINGS "openmp" "no")
if( NOT ((ENABLE_THREADING STREQUAL "openmp") OR (ENABLE_THREADING STREQUAL "no")) )
message(FATAL_ERROR "ENABLE_THREADING option '${ENABLE_THREADING}' is not supported. Please use one of the following options \
during CMake invokation: openmp, no")
during CMake invocation: openmp, no")
endif()
else()
set_property(CACHE ENABLE_THREADING PROPERTY STRINGS "openmp" "pthreads" "no")
if( NOT ((ENABLE_THREADING STREQUAL "openmp") OR (ENABLE_THREADING STREQUAL "pthreads") OR (ENABLE_THREADING STREQUAL "no")) )
message(FATAL_ERROR "ENABLE_THREADING option '${ENABLE_THREADING}' is not supported. Please use one of the following options \
during CMake invokation: openmp, pthreads, no")
during CMake invocation: openmp, pthreads, no")
endif()
endif()
set(THREAD_PART_JRIR "slab" CACHE STRING "The method of assigning micropanels to threads in the JR and JR loops.")
set_property(CACHE THREAD_PART_JRIR PROPERTY STRINGS "slab" "rr")
if( NOT ((THREAD_PART_JRIR STREQUAL "slab") OR (THREAD_PART_JRIR STREQUAL "rr")) )
message(FATAL_ERROR "THREAD_PART_JRIR option '${THREAD_PART_JRIR}' is not supported. Please use one of the following options \
during CMake invokation: slab, rr")
during CMake invocation: slab, rr")
endif()
# Export symbols only for Linux.
if(NOT WIN32)
@@ -255,7 +255,7 @@ if(NOT WIN32)
set_property(CACHE EXPORT_SHARED PROPERTY STRINGS "public" "all")
if( NOT ((EXPORT_SHARED STREQUAL "public") OR (EXPORT_SHARED STREQUAL "all")) )
message(FATAL_ERROR "EXPORT_SHARED option '${EXPORT_SHARED}' is not supported. Please use one of the following options \
during CMake invokation: public, all")
during CMake invocation: public, all")
endif()
endif()
option(ENABLE_PBA_POOLS "Internal memory pools for packing blocks" ON)
@@ -265,13 +265,13 @@ set(INT_SIZE "auto" CACHE STRING "BLIS API integer size")
set_property(CACHE INT_SIZE PROPERTY STRINGS "auto" "32" "64")
if( NOT ((INT_SIZE STREQUAL "auto") OR (INT_SIZE STREQUAL "32") OR (INT_SIZE STREQUAL "64")) )
message(FATAL_ERROR "INT_SIZE option '${INT_SIZE}' is not supported. Please use one of the following options \
during CMake invokation: auto, 32, 64")
during CMake invocation: auto, 32, 64")
endif()
set(BLAS_INT_SIZE "32" CACHE STRING "BLAS/CBLAS API integer size")
set_property(CACHE BLAS_INT_SIZE PROPERTY STRINGS "auto" "32" "64")
if( NOT ((BLAS_INT_SIZE STREQUAL "auto") OR (BLAS_INT_SIZE STREQUAL "32") OR (BLAS_INT_SIZE STREQUAL "64")) )
message(FATAL_ERROR "BLAS_INT_SIZE option '${BLAS_INT_SIZE}' is not supported. Please use one of the following options \
during CMake invokation: auto, 32, 64")
during CMake invocation: auto, 32, 64")
endif()
option(ENABLE_BLAS "BLAS compatiblity layer" ON)
option(ENABLE_CBLAS "CBLAS compatiblity layer" OFF)
@@ -283,6 +283,40 @@ option(ENABLE_SMALL_MATRIX "Small matrix handling" ON)
option(ENABLE_SUP_HANDLING "SUP matrix handling" ON)
option(ENABLE_SMALL_MATRIX_TRSM "TRSM Small matrix handling" ON)
option(ENABLE_TRSM_PREINVERSION "Enable TRSM preinversion" ON)
set(ENABLE_AOCL_DTL "OFF" CACHE STRING "Enable DTL Usage. Use with option ALL to enable both Tracing and Logging, TRACE to enable Tracing, and LOG to enable only logging")
set_property(CACHE ENABLE_AOCL_DTL PROPERTY STRINGS ALL TRACE LOG OFF )
# ENABLE AOCL Trace, Log and Dump from CMAKE
if(ENABLE_AOCL_DTL)
message(STATUS "ENABLE_AOCL_DTL : ${ENABLE_AOCL_DTL}")
if(ENABLE_AOCL_DTL STREQUAL "ALL" )
set(ENABLE_DTL_TRACE_01 1)
set(ENABLE_DTL_LOG_01 1)
elseif(ENABLE_AOCL_DTL STREQUAL "TRACE")
set(ENABLE_DTL_TRACE_01 1)
set(ENABLE_DTL_LOG_01 0)
elseif(ENABLE_AOCL_DTL STREQUAL "LOG")
set(ENABLE_DTL_TRACE_01 0)
set(ENABLE_DTL_LOG_01 1)
else()
message(FATAL_ERROR "ENABLE_AOCL_DTL option '${ENABLE_AOCL_DTL}' is not supported. Please use one of the following options \
during CMake invocation: ALL, TRACE, LOG, OFF")
endif()
else()
set(ENABLE_DTL_TRACE_01 0)
set(ENABLE_DTL_LOG_01 0)
endif()
set(AOCL_DTL_TRACE_LEVEL "5" CACHE STRING "Level of detail in tracing, see the description in aocl_dtl/aocldtlcf.h for more details. Possible values 1..10, default 5")
set_property(CACHE AOCL_DTL_TRACE_LEVEL PROPERTY STRINGS "1" "2" "3" "4" "5" "6" "7" "8" "9" "10")
if( NOT ((AOCL_DTL_TRACE_LEVEL STREQUAL "1") OR (AOCL_DTL_TRACE_LEVEL STREQUAL "2") OR (AOCL_DTL_TRACE_LEVEL STREQUAL "3") OR
(AOCL_DTL_TRACE_LEVEL STREQUAL "4") OR (AOCL_DTL_TRACE_LEVEL STREQUAL "5") OR (AOCL_DTL_TRACE_LEVEL STREQUAL "6") OR
(AOCL_DTL_TRACE_LEVEL STREQUAL "7") OR (AOCL_DTL_TRACE_LEVEL STREQUAL "8") OR (AOCL_DTL_TRACE_LEVEL STREQUAL "9") OR
(AOCL_DTL_TRACE_LEVEL STREQUAL "10")
) )
message(FATAL_ERROR "AOCL_DTL_TRACE_LEVEL option '${AOCL_DTL_TRACE_LEVEL}' is not supported. Please use one of the following options \
during CMake invocation: 1 .. 10")
endif()
if(WIN32)
set(ENABLE_MEMKIND "no" CACHE STRING "libmemkind for manage memory pools")
set_property(CACHE ENABLE_MEMKIND PROPERTY STRINGS "no")
@@ -294,7 +328,7 @@ else()
set_property(CACHE ENABLE_MEMKIND PROPERTY STRINGS "auto" "yes" "no")
if( NOT ((ENABLE_MEMKIND STREQUAL "auto") OR (ENABLE_MEMKIND STREQUAL "yes") OR (ENABLE_MEMKIND STREQUAL "no")) )
message(FATAL_ERROR "ENABLE_MEMKIND option '${ENABLE_MEMKIND}' is not supported. Please use one of the following options \
during CMake invokation: auto, yes, no")
during CMake invocation: auto, yes, no")
endif()
endif()
option(ENABLE_AOCL_DYNAMIC "Dynamic selection of number of threads" ON)
@@ -304,14 +338,14 @@ if(WIN32)
set_property(CACHE COMPLEX_RETURN PROPERTY STRINGS "gnu" "intel")
if( NOT ((COMPLEX_RETURN STREQUAL "gnu") OR (COMPLEX_RETURN STREQUAL "intel")) )
message(FATAL_ERROR "COMPLEX_RETURN option '${COMPLEX_RETURN}' is not supported. Please use one of the following options \
during CMake invokation: gnu, intel")
during CMake invocation: gnu, intel")
endif()
else()
set(COMPLEX_RETURN "default" CACHE STRING "The method used for returning complex numbers")
set_property(CACHE COMPLEX_RETURN PROPERTY STRINGS "default" "gnu" "intel")
if( NOT ((COMPLEX_RETURN STREQUAL "default") OR (COMPLEX_RETURN STREQUAL "gnu") OR (COMPLEX_RETURN STREQUAL "intel")) )
message(FATAL_ERROR "COMPLEX_RETURN option '${COMPLEX_RETURN}' is not supported. Please use one of the following options \
during CMake invokation: default, gnu, intel")
during CMake invocation: default, gnu, intel")
endif()
endif()
# If the CONFIG_LIST does not already contain the CONFIG_NAME (i.e.,
@@ -704,6 +738,8 @@ if((INT_TYPE_SIZE STREQUAL "32") AND (BLAS_INT_TYPE_SIZE STREQUAL "64"))
To avoid the possibility of truncation, we do not allow use of 64-bit integers in the BLAS API with 32-bit integers in BLIS. \
Please use a different configuration of integers.")
endif()
cmake_print_variables(ENABLE_ADDON)
if(ENABLE_ADDON STREQUAL "")
message(" Configuring with no addons.")

View File

@@ -11,7 +11,12 @@
dim_t AOCL_get_requested_threads_count(void)
{
return bli_thread_get_num_threads();
dim_t nthreads = bli_thread_get_num_threads();
// If BLIS ways parallelism has been set, or if the OpenMP level
// is not active, then stored nt is currently -1. Change value to
// 1 for printing in logs
if ( nthreads < 0 ) nthreads = 1;
return nthreads;
}
#if AOCL_DTL_LOG_ENABLE
@@ -87,7 +92,6 @@ void AOCL_DTL_log_gemm_sizes(int8 loglevel,
(inc_t)lda, (inc_t)ldb,
beta_real, beta_imag,
(inc_t)ldc);
DTL_Trace(loglevel, TRACE_TYPE_LOG, function_name, function_name, line, buffer);
}

View File

@@ -5,35 +5,31 @@
* libaray, all debug features (except auto trace)
* can be enabled/disabled in this file.
*
* Copyright (C) 2020 - 2023, Advanced Micro Devices, Inc. All rights reserved.
* Copyright (C) 2020 - 2025, Advanced Micro Devices, Inc. All rights reserved.
*
*==================================================================*/
#ifndef _AOCLDTLCF_H_
#define _AOCLDTLCF_H_
/* Macro for tracing the log If the user wants to enable tracing he has to
enable this macro by making it to 1 else 0 */
#define AOCL_DTL_TRACE_ENABLE 0
/* DTL_DumpData functionality (AOCL_DTL_DUMP_ENABLE) is not used at present */
/* Macro for dumping the log If the user wants to enable dumping he has to
enable this macro by making it to 1 else 0 */
#define AOCL_DTL_DUMP_ENABLE 0
/* Macro for dumping the log If the user wants to enable input logs he has to
enable this macro by making it to 1 else 0 */
#define AOCL_DTL_LOG_ENABLE 0
/* AOCL_DTL_LOG_ENABLE and AOCL_DTL_TRACE_ENABLE now defined via configure
and cmake options */
/* Select the trace level till which you want to log the data */
/* By default it will log for all levels */
#define AOCL_DTL_TRACE_LEVEL AOCL_DTL_LEVEL_TRACE_5
/* Default set in configure and CMakeLists.txt is AOCL_DTL_TRACE_LEVEL_NUMBER=5 */
#define AOCL_DTL_TRACE_LEVEL AOCL_DTL_TRACE_LEVEL_NUMBER
/* user has to explicitly use the below macros to identify
ciriticality of the logged message */
criticality of the logged message */
#define AOCL_DTL_LEVEL_ALL (15)
#define AOCL_DTL_LEVEL_TRACE_10 (15)
#define AOCL_DTL_LEVEL_TRACE_9 (14)
#define AOCL_DTL_LEVEL_TRACE_8 (13)
#define AOCL_DTL_LEVEL_TRACE_7 (12) /* Kernels */
#define AOCL_DTL_LEVEL_TRACE_7 (12) /* Kernels */
#define AOCL_DTL_LEVEL_TRACE_6 (11)
#define AOCL_DTL_LEVEL_TRACE_5 (10)
#define AOCL_DTL_LEVEL_TRACE_4 (9)

View File

@@ -236,4 +236,14 @@
#define __blis_arch_type_name "@rename_blis_arch_type@"
#define __blis_model_type_name "@rename_blis_model_type@"
#if @enable_aocl_dtl_trace@
#define AOCL_DTL_TRACE_ENABLE 1
#endif
#if @enable_aocl_dtl_log@
#define AOCL_DTL_LOG_ENABLE 1
#endif
#define AOCL_DTL_TRACE_LEVEL_NUMBER AOCL_DTL_LEVEL_TRACE_@aocl_dtl_trace_level_number@
#endif

View File

@@ -234,4 +234,14 @@ ${KERNEL_LIST_DEFINES}
#define __blis_arch_type_name "${RENAME_BLIS_ARCH_TYPE}"
#define __blis_model_type_name "${RENAME_BLIS_MODEL_TYPE}"
#if ${ENABLE_DTL_TRACE_01}
#define AOCL_DTL_TRACE_ENABLE 1
#endif
#if ${ENABLE_DTL_LOG_01}
#define AOCL_DTL_LOG_ENABLE 1
#endif
#define AOCL_DTL_TRACE_LEVEL_NUMBER AOCL_DTL_LEVEL_TRACE_${AOCL_DTL_TRACE_LEVEL}
#endif

53
configure vendored
View File

@@ -421,6 +421,27 @@ print_usage()
echo " Change environment variable used to select architecture model specific"
echo " optimizations from BLIS_MODEL_TYPE to STRING"
echo " "
echo " --enable-aocl-dtl=OPTION, --disable-aocl-dtl"
echo " "
echo " Enable DTL tracing and/or logging functionality"
echo " OPTION={all,trace,log,off}. The default is 'off'."
echo " Unrecognized options will be treated as 'off'."
echo " Details of the options:"
echo " * logging records basic information for each BLAS"
echo " call, with some APIs including timing information."
echo " * tracing records more detailed information on"
echo " the call stack within the BLAS APIs, and is mostly"
echo " of use for BLIS developers. The level of detail is"
echo " controlled by --aocl-dtl-trace-level option. More detailed"
echo " tracing will significantly increase API runtime."
echo " "
echo " --aocl-dtl-trace-level=OPTION"
echo " "
echo " Sets the level of detail in tracing, see the description"
echo " in aocl_dtl/aocldtlcf.h for more details."
echo " OPTION=1..10, used to set different levels of detail in"
echo " tracing. Default value is 5."
echo " "
echo " -q, --quiet Suppress informational output. By default, configure"
echo " is verbose. (NOTE: -q is not yet implemented)"
echo " "
@@ -2167,6 +2188,10 @@ main()
rename_blis_arch_type='BLIS_ARCH_TYPE'
rename_blis_model_type='BLIS_MODEL_TYPE'
# DTL tracing/logging flag.
enable_aocl_dtl='off'
aocl_dtl_trace_level_number='unset'
# The addon flag and names.
addon_flag=''
addon_list=''
@@ -2437,6 +2462,15 @@ main()
rename-blis-model-type=*)
rename_blis_model_type=${OPTARG#*=}
;;
enable-aocl-dtl=*)
enable_aocl_dtl=${OPTARG#*=}
;;
disable-aocl-dtl=*)
enable_aocl_dtl='off'
;;
aocl-dtl-trace-level=*)
aocl_dtl_trace_level_number=${OPTARG#*=}
;;
*)
print_usage
;;
@@ -3329,6 +3363,22 @@ main()
enable_trsm_preinversion_01=0
fi
# Check AOCL DTL flag configuration
enable_aocl_dtl_trace_01=0
enable_aocl_dtl_log_01=0
if [ "x${enable_aocl_dtl}" = "xtrace" ]; then
enable_aocl_dtl_trace_01=1
elif [ "x${enable_aocl_dtl}" = "xlog" ]; then
enable_aocl_dtl_log_01=1
elif [ "x${enable_aocl_dtl}" = "xall" ]; then
enable_aocl_dtl_trace_01=1
enable_aocl_dtl_log_01=1
fi
if [ "x${aocl_dtl_trace_level_number}" = "xunset" ]; then
aocl_dtl_trace_level_number=5
fi
# Check aocl dynamic threading configuration and enable it only if
# multi-threading is enabled
if [ "x${enable_aocl_dynamic}" = "xyes" ]; then
@@ -3702,6 +3752,9 @@ main()
| sed -e "s/@disable_blis_arch_type@/${disable_blis_arch_type_01}/g" \
| sed -e "s/@rename_blis_arch_type@/${rename_blis_arch_type}/g" \
| sed -e "s/@rename_blis_model_type@/${rename_blis_model_type}/g" \
| sed -e "s/@enable_aocl_dtl_trace@/${enable_aocl_dtl_trace_01}/g" \
| sed -e "s/@enable_aocl_dtl_log@/${enable_aocl_dtl_log_01}/g" \
| sed -e "s/@aocl_dtl_trace_level_number@/${aocl_dtl_trace_level_number}/g" \
> "${bli_config_h_out_path}"
# -- Instantiate bli_addon.h file from template ----------------------------