SWDEV-558845 - Support image in rocr on Windows (#1582)

Enable image build in Windows.
Remove some useless codes that fail building in Windows.
Some minor improvement.
Temporarily exclude mipmap test files.
Prevent negative tests affect some tests.
Move some catch info log codes into failed cases.
此提交包含在:
MachineTom authored and GitHub committed 2025-11-05 09:33:41 -05:00
1 父節點 16334bc15d
當前提交 3b1c0c3464
44 file changed
+577 -531

No files matched your search

+3 -8
查看文件
@@ -261,15 +261,10 @@ if (${PC_SAMPLING_SUPPORT})
target_sources( ${CORE_RUNTIME_TARGET} PRIVATE ${PCS_SRCS} )
endif()
if (UNIX)
if ( NOT DEFINED IMAGE_SUPPORT AND CMAKE_SYSTEM_PROCESSOR MATCHES "i?86|x86_64|amd64|AMD64|loongarch64" )
set ( IMAGE_SUPPORT ON )
endif()
set ( IMAGE_SUPPORT ${IMAGE_SUPPORT} CACHE BOOL "Build with image support (default: ON for x86, OFF elsewise)." )
else()
# Force IMAGE_SUPPORT to be OFF
set(IMAGE_SUPPORT OFF CACHE BOOL "Build with image support (forced to OFF)" FORCE)
if (NOT DEFINED IMAGE_SUPPORT AND CMAKE_SYSTEM_PROCESSOR MATCHES "i?86|x86_64|amd64|AMD64|loongarch64")
set (IMAGE_SUPPORT ON)
endif()
set (IMAGE_SUPPORT ${IMAGE_SUPPORT} CACHE BOOL "Build with image support (default: ON for x86, OFF elsewise).")
## Optional image module defintions.
if(${IMAGE_SUPPORT})
+2 -1
查看文件
@@ -289,7 +289,9 @@ void SurfaceGpuList(std::vector<int32_t>& gpu_list, bool xnack_mode, bool enable
core::g_use_interrupt_wait = false;
if (core::Runtime::runtime_singleton_->thunkLoader()->IsDXG()) {
core::Runtime::runtime_singleton_->flag().disable_image(true);
#if defined(_WIN32)
core::Runtime::runtime_singleton_->flag().disable_image(false);
if (node_prop.Capability2.ui32.AqlEmulationPm4_)
#endif
{
@@ -297,7 +299,6 @@ void SurfaceGpuList(std::vector<int32_t>& gpu_list, bool xnack_mode, bool enable
core::Runtime::runtime_singleton_->flag().disable_scratch();
}
core::Runtime::runtime_singleton_->flag().set_sdma(false, false);
core::Runtime::runtime_singleton_->flag().disable_image(true);
core::Runtime::runtime_singleton_->flag().disable_xnack();
core::Runtime::runtime_singleton_->flag().disable_fine_grain_pcie();
core::Runtime::runtime_singleton_->flag().set_ipc_mode_legacy(false);
-5
查看文件
@@ -41,11 +41,6 @@
////////////////////////////////////////////////////////////////////////////////
#include "blit_kernel.h"
#if (defined(WIN32) || defined(_WIN32))
#define NOMINMAX
#endif
#include <algorithm>
#include <atomic>
#include <sstream>
+14 -3
查看文件
@@ -67,10 +67,12 @@ endif()
## Add custom command to generate a kernel code object file
##==========================================
function(gen_kernel_bc TARGET_ID INPUT_FILE OUTPUT_FILE)
if(WIN32)
set (WIN_CL_COMPILE_OPTION "-fshort-wchar")
endif()
separate_arguments(CLANG_ARG_LIST UNIX_COMMAND
"-O2 -x cl -Xclang -finclude-default-header -cl-denorms-are-zero -cl-std=CL2.0
-target amdgcn-amd-amdhsa -mcpu=${TARGET_ID} -mcode-object-version=4
-target amdgcn-amd-amdhsa -mcpu=${TARGET_ID} -mcode-object-version=4 ${WIN_CL_COMPILE_OPTION}
-o ${OUTPUT_FILE} ${INPUT_FILE}")
## Add custom command to produce a code object file.
@@ -128,9 +130,18 @@ function(generate_blit_file BFILE)
## Add a custom command that generates opencl_blit_objects.cpp
## This depends on all the generated code object files and the C++ generator script.
add_custom_command(OUTPUT ${BFILE}.cpp
if (UNIX)
add_custom_command(OUTPUT ${BFILE}.cpp
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create_hsaco_ascii_file.sh ${CMAKE_CURRENT_BINARY_DIR}/${BFILE}.cpp
DEPENDS ${HSACO_TARG_LIST} create_hsaco_ascii_file.sh )
else()
find_package(Python3 COMPONENTS Interpreter REQUIRED)
add_custom_command(
OUTPUT ${BFILE}.cpp
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/create_hsaco_ascii_file.py ${CMAKE_CURRENT_BINARY_DIR}/${BFILE}.cpp ${HSACO_TARG_LIST}
COMMENT "Collating blit shaders..."
DEPENDS ${HSACO_TARG_LIST} create_hsaco_ascii_file.py)
endif()
## Export a target that builds (and depends on) opencl_blit_objects.cpp
add_custom_target( ${BFILE} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BFILE}.cpp )
@@ -0,0 +1,71 @@
################################################################################
##
## Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
##
## SPDX-License-Identifier: MIT
##
################################################################################
import sys
def GetSize(fileobject):
fileobject.seek(0,2) # move the cursor to the end of the file
size = fileobject.tell()
return size
def DumpFile(header, input_name):
try:
with open(input_name, "rb") as binary_file:
# Read the entire content of the file as bytes
binary_data = binary_file.read()
file_size = GetSize(binary_file)
#print(f"Binary size: {file_size}")
# Reset file pointer
binary_file.seek(0)
parts = input_name.split('.')
file_name = parts[0]
content = f"unsigned char {file_name}""[] = {\n "
header.write(content)
line = 0
count = 0
for byte_value in binary_data:
count += 1
padded_hex = '{:02x}'.format(byte_value)
if (count != file_size):
header.write(f"0x{padded_hex},")
else:
header.write(f"0x{padded_hex}")
line += 1
if (line == 12):
header.write(f"\n ")
line = 0
else:
header.write(f" ")
header.write("\n};\nunsigned int "f"{file_name}_len = {file_size};\n")
except FileNotFoundError:
print(f"Error: The file {input_name} was not found.")
except Exception as e:
print(f"An error occurred: {e}")
if len(sys.argv) > 1:
header_name = sys.argv[1];
with open(header_name, 'w') as header:
header.write("//==============================================================================\n")
header.write("// This file is automatically generated during build process, don't modify it\n")
header.write("//==============================================================================\n\n")
header.write("namespace rocr {\n")
header.write("namespace image {\n\n")
for i, arg in enumerate(sys.argv):
if (i > 1):
#print(f"File {i}: {arg}\n")
DumpFile(header, arg)
header.write("} // namespace image\n")
header.write("} // namespace rocr\n\n")
else:
print("Empty arguments!")
-5
查看文件
@@ -52,11 +52,6 @@
#include <climits>
#include <cmath>
#if (defined(WIN32) || defined(_WIN32))
#define NOMINMAX
__inline long int lrintf(float f) { return _mm_cvtss_si32(_mm_load_ss(&f)); }
#endif
namespace rocr {
namespace image {
-1
查看文件
@@ -40,7 +40,6 @@
//
////////////////////////////////////////////////////////////////////////////////
#define NOMINMAX
#include "image_manager_ai.h"
#include <assert.h>
-1
查看文件
@@ -40,7 +40,6 @@
//
////////////////////////////////////////////////////////////////////////////////
#define NOMINMAX
#include "image_manager_gfx11.h"
#include <assert.h>
-1
查看文件
@@ -40,7 +40,6 @@
//
////////////////////////////////////////////////////////////////////////////////
#define NOMINMAX
#include "image_manager_gfx12.h"
#include <assert.h>
+2 -3
查看文件
@@ -40,7 +40,6 @@
//
////////////////////////////////////////////////////////////////////////////////
#define NOMINMAX
#include "image_manager_kv.h"
#include <assert.h>
@@ -100,8 +99,8 @@ hsa_status_t ImageManagerKv::Initialize(hsa_agent_t agent_handle) {
assert(status == HSA_STATUS_SUCCESS);
HsaGpuTileConfig tileConfig = {0};
unsigned int tc[40];
unsigned int mtc[40];
unsigned int tc[40] = {0};
unsigned int mtc[40] = {0};
tileConfig.TileConfig = &tc[0];
tileConfig.NumTileConfigs = 40;
tileConfig.MacroTileConfig = &mtc[0];
-1
查看文件
@@ -40,7 +40,6 @@
//
////////////////////////////////////////////////////////////////////////////////
#define NOMINMAX
#include "image_manager_nv.h"
#include <assert.h>
-1
查看文件
@@ -40,7 +40,6 @@
//
////////////////////////////////////////////////////////////////////////////////
#define NOMINMAX
#include "image_runtime.h"
#include <assert.h>
-16
查看文件
@@ -280,22 +280,6 @@ static __forceinline uint64_t NextPow2(uint64_t value) {
static __forceinline bool strIsEmpty(const char* str) noexcept { return str[0] == '\0'; }
static __forceinline std::string& ltrim(std::string& s) {
auto it = std::find_if(s.begin(), s.end(),
[](char c) { return !std::isspace<char>(c, std::locale::classic()); });
s.erase(s.begin(), it);
return s;
}
static __forceinline std::string& rtrim(std::string& s) {
auto it = std::find_if(s.rbegin(), s.rend(),
[](char c) { return !std::isspace<char>(c, std::locale::classic()); });
s.erase(it.base(), s.end());
return s;
}
static __forceinline std::string& trim(std::string& s) { return ltrim(rtrim(s)); }
template<uint32_t lowBit, uint32_t highBit, typename T>
static __forceinline uint32_t BitSelect(T p) {
static_assert(sizeof(T) <= sizeof(uintptr_t), "Type out of range.");