{% set name = "nccl" %}
{% set version = "2.21.5-1" %}

package:
  name: {{ name|lower }}
  version: {{ version|replace("-", ".") }}

source:
  url: https://github.com/NVIDIA/nccl/archive/v{{ version }}.tar.gz
  sha256: 1923596984d85e310b5b6c52b2c72a1b93da57218f2bc5a5c7ac3d59297a3303
  patches:
    # Upstreaming w/PR: https://github.com/NVIDIA/nccl/pull/854
    - 0001-Allow-custom-NVCC-path.patch

build:
  number: 0
  skip: true  # [(not linux) or cuda_compiler_version in (undefined, "None", "10.2")]
  ignore_run_exports_from:
    # Ignore `cudatoolkit` dependency in CUDA 11 builds
    - {{ compiler("cuda") }}  # [(cuda_compiler_version or "").startswith("11")]
  run_exports:
    # xref: https://github.com/NVIDIA/nccl/issues/218
    - {{ pin_subpackage(name, max_pin="x") }}

requirements:
  build:
    - {{ compiler("c") }}
    - {{ compiler("cxx") }}
    - {{ compiler("cuda") }}
    - make
  host:
    - cuda-version ={{ cuda_compiler_version }}          # [(cuda_compiler_version or "").startswith("11")]
  run:
    - {{ pin_compatible("cuda-version", max_pin="x") }}  # [(cuda_compiler_version or "").startswith("11")]

test:
  commands:
    - test -f "${PREFIX}/include/nccl.h"
    - test -f "${PREFIX}/lib/libnccl.so"
    - test ! -f "${PREFIX}/lib/libnccl_static.a"

about:
  home: https://developer.nvidia.com/nccl
  license: BSD-3-Clause
  license_family: BSD
  license_file: LICENSE.txt
  summary: Optimized primitives for collective multi-GPU communication

  description: |
    The NVIDIA Collective Communications Library (NCCL) implements multi-GPU
    and multi-node collective communication primitives that are performance
    optimized for NVIDIA GPUs. NCCL provides routines such as all-gather,
    all-reduce, broadcast, reduce, reduce-scatter, that are optimized to
    achieve high bandwidth over PCIe and NVLink high-speed interconnect.

  doc_url: https://docs.nvidia.com/deeplearning/sdk/nccl-developer-guide/docs/index.html
  dev_url: https://github.com/NVIDIA/nccl

extra:
  recipe-maintainers:
    - jakirkham
    - leofang
