Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thecomputekid/premake5-cuda
Premake5 module that enables CUDA development in Visual Studio using the native CUDA Toolkit integration.
https://github.com/thecomputekid/premake5-cuda
cuda premake-module premake5 visual-studio
Last synced: 24 days ago
JSON representation
Premake5 module that enables CUDA development in Visual Studio using the native CUDA Toolkit integration.
- Host: GitHub
- URL: https://github.com/thecomputekid/premake5-cuda
- Owner: theComputeKid
- License: mit
- Created: 2021-03-27T10:26:53.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-15T12:09:18.000Z (5 months ago)
- Last Synced: 2024-09-15T13:51:03.984Z (5 months ago)
- Topics: cuda, premake-module, premake5, visual-studio
- Language: Lua
- Homepage:
- Size: 66.4 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
a premake5 extension for cuda
premake5-CUDACompiles CUDA code using the Visual Studio CUDA Toolkit extension on Windows and `nvcc` on Linux. Enabled macros (listed in `src/cuda-exported-variables.lua`):
- `cudaFiles` (Table) -> list of files to be compiled by NVCC to binary (relative path from solution root).
- `cudaPTXFiles` (Table) -> list of files to be compiled by NVCC to PTX (relative path from solution root) - Windows only.
- `cudaRelocatableCode` (Bool) -> triggers -rdc=true.
- `cudaExtensibleWholeProgram` (Bool) -> triggers extensible whole program compilation.
- `cudaCompilerOptions` (Table) -> passed to nvcc.
- `cudaLinkerOptions` (Table) -> passed to nvlink.
- `cudaFastMath` (Bool) -> triggers fast math optimizations.
- `cudaVerbosePTXAS` (Bool) -> triggers code gen verbosity.
- `cudaMaxRegCount` (String) -> number to determine the max used registers.
- `cudaKeep` (Bool) -> keeps preprocessed output.
- `cudaPath` (String) -> custom CUDA install path.
- `cudaGenLineInfo` (Bool) -> generates line info.
- `cudaIntDir` (String) -> Intermediary directory for CUDA files - Windows only.
- `cudaKeepDir` (String) -> Directory to place cudaKeep files (on Linux, requires an existing directory).The following functions are provided:
- `detectNvccVersion()` -> try to detect the default version of nvcc on the system.
- `detectNvccVersion(cudaPath)` -> try to detect the version of nvcc from a provided path.----------------
Notes for Windows:
----------------Files specified by `files` are compiled by `cl` and not `nvcc`.
An example is provided in the test folder where a CUDA executable project containing C++, PTX and CUDA files is linked against a CUDA shared library project. If you clone this repo recursively (i.e. with `-recursive`), it will also pull the premake5 repo, which can be used via the makefile to build premake and then the tests (e.g. via the `nmake` command). You do not need the premake5 repo unless you want to build the tests.
To use:
- Install the CUDA toolkit, along with its Visual Studio integration.
- Copy the premake5-cuda folder to your project.
- Include it in your premake5.lua file as shown in the example.Tested with Visual Studio 2022 (toolkit v143) with CUDA toolkit 12.1 VS integration.
Note: If PTX is requested, it will be found in the output object folder, with the .obj extension, though, it can be opened with a text editor for inspection.
----------------
Notes for Linux:
----------------This extension was primarily made for VS on Windows, with the CUDA toolkit extension. Linux is a work in progress and does not have feature parity with Windows yet. Differences are:
- toolset must be set as `"nvcc"`.
- rules must be set to `'cu'`.
- `cudaPTXFiles` and `cudaIntDir` not supported.
- the list of cuda files must be provided in `files` instead of `cudaFiles`.
- unlike Windows, the whole project is compiled by `nvcc` and not just the `.cu` files.See test premake5 file for how linux config differs. The differences are summarised here:
```
if os.target() == "windows" then
cudaFiles { "exe/cu/**.cu" } -- files to be compiled into binaries by VS CUDA.
cudaPTXFiles { "exe/ptx/**.cu" } -- files to be compiled into ptx, Windows only.
else
toolset "nvcc"
files { "exe/cu/**.cu" }
rules {"cu"}
end
```Admittedly, Linux support is a bit clunky but it should get the job done.