Files
TheRock/rocm-libraries/projects/hiptensor/cmake/Functions/CopyYamlFolder.cmake
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

145 lines
5.6 KiB
CMake

# Function to copy multiple folders with path transformation
function(copy_emulation_config_folders)
# Function arguments
set(options "") # Optional arguments
set(oneValueArgs DESTINATION_PREFIX) # Single-value arguments
set(multiValueArgs SOURCE_FOLDERS SOURCE_SCRIPTS) # Multi-value arguments
cmake_parse_arguments(COPY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Check if required parameters are provided
if(NOT COPY_SOURCE_FOLDERS)
message(FATAL_ERROR "SOURCE_FOLDERS must be specified")
endif()
if(NOT COPY_SOURCE_SCRIPTS)
message(FATAL_ERROR "SOURCE_SCRIPTS must be specified")
endif()
if(NOT COPY_DESTINATION_PREFIX)
message(FATAL_ERROR "DESTINATION_PREFIX must be specified")
endif()
# Process each source folder
foreach(source_path ${COPY_SOURCE_FOLDERS})
# Ensure source directory exists
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source_path})
message(WARNING "Source directory '${CMAKE_CURRENT_SOURCE_DIR}/${source_path}' does not exist, skipping...")
continue()
endif()
# Extract the folder name (e.g., "folder01" from "folder01/configs/emulation")
string(REGEX MATCH "^[^/]+" folder_name ${source_path})
# Create the destination path
set(dest_path "${COPY_DESTINATION_PREFIX}/${folder_name}")
# Find all files recursively in the source folder
file(GLOB_RECURSE source_files
LIST_DIRECTORIES false
"${CMAKE_CURRENT_SOURCE_DIR}/${source_path}/*.yaml"
)
# Create the destination directory
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${dest_path})
# Copy each file preserving directory structure
foreach(source_file ${source_files})
# Get the relative path from the source directory
file(RELATIVE_PATH rel_path
"${CMAKE_CURRENT_SOURCE_DIR}/${source_path}"
"${source_file}"
)
# Get the destination directory for this file
get_filename_component(dest_dir
"${CMAKE_BINARY_DIR}/${dest_path}/${rel_path}"
DIRECTORY
)
# Create destination directory if it doesn't exist
file(MAKE_DIRECTORY ${dest_dir})
# Copy the file
configure_file(
${source_file}
"${CMAKE_BINARY_DIR}/${dest_path}/${rel_path}"
COPYONLY
)
endforeach()
endforeach()
foreach(source_script_path ${COPY_SOURCE_SCRIPTS})
# Ensure source directory exists
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source_script_path})
message(WARNING "Source directory '${CMAKE_CURRENT_SOURCE_DIR}/${source_script_path}' does not exist, skipping...")
continue()
endif()
get_filename_component(source_script_name ${source_script_path} NAME)
# Copy the file
file(COPY_FILE
${source_script_path}
"${CMAKE_BINARY_DIR}/${source_script_name}"
)
endforeach()
message(STATUS "Copying emulation test config files")
# Create a custom target to track the copied files
add_custom_target(copy_emulation_config_files DEPENDS ${source_files} ${COPY_SOURCE_SCRIPTS})
endfunction()
function(copy_code_coverage_config_files SOURCE_FOLDER DEST_FOLDER)
# Define the patterns to process
set(PATTERNS "01_contraction" "02_elementwise" "03_reduction")
# Initialize variable to track copied files
set(COPIED_FILES_LIST "")
# Process each pattern
foreach(PATTERN ${PATTERNS})
# Create the source path
if(PATTERN STREQUAL "01_contraction")
set(SOURCE_PATHS "${SOURCE_FOLDER}/${PATTERN}/configs/code_coverage/")
elseif(PATTERN STREQUAL "02_elementwise")
# The config files of quick and code coverage are the same for permution and reduction
# reuse the quick config files to avoid duplicated files
set(SOURCE_PATHS
"${SOURCE_FOLDER}/${PATTERN}/configs/emulation/quick/permutation"
"${SOURCE_FOLDER}/${PATTERN}/configs/emulation/quick/binary_op"
"${SOURCE_FOLDER}/${PATTERN}/configs/emulation/quick/trinary_op"
)
elseif(PATTERN STREQUAL "03_reduction")
set(SOURCE_PATHS "${SOURCE_FOLDER}/${PATTERN}/configs/code_coverage/")
endif()
foreach(SOURCE_PATH ${SOURCE_PATHS})
# Check if the source directory exists
if(EXISTS "${SOURCE_PATH}")
# Create destination directory if it doesn't exist
file(MAKE_DIRECTORY "${DEST_FOLDER}/${PATTERN}")
# Find all yaml files in the source directory
file(GLOB YAML_FILES "${SOURCE_PATH}/*.yaml")
# Copy each yaml file to the destination
foreach(YAML_FILE ${YAML_FILES})
get_filename_component(FILE_NAME ${YAML_FILE} NAME)
file(COPY "${YAML_FILE}" DESTINATION "${DEST_FOLDER}/${PATTERN}")
message(VERBOSE "Copied ${FILE_NAME} to ${DEST_FOLDER}/${PATTERN}/")
list(APPEND COPIED_FILES_LIST "${SOURCE_PATH}/${FILE_NAME}")
endforeach()
else()
message(WARNING "Source directory ${SOURCE_PATH} does not exist.")
endif()
endforeach()
endforeach()
message(STATUS "Copying code coverage config files")
# Create a custom target to track the copied files
add_custom_target(copy_code_coverage_config_files DEPENDS ${COPIED_FILES_LIST})
endfunction()