Skip to content

Commit

Permalink
Merged AOCL BLIS 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dzambare committed Jul 9, 2022
2 parents 3aa0044 + 1a63b9f commit 77c8f06
Show file tree
Hide file tree
Showing 127 changed files with 32,519 additions and 10,188 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,13 @@ out.*
GPATH
GRTAGS
GTAGS

# Windows Build
build/*
bin/*
*.dll
*.lib
*.pdb
*.exe

.vscode
42 changes: 27 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Copyright (C) 2021, Advanced Micro Devices, Inc. All rights reserved.##
##Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved.##

cmake_minimum_required(VERSION 3.0.0)

Expand All @@ -10,7 +10,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")


SET(AOCL_BLIS_FAMILY "zen" CACHE STRING "AOCL BLIS family name")
SET(OPENMP_PATH "C:\\Program Files\\LLVM\\lib" CACHE STRING "openmp library
SET(OpenMP_libomp_LIBRARY "C:/Program Files/LLVM/lib/libomp.lib" CACHE STRING "openmp library
path")
set(TARGET_ARCH ${AOCL_BLIS_FAMILY})
set(AOCL_BLIS_ZEN TRUE)
Expand Down Expand Up @@ -90,9 +90,8 @@ option(BLIS_ENABLE_ILP64 "ENABLE BLIS ILP64" OFF)
option(ENABLE_INT_TYPE_SIZE " Internal BLIS integers ,used in native BLIS interfaces based on architecture dependent " ON)
option(ENABLE_BLASTEST "Enable the blastest" OFF)
option(ENABLE_TESTCPP_TESTING "Enabling testcpp" OFF)
option (ENABLE_NO_UNDERSCORE_API "export APIs without underscore" ON)
option (ENABLE_NO_UNDERSCORE_API "export APIs without underscore" OFF)
option (ENABLE_UPPERCASE_API "export APIs with uppercase" OFF)
option (ENABLE_API_WRAPPER "Enable wrapper code" OFF)
option (ENABLE_COMPLEX_RETURN_INTEL "Enable complex_return_intel" OFF)
option (ENABLE_TRSM_PREINVERSION "Enable TRSM preinversion" ON)
option (ENABLE_AOCL_DYNAMIC "Enable Dynamic Multi-threading" OFF)
Expand Down Expand Up @@ -122,10 +121,6 @@ if(ENABLE_UPPERCASE_API)
add_definitions(-DBLIS_ENABLE_UPPERCASE_API)
endif()

if(ENABLE_API_WRAPPER)
add_definitions(-DBLIS_ENABLE_API_WRAPPER)
endif()

if(ENABLE_AOCL_DYNAMIC)
set(AOCL_DYNAMIC TRUE)
endif()
Expand Down Expand Up @@ -260,7 +255,9 @@ if(ENABLE_MULTITHREADING)
find_package(OpenMP)
if (OPENMP_FOUND)
set(BLIS_ENABLE_OPENMP TRUE)
add_compile_options(-Xclang -fopenmp)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
message (FATAL_ERROR "Openmp Not Found")
endif()
Expand Down Expand Up @@ -524,20 +521,34 @@ execute_process(
OUTPUT_VARIABLE CMD_OUTPUT)
message( STATUS "Generating monolithic header file :" ${CMD_OUTPUT})

# Logic to generate the cblas.h in include folder.
set(CBLAS_H "cblas.h")
# Arguements for python script
set(C_COMMENT "-c")
set(VERBOSE "-v1")
set(INPUT "${CMAKE_SOURCE_DIR}/frame/compat/cblas/src/${CBLAS_H}")
set(OUTPUT "${CMAKE_SOURCE_DIR}/include/${TARGET_ARCH}/${CBLAS_H}")
set(TEMP_DIR "${INCLUDE}")
set(DIR_H_PATH "${HEADER_PATH}")

# Run python script to generate monolithic header at configuration time
execute_process(
COMMAND ${PYTHON_EXE} ${FLATTEN_PY} "${C_COMMENT}" "${VERBOSE}" "${INPUT}" "${OUTPUT}" "${TEMP_DIR}" "${DIR_H_PATH}"
RESULT_VARIABLE CMD_RESULT
OUTPUT_VARIABLE CMD_OUTPUT)
message( STATUS "Generating monolithic cblas header file :" ${CMD_OUTPUT})

# setting the blis version string
file (STRINGS "version" BLIS_VERSION)
set(BLIS_VERSION_STRING ${BLIS_VERSION})
add_definitions(-DBLIS_VERSION_STRING="AOCL BLIS ${BLIS_VERSION_STRING}")

message( STATUS "OPENMP PATH:" ${OPENMP_PATH})
link_directories("${OPENMP_PATH}")

if(BUILD_SHARED_LIBS)
add_library("${PROJECT_NAME}" SHARED ${CMAKE_SOURCE_DIR}/bli_config.h
${CMAKE_SOURCE_DIR}/include/${TARGET_ARCH}/blis.h
${headers})
if(ENABLE_OPENMP)
target_link_libraries("${PROJECT_NAME}" PUBLIC "${OPENMP_PATH}/libomp.lib")
target_link_libraries("${PROJECT_NAME}" PRIVATE OpenMP::OpenMP_CXX)
endif()
target_compile_definitions("${PROJECT_NAME}" PUBLIC -DBLIS_IS_BUILDING_LIBRARY)
set_target_properties("${PROJECT_NAME}" PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "${LIB_NAME}")
Expand All @@ -547,9 +558,10 @@ if(NOT BUILD_SHARED_LIBS)
${CMAKE_SOURCE_DIR}/include/${TARGET_ARCH}/blis.h
${headers})
if(ENABLE_OPENMP)
target_link_libraries("${PROJECT_NAME}" PUBLIC "${OPENMP_PATH}/libomp.lib")
set_target_properties("${PROJECT_NAME}" PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "${LIB_NAME}" STATIC_LIBRARY_OPTIONS "${OpenMP_libomp_LIBRARY}")
else()
set_target_properties("${PROJECT_NAME}" PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "${LIB_NAME}")
endif()
set_target_properties("${PROJECT_NAME}" PROPERTIES LINKER_LANGUAGE C OUTPUT_NAME "${LIB_NAME}")
endif()

link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ copyright info. All parties provide their portions of the code under the

Copyright (C) 2018, The University of Texas at Austin
Copyright (C) 2016, Hewlett Packard Enterprise Development LP
Copyright (C) 2018 - 2021, Advanced Micro Devices, Inc.
Copyright (C) 2018 - 2022, Advanced Micro Devices, Inc.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
Expand Down
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# libraries.
#
# Copyright (C) 2014, The University of Texas at Austin
# Copyright (C) 2021, Advanced Micro Devices, Inc. All rights reserved.
# Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -212,6 +212,27 @@ MK_REFKERN_OBJS := $(foreach arch, $(CONFIG_LIST), \
# Generate object file paths for all of the portable framework source code.
MK_FRAME_OBJS := $(call gen-obj-paths-from-src,$(FRAME_SRC_SUFS),$(MK_FRAME_SRC),$(FRAME_PATH),$(BASE_OBJ_FRAME_PATH))

# AMD has optimized some of the framework files, these optimizations
# may not be compatible with other platforms.
#
# In order to keep main framework code independent of AMD changes,
# AMD has duplicated the files and updated them for example
# frame/compact/bla_gemm.c : generic framework file
# frame/compact/bla_gemm_amd.c : AMD optimized framework file
# Based on the archiecture we choose correct files

ifeq ($(MK_IS_ARCH_ZEN),yes)
# Build is being done for AMD platforms, remove the objects which
# don't have amd suffix (for which exists AMD specific implementation).
MK_FRAME_AMD_OBJS := $(filter $(BASE_OBJ_FRAME_PATH)/%amd.o, $(MK_FRAME_OBJS))
FILES_TO_REMOVE := $(subst _amd.o,.o, $(MK_FRAME_AMD_OBJS))
MK_FRAME_OBJS := $(filter-out $(FILES_TO_REMOVE), $(MK_FRAME_OBJS))
else
# Build is done for non AMD platforms, remove the amd specific objects
MK_FRAME_AMD_OBJS := $(filter $(BASE_OBJ_FRAME_PATH)/%amd.o, $(MK_FRAME_OBJS))
MK_FRAME_OBJS := $(filter-out $(MK_FRAME_AMD_OBJS), $(MK_FRAME_OBJS))
endif

# Generate object file paths for all of the debgu and trace logger.
MK_AOCLDTL_OBJS := $(call gen-obj-paths-from-src,$(AOCLDTL_SRC_SUFS),$(MK_AOCLDTL_SRC),$(AOCLDTL_PATH),$(BASE_OBJ_AOCLDTL_PATH))

Expand Down Expand Up @@ -1338,4 +1359,3 @@ else
@echo "Uninstalling $(@F) from $(@D)/"
@- $(RM_F) $@
endif

51 changes: 41 additions & 10 deletions aocl_dtl/aocldtl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = TRUE;
#endif

#if AOCL_DTL_AUTO_TRACE_ENABLE
Expand All @@ -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))
Expand 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", TRUE );
#endif

#if AOCL_DTL_AUTO_TRACE_ENABLE
Expand All @@ -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

Expand Down Expand Up @@ -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();

Expand Down
28 changes: 27 additions & 1 deletion aocl_dtl/aocldtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* It provides defination for all macros to be
* used by user to add debug/trace information.
*
* Copyright (C) 2020-2021, Advanced Micro Devices, Inc. All rights reserved.
* Copyright (C) 2020-2022, Advanced Micro Devices, Inc. All rights reserved.
*
*==================================================================*/

Expand All @@ -15,6 +15,7 @@
#include "aocldtlcf.h"
#include "aocltpdef.h"
#include "aoclflist.h"
#include "aoclos.h"

#define TRACE_TYPE_FENTRY (1)
#define TRACE_TYPE_FEXIT (2)
Expand Down Expand Up @@ -108,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()
Expand Down
Loading

0 comments on commit 77c8f06

Please sign in to comment.