No description
Find a file
2024-11-30 09:57:25 +01:00
c2nim/cuda12_5 translate 'cuda.h' header (cuda driver api) to nim. cuda nim file compiles 2024-11-10 12:27:23 +01:00
examples new runtime compilation example 2024-11-10 12:27:23 +01:00
include translate 'cuda.h' header (cuda driver api) to nim. cuda nim file compiles 2024-11-10 12:27:23 +01:00
src nim 1.4.x compat 2024-11-30 09:51:24 +01:00
utils restructure in a way that nimble likes, adapt nimble file to support multiple versions, and fix a bug on postprocessor 2024-10-11 10:59:10 +02:00
.gitignore Backwards nim compat, more examples, and check update (#22) 2024-10-14 11:02:19 +02:00
changelog.org update changelog, push v0.2.2 2024-11-30 09:57:25 +01:00
LICENSE Added LICENSE 2017-05-19 16:56:29 +02:00
nimcuda.nimble update changelog, push v0.2.2 2024-11-30 09:57:25 +01:00
README.md Update README.md 2024-10-11 10:59:10 +02:00

NimCUDA

Nim bindings for the CUDA libraries. The versions currently in use are

  • CUDA 8.0 + CuDNN 5.1
  • CUDA 12.5

Status

Most libraries have working bindings. Out of these:

  • most bindings are generated using c2nim and suitable directives (see the files inside /c2nim)
  • a preprocessor is used on the header files to help with common issues that c2nim has during parsing.
  • a postprocessor is used on the nim files to help alleviate some common output problems that c2nim has.
  • some headers files are manually edited before being passed to c2nim.
  • some nim files are manually edited.

Ideally, once some improvements are available in c2nim, there should be no need to manually modify any files.

Usage

See a few examples under /examples. The examples can be run with the command nimble EXAMPLE_NAME CUDA_VERSION, where EXAMPLE_NAME is one of the examples and CUDA_VERSION is the version of cuda that you want it to run on - for instance nimble fft 12.5.

API documentation lives under /htmldocs. Generate it by running nimble docs.

Name mangling

c2nim supports name mangling, which could be useful to simplify a few names (e.g. turn CUBLAS_STATUS_ARCH_MISMATCH into ARCH_MISMATCH, which can be qualified as cublasStatus_t.ARCH_MISMATCH in case of ambiguity).

Right now, no unnecessary mangling is performed, because the API surface is large and not always consistent, so it felt simpler to leave it as is. This may change in a future release.

Error handling

In each cuda version's library there is a file called check.nim. In it are a few templates that turn CUDA errors into Nim exceptions. They are all under the overloaded name check, so that one can do, for instance

check cudaMalloc(cast[ptr pointer](addr gpuRows), sizeof(rows))

(here cudaMalloc is one of the many functions that fail by returning an error code).