From 85cccfb81f4c01863817a3e8da54cd4fb6904e1d Mon Sep 17 00:00:00 2001 From: Keren Zhou Date: Sun, 20 Nov 2022 21:40:36 -0800 Subject: [PATCH] [BUILD] Fix compilation problems in the release build (#897) --- .../TritonGPUToLLVM/TritonGPUToLLVM.cpp | 15 +++++++++----- python/setup.py | 20 +++++++++---------- python/src/triton.cc | 2 +- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/Conversion/TritonGPUToLLVM/TritonGPUToLLVM.cpp b/lib/Conversion/TritonGPUToLLVM/TritonGPUToLLVM.cpp index 0d0b62280..8338388be 100644 --- a/lib/Conversion/TritonGPUToLLVM/TritonGPUToLLVM.cpp +++ b/lib/Conversion/TritonGPUToLLVM/TritonGPUToLLVM.cpp @@ -1438,9 +1438,10 @@ struct BroadcastOpConversion SmallVector resultLogicalShape(2 * rank); SmallVector broadcastDims; for (unsigned d = 0; d < rank; ++d) { - unsigned resultShapePerCTA = triton::gpu::getSizePerThread(resultLayout)[d] * - triton::gpu::getThreadsPerWarp(resultLayout)[d] * - triton::gpu::getWarpsPerCTA(resultLayout)[d]; + unsigned resultShapePerCTA = + triton::gpu::getSizePerThread(resultLayout)[d] * + triton::gpu::getThreadsPerWarp(resultLayout)[d] * + triton::gpu::getWarpsPerCTA(resultLayout)[d]; int64_t numCtas = ceil(resultShape[d], resultShapePerCTA); if (srcShape[d] != resultShape[d]) { assert(srcShape[d] == 1); @@ -1450,10 +1451,12 @@ struct BroadcastOpConversion std::max(1, triton::gpu::getSizePerThread(srcLayout)[d]); } else { srcLogicalShape[d] = numCtas; - srcLogicalShape[d + rank] = triton::gpu::getSizePerThread(resultLayout)[d]; + srcLogicalShape[d + rank] = + triton::gpu::getSizePerThread(resultLayout)[d]; } resultLogicalShape[d] = numCtas; - resultLogicalShape[d + rank] = triton::gpu::getSizePerThread(resultLayout)[d]; + resultLogicalShape[d + rank] = + triton::gpu::getSizePerThread(resultLayout)[d]; srcLogicalOrder[d] = order[d] + rank; srcLogicalOrder[d + rank] = order[d]; @@ -1968,6 +1971,7 @@ struct PrintfOpConversion return "%u"; } assert(false && "not supported type"); + return ""; } // declare vprintf(i8*, i8*) as external function @@ -5482,6 +5486,7 @@ Value convertSplatLikeOpWithMmaLayout(const MmaEncodingAttr &layout, } assert(false && "Unsupported mma layout found"); + return {}; } class TritonGPUToLLVMTypeConverter : public LLVMTypeConverter { diff --git a/python/setup.py b/python/setup.py index a39aa1e5b..73b03d55f 100644 --- a/python/setup.py +++ b/python/setup.py @@ -6,7 +6,6 @@ import shutil import subprocess import sys import tarfile -import tempfile import urllib.request from distutils.version import LooseVersion from typing import NamedTuple @@ -26,7 +25,9 @@ def get_build_type(): elif check_env_flag("REL_WITH_DEB_INFO"): return "RelWithDebInfo" else: - return "Release" + return "Debug" + # TODO(Keren): Restore this before we merge into master + #return "Release" # --- third party packages ----- @@ -124,19 +125,14 @@ class CMakeBuild(build_ext): self.build_extension(ext) def build_extension(self, ext): - self.debug = True lit_dir = shutil.which('lit') triton_cache_path = os.path.join(os.environ["HOME"], ".triton") # lit is used by the test suite 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 - build_suffix = 'debug' if self.debug else 'release' - llvm_build_dir = os.path.join(tempfile.gettempdir(), "llvm-" + build_suffix) if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) - if not os.path.exists(llvm_build_dir): - os.makedirs(llvm_build_dir) # python directories python_include_dir = distutils.sysconfig.get_python_inc() cmake_args = [ @@ -145,13 +141,13 @@ class CMakeBuild(build_ext): "-DTRITON_BUILD_TUTORIALS=OFF", "-DTRITON_BUILD_PYTHON_MODULE=ON", # '-DPYTHON_EXECUTABLE=' + sys.executable, - # '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON', + '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON', "-DPYTHON_INCLUDE_DIRS=" + python_include_dir, "-DLLVM_EXTERNAL_LIT=" + lit_dir ] + thirdparty_cmake_args # configuration - cfg = "Debug" if self.debug else "Release" + cfg = get_build_type() build_args = ["--config", cfg] if platform.system() == "Windows": @@ -183,7 +179,11 @@ setup( "torch", "lit", ], - package_data={"triton/ops": ["*.c"], "triton/ops/blocksparse": ["*.c"]}, + package_data={ + "triton/ops": ["*.c"], + "triton/ops/blocksparse": ["*.c"], + "triton/language": ["*.bc"] + }, include_package_data=True, ext_modules=[CMakeExtension("triton", "triton/_C/")], cmdclass={"build_ext": CMakeBuild}, diff --git a/python/src/triton.cc b/python/src/triton.cc index f07d4cfee..f7c29dd4a 100644 --- a/python/src/triton.cc +++ b/python/src/triton.cc @@ -551,7 +551,7 @@ void init_triton_ir(py::module &&m) { return llvm::dyn_cast(funcOperation); auto loc = self.getUnknownLoc(); if (auto funcTy = funcType.dyn_cast()) { - mlir::ArrayRef attrs = { + llvm::SmallVector attrs = { mlir::NamedAttribute(self.getStringAttr("sym_visibility"), self.getStringAttr(visibility))}; return self.create(loc, funcName, funcTy, attrs);