easyblock = 'CMakeMake'

name = "CuSan"
version = "0.1-beta"

homepage = 'https://github.com/ahueck/cusan'
description = """ CuSan is tool to find data races between (asynchronous) CUDA calls and the host. 
To that end, we analyze and instrument CUDA codes to track CUDA domain-specific memory accesses and synchronization semantics during compilation using LLVM. 
Our runtime then passes these information appropriately to ThreadSanitizer (packaged with Clang/LLVM) for the final data race analysis.
"""

toolchain = {'name': 'nvompi', 'version': '2022.07'}

source_urls = ['https://hpc.rwth-aachen.de/must/files/']
sources = [{
    "filename": '%(name)s-v%(version)s.tar.gz',
    "git_config": {
       'url': 'https://github.com/ahueck',
       'repo_name': 'cusan',
       'commit': '39c51c013e8f8047069dcc4808357e77ef07e0b5',
       'recursive': True,
       'keep_git_dir': True,
    }
}]

patches = [
    'CuSan-0.1-beta-disable-tests.patch',
]
checksums = ['abd7184f428dccf1ea7904196d3d17be06a3535509b4d808a65951c286fafa1a',
             '1995f68824bddd81d74cc892bdeeb12e76c355daa8ec506ff38a6de6473dd362']

builddependencies = [
    ('CMake', '3.24.3'),
    ('Python', '3.10.4'),
]

dependencies = [
    #('Graphviz', '2.49.3'),
    ('Clang', '13.0.1', '-CUDA-11.7.0'),
]

preconfigopts = 'export CC=clang CXX=clang++ OMPI_CC=clang OMPI_CXX=clang++ CFLAGS="" CXXFLAGS="" FCFLAGS="" && '
configopts = '-DCMAKE_BUILD_TYPE=Release -DCUSAN_LOG_LEVEL_RT=0 -DCUSAN_FIBERPOOL=OFF'

sanity_check_paths = {
    'files': ["bin/cusan-clang", "lib/cusanTransformPass.so"],
    'dirs': [],
}

moduleclass = 'perf'
