Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
##
# This file is an EasyBuild reciPY as per https://github.com/easybuilders/easybuild
#
# Copyright:: Copyright 2013-2015 Dmitri Gribenko, Ward Poelmans
# Authors:: Dmitri Gribenko <[email protected]>
# Authors:: Ward Poelmans <[email protected]>
# License:: GPLv2 or later, MIT, three-clause BSD.
# $Id$
##

name = 'Clang'
version = '17.0.0_20230515'
versionsuffix = '-CUDA-%(cudaver)s'
_commit = 'c5dede880d17'

homepage = 'https://clang.llvm.org/'
description = """C, C++, Objective-C compiler, based on LLVM. Does not
include C++ standard library -- use libstdc++ from GCC."""

# Clang also depends on libstdc++ during runtime, but this dependency is
# already specified as the toolchain.
toolchain = {'name': 'GCCcore', 'version': '12.3.0'}

sources = [{
'source_urls': ["https://github.com/llvm/llvm-project/archive"],
'download_filename': '%s.tar.gz' % _commit,
'filename': 'llvm-project-%s.tar.gz' % version,
}]
checksums = ['6f371f9ac208b8e9dc57fc117b1a9c8565d7ea2bbb49a2768cb9c3c0fee0291d']

builddependencies = [
('CMake', '3.26.3'),
('Perl', '5.36.1'),
# Including Python bindings would require this as a runtime dep
('Python', '3.11.3'),
]
dependencies = [
# since Clang is a compiler, binutils is a runtime dependency too
('binutils', '2.40'),
('hwloc', '2.9.1'),
('libxml2', '2.11.4'),
('ncurses', '6.4'),
('GMP', '6.2.1'),
('Z3', '4.12.2'),
('CUDA', '12.1.1', '', SYSTEM),
]

# enabling RTTI makes the flang compiler need to link to libc++ so instead of
# flang-new -flang-experimental-exec -fopenmp hello_openmp.f90
# you would need
# flang-new -flang-experimental-exec -fopenmp hello_openmp.f90 -l c++
enable_rtti = False

assertions = True
python_bindings = False
skip_all_tests = True

llvm_runtimes = ['libunwind', 'libcxx', 'libcxxabi']
llvm_projects = ['polly', 'lld', 'lldb', 'clang-tools-extra', 'flang']

moduleclass = 'compiler'
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Disable experimental support for AMD GPUs
author: Alex Domingo (Vrije Universiteit Brussel)
author: Samuel Moors (Vrije Universiteit Brussel)
diff -ur triton-2.1.0.orig/CMakeLists.txt triton-2.1.0/CMakeLists.txt
--- triton-2.1.0.orig/CMakeLists.txt 2023-09-01 08:28:27.000000000 +0200
+++ triton-2.1.0/CMakeLists.txt 2024-09-01 10:40:17.863374000 +0200
@@ -70,7 +70,7 @@
AMDGPUInfo AMDGPUcodegen
)
else()
- find_package(LLVM 11 REQUIRED COMPONENTS "nvptx;amdgpu")
+ find_package(LLVM 11 REQUIRED COMPONENTS "nvptx")
endif()

message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
@@ -89,9 +89,7 @@
LLVMNVPTXCodeGen
LLVMNVPTXDesc
LLVMNVPTXInfo
- LLVMAMDGPUDisassembler
LLVMMCDisassembler
- LLVMAMDGPUCodeGen
LLVMMIRParser
LLVMGlobalISel
LLVMSelectionDAG
@@ -116,10 +114,7 @@
LLVMObject
LLVMTextAPI
LLVMBitReader
- LLVMAMDGPUAsmParser
LLVMMCParser
- LLVMAMDGPUDesc
- LLVMAMDGPUUtils
LLVMMC
LLVMDebugInfoCodeView
LLVMDebugInfoMSF
@@ -127,7 +122,6 @@
LLVMRemarks
LLVMBitstreamReader
LLVMBinaryFormat
- LLVMAMDGPUInfo
LLVMSupport
LLVMDemangle
LLVMPasses
diff -ur triton-2.1.0.orig/lib/Target/HSACO/HSACOTranslation.cpp triton-2.1.0/lib/Target/HSACO/HSACOTranslation.cpp
--- triton-2.1.0.orig/lib/Target/HSACO/HSACOTranslation.cpp 2023-09-01 08:28:27.000000000 +0200
+++ triton-2.1.0/lib/Target/HSACO/HSACOTranslation.cpp 2024-09-02 21:27:09.233712000 +0200
@@ -37,13 +37,6 @@

namespace {

-void init_llvm() {
- LLVMInitializeAMDGPUTarget();
- LLVMInitializeAMDGPUTargetInfo();
- LLVMInitializeAMDGPUTargetMC();
- LLVMInitializeAMDGPUAsmParser();
- LLVMInitializeAMDGPUAsmPrinter();
-}

std::unique_ptr<llvm::TargetMachine>
initialize_module(llvm::Module *module, const std::string &triple,
@@ -155,7 +148,6 @@
llir_to_amdgcn_and_hsaco(llvm::Module *module, std::string gfx_arch,
std::string gfx_triple, std::string gfx_features) {

- init_llvm();

// verify and store llvm
auto module_obj = llvm::CloneModule(*module);
diff -ur triton-2.1.0.orig/python/src/triton.cc triton-2.1.0/python/src/triton.cc
--- triton-2.1.0.orig/python/src/triton.cc 2023-09-01 08:28:27.000000000 +0200
+++ triton-2.1.0/python/src/triton.cc 2024-09-01 10:41:29.146862440 +0200
@@ -60,7 +60,6 @@
enum backend_t {
HOST,
CUDA,
- ROCM,
};

void init_triton_runtime(py::module &&m) {
@@ -68,7 +67,6 @@
py::enum_<backend_t>(m, "backend", py::module_local())
.value("HOST", HOST)
.value("CUDA", CUDA)
- .value("ROCM", ROCM)
.export_values();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
easyblock = 'PythonPackage'

name = 'Triton'
version = '2.1.0'
versionsuffix = '-CUDA-%(cudaver)s'

homepage = 'https://triton-lang.org/'

description = """Triton is a language and compiler for parallel programming. It aims to provide a
Python-based programming environment for productively writing custom DNN compute
kernels capable of running at maximal throughput on modern GPU hardware."""

toolchain = {'name': 'foss', 'version': '2023a'}

github_account = 'openai'
source_urls = [GITHUB_LOWER_SOURCE]
sources = ['v%(version)s.tar.gz']
patches = [
'%(name)s-%(version)s-disable_rocm_support.patch',
'%(name)s-%(version)s-use_eb_env_python_build.patch',
]
checksums = [
{'v2.1.0.tar.gz': '4338ca0e80a059aec2671f02bfc9320119b051f378449cf5f56a1273597a3d99'},
{'Triton-2.1.0-disable_rocm_support.patch': 'e4d7c0947c3287b3f0871a004e8b483963f637c9fa3ef6212ac3a34660de2a7c'},
{'Triton-2.1.0-use_eb_env_python_build.patch': 'd68bf766c699ad6a778d9449d3bccdadc2f20f1f86ba13e1359ad297b12fbf7c'},
]

builddependencies = [
('Clang', '17.0.0_20230515', versionsuffix), # this is the exact commit that would be downloaded by Triton
('CMake', '3.26.3'),
]

dependencies = [
('CUDA', '12.1.1', '', SYSTEM),
('Python', '3.11.3'),
('PyTorch', '2.1.2', versionsuffix),
]

use_pip = True
download_dep_fail = True

start_dir = 'python'

preinstallopts = 'export LLVM_INCLUDE_DIRS=$EBROOTCLANG/include && '
preinstallopts += 'export LLVM_LIBRARY_DIR=$EBROOTCLANG/lib && '
preinstallopts += 'export LLVM_SYSPATH=$EBROOTCLANG && '
preinstallopts += 'export TRITON_BUILD_WITH_CLANG_LLD=1 && '

# make pip print output of cmake
installopts = "-v "

sanity_pip_check = True

modluafooter = 'setenv("TRITON_PTXAS_PATH", pathJoin(os.getenv("CUDA_HOME"), "bin", "ptxas"))'

moduleclass = 'devel'
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Fix Triton cmake build to use dependencies from EasyBuild
author: Alex Domingo (Vrije Universiteit Brussel)
author: Samuel Moors (Vrije Universiteit Brussel)
diff -ur triton-2.1.0.orig/lib/Target/LLVMIR/LLVMIRTranslation.cpp triton-2.1.0/lib/Target/LLVMIR/LLVMIRTranslation.cpp
--- triton-2.1.0.orig/lib/Target/LLVMIR/LLVMIRTranslation.cpp 2023-09-01 08:28:27.000000000 +0200
+++ triton-2.1.0/lib/Target/LLVMIR/LLVMIRTranslation.cpp 2024-09-02 19:46:06.574421829 +0200
@@ -35,6 +35,7 @@
#endif
#include <filesystem>
#include <iterator>
+#include <cstdlib> // for getenv

namespace fs = std::filesystem;

@@ -177,6 +178,7 @@
}

if (!funcs.empty()) {
+ std::filesystem::path cuda_home = std::getenv("CUDA_HOME");
static const std::string libdevice = "libdevice";
// first search for environmental path
std::string env_path = ::triton::tools::getenv("TRITON_LIBDEVICE_PATH");
@@ -189,8 +191,7 @@
// `triton/third_party/cuda/lib/libdevice.10.bc`
static const auto this_library_path = getThisLibraryPath();
static const auto runtime_path =
- this_library_path.parent_path().parent_path() / "third_party" / "cuda" /
- "lib" / "libdevice.10.bc";
+ cuda_home / "nvvm" / "libdevice" / "libdevice.10.bc";
if (fs::exists(runtime_path)) {
externLibs.try_emplace(libdevice, runtime_path.string());
} else {
diff -ur triton-2.1.0.orig/python/setup.py triton-2.1.0/python/setup.py
--- triton-2.1.0.orig/python/setup.py 2023-09-01 08:28:27.000000000 +0200
+++ triton-2.1.0/python/setup.py 2024-09-02 18:16:58.044760300 +0200
@@ -202,13 +202,13 @@

def build_extension(self, ext):
lit_dir = shutil.which('lit')
- user_home = os.getenv("HOME") or os.getenv("USERPROFILE") or \
- os.getenv("HOMEPATH") or None
- if not user_home:
- raise RuntimeError("Could not find user home directory")
- triton_cache_path = os.path.join(user_home, ".triton")
+ # user_home = os.getenv("HOME") or os.getenv("USERPROFILE") or \
+ # os.getenv("HOMEPATH") or None
+ # if not user_home:
+ # raise RuntimeError("Could not find user home directory")
+ # triton_cache_path = os.path.join(user_home, ".triton")
# lit is used by the test suite
- thirdparty_cmake_args = get_thirdparty_packages(triton_cache_path)
+ # thirdparty_cmake_args = get_thirdparty_packages(triton_cache_path)
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.path)))
# create build directories
if not os.path.exists(self.build_temp):
@@ -216,8 +216,9 @@
# python directories
python_include_dir = sysconfig.get_path("platinclude")
cmake_args = [
+ "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
- "-DLLVM_ENABLE_WERROR=ON",
+ # "-DLLVM_ENABLE_WERROR=ON",
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir,
"-DTRITON_BUILD_TUTORIALS=OFF",
"-DTRITON_BUILD_PYTHON_MODULE=ON",
@@ -227,7 +228,7 @@
]
if lit_dir is not None:
cmake_args.append("-DLLVM_EXTERNAL_LIT=" + lit_dir)
- cmake_args.extend(thirdparty_cmake_args)
+ # cmake_args.extend(thirdparty_cmake_args)

# configuration
cfg = get_build_type()
@@ -245,7 +246,7 @@
build_args += ["--", "/m"]
else:
cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]
- max_jobs = os.getenv("MAX_JOBS", str(2 * os.cpu_count()))
+ max_jobs = os.getenv("MAX_JOBS", str(len(os.sched_getaffinity(0))))
build_args += ['-j' + max_jobs]

if check_env_flag("TRITON_BUILD_WITH_CLANG_LLD"):
@@ -262,7 +263,7 @@
subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=cmake_dir)


-download_and_copy_ptxas()
+# download_and_copy_ptxas()


setup(