Skip to content

Latest commit

 

History

History
124 lines (93 loc) · 4.57 KB

BUILD.md

File metadata and controls

124 lines (93 loc) · 4.57 KB

Build

Requirements

General

  • Only 64-bit systems are supported
  • C++ compilers with C++20 support (e.g., Clang-15, GCC-11, MSVC-17)
  • On Linux, uuid-dev is required to build the core libraries and the following libraries are required for the GUI module:
    • libopencv-dev
    • libglfw3-dev
    • libxinerama-dev
    • libxcursor-dev
    • libxi-dev

C++ with XMake

  • XMake 2.7.8+
  • The LLVM toolchain is recommended and well-tested
  • Building with XMake on Linux and macOS is experimental. You may encounter with RPATH issues. Please use CMake instead.

C++ with CMake

  • CMake 3.23+
  • Ninja is the recommended generator and is required for the Rust frontend

Rust (IR module / Rust frontend)

  • Rust 1.64+ (latest stable version is recommended)
  • To use the Rust frontend, please see luisa-compute-rs

Backends

  • CPU

    • clang++ must be in PATH
  • CUDA

    • CUDA 11.7 or higher
    • Nvidia graphics cards with appropriate drivers (R535+ for OptiX 8).
      • To use hardware ray tracing, RTX-compatible graphics cards are needed.
    • To build with GPU compression/decompression support, you may specify -D LUISA_COMPUTE_DOWNLOAD_NVCOMP=ON to let CMake automatically download the nvCOMP library for you
    • To build with GPU BC texture compression support, you may download NVTT 3
      • On Linux (or when the library is installed to a custom location on Windows), also specify -D NVTT_DIR=<path-to-nvtt> to the directory containing the NVTT DLLs so CMake could find it.
  • DirectX

    • DirectX 12 with ray tracing support
    • DirectX-12.1 & Shader Model 6.5 compatible graphics cards with appropriate drivers
  • Metal

    • macOS 13 or higher with Metal 3 support
    • Apple M1 chips are recommended (older GPUs are probably supported but not tested)

Build Instructions

XMake Build Commands

xmake f -c
xmake

XMake Options

All xmake options declared in ./xmake.lua clearly, you can create ./scripts/options.lua to save a default config for your local environment. An example of options.lua is:

-- for xmake internal arguments
lc_toolchain = {
	toolchain = "llvm",
}
-- for LC's custom options
function get_options()
	return {
		enable_dsl = true,
		enable_gui = true,
	}
end

Options in options.lua can be covered by command-line config, for example:

xmake f --enable_dsl=false --enable_gui=false -c
xmake

Now both "enable_dsl" and "enable_gui" are false values so the DSL and GUI modules will not be built.

You can use ./scripts/write_options.lua to generate a default options.lua:

xmake lua scripts/write_options.lua

XMake Config [Experimental]

When LuisaCompute is required by other xmake projects, include config/xmake_config.lua and call methods to add includedirs, linkdirs and defines to other projects.

CMake Build Commands

cmake -S . -B <build-dir> -D CMAKE_BUILD_TYPE=Release # if you want a debug build, change to `-D CMAKE_BUILD_TYPE=Debug`; optionally followed by other flags as listed above
cmake --build <build-dir> # when building on Windows using Visual Studio Generators, add `--config=Release` in a release build

CMake Flags

All backends are enabled by default if the corresponding required APIs/frameworks are detected available. You can override the default settings by specifying CMake flags manually, in form of -D FLAG=value behind the first cmake command.

Note: On Windows, please remember to replace the backslashes \\ in the paths with / when passing arguments to CMake.

  • LUISA_COMPUTE_ENABLE_CUDA: Enable CUDA backend (Default: ON)
  • LUISA_COMPUTE_ENABLE_DX: Enable DirectX backend (Default: ON)
  • LUISA_COMPUTE_ENABLE_METAL: Enable Metal backend (Default: ON)
  • LUISA_COMPUTE_ENABLE_CPU: Enable CPU backend (Default: ON)
  • LUISA_COMPUTE_ENABLE_GUI: Enable GUI display in C++ tests (Default: ON)

Note: You may also edit the scripts/options.cmake file (generated by bootstrap.py or copied by yourself from scripts/options.cmake.template) to set the default values of these flags. You can still override the default values by specifying the above CMake flags manually.

Running the Programs

  1. LuisaCompute C++ tests are output to the <build-dir>/bin folder.
  2. All tests accept a command-line argument specifying the backend, which can be chosen from cuda, dx, metal, and cpu (all in the lower case).