Skip to content

Commit 5e4f214

Browse files
author
Petr Vesely
committed
[UR] Format ur_api.h to fix doxygen rendering
1 parent bffad0c commit 5e4f214

File tree

6 files changed

+30
-25
lines changed

6 files changed

+30
-25
lines changed

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ install(
230230

231231
set(API_JSON_FILE ${PROJECT_BINARY_DIR}/unified_runtime.json)
232232

233-
# Generate source from the specification
234-
add_custom_target(generate-code USES_TERMINAL
235-
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/scripts
236-
COMMAND ${Python3_EXECUTABLE} run.py --api-json ${API_JSON_FILE}
237-
COMMAND ${Python3_EXECUTABLE} json2src.py --api-json ${API_JSON_FILE} ${PROJECT_SOURCE_DIR}
238-
)
239-
240233
if(UR_FORMAT_CPP_STYLE)
234+
# Generate source from the specification
235+
add_custom_target(generate-code USES_TERMINAL
236+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/scripts
237+
COMMAND ${Python3_EXECUTABLE} run.py --api-json ${API_JSON_FILE} --clang-format=${CLANG_FORMAT}
238+
COMMAND ${Python3_EXECUTABLE} json2src.py --api-json ${API_JSON_FILE} ${PROJECT_SOURCE_DIR}
239+
)
240+
241241
# Generate and format source from the specification
242242
add_custom_target(generate USES_TERMINAL
243243
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target generate-code

include/ur.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,13 @@ class ur_device_info_v(IntEnum):
561561
## available for this device.
562562
KERNEL_SET_SPECIALIZATION_CONSTANTS = 106 ## [::ur_bool_t] support the ::urKernelSetSpecializationConstants entry
563563
## point
564-
MEMORY_BUS_WIDTH = 107 ## [::ur_bool_t] Return 1 if the device doesn't have a notion of a "queue
565-
## index". Otherwise,
566-
## return the number of queue indices that are available for this device.
564+
MEMORY_BUS_WIDTH = 107 ## [uint32_t] return the width in bits of the memory bus interface of the
565+
## device.
567566
MAX_WORK_GROUPS_3D = 108 ## [size_t[3]] return max 3D work groups
568567
ASYNC_BARRIER = 109 ## [::ur_bool_t] return true if Async Barrier is supported
569568
MEM_CHANNEL_SUPPORT = 110 ## [::ur_bool_t] return true if specifying memory channels is supported
570-
HOST_PIPE_READ_WRITE_SUPPORTED = 111 ## [::ur_bool_t] Return true if the device supports enqueing commands to
571-
## read and write pipes from the host.
569+
HOST_PIPE_READ_WRITE_SUPPORTED = 111 ## [::ur_bool_t] Return true if the device supports enqueueing commands
570+
## to read and write pipes from the host.
572571
MAX_REGISTERS_PER_WORK_GROUP = 112 ## [uint32_t] The maximum number of registers available per block.
573572
IP_VERSION = 113 ## [uint32_t] The device IP version. The meaning of the device IP version
574573
## is implementation-defined, but newer devices should have a higher

include/ur_api.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -921,14 +921,13 @@ typedef enum ur_device_info_t {
921921
///< available for this device.
922922
UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS = 106, ///< [::ur_bool_t] support the ::urKernelSetSpecializationConstants entry
923923
///< point
924-
UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [::ur_bool_t] Return 1 if the device doesn't have a notion of a "queue
925-
///< index". Otherwise,
926-
///< return the number of queue indices that are available for this device.
924+
UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t] return the width in bits of the memory bus interface of the
925+
///< device.
927926
UR_DEVICE_INFO_MAX_WORK_GROUPS_3D = 108, ///< [size_t[3]] return max 3D work groups
928927
UR_DEVICE_INFO_ASYNC_BARRIER = 109, ///< [::ur_bool_t] return true if Async Barrier is supported
929928
UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT = 110, ///< [::ur_bool_t] return true if specifying memory channels is supported
930-
UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 111, ///< [::ur_bool_t] Return true if the device supports enqueing commands to
931-
///< read and write pipes from the host.
929+
UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 111, ///< [::ur_bool_t] Return true if the device supports enqueueing commands
930+
///< to read and write pipes from the host.
932931
UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t] The maximum number of registers available per block.
933932
UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t] The device IP version. The meaning of the device IP version
934933
///< is implementation-defined, but newer devices should have a higher

scripts/core/device.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,17 +370,15 @@ etors:
370370
- name: KERNEL_SET_SPECIALIZATION_CONSTANTS
371371
desc: "[$x_bool_t] support the $xKernelSetSpecializationConstants entry point"
372372
- name: MEMORY_BUS_WIDTH
373-
desc: |
374-
[$x_bool_t] Return 1 if the device doesn't have a notion of a "queue index". Otherwise,
375-
return the number of queue indices that are available for this device.
373+
desc: "[uint32_t] return the width in bits of the memory bus interface of the device."
376374
- name: MAX_WORK_GROUPS_3D
377375
desc: "[size_t[3]] return max 3D work groups"
378376
- name: ASYNC_BARRIER
379377
desc: "[$x_bool_t] return true if Async Barrier is supported"
380378
- name: MEM_CHANNEL_SUPPORT
381379
desc: "[$x_bool_t] return true if specifying memory channels is supported"
382380
- name: HOST_PIPE_READ_WRITE_SUPPORTED
383-
desc: "[$x_bool_t] Return true if the device supports enqueing commands to read and write pipes from the host."
381+
desc: "[$x_bool_t] Return true if the device supports enqueueing commands to read and write pipes from the host."
384382
- name: MAX_REGISTERS_PER_WORK_GROUP
385383
desc: "[uint32_t] The maximum number of registers available per block."
386384
- name: IP_VERSION

scripts/run.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def main():
119119
parser.add_argument("--ver", type=str, default=get_version_from_cmakelists(),
120120
required=False, help="specification version to generate.")
121121
parser.add_argument("--api-json", type=str, default="unified_runtime.json", required=False, help="json output file for the spec")
122+
parser.add_argument("--clang-format", type=str, default="clang-format", required=False, help="path to clang-format executable")
122123
args = vars(parser.parse_args())
123124
args['rev'] = revision()
124125

@@ -166,6 +167,13 @@ def main():
166167

167168
generate_code.generate_api(incpath, srcpath, config['namespace'], config['tags'], args['ver'], args['rev'], specs, input['meta'])
168169

170+
# clang-format ur_api.h
171+
proc = subprocess.run([args['clang_format'], "--style=file", "-i" , "ur_api.h"], stderr=subprocess.PIPE, cwd=incpath)
172+
if proc.returncode != 0:
173+
print("-- clang-format failed with non-zero return code. --")
174+
print(proc.stderr.decode())
175+
raise Exception("Failed to format ur_api.h")
176+
169177
if args['rst']:
170178
generate_docs.generate_rst(docpath, config['name'], config['namespace'], config['tags'], args['ver'], args['rev'], specs, input['meta'])
171179

@@ -198,8 +206,9 @@ def main():
198206

199207
print("\nCompleted in %.1f seconds!"%(time.time() - start))
200208

201-
except:
209+
except BaseException as e:
202210
print("Failed to generate specification.")
211+
print(e)
203212
return sys.exit(1)
204213

205214

source/common/ur_params.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3306,10 +3306,10 @@ inline void serializeTagged(std::ostream &os, const void *ptr,
33063306
} break;
33073307

33083308
case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: {
3309-
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
3310-
if (sizeof(ur_bool_t) > size) {
3309+
const uint32_t *tptr = (const uint32_t *)ptr;
3310+
if (sizeof(uint32_t) > size) {
33113311
os << "invalid size (is: " << size
3312-
<< ", expected: >=" << sizeof(ur_bool_t) << ")";
3312+
<< ", expected: >=" << sizeof(uint32_t) << ")";
33133313
return;
33143314
}
33153315
os << (void *)(tptr) << " (";

0 commit comments

Comments
 (0)