Skip to content

Commit 70fd73e

Browse files
committed
pre-commit: enable mdformat (markdown)
1 parent 9322601 commit 70fd73e

File tree

22 files changed

+824
-1063
lines changed

22 files changed

+824
-1063
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ repos:
6767
hooks:
6868
- id: gitleaks
6969

70+
- repo: https://github.com/hukkin/mdformat
71+
rev: 1.0.0
72+
hooks:
73+
- id: mdformat
74+
args: [ --number, --wrap=80 ]
75+
additional_dependencies:
76+
- mdformat-gfm
77+
- mdformat-ruff
78+
- mdformat-shfmt
79+
7080
- repo: https://github.com/astral-sh/ruff-pre-commit
7181
rev: v0.15.5
7282
hooks:

CODE_OF_CONDUCT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ that end, we have a few ground rules that we ask people to adhere to:
5353
projects, or publications, say so. Add a comment in the source code at the
5454
point where the idea is used. If adapting code, this requirement is above and
5555
beyond any requirements placed on you by the license of the original code.
56-
Additionally, any code generated by an AI tool (such as a large language model)
57-
must be clearly identified as such in the commit message using
56+
Additionally, any code generated by an AI tool (such as a large language
57+
model) must be clearly identified as such in the commit message using
5858
"Co-authored-by: The name of the tool". We all like recognition for our work.
5959
To that end...
6060

README.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ For more detail about what Halide is, see https://halide-lang.org.
2121

2222
For API documentation see https://halide-lang.org/docs.
2323

24-
For some example code, read through the tutorials online
25-
at https://halide-lang.org/tutorials. The corresponding code is in the
26-
`tutorials/` directory. Larger examples are in the `apps/` directory.
24+
For some example code, read through the tutorials online at
25+
https://halide-lang.org/tutorials. The corresponding code is in the `tutorials/`
26+
directory. Larger examples are in the `apps/` directory.
2727

2828
If you've acquired a full source distribution and want to build Halide, see the
2929
[notes below](#building-halide).
@@ -66,10 +66,8 @@ installed it in. On Windows, you will need to add the virtual environment root
6666
directory to `CMAKE_PREFIX_PATH`. This can be done by running
6767
`set CMAKE_PREFIX_PATH=%VIRTUAL_ENV%` in `cmd`.
6868

69-
Other build systems can find the Halide root path by running `python -c
70-
"import halide; print(halide.install_dir())"`.
71-
72-
[halide-pypi]: https://pypi.halide-lang.org/simple
69+
Other build systems can find the Halide root path by running
70+
`python -c "import halide; print(halide.install_dir())"`.
7371

7472
## Homebrew
7573

@@ -82,8 +80,8 @@ $ brew install halide
8280

8381
## Binary tarballs
8482

85-
The latest version of Halide can always be found on GitHub
86-
at https://github.com/halide/Halide/releases
83+
The latest version of Halide can always be found on GitHub at
84+
https://github.com/halide/Halide/releases
8785

8886
We provide binary releases for many popular platforms and architectures,
8987
including 32/64-bit x86 Windows, 64-bit x86/ARM macOS, and 32/64-bit x86/ARM
@@ -125,7 +123,7 @@ These are the **tested** host toolchain and platform combinations for building
125123
and running the Halide compiler library.
126124

127125
| Compiler | Version | OS | Architectures |
128-
|------------|--------------|------------------------|---------------|
126+
| ---------- | ------------ | ---------------------- | ------------- |
129127
| GCC | 9.5 | Ubuntu Linux 20.04 LTS | x86, x64 |
130128
| GCC | 11.4 | Ubuntu Linux 22.04 LTS | ARM32, ARM64 |
131129
| MSVC | 2022 (19.37) | Windows 11 (22631) | x86, x64 |
@@ -168,17 +166,17 @@ Replace `22` with the desired LLVM major version (`21`, `22`, `23`, or `main`).
168166
Binary wheels are available for Linux (x86-64, x86-32, AArch64, ARMv7), macOS
169167
(x86-64, ARM64), and Windows (x86-64, x86-32).
170168

171-
On macOS, [Homebrew](https://brew.sh) is also a good option: `brew install
172-
llvm`. On Debian flavors of Linux, the
169+
On macOS, [Homebrew](https://brew.sh) is also a good option:
170+
`brew install llvm`. On Debian flavors of Linux, the
173171
[LLVM APT repo](https://apt.llvm.org) works well; use the provided installation
174172
script.
175173

176174
<details>
177175
<summary>Building LLVM from source (advanced)</summary>
178176

179-
> [!WARNING]
180-
> Building LLVM from source requires significant time, disk space, and RAM.
181-
> Prefer the pre-built binaries above unless you need a custom configuration.
177+
> [!WARNING] Building LLVM from source requires significant time, disk space,
178+
> and RAM. Prefer the pre-built binaries above unless you need a custom
179+
> configuration.
182180
183181
First check it out from GitHub:
184182

@@ -235,8 +233,6 @@ recommend enabling the full set to simplify builds during development.
235233
This is discussed in greater detail in [BuildingHalideWithCMake.md]. CMake
236234
version 3.28+ is required to build Halide.
237235

238-
[BuildingHalideWithCMake.md]: doc/BuildingHalideWithCMake.md
239-
240236
### MacOS and Linux
241237

242238
After [acquiring LLVM](#acquiring-llvm), change directory to the Halide
@@ -301,8 +297,8 @@ Halide includes a `vcpkg-configuration.json` that automatically configures
301297
[overlay ports](https://learn.microsoft.com/en-us/vcpkg/concepts/overlay-ports)
302298
and overlay triplets. These overlays redirect LLVM and Python to system
303299
installations, so vcpkg only builds the smaller dependencies (flatbuffers, wabt,
304-
pybind11, etc.). You must have LLVM and Python installed separately
305-
(see [Acquiring LLVM](#acquiring-llvm) above).
300+
pybind11, etc.). You must have LLVM and Python installed separately (see
301+
[Acquiring LLVM](#acquiring-llvm) above).
306302

307303
#### Building Halide
308304

@@ -342,9 +338,8 @@ Subsets of the tests can be selected with `-L` and include `correctness`,
342338
<details>
343339
<summary>Building LLVM from source on Windows (advanced)</summary>
344340

345-
> [!WARNING]
346-
> Building LLVM from source requires significant time, disk space, and RAM.
347-
> Prefer the pre-built `halide-llvm` binaries (see
341+
> [!WARNING] Building LLVM from source requires significant time, disk space,
342+
> and RAM. Prefer the pre-built `halide-llvm` binaries (see
348343
> [Acquiring LLVM](#acquiring-llvm)) unless you need a custom configuration.
349344
350345
First, download LLVM's sources (these instructions use the 21.1.8 release).
@@ -407,10 +402,9 @@ commands that were run, as well as the environment variables they were run with.
407402

408403
## Building Halide with make
409404

410-
> [!WARNING]
411-
> We do not provide support for the Makefile. Feel free to use it, but if
412-
> anything goes wrong, switch to the CMake build. Note also that the Makefile
413-
> cannot build the Python bindings or produce install packages.
405+
> [!WARNING] We do not provide support for the Makefile. Feel free to use it,
406+
> but if anything goes wrong, switch to the CMake build. Note also that the
407+
> Makefile cannot build the Python bindings or produce install packages.
414408
415409
*TL;DR*: Have LLVM 17 (or greater) installed and run `make` in the root
416410
directory of the repository (where this README is).
@@ -463,7 +457,7 @@ output can be parsed programmatically by starting from the code in
463457
We have more documentation in `doc/`, the following links might be helpful:
464458

465459
| Document | Description |
466-
|-----------------------------------------------|---------------------------------------------------------------------------|
460+
| --------------------------------------------- | ------------------------------------------------------------------------- |
467461
| [CMake build](doc/BuildingHalideWithCMake.md) | How to configure and build Halide using CMake. |
468462
| [CMake package](doc/HalideCMakePackage.md) | How to use the Halide CMake package to build your code. |
469463
| [Hexagon](doc/Hexagon.md) | How to use the Hexagon backend. |
@@ -477,7 +471,10 @@ The following links are of greater interest to developers wishing to contribute
477471
code to Halide:
478472

479473
| Document | Description |
480-
|------------------------------------------|---------------------------------------------------------------------------------------------------------------|
474+
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
481475
| [CMake developer](doc/CodeStyleCMake.md) | Guidelines for authoring new CMake code. |
482476
| [FuzzTesting](doc/FuzzTesting.md) | Information about fuzz testing the Halide compiler (rather than pipelines). Intended for internal developers. |
483477
| [Testing](doc/Testing.md) | Information about our test organization and debugging tips. Intended for internal developers. |
478+
479+
[buildinghalidewithcmake.md]: doc/BuildingHalideWithCMake.md
480+
[halide-pypi]: https://pypi.halide-lang.org/simple

apps/HelloAndroid/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ HelloHalide is a simple application which applies a tone curve and sharpening to
22
a video preview from the camera on a phone or tablet.
33

44
This application builds for multiple native ABIs. (At present armeabi,
5-
armeabi-v7a, arm64-v8a, x86_64, and x86 are supported.) Halide code is
6-
generated for each architecture.
5+
armeabi-v7a, arm64-v8a, x86_64, and x86 are supported.) Halide code is generated
6+
for each architecture.
77

88
This build is meant to use Android command line tools. (An IDE is not required.)
99
In order to build, the following will be required:
@@ -48,8 +48,8 @@ application.
4848
Pay attention to the list of platforms supported by your Halide installation.
4949
They are listed in jni/Application.mk APP_ABI variable and in build.gradle archs
5050
map. For example, if your Halide installation was built without arm64-v8a,
51-
remove it from APP_ABI and archs. Both list and map should match, otherwise
52-
you will be getting compilation errors complaining about a missing hello.h file:
51+
remove it from APP_ABI and archs. Both list and map should match, otherwise you
52+
will be getting compilation errors complaining about a missing hello.h file:
5353

5454
```
5555
:compileDebugNdkClassic FAILED

apps/HelloAndroidCamera2/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ E/halide_native( 6146): ANativeWindow buffer locked but its size was 1920 x
2121
1440, expected 1440 x 1080
2222

2323
This application builds for multiple native ABIs. (At present armeabi,
24-
armeabi-v7a, arm64-v8a, x86_64, and x86 are supported.) Halide code is
25-
generated for each architecture.
24+
armeabi-v7a, arm64-v8a, x86_64, and x86 are supported.) Halide code is generated
25+
for each architecture.
2626

2727
This build is meant to use Android command line tools. (An IDE is not required.)
2828
In order to build, the following will be required:
@@ -66,8 +66,8 @@ application.
6666
Pay attention to the list of platforms supported by your Halide installation.
6767
They are listed in jni/Application.mk APP_ABI variable and in build.gradle archs
6868
map. For example, if your Halide installation was built without arm64-v8a,
69-
remove it from APP_ABI and archs. Both list and map should match, otherwise
70-
you will be getting compilation errors complaining about a missing
69+
remove it from APP_ABI and archs. Both list and map should match, otherwise you
70+
will be getting compilation errors complaining about a missing
7171
halide_generated.h file:
7272

7373
```

apps/HelloBaremetal/README.md

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,72 @@
11
# HelloBaremetal
2+
23
## Overview
3-
This is a sample application which demonstrates how to cross-compile the application with Halide generated function for baremetal target system without OS.
4+
5+
This is a sample application which demonstrates how to cross-compile the
6+
application with Halide generated function for baremetal target system without
7+
OS.
48

59
## Setup
6-
There are wide varieties of baremetal system and this application is created just for one of them. More specifically, it is tested with the following conditions.
7-
- Compiled by [Arm GNU Toolchain](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) (version 12.2) AArch32 bare-metal target (`arm-none-eabi`)
8-
- Targeted for Arm 32 bit CPU with NEON (Cortex-A9) on Arm Realview boards on [QEMU Arm System emulator](https://www.qemu.org/docs/master/system/target-arm.html) (version 7.2.50)
9-
- With "semihosting" mode, where some limited I/O communication is available between host and target (e.g. printf() to stdout)
1010

11-
Because we cannot rely on the abstraction of OS, you will probably need to modify some parts if you target for different setup.
11+
There are wide varieties of baremetal system and this application is created
12+
just for one of them. More specifically, it is tested with the following
13+
conditions.
14+
15+
- Compiled by
16+
[Arm GNU Toolchain](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads)
17+
(version 12.2) AArch32 bare-metal target (`arm-none-eabi`)
18+
- Targeted for Arm 32 bit CPU with NEON (Cortex-A9) on Arm Realview boards on
19+
[QEMU Arm System emulator](https://www.qemu.org/docs/master/system/target-arm.html)
20+
(version 7.2.50)
21+
- With "semihosting" mode, where some limited I/O communication is available
22+
between host and target (e.g. printf() to stdout)
23+
24+
Because we cannot rely on the abstraction of OS, you will probably need to
25+
modify some parts if you target for different setup.
1226

1327
## How to build
28+
1429
### Cross compilation
15-
Halide cross-compiling in CMake is tricky and there are a couple of ways to realize it. This application demonstrates 3 different ways with concrete code, located in `CMakeLists.txt` in the following sub directories.
30+
31+
Halide cross-compiling in CMake is tricky and there are a couple of ways to
32+
realize it. This application demonstrates 3 different ways with concrete code,
33+
located in `CMakeLists.txt` in the following sub directories.
34+
1635
1. cmake-twice
17-
1. cmake-super_build
18-
1. cmake-external_project
36+
2. cmake-super_build
37+
3. cmake-external_project
1938

20-
If you want to understand the detail of build steps, please read "Cross compiling" section of [README_cmake](../../README_cmake.md#cross-compiling), and then `build.sh` and `CMakeLists.txt` in each sub directories.
39+
If you want to understand the detail of build steps, please read "Cross
40+
compiling" section of [README_cmake](../../README_cmake.md#cross-compiling), and
41+
then `build.sh` and `CMakeLists.txt` in each sub directories.
2142

2243
### Build procedure
44+
2345
#### Baremetal target
24-
As a prerequisite, toolchain described above needs to be installed in your host machine. The detail of the toolchanin configuration is set in [toolchain.arm-32-sample.cmake](cmake/toolchain.arm-32-sample.cmake), which you might need to modify depending on the target baremetal system.
25-
Then, just run the build script in one of the aforementioned sub directories.
46+
47+
As a prerequisite, toolchain described above needs to be installed in your host
48+
machine. The detail of the toolchanin configuration is set in
49+
[toolchain.arm-32-sample.cmake](cmake/toolchain.arm-32-sample.cmake), which you
50+
might need to modify depending on the target baremetal system. Then, just run
51+
the build script in one of the aforementioned sub directories.
52+
2653
```
2754
cd cmake-<xxx>/
2855
./build.sh
2956
```
3057

3158
#### Host target
32-
This application can be built for host target as well by the simple steps shown below.
59+
60+
This application can be built for host target as well by the simple steps shown
61+
below.
62+
3363
```
3464
cd cmake-<xxx>/
3565
cmake -DCMAKE_PREFIX_PATH=<path/to/halide install> -B build .
3666
cmake --build build/
3767
```
3868

3969
## How to run
40-
`run.sh` in each sub directories is a sample script that shows how to run the executable on QEMU Arm System emulator with semihosting mode.
70+
71+
`run.sh` in each sub directories is a sample script that shows how to run the
72+
executable on QEMU Arm System emulator with semihosting mode.

apps/HelloWasm/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ To try it out,
88

99
- Run a local webserver using, e.g.: python3 -m http.server 8080 &
1010

11-
- Load Google chrome (at least version 84), go to chrome://flags, and turn on all the experimental webassembly stuff (e.g. threads, simd). If you don't do this, only the single-threaded scalar variant will work (at the time of writing).
11+
- Load Google chrome (at least version 84), go to chrome://flags, and turn on
12+
all the experimental webassembly stuff (e.g. threads, simd). If you don't do
13+
this, only the single-threaded scalar variant will work (at the time of
14+
writing).
1215

1316
- Visit http://127.0.0.1:8080/index.html
1417

15-
- Finally, run `make benchmark_native` and compare the performance you get with native code
18+
- Finally, run `make benchmark_native` and compare the performance you get with
19+
native code

0 commit comments

Comments
 (0)