# IT4Innovations
# LK 2024

easyblock = 'ConfigureMake'

name = 'UCC-CUDA'
version = '1.3.0'
versionsuffix = '-CUDA-%(cudaver)s'

homepage = 'https://www.openucx.org/'
description = """UCC (Unified Collective Communication) is a collective
communication operations API and library that is flexible, complete, and 
feature-rich for current and emerging programming models and runtimes.

This module adds the UCC CUDA support.
"""

toolchain = {'name': 'GCCcore', 'version': '12.2.0'}
toolchainopts = {'pic': True}

source_urls = ['https://github.com/openucx/ucc/archive/refs/tags']
sources = ['v%(version)s.tar.gz']
#patches = [
#    '%(name)s-1.3.0_link_against_existing_UCC_libs.patch',
#    '%(name)s-1.3.0_cuda_12_mem_ops.patch',
#]
checksums = [
    {'v1.3.0.tar.gz': 'b56379abe5f1c125bfa83be305d78d81a64aa271b7b5fff0ac17b86725ff3acf'},
    {'UCC-CUDA-1.3.0_link_against_existing_UCC_libs.patch': '328e0f7e4de76a9dc6ecc07427581df661c27f6c0ace24f49a7b3289a39777c7'},
    {'UCC-CUDA-1.3.0_cuda_12_mem_ops.patch': 'fc3ea1487d29dc626db2363ef5a79e7f0906f6a7507a363fa6167a812b143eb6'},
]

builddependencies = [
    ('binutils', '2.39'),
    ('Autotools', '20220317'),
]

dependencies = [
    ('UCC', '1.3.0'),
    ('CUDA',  '12.3.0', '', SYSTEM),
    ('UCX-CUDA', '1.16.0', '-CUDA-%(cudaver)s'),
    ('NCCL', '2.21.5', '-CUDA-%(cudaver)s'),
]

preconfigopts = "./autogen.sh && "

buildopts = '-C src/components/mc/cuda V=1 && make -C src/components/tl/nccl V=1'
installopts = '-C src/components/mc/cuda && make -C src/components/tl/nccl install'

sanity_check_paths = {
    'files': ['lib/ucc/libucc_mc_cuda.%s' % SHLIB_EXT, 'lib/ucc/libucc_tl_nccl.%s' % SHLIB_EXT],
    'dirs': ['lib']
}

sanity_check_commands = ["ucc_info -c"]

modextrapaths = {'EB_UCC_EXTRA_COMPONENT_PATH': 'lib/ucc'}

moduleclass = 'lib'
