SWDEV-222307 - Add CMake support for PAL
Remove dependency on COMGR headers from backends.
Remove GFX103 PAL defines.
Change-Id: I6ff76dca2a0c84bc191e8fc8b639f2f5872d2085
[ROCm/clr commit: 1be1e69f2a]
This commit is contained in:
@@ -1123,7 +1123,11 @@ static inline cl_kernel_arg_type_qualifier GetOclTypeQualOCL(const aclArgData* a
|
||||
|
||||
// ================================================================================================
|
||||
#if defined(USE_COMGR_LIBRARY)
|
||||
bool Kernel::GetAttrCodePropMetadata(const amd_comgr_metadata_node_t kernelMetaNode) {
|
||||
bool Kernel::GetAttrCodePropMetadata() {
|
||||
amd_comgr_metadata_node_t kernelMetaNode;
|
||||
if (!prog().getKernelMetadata(name(), &kernelMetaNode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
InitParameters(kernelMetaNode);
|
||||
|
||||
|
||||
@@ -511,7 +511,7 @@ class Kernel : public amd::HeapObject {
|
||||
void InitParameters(const amd_comgr_metadata_node_t kernelMD);
|
||||
|
||||
//! Retrieve kernel attribute and code properties metadata
|
||||
bool GetAttrCodePropMetadata(const amd_comgr_metadata_node_t kernelMetaNode);
|
||||
bool GetAttrCodePropMetadata();
|
||||
|
||||
//! Retrieve the available SGPRs and VGPRs
|
||||
bool SetAvailableSgprVgpr(const std::string& targetIdent);
|
||||
|
||||
@@ -220,9 +220,13 @@ class Program : public amd::HeapObject {
|
||||
amd_comgr_metadata_node_t metadata() const { return metadata_; }
|
||||
|
||||
//! Get the kernel metadata
|
||||
const amd_comgr_metadata_node_t* getKernelMetadata(const std::string name) const {
|
||||
const bool getKernelMetadata(const std::string name, amd_comgr_metadata_node_t* meta) const {
|
||||
auto it = kernelMetadataMap_.find(name);
|
||||
return (it == kernelMetadataMap_.end()) ? nullptr : &(it->second);
|
||||
if (it != kernelMetadataMap_.end()) {
|
||||
*meta = it->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint32_t codeObjectVer() const { return codeObjectVer_; }
|
||||
|
||||
@@ -72,17 +72,13 @@ target_compile_definitions(vdipal PRIVATE PAL_BUILD_RENOIR=1)
|
||||
|
||||
# GFX10 targets
|
||||
target_compile_definitions(vdipal PRIVATE PAL_BUILD_GFX10=1)
|
||||
target_compile_definitions(vdipal PRIVATE PAL_BUILD_GFX103=1)
|
||||
target_compile_definitions(vdipal PRIVATE PAL_BUILD_NAVI12=1)
|
||||
target_compile_definitions(vdipal PRIVATE PAL_BUILD_NAVI14=1)
|
||||
|
||||
target_compile_definitions(vdipal PRIVATE OPENCL_MAINLINE=1)
|
||||
|
||||
if(${USE_COMGR_LIBRARY} MATCHES "yes")
|
||||
target_compile_definitions(vdipal PRIVATE USE_COMGR_LIBRARY -DCOMGR_DYN_DLL)
|
||||
if (DEFINED COMGR_INCLUDES AND NOT ${COMGR_INCLUDES} STREQUAL "")
|
||||
target_include_directories(${COMGR_INCLUDES})
|
||||
endif() # if (DEFINED COMGR_INCLUDES AND NOT ${COMGR_INCLUDES} STREQUAL "")
|
||||
target_compile_definitions(vdipal PRIVATE USE_COMGR_LIBRARY)
|
||||
endif()
|
||||
|
||||
target_include_directories(vdipal PRIVATE ${CMAKE_SOURCE_DIR}/compiler/sc/HSAIL/include)
|
||||
|
||||
@@ -154,7 +154,7 @@ bool PalCounterReference::finalize() {
|
||||
}
|
||||
}
|
||||
|
||||
static const std::array<PCIndexSelect, 49> blockIdToIndexSelect = {{
|
||||
static const std::array<PCIndexSelect, 46> blockIdToIndexSelect = {{
|
||||
PCIndexSelect::None, // CPF
|
||||
PCIndexSelect::ShaderEngine, // IA
|
||||
PCIndexSelect::ShaderEngine, // VGT
|
||||
@@ -201,9 +201,11 @@ static const std::array<PCIndexSelect, 49> blockIdToIndexSelect = {{
|
||||
PCIndexSelect::None, // GCR
|
||||
PCIndexSelect::None, // PH
|
||||
PCIndexSelect::ShaderArray, // UTCL1
|
||||
#if 0
|
||||
PCIndexSelect::None, // GeDist
|
||||
PCIndexSelect::ShaderEngine, // GeSe
|
||||
PCIndexSelect::None, // Df
|
||||
#endif
|
||||
}};
|
||||
|
||||
static_assert(blockIdToIndexSelect.size() == static_cast<size_t>(Pal::GpuBlock::Count), "size of blockIdToIndexSelect does not match GpuBlock::Count");
|
||||
@@ -690,7 +692,6 @@ void PerfCounter::convertInfo() {
|
||||
}
|
||||
break;
|
||||
case Pal::GfxIpLevel::GfxIp10_1:
|
||||
case Pal::GfxIpLevel::GfxIp10_3:
|
||||
if (info_.blockIndex_ < gfx10BlockIdPal.size()) {
|
||||
auto p = gfx10BlockIdPal[info_.blockIndex_];
|
||||
info_.blockIndex_ = std::get<0>(p);
|
||||
|
||||
@@ -197,7 +197,7 @@ bool NullDevice::init() {
|
||||
ShouldNotReachHere();
|
||||
break;
|
||||
case 3:
|
||||
ipLevel = Pal::GfxIpLevel::GfxIp10_3;
|
||||
ShouldNotReachHere();
|
||||
break;
|
||||
case 4:
|
||||
ShouldNotReachHere();
|
||||
|
||||
@@ -426,12 +426,7 @@ bool LightningKernel::init() {
|
||||
flags_.internalKernel_ =
|
||||
(compileOptions_.find("-cl-internal-kernel") != std::string::npos) ? true : false;
|
||||
|
||||
const amd_comgr_metadata_node_t* kernelMetaNode = prog().getKernelMetadata(name());
|
||||
if (kernelMetaNode == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetAttrCodePropMetadata(*kernelMetaNode)) {
|
||||
if (!GetAttrCodePropMetadata()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -472,10 +472,10 @@ void Resource::memTypeToHeap(Pal::GpuMemoryCreateInfo* createInfo) {
|
||||
switch (memoryType()) {
|
||||
case Local:
|
||||
case Scratch:
|
||||
createInfo->mallPolicy = static_cast<Pal::GpuMemMallPolicy>(dev().settings().mallPolicy_);
|
||||
// createInfo->mallPolicy = static_cast<Pal::GpuMemMallPolicy>(dev().settings().mallPolicy_);
|
||||
break;
|
||||
default:
|
||||
createInfo->mallPolicy = Pal::GpuMemMallPolicy::Never;
|
||||
// createInfo->mallPolicy = Pal::GpuMemMallPolicy::Never;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1951,7 +1951,7 @@ bool MemorySubAllocator::CreateChunk(const Pal::IGpuMemory* reserved_va) {
|
||||
createInfo.heapCount = 1;
|
||||
createInfo.heaps[0] = Pal::GpuHeapInvisible;
|
||||
createInfo.flags.peerWritable = device_->P2PAccessAllowed();
|
||||
createInfo.mallPolicy = static_cast<Pal::GpuMemMallPolicy>(device_->settings().mallPolicy_);
|
||||
// createInfo.mallPolicy = static_cast<Pal::GpuMemMallPolicy>(device_->settings().mallPolicy_);
|
||||
GpuMemoryReference* mem_ref = GpuMemoryReference::Create(*device_, createInfo);
|
||||
if (mem_ref != nullptr) {
|
||||
return InitAllocator(mem_ref);
|
||||
@@ -1971,7 +1971,7 @@ bool CoarseMemorySubAllocator::CreateChunk(const Pal::IGpuMemory* reserved_va) {
|
||||
createInfo.heapCount = 2;
|
||||
createInfo.heaps[0] = Pal::GpuHeapInvisible;
|
||||
createInfo.heaps[1] = Pal::GpuHeapLocal;
|
||||
createInfo.mallPolicy = static_cast<Pal::GpuMemMallPolicy>(device_->settings().mallPolicy_);
|
||||
// createInfo.mallPolicy = static_cast<Pal::GpuMemMallPolicy>(device_->settings().mallPolicy_);
|
||||
GpuMemoryReference* mem_ref = GpuMemoryReference::Create(*device_, createInfo);
|
||||
if (mem_ref != nullptr) {
|
||||
return InitAllocator(mem_ref);
|
||||
@@ -1987,7 +1987,7 @@ bool FineMemorySubAllocator::CreateChunk(const Pal::IGpuMemory* reserved_va) {
|
||||
createInfo.alignment = MaxGpuAlignment;
|
||||
createInfo.flags.useReservedGpuVa = (reserved_va != nullptr);
|
||||
createInfo.pReservedGpuVaOwner = reserved_va;
|
||||
createInfo.mallPolicy = Pal::GpuMemMallPolicy::Never;
|
||||
// createInfo.mallPolicy = Pal::GpuMemMallPolicy::Never;
|
||||
GpuMemoryReference* mem_ref = GpuMemoryReference::Create(*device_, createInfo);
|
||||
if ((mem_ref != nullptr) && InitAllocator(mem_ref)) {
|
||||
mem_ref->iMem()->Map(&mem_ref->cpuAddress_);
|
||||
|
||||
@@ -493,7 +493,6 @@ bool Settings::create(const Pal::DeviceProperties& palProp,
|
||||
|
||||
if (useLightning_) {
|
||||
switch (palProp.gfxLevel) {
|
||||
case Pal::GfxIpLevel::GfxIp10_3:
|
||||
case Pal::GfxIpLevel::GfxIp10_1:
|
||||
case Pal::GfxIpLevel::GfxIp9:
|
||||
singleFpDenorm_ = true;
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
include(bc2h)
|
||||
|
||||
set(INC_SUFFIX "amdgcn.inc")
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/utils/common)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/utils/libelf)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(${ROCM_OCL_INCLUDES})
|
||||
|
||||
if(${USE_COMGR_LIBRARY} MATCHES "yes")
|
||||
add_definitions(-DUSE_COMGR_LIBRARY -DCOMGR_DYN_DLL)
|
||||
find_package(amd_comgr REQUIRED CONFIG)
|
||||
include_directories("$<TARGET_PROPERTY:amd_comgr,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
add_definitions(-DUSE_COMGR_LIBRARY)
|
||||
endif()
|
||||
|
||||
add_library(oclrocm OBJECT
|
||||
@@ -30,83 +24,3 @@ add_library(oclrocm OBJECT
|
||||
)
|
||||
set_target_properties(oclrocm PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# FIXME: Remove following if block after enabling COMGR by default
|
||||
if (${USE_COMGR_LIBRARY} STREQUAL "no")
|
||||
# generating libraries.amdgcn.inc
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc "// Automatically generated file; DO NOT EDIT.\n")
|
||||
|
||||
foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS})
|
||||
get_target_property(lib_file ${AMDGCN_LIB_TARGET} OUTPUT_NAME)
|
||||
get_target_property(lib_file_name ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_NAME)
|
||||
get_target_property(lib_file_path ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY)
|
||||
set(bclib "${lib_file}")
|
||||
set(header "${lib_file_name}.${INC_SUFFIX}")
|
||||
set(symbol "${lib_file_name}_lib")
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${header}
|
||||
COMMAND bc2h ${bclib} ${CMAKE_CURRENT_BINARY_DIR}/${header} ${symbol}
|
||||
DEPENDS bc2h ${AMDGCN_LIB_TARGET}
|
||||
COMMENT "Generating ${header}"
|
||||
)
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/${target}.inc)
|
||||
|
||||
add_custom_target(${header}_target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${header})
|
||||
add_dependencies(oclrocm ${header}_target)
|
||||
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc "#include \"${header}\"\n")
|
||||
endforeach()
|
||||
|
||||
# Generate function to select libraries for a given GFXIP number.
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc
|
||||
"static inline std::tuple<const char*, const void*, size_t> get_oclc_isa_version(uint gfxip) { \
|
||||
switch (gfxip) {\n")
|
||||
foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS})
|
||||
if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_isa_version_[0-9]+_lib$")
|
||||
string(REGEX REPLACE "^oclc_isa_version_([0-9]+)_lib$" "\\1" gfxip ${AMDGCN_LIB_TARGET})
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc
|
||||
"case ${gfxip}: return std::make_tuple( \"oclc_isa_version_${gfxip}_lib.bc\","
|
||||
" oclc_isa_version_${gfxip}_lib, oclc_isa_version_${gfxip}_lib_size); break;\n")
|
||||
endif()
|
||||
endforeach()
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc
|
||||
"default: return std::make_tuple(\"\",(const void*)0,(size_t)0); }\n}\n")
|
||||
|
||||
foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS})
|
||||
if (${AMDGCN_LIB_TARGET} MATCHES "oclc_(.*)_on_lib")
|
||||
string(REGEX REPLACE "oclc_(.*)_on_lib" "\\1" function ${AMDGCN_LIB_TARGET})
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc
|
||||
"static inline std::tuple<const char*,const void*,size_t> get_oclc_${function}(bool on)"
|
||||
" { return std::make_tuple( on ? \"oclc_${function}_on_lib.bc\" : \"oclc_${function}_off_lib.bc\","
|
||||
" (const void*)(on ? oclc_${function}_on_lib : oclc_${function}_off_lib),"
|
||||
" on ? oclc_${function}_on_lib_size : oclc_${function}_off_lib_size); }\n")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# generating opencl*.inc files
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch
|
||||
COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL1.2 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch < ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h
|
||||
DEPENDS clang ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h
|
||||
COMMENT "Generating opencl1.2-c.amdgcn.pch"
|
||||
)
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc
|
||||
COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc opencl1_2_c
|
||||
DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch
|
||||
COMMENT "Generating opencl1.2-c.amdgcn.inc"
|
||||
)
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch)
|
||||
add_custom_target(opencl1.2-c.amdgcn.inc_target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc)
|
||||
add_dependencies(oclrocm opencl1.2-c.amdgcn.inc_target)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch
|
||||
COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL2.0 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch < ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h
|
||||
DEPENDS clang ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h
|
||||
COMMENT "Generating opencl2.0-c.amdgcn.pch"
|
||||
)
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc
|
||||
COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc opencl2_0_c
|
||||
DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch
|
||||
COMMENT "Generating opencl2.0-c.amdgcn.inc"
|
||||
)
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch)
|
||||
add_custom_target(opencl2.0-c.amdgcn.inc_target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc)
|
||||
add_dependencies(oclrocm opencl2.0-c.amdgcn.inc_target)
|
||||
endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no")
|
||||
|
||||
@@ -48,13 +48,7 @@ bool LightningKernel::init() {
|
||||
|
||||
hsa_agent_t hsaDevice = program()->hsaDevice();
|
||||
|
||||
const amd_comgr_metadata_node_t* kernelMetaNode =
|
||||
static_cast<const LightningProgram*>(program())->getKernelMetadata(name());
|
||||
if (kernelMetaNode == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetAttrCodePropMetadata(*kernelMetaNode)) {
|
||||
if (!GetAttrCodePropMetadata()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Verwijs in nieuw issue
Block a user