Replace SP3 dynamic assembly with pre-assembled binaries
This is the first part of transitioning to the LLVM-based assembler. SP3 is deprecated and all references to the library are removed. Pending LLVM support, relevant shaders have been precompiled. Change-Id: I7d44cef5ded1836c4a74b77881af5bea8803d2c1
This commit is contained in:
1 förälder
aba3046bb6
incheckning
712ea75377
10 files changed
+208
-1271
No files matched your search
@@ -66,18 +66,6 @@ if ( NOT EXISTS ${HSATHK_BUILD_LIB_PATH}/libhsakmt.so.1 )
|
||||
MESSAGE ( FATAL_ERROR "Environment variable HSATHK_BUILD_LIB_PATH is not set to point to the location where KFD Thunk library libhsakmt.so.1 could be found." )
|
||||
endif ()
|
||||
|
||||
if ( EXISTS ${LIBSP3_BUILD_INC_PATH}/sp3.h )
|
||||
set ( LIBSP3_BUILD_INC_PATH ${LIBSP3_BUILD_INC_PATH} )
|
||||
else ()
|
||||
set ( LIBSP3_BUILD_INC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../utils/sp3 )
|
||||
endif ()
|
||||
|
||||
if ( EXISTS ${LIBSP3_BUILD_LIB_PATH}/libsp3.a )
|
||||
set ( LIBSP3_BUILD_LIB_PATH ${LIBSP3_BUILD_LIB_PATH} )
|
||||
else ()
|
||||
set ( LIBSP3_BUILD_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../utils/sp3 )
|
||||
endif ()
|
||||
|
||||
MESSAGE ( ------IS64BIT: ${IS64BIT} )
|
||||
MESSAGE ( ------Compiler: ${CMAKE_CXX_COMPILER} )
|
||||
MESSAGE ( ------Version: ${CMAKE_CXX_COMPILER_VERSION} )
|
||||
@@ -153,11 +141,9 @@ include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
|
||||
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/../inc )
|
||||
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/inc )
|
||||
include_directories ( ${HSATHK_BUILD_INC_PATH} )
|
||||
include_directories ( ${LIBSP3_BUILD_INC_PATH} )
|
||||
|
||||
## Library path(s).
|
||||
link_directories ( ${HSATHK_BUILD_LIB_PATH} )
|
||||
link_directories ( ${LIBSP3_BUILD_LIB_PATH} )
|
||||
|
||||
add_library ( ${CORE_RUNTIME_TARGET} SHARED ${CORE_SRCS} )
|
||||
|
||||
@@ -172,7 +158,6 @@ target_link_libraries ( ${CORE_RUNTIME_TARGET}
|
||||
PRIVATE amdhsaloader
|
||||
PRIVATE amdhsacode
|
||||
PRIVATE hsakmt
|
||||
PRIVATE sp3
|
||||
dl pthread rt
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The University of Illinois/NCSA
|
||||
// Open Source License (NCSA)
|
||||
//
|
||||
// Copyright (c) 2014-2015, Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Developed by:
|
||||
//
|
||||
// AMD Research and AMD HSA Software Development
|
||||
//
|
||||
// Advanced Micro Devices, Inc.
|
||||
//
|
||||
// www.amd.com
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal with the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimers.
|
||||
// - Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimers in
|
||||
// the documentation and/or other materials provided with the distribution.
|
||||
// - Neither the names of Advanced Micro Devices, Inc,
|
||||
// nor the names of its contributors may be used to endorse or promote
|
||||
// products derived from this Software without specific prior written
|
||||
// permission.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS WITH THE SOFTWARE.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef HSA_RUNTIME_CORE_INC_AMD_GPU_SHADERS_H_
|
||||
#define HSA_RUNTIME_CORE_INC_AMD_GPU_SHADERS_H_
|
||||
|
||||
namespace amd {
|
||||
|
||||
static const unsigned int kCodeCopyAligned7[] = {
|
||||
0xC0820100, 0xC0840104, 0xC0860108, 0xC088010C, 0xC08A0110, 0xC00C0114,
|
||||
0xBF8C007F, 0x8F028602, 0x4A000002, 0x7E060205, 0xD24A6A02, 0x00000900,
|
||||
0xD2506A03, 0x01A90103, 0x7E0A0207, 0xD24A6A04, 0x00000D00, 0xD2506A05,
|
||||
0x01A90105, 0xD1C2006A, 0x00001102, 0xBF86000F, 0x87FE6A7E, 0xDC200000,
|
||||
0x01000002, 0xBF8C0F70, 0xD24A6A02, 0x00003102, 0xD2506A03, 0x01A90103,
|
||||
0xDC600000, 0x00000104, 0xD24A6A04, 0x00003104, 0xD2506A05, 0x01A90105,
|
||||
0xBF82FFEE, 0xBEFE04C1, 0x8F198418, 0x34020084, 0x7E060209, 0xD24A6A02,
|
||||
0x00001101, 0xD2506A03, 0x01A90103, 0x7E0A020B, 0xD24A6A04, 0x00001501,
|
||||
0xD2506A05, 0x01A90105, 0xD1C2006A, 0x00001902, 0xBF86000E, 0xDC380000,
|
||||
0x08000002, 0xD24A6A02, 0x00003302, 0xD2506A03, 0x01A90103, 0xBF8C0F70,
|
||||
0xDC780000, 0x00000804, 0xD24A6A04, 0x00003304, 0xD2506A05, 0x01A90105,
|
||||
0xBF82FFEF, 0x8F198218, 0x34020082, 0x7E06020D, 0xD24A6A02, 0x00001901,
|
||||
0xD2506A03, 0x01A90103, 0x7E0A020F, 0xD24A6A04, 0x00001D01, 0xD2506A05,
|
||||
0x01A90105, 0xD1C2006A, 0x00002102, 0xBF86000F, 0x87FE6A7E, 0xDC300000,
|
||||
0x01000002, 0xD24A6A02, 0x00003302, 0xD2506A03, 0x01A90103, 0xBF8C0F70,
|
||||
0xDC700000, 0x00000104, 0xD24A6A04, 0x00003304, 0xD2506A05, 0x01A90105,
|
||||
0xBF82FFEE, 0xBEFE04C1, 0x7E060211, 0xD24A6A02, 0x00002100, 0xD2506A03,
|
||||
0x01A90103, 0x7E0A0213, 0xD24A6A04, 0x00002500, 0xD2506A05, 0x01A90105,
|
||||
0xD1C2006A, 0x00002902, 0xBF860006, 0x87FE6A7E, 0xDC200000, 0x01000002,
|
||||
0xBF8C0F70, 0xDC600000, 0x00000104, 0xBF810000,
|
||||
};
|
||||
|
||||
static const unsigned int kCodeCopyMisaligned7[] = {
|
||||
0xC0820100, 0xC0840104, 0xC0860108, 0xC008010C, 0xBF8C007F, 0x8F028602,
|
||||
0x4A000002, 0x7E060205, 0xD24A6A02, 0x00000900, 0xD2506A03, 0x01A90103,
|
||||
0x7E0A0207, 0xD24A6A04, 0x00000D00, 0xD2506A05, 0x01A90105, 0xD1C2006A,
|
||||
0x00001102, 0xBF860032, 0xDC200000, 0x06000002, 0xD24A6A02, 0x00002102,
|
||||
0xD2506A03, 0x01A90103, 0xDC200000, 0x07000002, 0xD24A6A02, 0x00002102,
|
||||
0xD2506A03, 0x01A90103, 0xDC200000, 0x08000002, 0xD24A6A02, 0x00002102,
|
||||
0xD2506A03, 0x01A90103, 0xDC200000, 0x09000002, 0xD24A6A02, 0x00002102,
|
||||
0xD2506A03, 0x01A90103, 0xBF8C0F70, 0xDC600000, 0x00000604, 0xD24A6A04,
|
||||
0x00002104, 0xD2506A05, 0x01A90105, 0xDC600000, 0x00000704, 0xD24A6A04,
|
||||
0x00002104, 0xD2506A05, 0x01A90105, 0xDC600000, 0x00000804, 0xD24A6A04,
|
||||
0x00002104, 0xD2506A05, 0x01A90105, 0xDC600000, 0x00000904, 0xD24A6A04,
|
||||
0x00002104, 0xD2506A05, 0x01A90105, 0xBF82FFCB, 0x7E060209, 0xD24A6A02,
|
||||
0x00001100, 0xD2506A03, 0x01A90103, 0x7E0A020B, 0xD24A6A04, 0x00001500,
|
||||
0xD2506A05, 0x01A90105, 0xD1C2006A, 0x00001902, 0xBF86000F, 0x87FE6A7E,
|
||||
0xDC200000, 0x01000002, 0xD24A6A02, 0x00002102, 0xD2506A03, 0x01A90103,
|
||||
0xBF8C0F70, 0xDC600000, 0x00000104, 0xD24A6A04, 0x00002104, 0xD2506A05,
|
||||
0x01A90105, 0xBF82FFEE, 0xBF810000,
|
||||
};
|
||||
|
||||
static const unsigned int kCodeFill7[] = {
|
||||
0xC0820100, 0xC0840104, 0xBF8C007F, 0x8F028602, 0x4A000002, 0x7E08020A,
|
||||
0x7E0A020A, 0x7E0C020A, 0x7E0E020A, 0x8F0C840B, 0x34020084, 0x7E060205,
|
||||
0xD24A6A02, 0x00000901, 0xD2506A03, 0x01A90103, 0xD1C2006A, 0x00000D02,
|
||||
0xBF860007, 0xDC780000, 0x00000402, 0xD24A6A02, 0x00001902, 0xD2506A03,
|
||||
0x01A90103, 0xBF82FFF6, 0x8F0C820B, 0x34020082, 0x7E060207, 0xD24A6A02,
|
||||
0x00000D01, 0xD2506A03, 0x01A90103, 0xD1C2006A, 0x00001102, 0xBF860008,
|
||||
0x87FE6A7E, 0xDC700000, 0x00000402, 0xD24A6A02, 0x00001902, 0xD2506A03,
|
||||
0x01A90103, 0xBF82FFF5, 0xBF810000,
|
||||
};
|
||||
|
||||
static const unsigned int kCodeTrapHandler8[] = {
|
||||
0xC0061C80, 0x000000C0, 0xBF8C007F, 0xBEFE0181, 0x80728872, 0x82738073,
|
||||
0x7E000272, 0x7E020273, 0x7E0402FF, 0x80000000, 0x7E060280, 0xDD800000,
|
||||
0x00000200, 0xBF8C0F70, 0x7DD40500, 0xBF870011, 0xC0061D39, 0x00000008,
|
||||
0xBF8C007F, 0x86F47474, 0xBF84000C, 0x80729072, 0x82738073, 0xC0021CB9,
|
||||
0x00000000, 0xBF8C007F, 0x7E000274, 0x7E020275, 0x7E040272, 0xDC700000,
|
||||
0x00000200, 0xBF8C0F70, 0xBF900001, 0xBF8D0001, 0xBE801F70,
|
||||
};
|
||||
|
||||
static const unsigned int kCodeCopyAligned8[] = {
|
||||
0xC00A0100, 0x00000000, 0xC00A0200, 0x00000010, 0xC00A0300, 0x00000020,
|
||||
0xC00A0400, 0x00000030, 0xC00A0500, 0x00000040, 0xC0020600, 0x00000050,
|
||||
0xBF8C007F, 0x8E028602, 0x32000002, 0x7E060205, 0xD1196A02, 0x00000900,
|
||||
0xD11C6A03, 0x01A90103, 0x7E0A0207, 0xD1196A04, 0x00000D00, 0xD11C6A05,
|
||||
0x01A90105, 0xD0E9006A, 0x00001102, 0xBF86000F, 0x86FE6A7E, 0xDC400000,
|
||||
0x01000002, 0xBF8C0F70, 0xD1196A02, 0x00003102, 0xD11C6A03, 0x01A90103,
|
||||
0xDC600000, 0x00000104, 0xD1196A04, 0x00003104, 0xD11C6A05, 0x01A90105,
|
||||
0xBF82FFEE, 0xBEFE01C1, 0x8E198418, 0x24020084, 0x7E060209, 0xD1196A02,
|
||||
0x00001101, 0xD11C6A03, 0x01A90103, 0x7E0A020B, 0xD1196A04, 0x00001501,
|
||||
0xD11C6A05, 0x01A90105, 0xD0E9006A, 0x00001902, 0xBF86000E, 0xDC5C0000,
|
||||
0x08000002, 0xD1196A02, 0x00003302, 0xD11C6A03, 0x01A90103, 0xBF8C0F70,
|
||||
0xDC7C0000, 0x00000804, 0xD1196A04, 0x00003304, 0xD11C6A05, 0x01A90105,
|
||||
0xBF82FFEF, 0x8E198218, 0x24020082, 0x7E06020D, 0xD1196A02, 0x00001901,
|
||||
0xD11C6A03, 0x01A90103, 0x7E0A020F, 0xD1196A04, 0x00001D01, 0xD11C6A05,
|
||||
0x01A90105, 0xD0E9006A, 0x00002102, 0xBF86000F, 0x86FE6A7E, 0xDC500000,
|
||||
0x01000002, 0xD1196A02, 0x00003302, 0xD11C6A03, 0x01A90103, 0xBF8C0F70,
|
||||
0xDC700000, 0x00000104, 0xD1196A04, 0x00003304, 0xD11C6A05, 0x01A90105,
|
||||
0xBF82FFEE, 0xBEFE01C1, 0x7E060211, 0xD1196A02, 0x00002100, 0xD11C6A03,
|
||||
0x01A90103, 0x7E0A0213, 0xD1196A04, 0x00002500, 0xD11C6A05, 0x01A90105,
|
||||
0xD0E9006A, 0x00002902, 0xBF860006, 0x86FE6A7E, 0xDC400000, 0x01000002,
|
||||
0xBF8C0F70, 0xDC600000, 0x00000104, 0xBF810000,
|
||||
};
|
||||
|
||||
static const unsigned int kCodeCopyMisaligned8[] = {
|
||||
0xC00A0100, 0x00000000, 0xC00A0200, 0x00000010, 0xC00A0300, 0x00000020,
|
||||
0xC0020400, 0x00000030, 0xBF8C007F, 0x8E028602, 0x32000002, 0x7E060205,
|
||||
0xD1196A02, 0x00000900, 0xD11C6A03, 0x01A90103, 0x7E0A0207, 0xD1196A04,
|
||||
0x00000D00, 0xD11C6A05, 0x01A90105, 0xD0E9006A, 0x00001102, 0xBF860032,
|
||||
0xDC400000, 0x06000002, 0xD1196A02, 0x00002102, 0xD11C6A03, 0x01A90103,
|
||||
0xDC400000, 0x07000002, 0xD1196A02, 0x00002102, 0xD11C6A03, 0x01A90103,
|
||||
0xDC400000, 0x08000002, 0xD1196A02, 0x00002102, 0xD11C6A03, 0x01A90103,
|
||||
0xDC400000, 0x09000002, 0xD1196A02, 0x00002102, 0xD11C6A03, 0x01A90103,
|
||||
0xBF8C0F70, 0xDC600000, 0x00000604, 0xD1196A04, 0x00002104, 0xD11C6A05,
|
||||
0x01A90105, 0xDC600000, 0x00000704, 0xD1196A04, 0x00002104, 0xD11C6A05,
|
||||
0x01A90105, 0xDC600000, 0x00000804, 0xD1196A04, 0x00002104, 0xD11C6A05,
|
||||
0x01A90105, 0xDC600000, 0x00000904, 0xD1196A04, 0x00002104, 0xD11C6A05,
|
||||
0x01A90105, 0xBF82FFCB, 0x7E060209, 0xD1196A02, 0x00001100, 0xD11C6A03,
|
||||
0x01A90103, 0x7E0A020B, 0xD1196A04, 0x00001500, 0xD11C6A05, 0x01A90105,
|
||||
0xD0E9006A, 0x00001902, 0xBF86000F, 0x86FE6A7E, 0xDC400000, 0x01000002,
|
||||
0xD1196A02, 0x00002102, 0xD11C6A03, 0x01A90103, 0xBF8C0F70, 0xDC600000,
|
||||
0x00000104, 0xD1196A04, 0x00002104, 0xD11C6A05, 0x01A90105, 0xBF82FFEE,
|
||||
0xBF810000,
|
||||
};
|
||||
|
||||
static const unsigned int kCodeFill8[] = {
|
||||
0xC00A0100, 0x00000000, 0xC00A0200, 0x00000010, 0xBF8C007F, 0x8E028602,
|
||||
0x32000002, 0x7E08020A, 0x7E0A020A, 0x7E0C020A, 0x7E0E020A, 0x8E0C840B,
|
||||
0x24020084, 0x7E060205, 0xD1196A02, 0x00000901, 0xD11C6A03, 0x01A90103,
|
||||
0xD0E9006A, 0x00000D02, 0xBF860007, 0xDC7C0000, 0x00000402, 0xD1196A02,
|
||||
0x00001902, 0xD11C6A03, 0x01A90103, 0xBF82FFF6, 0x8E0C820B, 0x24020082,
|
||||
0x7E060207, 0xD1196A02, 0x00000D01, 0xD11C6A03, 0x01A90103, 0xD0E9006A,
|
||||
0x00001102, 0xBF860008, 0x86FE6A7E, 0xDC700000, 0x00000402, 0xD1196A02,
|
||||
0x00001902, 0xD11C6A03, 0x01A90103, 0xBF82FFF5, 0xBF810000,
|
||||
};
|
||||
|
||||
} // namespace amd
|
||||
|
||||
#endif // header guard
|
||||
@@ -46,19 +46,19 @@
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <climits>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "core/inc/amd_aql_queue.h"
|
||||
#include "core/inc/amd_blit_kernel.h"
|
||||
#include "core/inc/amd_blit_sdma.h"
|
||||
#include "core/inc/amd_gpu_shaders.h"
|
||||
#include "core/inc/amd_memory_region.h"
|
||||
#include "core/inc/interrupt_signal.h"
|
||||
#include "core/inc/isa.h"
|
||||
#include "core/inc/runtime.h"
|
||||
|
||||
#include "utils/sp3/sp3.h"
|
||||
|
||||
#include "hsa_ext_image.h"
|
||||
|
||||
// Size of scratch (private) segment pre-allocated per thread, in bytes.
|
||||
@@ -182,49 +182,58 @@ GpuAgent::~GpuAgent() {
|
||||
void GpuAgent::AssembleShader(const char* src_sp3, const char* func_name,
|
||||
AssembleTarget assemble_target, void*& code_buf,
|
||||
size_t& code_buf_size) const {
|
||||
#ifdef __linux__ // No VS builds of libsp3 available right now
|
||||
std::string src_sp3_unified(src_sp3);
|
||||
// Select precompiled shader implementation from name/target.
|
||||
struct ASICShader {
|
||||
const void* code;
|
||||
size_t size;
|
||||
int num_sgprs;
|
||||
int num_vgprs;
|
||||
};
|
||||
|
||||
if (isa_->GetMajorVersion() == 7) {
|
||||
// On Gfx7 replace v_add_u32 with legacy equivalent v_add_i32.
|
||||
std::string add_inst_gfx8("v_add_u32"), add_inst_gfx7("v_add_i32");
|
||||
struct CompiledShader {
|
||||
ASICShader compute_7;
|
||||
ASICShader compute_8;
|
||||
};
|
||||
|
||||
for (size_t instIdx = 0; (instIdx = src_sp3_unified.find(
|
||||
add_inst_gfx8, instIdx)) != std::string::npos;
|
||||
instIdx += add_inst_gfx8.size()) {
|
||||
src_sp3_unified.replace(instIdx, add_inst_gfx7.size(), add_inst_gfx7);
|
||||
}
|
||||
}
|
||||
std::map<std::string, CompiledShader> compiled_shaders = {
|
||||
{"TrapHandler",
|
||||
{{NULL, 0, 0, 0}, {kCodeTrapHandler8, sizeof(kCodeTrapHandler8), 2, 4}}},
|
||||
{"CopyAligned",
|
||||
{{kCodeCopyAligned7, sizeof(kCodeCopyAligned7), 32, 12},
|
||||
{kCodeCopyAligned8, sizeof(kCodeCopyAligned8), 32, 12}}},
|
||||
{"CopyMisaligned",
|
||||
{{kCodeCopyMisaligned7, sizeof(kCodeCopyMisaligned7), 23, 10},
|
||||
{kCodeCopyMisaligned8, sizeof(kCodeCopyMisaligned8), 23, 10}}},
|
||||
{"Fill",
|
||||
{{kCodeFill7, sizeof(kCodeFill7), 19, 8},
|
||||
{kCodeFill8, sizeof(kCodeFill8), 19, 8}}}};
|
||||
|
||||
// Assemble source string with libsp3.
|
||||
sp3_context* sp3 = sp3_new();
|
||||
auto compiled_shader_it = compiled_shaders.find(func_name);
|
||||
assert(compiled_shader_it != compiled_shaders.end() &&
|
||||
"Precompiled shader unavailable");
|
||||
|
||||
ASICShader* asic_shader = NULL;
|
||||
|
||||
switch (isa_->GetMajorVersion()) {
|
||||
case 7:
|
||||
sp3_setasic(sp3, "CI");
|
||||
sp3_set_param_int(sp3, "kGFXIPVersion", 7);
|
||||
asic_shader = &compiled_shader_it->second.compute_7;
|
||||
break;
|
||||
case 8:
|
||||
sp3_setasic(sp3, "VI");
|
||||
sp3_set_param_int(sp3, "kGFXIPVersion", 8);
|
||||
asic_shader = &compiled_shader_it->second.compute_8;
|
||||
break;
|
||||
default:
|
||||
assert(false && "SP3 assembly not supported on this agent");
|
||||
assert(false && "Precompiled shader unavailable for target");
|
||||
}
|
||||
|
||||
sp3_parse_string(sp3, src_sp3_unified.c_str());
|
||||
sp3_shader* code_sp3_meta = sp3_compile(sp3, func_name);
|
||||
|
||||
// Allocate a GPU-visible buffer for the shader.
|
||||
HsaMemFlags code_buf_flags = {0};
|
||||
code_buf_flags.ui32.HostAccess = 1;
|
||||
code_buf_flags.ui32.ExecuteAccess = 1;
|
||||
code_buf_flags.ui32.NoSubstitute = 1;
|
||||
|
||||
size_t code_size = code_sp3_meta->size * sizeof(uint32_t);
|
||||
size_t header_size =
|
||||
(assemble_target == AssembleTarget::AQL ? sizeof(amd_kernel_code_t) : 0);
|
||||
code_buf_size = AlignUp(header_size + code_size, 0x1000);
|
||||
code_buf_size = AlignUp(header_size + asic_shader->size, 0x1000);
|
||||
|
||||
HSAKMT_STATUS err =
|
||||
hsaKmtAllocMemory(node_id(), code_buf_size, code_buf_flags, &code_buf);
|
||||
@@ -239,8 +248,8 @@ void GpuAgent::AssembleShader(const char* src_sp3, const char* func_name,
|
||||
if (assemble_target == AssembleTarget::AQL) {
|
||||
amd_kernel_code_t* header = reinterpret_cast<amd_kernel_code_t*>(code_buf);
|
||||
|
||||
int gran_sgprs = std::max(0, (int(code_sp3_meta->nsgprs) - 1) / 8);
|
||||
int gran_vgprs = std::max(0, (int(code_sp3_meta->nvgprs) - 1) / 4);
|
||||
int gran_sgprs = std::max(0, (int(asic_shader->num_sgprs) - 1) / 8);
|
||||
int gran_vgprs = std::max(0, (int(asic_shader->num_vgprs) - 1) / 4);
|
||||
|
||||
header->kernel_code_entry_byte_offset = sizeof(amd_kernel_code_t);
|
||||
AMD_HSA_BITS_SET(header->kernel_code_properties,
|
||||
@@ -262,14 +271,9 @@ void GpuAgent::AssembleShader(const char* src_sp3, const char* func_name,
|
||||
AMD_COMPUTE_PGM_RSRC_TWO_ENABLE_SGPR_WORKGROUP_ID_X, 1);
|
||||
}
|
||||
|
||||
// Copy trap handler code into the GPU-visible buffer.
|
||||
memcpy((void*)(uintptr_t(code_buf) + header_size), code_sp3_meta->data,
|
||||
code_size);
|
||||
|
||||
// Release SP3 resources.
|
||||
sp3_free_shader(code_sp3_meta);
|
||||
sp3_close(sp3);
|
||||
#endif
|
||||
// Copy shader code into the GPU-visible buffer.
|
||||
memcpy((void*)(uintptr_t(code_buf) + header_size), asic_shader->code,
|
||||
asic_shader->size);
|
||||
}
|
||||
|
||||
void GpuAgent::ReleaseShader(void* code_buf, size_t code_buf_size) const {
|
||||
@@ -988,7 +992,6 @@ void GpuAgent::SyncClocks() {
|
||||
}
|
||||
|
||||
void GpuAgent::BindTrapHandler() {
|
||||
#ifdef __linux__ // No raw string literal support in VS builds right now
|
||||
const char* src_sp3 = R"(
|
||||
var s_trap_info_lo = ttmp0
|
||||
var s_trap_info_hi = ttmp1
|
||||
@@ -1068,7 +1071,6 @@ void GpuAgent::BindTrapHandler() {
|
||||
HSAKMT_STATUS err = hsaKmtSetTrapHandler(node_id(), trap_code_buf_,
|
||||
trap_code_buf_size_, NULL, 0);
|
||||
assert(err == HSAKMT_STATUS_SUCCESS && "hsaKmtSetTrapHandler() failed");
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in new issue
Block a user