Added runtime control for DTL logging Feature

The logs can be enabled with following two methods:
  -- Environment variable based control: The feature can be enabled
     by specifying environment variable AOCL_VERBOSE=1.
  -- API based control: Two API's will be added to enable/disable
     logging at runtime
     1. AOCL_DTL_Enable_Logs()
     2. AOCL_DTL_Disable_Logs()
  -- The API takes precedence over the environment settings.

AMD-Internal: [CPUPL-2101]
Change-Id: Ie71c1095496fae89226049c9b9f80b00400350d5
This commit is contained in:
Dipal M Zambare
2022-04-07 13:47:39 +05:30
parent 1a3428ddfc
commit f23233eb4c
4 changed files with 163 additions and 62 deletions

View File

@@ -5,7 +5,7 @@
* These functions are invoked though macros by
* end user.
*
* Copyright (C) 2020-2021, Advanced Micro Devices, Inc. All rights reserved.
* Copyright (C) 2020-2022, Advanced Micro Devices, Inc. All rights reserved.
*
*=======================================================================*/
#include "blis.h"
@@ -56,6 +56,10 @@ static char *pchDTL_LOG_FILE = AOCL_DTL_LOG_FILE;
/* Global file pointer for logging the results */
AOCL_FLIST_Node *gpLogFileList = NULL;
/* Global flag to check if logging is enabled or not */
Bool gbIsLoggingEnabled = FALSE;
#endif
#if AOCL_DTL_AUTO_TRACE_ENABLE
@@ -82,6 +86,23 @@ AOCL_FLIST_Node *gpAutoTraceFileList = NULL;
void DTL_Initialize(
uint32 ui32CurrentLogLevel)
{
/*
* This function can be invoked multiple times either via library
* initialization function (e.g. bli_init()) or when user changes
* logging state using API. However we want it to run only once
* This flag ensure that it is executed only once.
*
* DTL can be used with many libraries hence it needs its own
* method to ensure this.
*/
static Bool bIsDTLInitDone = FALSE;
if (bIsDTLInitDone)
{
return;
}
/* If user selects invalid trace log level then the dafault trace log level
will be AOCL_DTL_LEVEL_ALL */
if ((ui32CurrentLogLevel < 1) || (ui32CurrentLogLevel > AOCL_DTL_LEVEL_ALL))
@@ -107,15 +128,9 @@ void DTL_Initialize(
#endif
#if (AOCL_DTL_LOG_ENABLE || AOCL_DTL_DUMP_ENABLE)
/* Create/Open the file to log the log data */
AOCL_FLIST_AddFile(pchDTL_LOG_FILE, &gpLogFileList, AOCL_gettid());
if (NULL == gpLogFileList)
{
/* Unable to open the specified file.*/
AOCL_DEBUGPRINT("Unable to create the log file %s\n", pchDTL_LOG_FILE);
return;
}
/* Check if DTL logging is requested via envoronment variable */
gbIsLoggingEnabled = bli_env_get_var( "AOCL_VERBOSE", FALSE );
#endif
#if AOCL_DTL_AUTO_TRACE_ENABLE
@@ -133,6 +148,9 @@ void DTL_Initialize(
/* Save Id for main thread */
gtidMainThreadID = AOCL_gettid();
// Ensure that this function is executed only once
bIsDTLInitDone = TRUE;
} /* DTL_Initialize */
#endif
@@ -193,6 +211,19 @@ void DTL_Trace(
{
uint8 i = 0;
AOCL_FAL_FILE *pOutFile = NULL;
#if AOCL_DTL_LOG_ENABLE
/*
* For performance reasons we check the logging state in end user
* macros, this is just an additional check in case the function
* is invoked from any other context.
*/
if (gbIsLoggingEnabled == FALSE && ui8LogType == TRACE_TYPE_LOG)
{
return;
}
#endif
uint64 u64EventTime = AOCL_getTimestamp();
dim_t u64RequestedThreadsCount = AOCL_get_requested_threads_count();

View File

@@ -109,6 +109,31 @@
void AOCL_DTL_start_perf_timer(void);
uint64 AOCL_DTL_get_time_spent(void);
/*
* Logging of inputs can be enabled by two methods:
*
* 1. Using environment variable AOCL_VERBOSE.
* 2. APIs
*
* The API takes precedence over environment variable.
*
* The global flag is maintain in the code to track the final
* state of the logging feature.
*/
extern Bool gbIsLoggingEnabled;
/* API to enable logging at runtime */
#define AOCL_DTL_Enable_Logs() \
/* Initialize DTL if not alredy done so */ \
AOCL_DTL_INITIALIZE(AOCL_DTL_TRACE_LEVEL); \
gbIsLoggingEnabled = TRUE;
/* API to disable logging at runtime */
#define AOCL_DTL_Disable_Logs() \
/* Initialize DTL if not alredy done so */ \
AOCL_DTL_INITIALIZE(AOCL_DTL_TRACE_LEVEL); \
gbIsLoggingEnabled = FALSE;
/* Macro to log the Data */
#define AOCL_DTL_START_PERF_TIMER() \
AOCL_DTL_start_perf_timer()

View File

@@ -3,7 +3,7 @@
*
* Description : BLIS library specific debug helpes.
*
* Copyright (C) 2020-2021, Advanced Micro Devices, Inc. All rights reserved.
* Copyright (C) 2020-2022, Advanced Micro Devices, Inc. All rights reserved.
*
*==================================================================*/
@@ -385,115 +385,148 @@ void AOCL_DTL_log_trmm_sizes(int8 loglevel,
#define AOCL_DTL_LOG_GEMM_INPUTS(loglevel, dt, transa, transb, m, n, k, alpha, lda, ldb, beta, ldc) \
AOCL_DTL_log_gemm_sizes(loglevel, dt, transa, transb, m, n, k, alpha, lda, ldb, beta, ldc, __FILE__, __FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_gemm_sizes(loglevel, dt, transa, transb, m, n, k, alpha, lda, ldb, beta, ldc, \
__FILE__, __FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_GEMM_STATS(loglevel, m, n, k) \
AOCL_DTL_log_gemm_stats(loglevel, m, n, k);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_gemm_stats(loglevel, m, n, k);
#define AOCL_DTL_LOG_TRSM_INPUTS(loglevel, dt, side, uploa, transa, diaga, m, n, alpha, lda, ldb) \
AOCL_DTL_log_trsm_sizes(loglevel, dt, side, uploa, transa, diaga, m, n, alpha, lda, ldb, __FILE__, __FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_trsm_sizes(loglevel, dt, side, uploa, transa, diaga, m, n, alpha, lda, ldb, \
__FILE__, __FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_GEMMT_INPUTS(loglevel, dt, uplo, transa, transb, n, k, alpha, lda, ldb, beta, ldc) \
AOCL_DTL_log_gemmt_sizes(loglevel, dt, uplo, transa, transb, n, k, alpha, lda, ldb, beta, ldc, __FILE__,__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_gemmt_sizes(loglevel, dt, uplo, transa, transb, n, k, alpha, lda, ldb, beta, ldc, \
__FILE__,__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_HEMM_INPUTS(loglevel, dt_type, side, uplo, m, n, alpha, lda, ldb, beta, ldc) \
AOCL_DTL_log_hemm_sizes(loglevel, dt_type, side, uplo, m, n, alpha, lda, ldb, beta, ldc, \
__FILE__, __FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_hemm_sizes(loglevel, dt_type, side, uplo, m, n, alpha, lda, ldb, beta, ldc, \
__FILE__, __FUNCTION__, __LINE__);
// Level-3 Macros
#define AOCL_DTL_LOG_HERK_INPUTS(loglevel, dt_type, uploc, transa, m, k, alpha, lda, beta, ldc)\
AOCL_DTL_log_herk_sizes(loglevel, dt_type, transa, uploc, m, k, alpha, lda, beta, ldc, __FILE__,\
__FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_herk_sizes(loglevel, dt_type, transa, uploc, m, k, alpha, lda, beta, ldc, __FILE__,\
__FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_HER2K_INPUTS(loglevel, dt_type, uploc, transa, m, k, alpha, lda, ldb, beta, ldc)\
AOCL_DTL_log_her2k_sizes(loglevel, dt_type, uploc, transa, m, k, alpha, lda, ldb, beta, ldc, __FILE__,\
__FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_her2k_sizes(loglevel, dt_type, uploc, transa, m, k, alpha, lda, ldb, beta, ldc, __FILE__,\
__FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_SYMM_INPUTS(loglevel, dt_type, side, uploa, m, n, alpha, lda, ldb, beta, ldc)\
AOCL_DTL_log_symm_sizes(loglevel, dt_type, side, uploa, m, n, alpha, lda, ldb, beta, ldc, __FILE__,\
__FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_symm_sizes(loglevel, dt_type, side, uploa, m, n, alpha, lda, ldb, beta, ldc, __FILE__,\
__FUNCTION__, __LINE__);
// Level-2 Macros
#define AOCL_DTL_LOG_GEMV_INPUTS(loglevel, dt_type, transa, m, n, alp, lda, incx, beta, incy) \
AOCL_DTL_log_gemv_sizes(loglevel, dt_type, transa, m, n, alp, lda, incx, beta, incy, __FILE__,\
__FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_gemv_sizes(loglevel, dt_type, transa, m, n, alp, lda, incx, beta, incy, __FILE__,\
__FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_GER_INPUTS(loglevel, dt_type, m, n, alpha, incx, incy, lda) \
AOCL_DTL_log_ger_sizes(loglevel, dt_type, m, n, alpha, incx, incy, lda, __FILE__, __FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_ger_sizes(loglevel, dt_type, m, n, alpha, incx, incy, lda, __FILE__, __FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_HER_INPUTS(loglevel, dt_type, uploa, m, alpha, incx, lda )\
AOCL_DTL_log_her_sizes(loglevel, dt_type, uploa, m, alpha, incx, lda, __FILE__,__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_her_sizes(loglevel, dt_type, uploa, m, alpha, incx, lda, __FILE__,__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_SYMV_INPUTS(loglevel, dt_type, uploa, m, alpha, lda, incx, beta, incy)\
AOCL_DTL_log_symv_sizes(loglevel, dt_type, uploa, m, alpha, lda, incx, beta, incy, __FILE__,\
__FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_symv_sizes(loglevel, dt_type, uploa, m, alpha, lda, incx, beta, incy, __FILE__,\
__FUNCTION__, __LINE__);
// Level-1 Macros
#define AOCL_DTL_LOG_COPY_INPUTS(loglevel, dt_type, n, incx, incy) \
AOCL_DTL_log_copy_sizes(loglevel, dt_type, n, incx, incy, __FILE__, __FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_copy_sizes(loglevel, dt_type, n, incx, incy, __FILE__, __FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_SCAL_INPUTS(loglevel, dt_type, alpha, n, incx )\
AOCL_DTL_log_scal_sizes(loglevel, dt_type, alpha, n, incx, __FILE__,__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_scal_sizes(loglevel, dt_type, alpha, n, incx, __FILE__,__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_SWAP_INPUTS(loglevel, dt_type, n, incx, incy)\
AOCL_DTL_log_swap_sizes(loglevel, dt_type, n, incx, incy, __FILE__,__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_swap_sizes(loglevel, dt_type, n, incx, incy, __FILE__,__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_NRM2_INPUTS(loglevel, dt_type, n, incx)\
AOCL_DTL_log_nrm2_sizes(loglevel, dt_type, n, incx, __FILE__,__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_nrm2_sizes(loglevel, dt_type, n, incx, __FILE__,__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_HEMV_INPUTS(loglevel, dt_type, uploa, m, alpha, lda, incx, beta, incy) \
AOCL_DTL_log_hemv_sizes(loglevel, dt_type, uploa, m, alpha, lda, incx, beta, incy, \
__FILE__, __FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_hemv_sizes(loglevel, dt_type, uploa, m, alpha, lda, incx, beta, incy, \
__FILE__, __FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_HER2_INPUTS(loglevel, dt_type, uploa, m, alpha, incx, incy, lda) \
AOCL_DTL_log_her2_sizes(loglevel, dt_type, uploa, m, alpha, incx, incy, lda, \
__FILE__, __FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_her2_sizes(loglevel, dt_type, uploa, m, alpha, incx, incy, lda, \
__FILE__, __FUNCTION__, __LINE__);
// Level-1 Macros
#define AOCL_DTL_LOG_AMAX_INPUTS(loglevel, dt_type, n, incx) \
AOCL_DTL_log_amax_sizes(loglevel, dt_type, n, incx, __FILE__, __FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_amax_sizes(loglevel, dt_type, n, incx, __FILE__, __FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_ASUM_INPUTS(loglevel, dt_type, n, incx) \
AOCL_DTL_log_asum_sizes(loglevel, dt_type, n, incx, __FILE__, __FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_asum_sizes(loglevel, dt_type, n, incx, __FILE__, __FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_AXPBY_INPUTS(loglevel, dt_type, n, alpha, incx, beta, incy) \
AOCL_DTL_log_axpby_sizes(loglevel, dt_type, n, alpha, incx, beta, incy, __FILE__,\
__FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_axpby_sizes(loglevel, dt_type, n, alpha, incx, beta, incy, __FILE__,\
__FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_AXPY_INPUTS(loglevel, dt_type, n, alpha, incx, incy) \
AOCL_DTL_log_axpy_sizes(loglevel, dt_type, n, alpha, incx, incy, __FILE__,\
__FUNCTION__, __LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_axpy_sizes(loglevel, dt_type, n, alpha, incx, incy, __FILE__,\
__FUNCTION__, __LINE__);
#define AOCL_DTL_LOG_DOTV_INPUTS(loglevel, dt_type, n, incx, incy) \
AOCL_DTL_log_dotv_sizes(loglevel, dt_type, n, incx, incy, __FILE__, __FUNCTION__, __LINE__); \
if (gbIsLoggingEnabled) \
AOCL_DTL_log_dotv_sizes(loglevel, dt_type, n, incx, incy, __FILE__, __FUNCTION__, __LINE__); \
#define AOCL_DTL_LOG_SYR2_INPUTS(loglevel, dt_type, uploa, m, alpha, incx, incy, lda) \
AOCL_DTL_log_syr2_sizes(loglevel, dt_type, uploa, m, alpha, incx, incy, lda, __FILE__,\
__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_syr2_sizes(loglevel, dt_type, uploa, m, alpha, incx, incy, lda, __FILE__,\
__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_SYR2K_INPUTS(loglevel, dt_type, uploc, transa, m, k, alpha, lda, ldb, beta, ldc) \
AOCL_DTL_log_syr2k_sizes(loglevel, dt_type, uploc, transa, m, k, alpha, lda, ldb, beta,\
ldc, __FILE__, __FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_syr2k_sizes(loglevel, dt_type, uploc, transa, m, k, alpha, lda, ldb, beta,\
ldc, __FILE__, __FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_SYR_INPUTS(loglevel, dt_type, uploa, m, alpha, incx, lda) \
AOCL_DTL_log_syr_sizes(loglevel, dt_type, uploa, m, alpha, incx, lda,\
__FILE__,__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_syr_sizes(loglevel, dt_type, uploa, m, alpha, incx, lda,\
__FILE__,__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_SYRK_INPUTS(loglevel, dt_type, uploc, transa, m, k, alpha, lda, beta, ldc) \
AOCL_DTL_log_syrk_sizes(loglevel, dt_type, uploc, transa, m, k, alpha, lda, beta, ldc, __FILE__,\
__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_syrk_sizes(loglevel, dt_type, uploc, transa, m, k, alpha, lda, beta, ldc, __FILE__,\
__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_TRMM_INPUTS(loglevel, dt_type, side, uploa, transa, diaga, m, n, alpha, lda, ldb) \
AOCL_DTL_log_trmm_sizes(loglevel, dt_type, side, uploa, transa, diaga, m, n, alpha, lda, ldb, __FILE__,\
__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_trmm_sizes(loglevel, dt_type, side, uploa, transa, diaga, m, n, alpha, lda, ldb, __FILE__,\
__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_TRMV_INPUTS(loglevel, dt_type, uploa, transa, diaga, m, lda, incx) \
AOCL_DTL_log_trmv_sizes(loglevel, dt_type, uploa, transa, diaga, m, lda, incx,\
__FILE__,__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_trmv_sizes(loglevel, dt_type, uploa, transa, diaga, m, lda, incx,\
__FILE__,__FUNCTION__,__LINE__);
#define AOCL_DTL_LOG_TRSV_INPUTS(loglevel, dt_type, uploa, transa, diaga, m, lda, incx ) \
AOCL_DTL_log_trsv_sizes(loglevel, dt_type, uploa, transa, diaga, m, lda, incx,\
__FILE__,__FUNCTION__,__LINE__);
if (gbIsLoggingEnabled) \
AOCL_DTL_log_trsv_sizes(loglevel, dt_type, uploa, transa, diaga, m, lda, incx,\
__FILE__,__FUNCTION__,__LINE__);
#else
#define AOCL_DTL_LOG_GEMM_INPUTS(loglevel, dt, transa, transb, m, n, k, alpha, lda, ldb, beta, ldc)

View File

@@ -5,7 +5,7 @@
* libaray, all debug features (except auto trace)
* can be enabled/disabled in this file.
*
* Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
* Copyright (C) 2020-2022, Advanced Micro Devices, Inc. All rights reserved.
*
*==================================================================*/
@@ -20,9 +20,21 @@
enable this macro by making it to 1 else 0 */
#define AOCL_DTL_DUMP_ENABLE 0
/* Macro for logging the logs If the user wants to enable loging information he
has to enable this macro by making it to 1 else 0 */
#define AOCL_DTL_LOG_ENABLE 0
/*
* Logging of inputs can be enabled by two methods:
*
* 1. Using environment variable AOCL_VERBOSE.
* 2. APIs AOCL_DTL_Enable_Logs(), AOCL_DTL_Disable_Logs()
*
* The API takes precedence over environment variable.
*
* The global flag is maintain in the code to track the final
* state of the logging feature.
*
* Setting AOCL_DTL_LOG_ENABLE = 0 will disable this feature
* completely and it is not recommended.
*/
#define AOCL_DTL_LOG_ENABLE 1
/* Select the trace level till which you want to log the data */
/* By default it will log for all levels */