Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
7.7 kB · 382 lines
Nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383{ _cuda, lib }:let cudaLib = _cuda.lib;in{ /** Replaces dots in a string with underscores.
# Type
``` dotsToUnderscores :: (str :: String) -> String ```
# Inputs
`str`
: The string for which dots shall be replaced by underscores
# Examples
:::{.example} ## `cudaLib.dotsToUnderscores` usage examples
```nix dotsToUnderscores "1.2.3" => "1_2_3" ``` ::: */ dotsToUnderscores = lib.replaceStrings [ "." ] [ "_" ];
/** Removes the dots from a string.
# Type
``` dropDots :: (str :: String) -> String ```
# Inputs
`str`
: The string to remove dots from
# Examples
:::{.example} ## `cudaLib.dropDots` usage examples
```nix dropDots "1.2.3" => "123" ``` ::: */ dropDots = lib.replaceStrings [ "." ] [ "" ];
/** Produces an attribute set of useful data and functionality for packaging CUDA software within Nixpkgs.
# Type
``` formatCapabilities :: { cudaCapabilityToInfo :: AttrSet CudaCapability CudaCapabilityInfo , cudaCapabilities :: List CudaCapability , cudaForwardCompat :: Bool } -> { cudaCapabilities :: List CudaCapability , cudaForwardCompat :: Bool , gencode :: List String , realArches :: List String , virtualArches :: List String , archNames :: List String , arches :: List String , gencodeString :: String , cmakeCudaArchitecturesString :: String } ```
# Inputs
`cudaCapabilityToInfo`
: A mapping of CUDA capabilities to their information
`cudaCapabilities`
: A list of CUDA capabilities to use
`cudaForwardCompat`
: A boolean indicating whether to include the forward compatibility gencode (+PTX) to support future GPU generations */ formatCapabilities = { cudaCapabilityToInfo, cudaCapabilities, cudaForwardCompat, }: let /** The real architectures for the given CUDA capabilities.
# Type
``` realArches :: List String ``` */ realArches = lib.map cudaLib.mkRealArchitecture cudaCapabilities;
/** The virtual architectures for the given CUDA capabilities.
These are typically used for forward compatibility, when trying to support an architecture newer than the CUDA version allows.
# Type
``` virtualArches :: List String ``` */ virtualArches = lib.map cudaLib.mkVirtualArchitecture cudaCapabilities;
/** The gencode flags for the given CUDA capabilities.
# Type
``` gencode :: List String ``` */ gencode = let base = lib.map (cudaLib.mkGencodeFlag "sm") cudaCapabilities; forward = cudaLib.mkGencodeFlag "compute" (lib.last cudaCapabilities); in base ++ lib.optionals cudaForwardCompat [ forward ]; in { inherit cudaCapabilities cudaForwardCompat gencode realArches virtualArches ;
/** The architecture names for the given CUDA capabilities.
# Type
``` archNames :: List String ``` */ # E.g. [ "Ampere" "Turing" ] archNames = lib.pipe cudaCapabilities [ (lib.map (cudaCapability: cudaCapabilityToInfo.${cudaCapability}.archName)) lib.unique lib.naturalSort ];
/** The architectures for the given CUDA capabilities, including both real and virtual architectures.
When `cudaForwardCompat` is enabled, the last architecture in the list is used as the forward compatibility architecture.
# Type
``` arches :: List String ``` */ # E.g. [ "sm_75" "sm_86" "compute_86" ] arches = realArches ++ lib.optionals cudaForwardCompat [ (lib.last virtualArches) ];
/** The CMake-compatible CUDA architectures string for the given CUDA capabilities.
# Type
``` cmakeCudaArchitecturesString :: String ``` */ cmakeCudaArchitecturesString = cudaLib.mkCmakeCudaArchitecturesString cudaCapabilities;
/** The gencode string for the given CUDA capabilities.
# Type
``` gencodeString :: String ``` */ gencodeString = lib.concatStringsSep " " gencode; };
/** Produces a CMake-compatible CUDA architecture string from a list of CUDA capabilities.
# Type
``` mkCmakeCudaArchitecturesString :: (cudaCapabilities :: List String) -> String ```
# Inputs
`cudaCapabilities`
: The CUDA capabilities to convert
# Examples
:::{.example} ## `cudaLib.mkCmakeCudaArchitecturesString` usage examples
```nix mkCmakeCudaArchitecturesString [ "8.9" "10.0a" ] => "89;100a" ``` ::: */ mkCmakeCudaArchitecturesString = lib.concatMapStringsSep ";" cudaLib.dropDots;
/** Produces a gencode flag from a CUDA capability.
# Type
``` mkGencodeFlag :: (archPrefix :: String) -> (cudaCapability :: String) -> String ```
# Inputs
`archPrefix`
: The architecture prefix to use for the `code` field
`cudaCapability`
: The CUDA capability to convert
# Examples
:::{.example} ## `cudaLib.mkGencodeFlag` usage examples
```nix mkGencodeFlag "sm" "8.9" => "-gencode=arch=compute_89,code=sm_89" ```
```nix mkGencodeFlag "compute" "10.0a" => "-gencode=arch=compute_100a,code=compute_100a" ``` ::: */ mkGencodeFlag = archPrefix: cudaCapability: let cap = cudaLib.dropDots cudaCapability; in "-gencode=arch=compute_${cap},code=${archPrefix}_${cap}";
/** Produces a real architecture string from a CUDA capability.
# Type
``` mkRealArchitecture :: (cudaCapability :: String) -> String ```
# Inputs
`cudaCapability`
: The CUDA capability to convert
# Examples
:::{.example} ## `cudaLib.mkRealArchitecture` usage examples
```nix mkRealArchitecture "8.9" => "sm_89" ```
```nix mkRealArchitecture "10.0a" => "sm_100a" ``` ::: */ mkRealArchitecture = cudaCapability: "sm_" + cudaLib.dropDots cudaCapability;
/** Create a versioned attribute name from a version by replacing dots with underscores.
# Type
``` mkVersionedName :: (name :: String) -> (version :: Version) -> String ```
# Inputs
`name`
: The name to use
`version`
: The version to use
# Examples
:::{.example} ## `cudaLib.mkVersionedName` usage examples
```nix mkVersionedName "hello" "1.2.3" => "hello_1_2_3" ```
```nix mkVersionedName "cudaPackages" "12.8" => "cudaPackages_12_8" ``` ::: */ mkVersionedName = name: version: "${name}_${cudaLib.dotsToUnderscores version}";
/** Produces a virtual architecture string from a CUDA capability.
# Type
``` mkVirtualArchitecture :: (cudaCapability :: String) -> String ```
# Inputs
`cudaCapability`
: The CUDA capability to convert
# Examples
:::{.example} ## `cudaLib.mkVirtualArchitecture` usage examples
```nix mkVirtualArchitecture "8.9" => "compute_89" ```
```nix mkVirtualArchitecture "10.0a" => "compute_100a" ``` ::: */ mkVirtualArchitecture = cudaCapability: "compute_" + cudaLib.dropDots cudaCapability;}