From da3abfb0f85daa494710a4dbd8e3c80598964e96 Mon Sep 17 00:00:00 2001 From: Mukul Joshi Date: Wed, 17 Jun 2020 17:31:03 -0400 Subject: [PATCH] Update build script for SP3 static library Update build script and CMakeLists_sp3.txt file as SP3 directory structure has changed. The SP3 source code with gfx90a suport is merged into a new branch mukjoshi/sp3_gfx90a. Please make sure to checkout this branch before using the build script to generate the static library. Change-Id: I2bf0ade8b2d254cd7648cc8a6d69a83ee51344cd --- .../kfdtest/sp3/lib_helper/CMakeLists_sp3.txt | 24 +++++---- tests/kfdtest/sp3/lib_helper/build_sp3.sh | 2 +- tests/kfdtest/sp3/sp3.h | 53 ++++++++++++++++++- 3 files changed, 66 insertions(+), 13 deletions(-) diff --git a/tests/kfdtest/sp3/lib_helper/CMakeLists_sp3.txt b/tests/kfdtest/sp3/lib_helper/CMakeLists_sp3.txt index db59e3716e..ce8a3cb33f 100644 --- a/tests/kfdtest/sp3/lib_helper/CMakeLists_sp3.txt +++ b/tests/kfdtest/sp3/lib_helper/CMakeLists_sp3.txt @@ -39,7 +39,7 @@ set ( SCLIB_SRC ${PROJECT_SOURCE_DIR} ) #endif() include_directories(${SCLIB_SRC}/sp3) -include_directories(${SCLIB_SRC}/sp3/release_headers) +#include_directories(${SCLIB_SRC}/sp3/release_headers) include_directories(${SCLIB_SRC}/sp3/gen) set ( SRC_FILES ${SRC_FILES} ${SCLIB_SRC}/sp3/sp3-asic.c ) @@ -53,15 +53,17 @@ set ( SRC_FILES ${SRC_FILES} ${SCLIB_SRC}/sp3/sp3-cipher.c ) set ( SRC_FILES ${SRC_FILES} ${SCLIB_SRC}/sp3/sp3-vm.c ) aux_source_directory(${SCLIB_SRC}/sp3/gen SRC_FILES) -aux_source_directory(${SCLIB_SRC}/sp3/si SRC_FILES) -aux_source_directory(${SCLIB_SRC}/sp3/ci SRC_FILES) -aux_source_directory(${SCLIB_SRC}/sp3/gfx8 SRC_FILES) -aux_source_directory(${SCLIB_SRC}/sp3/gfx81 SRC_FILES) -aux_source_directory(${SCLIB_SRC}/sp3/gfx9 SRC_FILES) -aux_source_directory(${SCLIB_SRC}/sp3/gfx10 SRC_FILES) -aux_source_directory(${SCLIB_SRC}/sp3/release_headers/gfx81 SRC_FILES) -aux_source_directory(${SCLIB_SRC}/sp3/release_headers/gfx9 SRC_FILES) -aux_source_directory(${SCLIB_SRC}/sp3/release_headers/gfx10 SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/si/lib SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/ci/lib SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/gfx8/lib SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/gfx81/lib SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/gfx9/lib SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/gfx10/lib SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/aldbrn/lib SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/gfx81/arch SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/gfx9/arch SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/gfx10/arch SRC_FILES) +aux_source_directory(${SCLIB_SRC}/sp3/backend/aldbrn/arch SRC_FILES) message( STATUS "PROJECT_SOURCE_DIR:" ${PROJECT_SOURCE_DIR} ) @@ -70,7 +72,7 @@ message( STATUS "PROJECT_SOURCE_DIR:" ${PROJECT_SOURCE_DIR} ) # message(STATUS "${file}") #endforeach() -set ( CMAKE_C_FLAGS "-DSP3_STATIC_LIB -Wno-error -DPUBLIC_RELEASE -DLITTLEENDIAN_CPU -fPIC -DGFX10_BUILD" ) +set ( CMAKE_C_FLAGS "-DSP3_STATIC_LIB -Wno-error -DPUBLIC_RELEASE -DLITTLEENDIAN_CPU -fPIC -DGFX101_BUILD -DALDBRN_BUILD" ) add_library(amdsp3 ${SRC_FILES}) diff --git a/tests/kfdtest/sp3/lib_helper/build_sp3.sh b/tests/kfdtest/sp3/lib_helper/build_sp3.sh index 7cd20ccfb5..f93f145da6 100755 --- a/tests/kfdtest/sp3/lib_helper/build_sp3.sh +++ b/tests/kfdtest/sp3/lib_helper/build_sp3.sh @@ -44,7 +44,7 @@ popd rsync --progress -a build/libamdsp3.a $LIB_OUTPUT # Put the intermediate header files in the current folder for further processing -rsync --progress -a $SP3_PROJECT/sp3/sp3.h . +rsync --progress -a $SP3_PROJECT/sp3/public/lib/sp3.h . # Remove the build folder and CMakeLists.txt put into SP source folder rm -r build diff --git a/tests/kfdtest/sp3/sp3.h b/tests/kfdtest/sp3/sp3.h index e44ee406cf..513167d595 100644 --- a/tests/kfdtest/sp3/sp3.h +++ b/tests/kfdtest/sp3/sp3.h @@ -54,7 +54,9 @@ enum sp3_shtype { SP3_SHTYPE_HS = 4, SP3_SHTYPE_LS = 5, SP3_SHTYPE_CS = 6, +#ifdef NAVI10LITE_BUILD SP3_SHTYPE_ACV = 7, +#endif }; /// Assorted constants used by sp3 API. @@ -107,7 +109,7 @@ struct sp3_shader { uint32_t size; ///< Size of the compiled shader, in 32-bit words. uint32_t nsgprs; ///< Number of scalar GPRs used. uint32_t nvgprs; ///< Number of vector GPRs used. - uint32_t nsvgprs; ///< Number of shared vector GPRs used. + uint32_t nsvgprs; ///< Number of shared vector GPRs used (only available in certain projects). uint32_t naccvgprs; ///< Number of accumulator vector GPRs used (only available in certain projects). uint32_t nsgprs_manual_alloc; uint32_t nvgprs_manual_alloc; @@ -211,6 +213,13 @@ SP3_EXPORT struct sp3_context *sp3_new(void); /// /// Currently supported options: /// +/// stdlib (string) -- absolute path to standard library files. May be a colon-separated list +/// of paths that will be used to search for stdlib files. Used by sp3_parse_library(). +/// +/// The following options are deprecated because they take integer arguments; you should use +/// sp3_set_option_int() for these settings going forward. They will continue to be accepted by +/// this API to support legacy users. +/// /// Werror (boolean) -- indicates whether warnings should be treated as errors. /// /// wave_size (integer) -- sets the wave size being used by the draw calls that will be using @@ -222,11 +231,53 @@ SP3_EXPORT struct sp3_context *sp3_new(void); /// /// omit_code_end (boolean) -- omit generation of the S_CODE_END footer. /// +/// allow_raw_bits (boolean) -- allow use of the raw_bits() function in sp3 shaders. This is a +/// dangerous option to allow in general so you must explicitly enable this option, otherwise +/// the raw_bits() function will always error out. +/// SP3_EXPORT void sp3_set_option( struct sp3_context *state, const char *option, const char *value); +/// Set option for sp3. +/// +/// @param state sp3 context. +/// @param option Option name. Unknown options will raise an error. +/// @param value Option value. +/// +/// Currently supported options: +/// +/// Werror (boolean) -- indicates whether warnings should be treated as errors. +/// +/// wave_size (integer) -- sets the wave size being used by the draw calls that will be using +/// this shader. Ignored in certain ASICs. You may set this to 32, 64 or the special value 0 +/// to indicate no preference on wave size. The shader will be checked to ensure it is +/// compatible with the size specified here. +/// +/// omit_version (boolean) -- omit generation of the S_VERSION opcode. +/// +/// omit_code_end (boolean) -- omit generation of the S_CODE_END footer. +/// +/// allow_raw_bits (boolean) -- allow use of the raw_bits() function in sp3 shaders. This is a +/// dangerous option to allow in general so you must explicitly enable this option, otherwise +/// the raw_bits() function will always error out. +/// +/// secure_mode (boolean) -- run in secure mode. Disables macro language features in assembly +/// path including calls to custom functions. Useful if sp3 is used as a backend to a web-based +/// assembly tool. +/// +/// debug_encoding (boolean) -- if true, debug encoding selection logic for assembly. Only +/// supported in 10.4+ backends. +/// +/// no_vs_export_check (boolean) -- if true, disable VS export sanity check. Only supported in +/// 10.4+ backends. +/// +SP3_EXPORT void sp3_set_option_int( + struct sp3_context *state, + const char *option, + int32_t value); + /// Parse a file into a context. /// /// Use sp3_compile to generate binary microcode after the shader is parsed.