Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UR] Formatting check now only checks generated files #17160

Draft
wants to merge 1 commit into
base: sycl
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions .github/workflows/ur-source-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,8 @@ jobs:
Expand-Archive -Path "$WorkingDir\doxygen.zip"
Add-Content $env:GITHUB_PATH "$WorkingDir\doxygen"

- name: "[Lin] Install hwloc"
working-directory: ${{github.workspace}}/unified-runtime
if: matrix.os == 'ubuntu-22.04'
run: .github/scripts/install_hwloc.sh

- name: "[Win] Install hwloc"
working-directory: ${{github.workspace}}/unified-runtime
if: matrix.os == 'windows-2022'
run: vcpkg install hwloc:x64-windows

- name: Configure Unified Runtime project
working-directory: ${{github.workspace}}/unified-runtime
env:
VCPKG_PATH: "C:/vcpkg/packages/hwloc_x64-windows"
run: >
cmake
-B${{github.workspace}}/build
Expand All @@ -65,6 +53,7 @@ jobs:
-DCMAKE_BUILD_TYPE=Debug
-DUR_BUILD_TESTS=OFF
-DUR_FORMAT_CPP_STYLE=ON
-DUMF_DISABLE_HWLOC=ON

# Verifying license should be enough on a single OS
- name: Verify that each source file contains a license
Expand Down
7 changes: 5 additions & 2 deletions unified-runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,10 @@ if(UR_FORMAT_CPP_STYLE)
--api-json ${API_JSON_FILE}
--clang-format=${CLANG_FORMAT}
$<$<BOOL:${UR_ENABLE_FAST_SPEC_MODE}>:--fast-mode>
COMMAND ${Python3_EXECUTABLE} json2src.py --api-json ${API_JSON_FILE} ${PROJECT_SOURCE_DIR}
COMMAND ${Python3_EXECUTABLE} json2src.py
--api-json ${API_JSON_FILE}
--clang-format=${CLANG_FORMAT}
${PROJECT_SOURCE_DIR}
)

# Generate and format source from the specification
Expand All @@ -397,7 +400,7 @@ if(UR_FORMAT_CPP_STYLE)
add_custom_target(check-generated
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND git diff --exit-code
DEPENDS generate
DEPENDS generate-code
)
else()
message(STATUS " UR_FORMAT_CPP_STYLE not set. Targets: 'generate' and 'check-generated' are not available")
Expand Down
2 changes: 1 addition & 1 deletion unified-runtime/include/ur_api_funcs.def
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

// Auto-generated file, do not edit.
// Auto-generated file, do not edit.

_UR_API(urPlatformGet)
_UR_API(urPlatformGetInfo)
Expand Down
8 changes: 8 additions & 0 deletions unified-runtime/scripts/json2src.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def add_argument(parser, name, help, default=False):
default=sys.stdin,
help="JSON file containing the API specification, by default read from stdin",
)
parser.add_argument(
"--clang-format",
type=str,
default="clang-format",
required=False,
help="path to clang-format executable",
)
parser.add_argument("out_dir", type=str, help="Root of the loader repository.")
args = parser.parse_args()

Expand Down Expand Up @@ -154,6 +161,7 @@ def add_argument(parser, name, help, default=False):
input["meta"],
)

util.formatGeneratedFiles(args.clang_format)
if args.debug:
util.makoFileListWrite("generated.json")

Expand Down
13 changes: 2 additions & 11 deletions unified-runtime/scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,6 @@ def main():
input["meta"],
)

# clang-format ur_api.h
proc = subprocess.run(
[args["clang_format"], "--style=file", "-i", "ur_api.h"],
stderr=subprocess.PIPE,
cwd=incpath,
)
if proc.returncode != 0:
print("-- clang-format failed with non-zero return code. --")
print(proc.stderr.decode())
raise Exception("Failed to format ur_api.h")

if args["rst"]:
generate_docs.generate_rst(
docpath,
Expand Down Expand Up @@ -272,6 +261,8 @@ def main():
print("\nBuild failed, stopping execution!")
return

util.formatGeneratedFiles(args["clang_format"])

# phase 5: prep for publication of html or pdf
if args["html"] or args["pdf"]:
generate_docs.generate_common(
Expand Down
16 changes: 16 additions & 0 deletions unified-runtime/scripts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import glob
import json
import yaml
import subprocess
from mako.template import Template
from mako import exceptions

Expand Down Expand Up @@ -210,6 +211,21 @@ def makoFileListWrite(outpath):
jsonWrite(outpath, makoFileList)


def formatGeneratedFiles(clang_format):
for file in makoFileList:
if re.search(r"(\.h|\.hpp|\.c|\.cpp|\.def)$", file) is None:
continue
print("Formatting {}".format(file))
proc = subprocess.run(
[clang_format, "--style=file", "-i", file],
stderr=subprocess.PIPE,
)
if proc.returncode != 0:
print("-- clang-format failed with non-zero return code. --")
print(proc.stderr.decode())
raise Exception("Failed to format {}".format(file))


def makeErrorCount():
return len(makoErrorList)

Expand Down
156 changes: 105 additions & 51 deletions unified-runtime/source/common/stype_map_helpers.def
Original file line number Diff line number Diff line change
@@ -1,104 +1,158 @@

// This file is autogenerated from the template at templates/stype_map_helpers.hpp.mako
// This file is autogenerated from the template at
// templates/stype_map_helpers.hpp.mako

template <>
struct stype_map<ur_context_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES> {};
struct stype_map<ur_context_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES> {};
template <>
struct stype_map<ur_image_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_IMAGE_DESC> {};
struct stype_map<ur_image_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_IMAGE_DESC> {};
template <>
struct stype_map<ur_buffer_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_BUFFER_PROPERTIES> {};
struct stype_map<ur_buffer_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_BUFFER_PROPERTIES> {};
template <>
struct stype_map<ur_buffer_region_t> : stype_map_impl<UR_STRUCTURE_TYPE_BUFFER_REGION> {};
struct stype_map<ur_buffer_region_t>
: stype_map_impl<UR_STRUCTURE_TYPE_BUFFER_REGION> {};
template <>
struct stype_map<ur_buffer_channel_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES> {};
struct stype_map<ur_buffer_channel_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES> {};
template <>
struct stype_map<ur_buffer_alloc_location_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES> {};
struct stype_map<ur_buffer_alloc_location_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES> {};
template <>
struct stype_map<ur_program_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES> {};
struct stype_map<ur_program_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES> {};
template <>
struct stype_map<ur_usm_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_USM_DESC> {};
template <>
struct stype_map<ur_usm_host_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_USM_HOST_DESC> {};
struct stype_map<ur_usm_host_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_USM_HOST_DESC> {};
template <>
struct stype_map<ur_usm_device_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_USM_DEVICE_DESC> {};
struct stype_map<ur_usm_device_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_USM_DEVICE_DESC> {};
template <>
struct stype_map<ur_usm_pool_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_USM_POOL_DESC> {};
struct stype_map<ur_usm_pool_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_USM_POOL_DESC> {};
template <>
struct stype_map<ur_usm_pool_limits_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC> {};
struct stype_map<ur_usm_pool_limits_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC> {};
template <>
struct stype_map<ur_device_binary_t> : stype_map_impl<UR_STRUCTURE_TYPE_DEVICE_BINARY> {};
struct stype_map<ur_device_binary_t>
: stype_map_impl<UR_STRUCTURE_TYPE_DEVICE_BINARY> {};
template <>
struct stype_map<ur_sampler_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_SAMPLER_DESC> {};
struct stype_map<ur_sampler_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_SAMPLER_DESC> {};
template <>
struct stype_map<ur_queue_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_QUEUE_PROPERTIES> {};
struct stype_map<ur_queue_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_QUEUE_PROPERTIES> {};
template <>
struct stype_map<ur_queue_index_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES> {};
struct stype_map<ur_queue_index_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES> {};
template <>
struct stype_map<ur_context_native_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES> {};
struct stype_map<ur_context_native_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES> {};
template <>
struct stype_map<ur_kernel_native_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES> {};
struct stype_map<ur_kernel_native_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES> {};
template <>
struct stype_map<ur_queue_native_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES> {};
struct stype_map<ur_queue_native_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES> {};
template <>
struct stype_map<ur_mem_native_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES> {};
struct stype_map<ur_mem_native_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES> {};
template <>
struct stype_map<ur_event_native_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES> {};
struct stype_map<ur_event_native_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES> {};
template <>
struct stype_map<ur_platform_native_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES> {};
struct stype_map<ur_platform_native_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_PLATFORM_NATIVE_PROPERTIES> {};
template <>
struct stype_map<ur_device_native_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES> {};
struct stype_map<ur_device_native_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES> {};
template <>
struct stype_map<ur_program_native_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES> {};
struct stype_map<ur_program_native_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES> {};
template <>
struct stype_map<ur_sampler_native_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES> {};
struct stype_map<ur_sampler_native_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_SAMPLER_NATIVE_PROPERTIES> {};
template <>
struct stype_map<ur_queue_native_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC> {};
struct stype_map<ur_queue_native_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC> {};
template <>
struct stype_map<ur_device_partition_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES> {};
struct stype_map<ur_device_partition_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES> {};
template <>
struct stype_map<ur_kernel_arg_mem_obj_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES> {};
struct stype_map<ur_kernel_arg_mem_obj_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES> {};
template <>
struct stype_map<ur_physical_mem_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES> {};
struct stype_map<ur_physical_mem_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES> {};
template <>
struct stype_map<ur_kernel_arg_pointer_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES> {};
struct stype_map<ur_kernel_arg_pointer_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES> {};
template <>
struct stype_map<ur_kernel_arg_sampler_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES> {};
struct stype_map<ur_kernel_arg_sampler_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES> {};
template <>
struct stype_map<ur_kernel_exec_info_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES> {};
struct stype_map<ur_kernel_exec_info_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES> {};
template <>
struct stype_map<ur_kernel_arg_value_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES> {};
struct stype_map<ur_kernel_arg_value_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES> {};
template <>
struct stype_map<ur_kernel_arg_local_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES> {};
struct stype_map<ur_kernel_arg_local_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES> {};
template <>
struct stype_map<ur_usm_alloc_location_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC> {};
struct stype_map<ur_usm_alloc_location_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC> {};
template <>
struct stype_map<ur_exp_command_buffer_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC> {};
struct stype_map<ur_exp_command_buffer_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC> {};
template <>
struct stype_map<ur_exp_command_buffer_update_kernel_launch_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_DESC> {};
struct stype_map<ur_exp_command_buffer_update_kernel_launch_desc_t>
: stype_map_impl<
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_DESC> {};
template <>
struct stype_map<ur_exp_command_buffer_update_memobj_arg_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG_DESC> {};
struct stype_map<ur_exp_command_buffer_update_memobj_arg_desc_t>
: stype_map_impl<
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG_DESC> {};
template <>
struct stype_map<ur_exp_command_buffer_update_pointer_arg_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_POINTER_ARG_DESC> {};
struct stype_map<ur_exp_command_buffer_update_pointer_arg_desc_t>
: stype_map_impl<
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_POINTER_ARG_DESC> {};
template <>
struct stype_map<ur_exp_command_buffer_update_value_arg_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC> {};
struct stype_map<ur_exp_command_buffer_update_value_arg_desc_t>
: stype_map_impl<
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC> {};
template <>
struct stype_map<ur_exp_sampler_mip_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES> {};
struct stype_map<ur_exp_sampler_mip_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES> {};
template <>
struct stype_map<ur_exp_external_mem_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_EXTERNAL_MEM_DESC> {};
struct stype_map<ur_exp_external_mem_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_EXTERNAL_MEM_DESC> {};
template <>
struct stype_map<ur_exp_external_semaphore_desc_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_EXTERNAL_SEMAPHORE_DESC> {};
struct stype_map<ur_exp_external_semaphore_desc_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_EXTERNAL_SEMAPHORE_DESC> {};
template <>
struct stype_map<ur_exp_file_descriptor_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR> {};
struct stype_map<ur_exp_file_descriptor_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR> {};
template <>
struct stype_map<ur_exp_win32_handle_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE> {};
struct stype_map<ur_exp_win32_handle_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE> {};
template <>
struct stype_map<ur_exp_sampler_addr_modes_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_SAMPLER_ADDR_MODES> {};
struct stype_map<ur_exp_sampler_addr_modes_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_SAMPLER_ADDR_MODES> {};
template <>
struct stype_map<ur_exp_sampler_cubemap_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES> {};
struct stype_map<ur_exp_sampler_cubemap_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES> {};
template <>
struct stype_map<ur_exp_image_copy_region_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_IMAGE_COPY_REGION> {};
struct stype_map<ur_exp_image_copy_region_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_IMAGE_COPY_REGION> {};
template <>
struct stype_map<ur_exp_enqueue_native_command_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_ENQUEUE_NATIVE_COMMAND_PROPERTIES> {};
struct stype_map<ur_exp_enqueue_native_command_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_ENQUEUE_NATIVE_COMMAND_PROPERTIES> {
};
template <>
struct stype_map<ur_exp_enqueue_ext_properties_t> : stype_map_impl<UR_STRUCTURE_TYPE_EXP_ENQUEUE_EXT_PROPERTIES> {};

struct stype_map<ur_exp_enqueue_ext_properties_t>
: stype_map_impl<UR_STRUCTURE_TYPE_EXP_ENQUEUE_EXT_PROPERTIES> {};
Loading