halide 19.0.0__cp311-cp311-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. halide/__init__.py +39 -0
  2. halide/_generator_helpers.py +835 -0
  3. halide/bin/Halide.dll +0 -0
  4. halide/bin/adams2019_retrain_cost_model.exe +0 -0
  5. halide/bin/adams2019_weightsdir_to_weightsfile.exe +0 -0
  6. halide/bin/anderson2021_retrain_cost_model.exe +0 -0
  7. halide/bin/anderson2021_weightsdir_to_weightsfile.exe +0 -0
  8. halide/bin/featurization_to_sample.exe +0 -0
  9. halide/bin/gengen.exe +0 -0
  10. halide/bin/get_host_target.exe +0 -0
  11. halide/halide_.cp311-win_amd64.pyd +0 -0
  12. halide/imageio.py +60 -0
  13. halide/include/Halide.h +35293 -0
  14. halide/include/HalideBuffer.h +2618 -0
  15. halide/include/HalidePyTorchCudaHelpers.h +64 -0
  16. halide/include/HalidePyTorchHelpers.h +120 -0
  17. halide/include/HalideRuntime.h +2221 -0
  18. halide/include/HalideRuntimeCuda.h +89 -0
  19. halide/include/HalideRuntimeD3D12Compute.h +91 -0
  20. halide/include/HalideRuntimeHexagonDma.h +104 -0
  21. halide/include/HalideRuntimeHexagonHost.h +157 -0
  22. halide/include/HalideRuntimeMetal.h +112 -0
  23. halide/include/HalideRuntimeOpenCL.h +119 -0
  24. halide/include/HalideRuntimeQurt.h +32 -0
  25. halide/include/HalideRuntimeVulkan.h +137 -0
  26. halide/include/HalideRuntimeWebGPU.h +44 -0
  27. halide/lib/Halide.lib +0 -0
  28. halide/lib/HalidePyStubs.lib +0 -0
  29. halide/lib/Halide_GenGen.lib +0 -0
  30. halide/lib/autoschedule_adams2019.dll +0 -0
  31. halide/lib/autoschedule_anderson2021.dll +0 -0
  32. halide/lib/autoschedule_li2018.dll +0 -0
  33. halide/lib/autoschedule_mullapudi2016.dll +0 -0
  34. halide/lib/cmake/Halide/FindHalide_LLVM.cmake +152 -0
  35. halide/lib/cmake/Halide/FindV8.cmake +33 -0
  36. halide/lib/cmake/Halide/Halide-shared-deps.cmake +0 -0
  37. halide/lib/cmake/Halide/Halide-shared-targets-release.cmake +29 -0
  38. halide/lib/cmake/Halide/Halide-shared-targets.cmake +154 -0
  39. halide/lib/cmake/Halide/HalideConfig.cmake +162 -0
  40. halide/lib/cmake/Halide/HalideConfigVersion.cmake +65 -0
  41. halide/lib/cmake/HalideHelpers/FindHalide_WebGPU.cmake +27 -0
  42. halide/lib/cmake/HalideHelpers/Halide-Interfaces-release.cmake +112 -0
  43. halide/lib/cmake/HalideHelpers/Halide-Interfaces.cmake +236 -0
  44. halide/lib/cmake/HalideHelpers/HalideGeneratorHelpers.cmake +1056 -0
  45. halide/lib/cmake/HalideHelpers/HalideHelpersConfig.cmake +28 -0
  46. halide/lib/cmake/HalideHelpers/HalideHelpersConfigVersion.cmake +54 -0
  47. halide/lib/cmake/HalideHelpers/HalideTargetHelpers.cmake +99 -0
  48. halide/lib/cmake/HalideHelpers/MutexCopy.ps1 +31 -0
  49. halide/lib/cmake/HalideHelpers/TargetExportScript.cmake +55 -0
  50. halide/lib/cmake/Halide_Python/Halide_Python-targets-release.cmake +29 -0
  51. halide/lib/cmake/Halide_Python/Halide_Python-targets.cmake +125 -0
  52. halide/lib/cmake/Halide_Python/Halide_PythonConfig.cmake +26 -0
  53. halide/lib/cmake/Halide_Python/Halide_PythonConfigVersion.cmake +65 -0
  54. halide/share/doc/Halide/LICENSE.txt +233 -0
  55. halide/share/doc/Halide/README.md +439 -0
  56. halide/share/doc/Halide/doc/BuildingHalideWithCMake.md +626 -0
  57. halide/share/doc/Halide/doc/CodeStyleCMake.md +393 -0
  58. halide/share/doc/Halide/doc/FuzzTesting.md +104 -0
  59. halide/share/doc/Halide/doc/HalideCMakePackage.md +812 -0
  60. halide/share/doc/Halide/doc/Hexagon.md +73 -0
  61. halide/share/doc/Halide/doc/Python.md +844 -0
  62. halide/share/doc/Halide/doc/RunGen.md +283 -0
  63. halide/share/doc/Halide/doc/Testing.md +125 -0
  64. halide/share/doc/Halide/doc/Vulkan.md +287 -0
  65. halide/share/doc/Halide/doc/WebAssembly.md +228 -0
  66. halide/share/doc/Halide/doc/WebGPU.md +128 -0
  67. halide/share/tools/RunGen.h +1470 -0
  68. halide/share/tools/RunGenMain.cpp +642 -0
  69. halide/share/tools/adams2019_autotune_loop.sh +227 -0
  70. halide/share/tools/anderson2021_autotune_loop.sh +591 -0
  71. halide/share/tools/halide_benchmark.h +240 -0
  72. halide/share/tools/halide_image.h +31 -0
  73. halide/share/tools/halide_image_info.h +318 -0
  74. halide/share/tools/halide_image_io.h +2794 -0
  75. halide/share/tools/halide_malloc_trace.h +102 -0
  76. halide/share/tools/halide_thread_pool.h +161 -0
  77. halide/share/tools/halide_trace_config.h +559 -0
  78. halide-19.0.0.data/data/share/cmake/Halide/HalideConfig.cmake +6 -0
  79. halide-19.0.0.data/data/share/cmake/Halide/HalideConfigVersion.cmake +65 -0
  80. halide-19.0.0.data/data/share/cmake/HalideHelpers/HalideHelpersConfig.cmake +6 -0
  81. halide-19.0.0.data/data/share/cmake/HalideHelpers/HalideHelpersConfigVersion.cmake +54 -0
  82. halide-19.0.0.dist-info/METADATA +301 -0
  83. halide-19.0.0.dist-info/RECORD +85 -0
  84. halide-19.0.0.dist-info/WHEEL +5 -0
  85. halide-19.0.0.dist-info/licenses/LICENSE.txt +233 -0
@@ -0,0 +1,626 @@
1
+ # Building Halide with CMake
2
+
3
+ This is a detailed guide to building Halide with CMake. If you want to learn how
4
+ to use Halide in your own CMake projects, see [HalideCMakePackage.md]. If you
5
+ are looking for Halide's CMake coding guidelines, see [CodeStyleCMake.md].
6
+
7
+ <!-- TOC -->
8
+ * [Building Halide with CMake](#building-halide-with-cmake)
9
+ * [Installing CMake](#installing-cmake)
10
+ * [Cross-platform](#cross-platform)
11
+ * [Windows](#windows)
12
+ * [macOS](#macos)
13
+ * [Ubuntu Linux](#ubuntu-linux)
14
+ * [Optional: Install Ninja](#optional-install-ninja)
15
+ * [Dependencies](#dependencies)
16
+ * [Summary](#summary)
17
+ * [Installing dependencies](#installing-dependencies)
18
+ * [vcpkg](#vcpkg)
19
+ * [Windows](#windows-1)
20
+ * [Homebrew](#homebrew)
21
+ * [Ubuntu / Debian](#ubuntu--debian)
22
+ * [Python](#python)
23
+ * [Building Halide](#building-halide)
24
+ * [Basic build](#basic-build)
25
+ * [Windows](#windows-2)
26
+ * [macOS and Linux](#macos-and-linux)
27
+ * [CMake Presets](#cmake-presets)
28
+ * [Common presets](#common-presets)
29
+ * [Vcpkg presets](#vcpkg-presets)
30
+ * [Sanitizer presets](#sanitizer-presets)
31
+ * [Build options](#build-options)
32
+ * [Installing](#installing)
33
+ * [Building Halide with pip](#building-halide-with-pip)
34
+ <!-- TOC -->
35
+
36
+ # Installing CMake
37
+
38
+ This section covers installing a recent version of CMake and the correct
39
+ dependencies for building and using Halide. If you have not used CMake before,
40
+ we strongly suggest reading through the [CMake documentation][cmake-docs] first.
41
+
42
+ Halide requires at least version 3.28. Fortunately, getting a recent version of
43
+ CMake couldn't be easier, and there are multiple good options on any system to
44
+ do so. Generally, one should always have the most recent version of CMake
45
+ installed system-wide. CMake is committed to backwards compatibility and even
46
+ the most recent release can build projects over a decade old.
47
+
48
+ ## Cross-platform
49
+
50
+ Kitware provides packages for CMake on [PyPI][pypi-cmake] which can be installed
51
+ via `pip` into a [virtual environment][venv]. There are binary wheels available
52
+ for nearly all relevant platforms, including:
53
+
54
+ | OS | x86-32 | x86-64 | ARM64 |
55
+ |-------------------|--------------------|--------------------|----------------------------|
56
+ | Windows | :white_check_mark: | :white_check_mark: | :white_check_mark: |
57
+ | macOS | :x: | 10.10+ | 11.0+ (incl. `universal2`) |
58
+ | Linux (musl 1.1+) | :white_check_mark: | :white_check_mark: | :white_check_mark: |
59
+ | Linux (glibc) | glibc 2.12+ | glibc 2.12+ | glibc 2.17+ |
60
+
61
+ We recommend installing CMake using [pipx] to avoid package conflicts and
62
+ redundant installations. After installing pipx, run:
63
+
64
+ ```shell
65
+ $ pipx install cmake
66
+ ```
67
+
68
+ Alternatively, you can use a normal virtual environment:
69
+
70
+ ```shell
71
+ $ python -m pip install cmake
72
+ ```
73
+
74
+ If you don't want Python to manage your CMake installation, you can either
75
+ follow the platform-specific instructions below or install CMake
76
+ from [Kitware's binary releases][cmake-download]. If all else fails, you might
77
+ need to build CMake from source (e.g. on 32-bit ARM). In that case, follow the
78
+ directions posted on [Kitware's website][cmake-from-source].
79
+
80
+ ## Windows
81
+
82
+ On Windows, there are two primary methods for installing an up-to-date CMake:
83
+
84
+ 1. You can get CMake through the Visual Studio 2022 installer.
85
+ 2. You can use Windows's built-in package manager, [winget][winget]:
86
+ ```shell
87
+ winget install Kitware.CMake
88
+ ```
89
+
90
+ We prefer the first option for its simplicity. See
91
+ Microsoft's [documentation][vs-cmake-docs] for more details.
92
+
93
+ ## macOS
94
+
95
+ [Homebrew] keeps its [CMake package][brew-cmake] up to date. Simply run:
96
+
97
+ ```shell
98
+ $ brew install cmake
99
+ ```
100
+
101
+ ## Ubuntu Linux
102
+
103
+ There are a few good ways to install CMake on Ubuntu:
104
+
105
+ 1. If you're running 24.04 LTS, then simply running
106
+ `sudo apt install cmake` will install CMake 3.28.
107
+ 2. If you're running an older LTS or would like to use the newest CMake, try
108
+ installing via the [snap store][snap store]: `snap install cmake`. Note this
109
+ will conflict with an APT-provided CMake.
110
+ 3. Kitware also provides an [APT repository][cmake-apt] with up-to-date
111
+ releases. Compatible with 20.04 LTS+ and is the best option for 32-bit ARM.
112
+
113
+ For other Linux distributions, check with your distribution's package manager.
114
+
115
+ **Note:** On WSL 1, snap is not available; in this case, prefer to use APT. On
116
+ WSL 2, all methods are available.
117
+
118
+ ## Optional: Install Ninja
119
+
120
+ We strongly recommend using [Ninja] as your go-to CMake generator for working
121
+ with Halide. It has a much richer dependency structure than the alternatives,
122
+ and it is the only generator capable of producing accurate incremental builds.
123
+
124
+ It is available in most package repositories:
125
+
126
+ * Python: `pipx install ninja`
127
+ * Visual Studio Installer: alongside CMake
128
+ * winget: `winget install Ninja-build.Ninja`
129
+ * Homebrew: `brew install ninja`
130
+ * APT: `apt install ninja-build`
131
+
132
+ You can also place a [pre-built binary][ninja-download] from their website in
133
+ the PATH.
134
+
135
+ # Dependencies
136
+
137
+ ## Summary
138
+
139
+ The following is a complete list of required and optional dependencies for
140
+ building the core pieces of Halide.
141
+
142
+ | Dependency | Version | Required when... | Notes |
143
+ |---------------|--------------------|----------------------------|-----------------------------------------------------|
144
+ | [LLVM] | _see policy below_ | _always_ | WebAssembly and X86 targets are required. |
145
+ | [Clang] | `==LLVM` | _always_ | |
146
+ | [LLD] | `==LLVM` | _always_ | |
147
+ | [flatbuffers] | `~=23.5.26` | `WITH_SERIALIZATION=ON` | |
148
+ | [wabt] | `==1.0.36` | `Halide_WASM_BACKEND=wabt` | Does not have a stable API; exact version required. |
149
+ | [V8] | trunk | `Halide_WASM_BACKEND=V8` | Difficult to build. See [WebAssembly.md] |
150
+ | [Python] | `>=3.8` | `WITH_PYTHON_BINDINGS=ON` | |
151
+ | [pybind11] | `~=2.10.4` | `WITH_PYTHON_BINDINGS=ON` | |
152
+
153
+ Halide maintains the following compatibility policy with LLVM: Halide version
154
+ `N` supports LLVM versions `N`, `N-1`, and `N-2`. Our binary distributions
155
+ always include the latest `N` patch at time of release. For most users, we
156
+ recommend using a pre-packaged binary release of LLVM rather than trying to
157
+ build it yourself.
158
+
159
+ To build the apps, documentation, and tests, an extended set is needed.
160
+
161
+ | Dependency | Required when... | Notes |
162
+ |---------------------------------|-----------------------------------|-----------------------------------------------------------------------------|
163
+ | [CUDA Toolkit][FindCUDAToolkit] | building `apps/cuda_mat_mul` | When compiling Halide pipelines that use CUDA, only the drivers are needed. |
164
+ | [Doxygen][FindDoxygen] | `WITH_DOCS=ON` | |
165
+ | [Eigen3][Eigen3CMake] | building `apps/linear_algebra` | |
166
+ | [libjpeg][FindJPEG] | `WITH_TESTS=ON` | Optionally used by `halide_image_io.h` and `Halide::ImageIO` in CMake. |
167
+ | [libpng][FindPNG] | `WITH_TESTS=ON` | (same as libjpeg) |
168
+ | [BLAS][FindBLAS] | building `apps/linear_algebra` | [ATLAS] and [OpenBLAS] are supported implementations |
169
+ | [OpenCL][FindOpenCL] | compiling pipelines with `opencl` | |
170
+
171
+ It is best practice to configure your environment so that CMake can find
172
+ dependencies without package-specific hints. For instance, if you want CMake to
173
+ use a particular version of Python, create a virtual environment and activate it
174
+ _before_ configuring Halide. Similarly, the `CMAKE_PREFIX_PATH` variable can be
175
+ set to a local directory where from-source dependencies have been installed.
176
+ Carefully consult the [find_package] documentation to learn how the search
177
+ procedure works.
178
+
179
+ If the build still fails to find a dependency, each package provides a bespoke
180
+ interface for providing hints and overriding incorrect results. Documentation
181
+ for these packages is linked in the table above.
182
+
183
+ ## Installing dependencies
184
+
185
+ ### vcpkg
186
+
187
+ Halide has first-class support for using [vcpkg] to manage dependencies. The
188
+ list of dependencies and features is contained inside `vcpkg.json` at the root
189
+ of the repository.
190
+
191
+ By default, a minimum set of LLVM backends will be enabled to compile JIT code
192
+ for the host and the serialization feature will be enabled. When using the vcpkg
193
+ toolchain file, you can set `-DVCPKG_MANIFEST_FEATURES=developer`
194
+ to enable building all dependencies (except Doxygen, which is not available on
195
+ vcpkg).
196
+
197
+ By default, running `vcpkg install` will try to build all of LLVM. This is often
198
+ undesirable as it takes very long to do and consumes a lot of disk space,
199
+ especially as `vcpkg` requires special configuration to disable the debug build.
200
+ It will _also_ attempt to build Python 3 as a dependency of pybind11.
201
+
202
+ To mitigate this issue, we provide a [vcpkg-overlay] that disables building LLVM
203
+ and Python. When using the vcpkg toolchain, you can enable it by setting
204
+ `-DVCPKG_OVERLAY_PORTS=cmake/vcpkg`.
205
+
206
+ If you do choose to use vcpkg to build LLVM (the easiest way on Windows), note
207
+ that it is safe to delete the intermediate build files and caches in
208
+ `D:\vcpkg\buildtrees` and `%APPDATA%\local\vcpkg`.
209
+
210
+ For convenience, we provide [CMake presets](#cmake-presets) that set these flags
211
+ appropriately per-platform. They are documented further below.
212
+
213
+ ### Windows
214
+
215
+ On Windows, we recommend using `vcpkg` to install library dependencies.
216
+
217
+ To build the documentation, you will need to install [Doxygen]. This can be done
218
+ either from the [Doxygen website][doxygen-download] or through [winget][winget]:
219
+
220
+ ```shell
221
+ $ winget install DimitriVanHeesch.Doxygen
222
+ ```
223
+
224
+ To build the Python bindings, you will need to install Python 3. This should be
225
+ done by running the official installer from the [Python website][python]. Be
226
+ sure to download the debugging symbols through the installer. This will require
227
+ using the "Advanced Installation" workflow. Although it is not strictly
228
+ necessary, it is convenient to install Python system-wide on Windows (i.e.
229
+ `C:\Program Files`) because CMake looks at standard paths and registry keys.
230
+ This removes the need to manually set the `PATH`.
231
+
232
+ Once Python is installed, you can install the Python module dependencies either
233
+ globally or in a [virtual environment][venv] by running
234
+
235
+ ```shell
236
+ $ python -m pip install -r requirements.txt
237
+ ```
238
+
239
+ from the root of the repository.
240
+
241
+ ### Homebrew
242
+
243
+ On macOS, it is possible to install all dependencies via [Homebrew][homebrew]:
244
+
245
+ ```shell
246
+ $ brew install llvm flatbuffers wabt python pybind11 doxygen eigen libpng libjpeg openblas
247
+ ```
248
+
249
+ The `llvm` package includes `clang`, `clang-format`, and `lld`, too. To ensure
250
+ CMake can find the keg-only dependencies, set the following:
251
+
252
+ ```shell
253
+ $ export CMAKE_PREFIX_PATH="/opt/homebrew:/opt/homebrew/opt/llvm:/opt/homebrew/opt/jpeg"
254
+ ```
255
+
256
+ ### Ubuntu / Debian
257
+
258
+ On Ubuntu you should install the following packages (this includes the Python
259
+ module dependencies):
260
+
261
+ ```
262
+ $ sudo apt install clang-tools lld llvm-dev libclang-dev liblld-dev \
263
+ libpng-dev libjpeg-dev libgl-dev python3-dev python3-numpy python3-scipy \
264
+ python3-imageio python3-pybind11 libopenblas-dev libeigen3-dev \
265
+ libatlas-base-dev doxygen
266
+ ```
267
+
268
+ ### Python
269
+
270
+ When running the Python package, you will need to install additional
271
+ dependencies. These are tabulated in `requirements.txt` and may be installed
272
+ with:
273
+
274
+ ```shell
275
+ $ python -m pip install -U pip "setuptools[core]" wheel
276
+ $ python -m pip install -r requirements.txt
277
+ ```
278
+
279
+ # Building Halide
280
+
281
+ ## Basic build
282
+
283
+ These instructions assume that your working directory is the Halide repository
284
+ root.
285
+
286
+ ### Windows
287
+
288
+ If you plan to use the Ninja generator, be sure to launch the developer command
289
+ prompt corresponding to your intended environment. Note that whatever your
290
+ intended target system (x86, x64, or ARM), you must use the 64-bit _host tools_
291
+ because the 32-bit tools run out of memory during the linking step with LLVM.
292
+ More information is available from [Microsoft's documentation][msvc-cmd].
293
+
294
+ You should either open the correct Developer Command Prompt directly or run the
295
+ [`vcvarsall.bat`][vcvarsall] script with the correct argument, i.e. one of the
296
+ following:
297
+
298
+ ```shell
299
+ $ "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
300
+ $ "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64_x86
301
+ $ "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64_arm
302
+ ```
303
+
304
+ Then, assuming that vcpkg is installed to `D:\vcpkg`, simply run:
305
+
306
+ ```shell
307
+ $ cmake -G Ninja -S . -B build --toolchain D:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
308
+ $ cmake --build .\build
309
+ ```
310
+
311
+ Valid values of [`CMAKE_BUILD_TYPE`][cmake_build_type] are `Debug`,
312
+ `RelWithDebInfo`, `MinSizeRel`, and `Release`. When using a single-configuration
313
+ generator (like Ninja) you must specify a build type in the configuration step.
314
+
315
+ Otherwise, if you wish to create a Visual Studio based build system, you can
316
+ configure with:
317
+
318
+ ```shell
319
+ $ cmake -G "Visual Studio 17 2022" -Thost=x64 -A x64 -S . -B build ^
320
+ --toolchain D:\vcpkg\scripts\buildsystems\vcpkg.cmake
321
+ $ cmake --build .\build --config Release -j %NUMBER_OF_PROCESSORS%
322
+ ```
323
+
324
+ Because the Visual Studio generator is a _multi-config generator_, you don't set
325
+ `CMAKE_BUILD_TYPE` at configure-time, but instead pass the configuration to the
326
+ build (and test/install) commands with the `--config` flag. More documentation
327
+ is available in the [CMake User Interaction Guide][cmake-user-interaction].
328
+
329
+ The process is similar for 32-bit:
330
+
331
+ ```
332
+ > cmake -G "Visual Studio 17 2022" -Thost=x64 -A Win32 -S . -B build ^
333
+ --toolchain D:\vcpkg\scripts\buildsystems\vcpkg.cmake
334
+ > cmake --build .\build --config Release -j %NUMBER_OF_PROCESSORS%
335
+ ```
336
+
337
+ In both cases, the `-Thost=x64` flag ensures that the correct host tools are
338
+ used.
339
+
340
+ **Note:** due to limitations in MSBuild, incremental builds using the VS
341
+ generators will miss dependencies (including changes to headers in the
342
+ `src/runtime` folder). We recommend using Ninja for day-to-day development and
343
+ use Visual Studio only if you need it for packaging.
344
+
345
+ ### macOS and Linux
346
+
347
+ The instructions here are straightforward. Assuming your environment is set up
348
+ correctly, just run:
349
+
350
+ ```shell
351
+ $ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release
352
+ $ cmake --build build
353
+ ```
354
+
355
+ If you omit `-G Ninja`, a Makefile-based generator will likely be used instead.
356
+ In either case, [`CMAKE_BUILD_TYPE`][cmake_build_type] must be set to one of the
357
+ standard types: `Debug`, `RelWithDebInfo`, `MinSizeRel`, or `Release`.
358
+
359
+ ## CMake Presets
360
+
361
+ ### Common presets
362
+
363
+ Halide provides several [presets][cmake_presets] to make the above commands more
364
+ convenient. The following CMake preset commands correspond to the longer ones
365
+ above.
366
+
367
+ ```shell
368
+ $ cmake --preset=win64 # VS 2022 generator, 64-bit build, vcpkg deps
369
+ $ cmake --preset=win32 # VS 2022 generator, 32-bit build, vcpkg deps
370
+ $ cmake --preset=macOS # Ninja generator, macOS host build, Homebrew deps
371
+ $ cmake --preset=debug # Debug mode, any single-config generator / compiler
372
+ $ cmake --preset=release # Release mode, any single-config generator / compiler
373
+ ```
374
+
375
+ ### Vcpkg presets
376
+
377
+ Halide provides two sets of corresponding vcpkg-enabled presets: _base_ and
378
+ _full_.
379
+
380
+ | Base preset | Full preset |
381
+ |-----------------|----------------------|
382
+ | `win32` | `win32-vcpkg-full` |
383
+ | `win64` | `win64-vcpkg-full` |
384
+ | `macOS-vcpkg` | `macOS-vcpkg-full` |
385
+ | `debug-vcpkg` | `debug-vcpkg-full` |
386
+ | `release-vcpkg` | `release-vcpkg-full` |
387
+
388
+ In simple terms, the base presets rely on the system to provide LLVM and Python,
389
+ while the full presets delegate this to vcpkg (which consumes a large amount of
390
+ hard disk space and time).
391
+
392
+ The `macOS-vcpkg` preset adds `/opt/homebrew/opt/llvm` to
393
+ `CMAKE_PREFIX_PATH`.
394
+
395
+ ### Sanitizer presets
396
+
397
+ There are also presets to use some Clang sanitizers with the CMake build; at
398
+ present, only Fuzzer and ASAN (Address Sanitizer) are supported, and only on
399
+ linux-x86-64.
400
+
401
+ * `linux-x64-asan`: Use the Address Sanitizer
402
+ * `linux-x64-fuzzer`: Use the Clang fuzzer plugin
403
+
404
+ To use these, you must build LLVM with additional options:
405
+
406
+ ```
407
+ -DLLVM_ENABLE_PROJECTS="clang;lld;clang-tools-extra"
408
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind"
409
+ ```
410
+
411
+ ## Build options
412
+
413
+ Halide reads and understands several options that can configure the build. The
414
+ following are the most consequential and control how Halide is actually
415
+ compiled.
416
+
417
+ | Option | Default | Description |
418
+ |------------------------------------------|-----------------------|---------------------------------------------------------------------------------------------------|
419
+ | [`BUILD_SHARED_LIBS`][build_shared_libs] | `ON` | Standard CMake variable that chooses whether to build as a static or shared library. |
420
+ | `Halide_BUNDLE_STATIC` | `OFF` | When building Halide as a static library, merge static library dependencies into libHalide.a. |
421
+ | `Halide_LLVM_SHARED_LIBS` | `OFF` | Link to the shared version of LLVM. Not available on Windows. |
422
+ | `Halide_ENABLE_RTTI` | _inherited from LLVM_ | Enable RTTI when building Halide. Recommended to be set to `ON` |
423
+ | `Halide_ENABLE_EXCEPTIONS` | `ON` | Enable exceptions when building Halide |
424
+ | `Halide_TARGET` | _empty_ | The default target triple to use for `add_halide_library` (and the generator tests, by extension) |
425
+ | `WITH_AUTOSCHEDULERS` | `ON` | Enable building the autoschedulers. Requires `BUILD_SHARED_LIBS`. |
426
+ | `WITH_SERIALIZATION` | `ON` | Include experimental Serialization/Deserialization features |
427
+
428
+ The following options are disabled by default when building Halide through the [
429
+ `add_subdirectory`][add_subdirectory]
430
+ or [`FetchContent`][fetchcontent] mechanisms. They control whether non-essential
431
+ targets (like tests and documentation) are built.
432
+
433
+ | Option | Default | Description |
434
+ |------------------------|---------|------------------------------------------------------------------|
435
+ | `WITH_DOCS` | `OFF` | Enable building the documentation via Doxygen |
436
+ | `WITH_PACKAGING` | `ON` | Include the `install()` rules for Halide. |
437
+ | `WITH_PYTHON_BINDINGS` | `ON` | Enable building Python 3 bindings |
438
+ | `WITH_TESTS` | `ON` | Enable building unit and integration tests |
439
+ | `WITH_TUTORIALS` | `ON` | Enable building the tutorials |
440
+ | `WITH_UTILS` | `ON` | Enable building various utilities including the trace visualizer |
441
+
442
+ The following options are _advanced_ and should not be required in typical
443
+ workflows. Generally, these are used by Halide's own CI infrastructure, or as
444
+ escape hatches for third-party packagers.
445
+
446
+ | Option | Default | Description |
447
+ |-----------------------------|--------------------------------------------------------------------|------------------------------------------------------------------------------------------|
448
+ | `Halide_CLANG_TIDY_BUILD` | `OFF` | Used internally to generate fake compile jobs for runtime files when running clang-tidy. |
449
+ | `Halide_CCACHE_BUILD` | `OFF` | Use ccache with Halide-recommended settings to accelerate rebuilds. |
450
+ | `Halide_CCACHE_PARAMS` | `CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines` | Options to pass to `ccache` when using `Halide_CCACHE_BUILD`. |
451
+ | `Halide_VERSION_OVERRIDE` | `${Halide_VERSION}` | Override the VERSION for libHalide. |
452
+ | `Halide_SOVERSION_OVERRIDE` | `${Halide_VERSION_MAJOR}` | Override the SOVERSION for libHalide. Expects a positive integer (i.e. not a version). |
453
+
454
+ The following options control whether to build certain test subsets. They only
455
+ apply when `WITH_TESTS=ON`:
456
+
457
+ | Option | Default | Description |
458
+ |---------------------------|------------|---------------------------------------|
459
+ | `WITH_TEST_AUTO_SCHEDULE` | `ON` | enable the auto-scheduling tests |
460
+ | `WITH_TEST_CORRECTNESS` | `ON` | enable the correctness tests |
461
+ | `WITH_TEST_ERROR` | `ON` | enable the expected-error tests |
462
+ | `WITH_TEST_FUZZ` | _detected_ | enable the libfuzzer-based fuzz tests |
463
+ | `WITH_TEST_GENERATOR` | `ON` | enable the AOT generator tests |
464
+ | `WITH_TEST_PERFORMANCE` | `ON` | enable performance testing |
465
+ | `WITH_TEST_RUNTIME` | `ON` | enable testing the runtime modules |
466
+ | `WITH_TEST_WARNING` | `ON` | enable the expected-warning tests |
467
+
468
+ The following option selects the execution engine for in-process WASM testing:
469
+
470
+ | Option | Default | Description |
471
+ |-----------------------|---------|------------------------------------------------------------------------------------------|
472
+ | `Halide_WASM_BACKEND` | `wabt` | Select the backend for WASM testing. Can be `wabt`, `V8` or a false value such as `OFF`. |
473
+
474
+ ## Installing
475
+
476
+ Once built, Halide will need to be installed somewhere before using it in a
477
+ separate project. On any platform, this means running the
478
+ [`cmake --install`][cmake-install] command in one of two ways. For a
479
+ single-configuration generator (like Ninja), run either:
480
+
481
+ ```shell
482
+ $ cmake --install ./build --prefix /path/to/Halide-install
483
+ $ cmake --install .\build --prefix X:\path\to\Halide-install
484
+ ```
485
+
486
+ For a multi-configuration generator (like Visual Studio) run:
487
+
488
+ ```shell
489
+ $ cmake --install ./build --prefix /path/to/Halide-install --config Release
490
+ $ cmake --install .\build --prefix X:\path\to\Halide-install --config Release
491
+ ```
492
+
493
+ Of course, make sure that you build the corresponding config before attempting
494
+ to install it.
495
+
496
+ # Building Halide with pip
497
+
498
+ Halide also supports installation via the standard Python packaging workflow.
499
+ Running `pip install .` at the root of the repository will build a wheel and
500
+ install it into the currently active Python environment.
501
+
502
+ However, this comes with a few caveats:
503
+
504
+ 1. `Halide_USE_FETCHCONTENT` is disabled, so the environment must be prepared
505
+ for CMake to find its dependencies. This is easiest to do by setting either
506
+ `CMAKE_PREFIX_PATH` to pre-built dependencies or by setting
507
+ `CMAKE_TOOLCHAIN_FILE` to vcpkg.
508
+ 2. The build settings are fixed, meaning that `wabt` is required on non-Windows
509
+ systems, `flatbuffers` is always required, and the Python bindings must be
510
+ built.
511
+ 3. The generated wheel will likely only work on your system. In particular, it
512
+ will not be repaired with `auditwheel` or `delocate`.
513
+
514
+ Even so, this is a very good method of installing Halide. It supports both
515
+ Python and C++ `find_package` workflows.
516
+
517
+
518
+ [ATLAS]: http://math-atlas.sourceforge.net/
519
+
520
+ [BuildingHalideWithCMake.md]: ./BuildingHalideWithCMake.md
521
+
522
+ [Clang]: https://clang.llvm.org
523
+
524
+ [CodeStyleCMake.md]: ./CodeStyleCMake.md
525
+
526
+ [Eigen3CMake]: https://eigen.tuxfamily.org/dox/TopicCMakeGuide.html
527
+
528
+ [Eigen3]: http://eigen.tuxfamily.org/index.php?title=Main_Page
529
+
530
+ [FindBLAS]: https://cmake.org/cmake/help/latest/module/FindBLAS.html
531
+
532
+ [FindCUDAToolkit]: https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html
533
+
534
+ [FindCUDA]: https://cmake.org/cmake/help/latest/module/FindCUDA.html
535
+
536
+ [FindDoxygen]: https://cmake.org/cmake/help/latest/module/FindDoxygen.html
537
+
538
+ [FindJPEG]: https://cmake.org/cmake/help/latest/module/FindJPEG.html
539
+
540
+ [FindOpenCL]: https://cmake.org/cmake/help/latest/module/FindOpenCL.html
541
+
542
+ [FindPNG]: https://cmake.org/cmake/help/latest/module/FindPNG.html
543
+
544
+ [FindPython]: https://cmake.org/cmake/help/latest/module/FindPython.html
545
+
546
+ [HalideCMakePackage.md]: ./HalideCMakePackage.md
547
+
548
+ [LLVM]: https://github.com/llvm/llvm-project
549
+
550
+ [Ninja]: https://ninja-build.org/
551
+
552
+ [OpenBLAS]: https://www.openblas.net/
553
+
554
+ [V8]: https://v8.dev
555
+
556
+ [WebAssembly.md]: ./WebAssembly.md
557
+
558
+ [add_subdirectory]: https://cmake.org/cmake/help/latest/command/add_subdirectory.html
559
+
560
+ [brew-cmake]: https://formulae.brew.sh/cask/cmake#default
561
+
562
+ [build_shared_libs]: https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html
563
+
564
+ [cmake-apt]: https://apt.kitware.com/
565
+
566
+ [cmake-docs]: https://cmake.org/cmake/help/latest/
567
+
568
+ [cmake-download]: https://cmake.org/download/
569
+
570
+ [cmake-from-source]: https://cmake.org/install/
571
+
572
+ [cmake-install]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project
573
+
574
+ [cmake-user-interaction]: https://cmake.org/cmake/help/latest/guide/user-interaction/index.html#setting-build-variables
575
+
576
+ [cmake_build_type]: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
577
+
578
+ [cmake_presets]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
579
+
580
+ [doxygen-download]: https://www.doxygen.nl/download.html
581
+
582
+ [doxygen]: https://www.doxygen.nl/index.html
583
+
584
+ [enable_testing]: https://cmake.org/cmake/help/latest/command/enable_testing.html
585
+
586
+ [fetchcontent]: https://cmake.org/cmake/help/latest/module/FetchContent.html
587
+
588
+ [find_package]: https://cmake.org/cmake/help/latest/command/find_package.html
589
+
590
+ [flatbuffers]: https://github.com/google/flatbuffers
591
+
592
+ [homebrew]: https://brew.sh
593
+
594
+ [libjpeg]: https://www.libjpeg-turbo.org/
595
+
596
+ [libpng]: http://www.libpng.org/pub/png/libpng.html
597
+
598
+ [lld]: https://lld.llvm.org/
599
+
600
+ [msvc-cmd]: https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line
601
+
602
+ [ninja-download]: https://github.com/ninja-build/ninja/releases
603
+
604
+ [pipx]: https://pipx.pypa.io/stable/
605
+
606
+ [pybind11]: https://github.com/pybind/pybind11
607
+
608
+ [pypi-cmake]: https://pypi.org/project/cmake/
609
+
610
+ [python]: https://www.python.org/downloads/
611
+
612
+ [snap store]: https://snapcraft.io/cmake
613
+
614
+ [vcpkg-overlay]: https://learn.microsoft.com/en-us/vcpkg/concepts/overlay-ports
615
+
616
+ [vcpkg]: https://github.com/Microsoft/vcpkg
617
+
618
+ [vcvarsall]: https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line#developer_command_file_locations
619
+
620
+ [venv]: https://docs.python.org/3/tutorial/venv.html
621
+
622
+ [vs-cmake-docs]: https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio
623
+
624
+ [wabt]: https://github.com/WebAssembly/wabt
625
+
626
+ [winget]: https://learn.microsoft.com/en-us/windows/package-manager/winget/