Merge previous changes

This commit is contained in:
Yan Da
2022-04-27 14:06:55 +08:00
17 changed files with 37 additions and 35 deletions

View File

@@ -37,7 +37,7 @@ if(WIN32)
add_subdirectory(deps/dlfcn-win32/src ${CMAKE_BINARY_DIR}/dlfcn-win32) add_subdirectory(deps/dlfcn-win32/src ${CMAKE_BINARY_DIR}/dlfcn-win32)
endif() endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS -std=gnu++17") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS -fPIC -std=gnu++17")
########## ##########
@@ -162,7 +162,7 @@ list(APPEND CMAKE_MODULE_PATH ${LLVM_LIBRARY_DIR}/cmake/mlir)
include(TableGen) # required by AddMLIR include(TableGen) # required by AddMLIR
include(AddLLVM) include(AddLLVM)
include(AddMLIR) include(AddMLIR)
include(HandleLLVMOptions) # human-friendly error message # include(HandleLLVMOptions) # human-friendly error message
include_directories(${MLIR_INCLUDE_DIRS}) include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include) include_directories(${PROJECT_SOURCE_DIR}/include)
@@ -174,18 +174,15 @@ add_subdirectory(lib)
add_library(triton SHARED ${PYTHON_SRC}) add_library(triton SHARED ${PYTHON_SRC})
find_package(PythonLibs REQUIRED) # find_package(PythonLibs REQUIRED)
target_link_libraries(triton target_link_libraries(triton
${PYTHON_LIBRARIES}
TritonIR TritonIR
TritonDriver TritonDriver
# TritonCodeGen
# optimizations # optimizations
MLIRPass MLIRPass
MLIRTransforms MLIRTransforms
${PYTHON_LIBRARIES}
) )
target_link_options(triton PRIVATE ${LLVM_LDFLAGS}) target_link_options(triton PRIVATE ${LLVM_LDFLAGS})

View File

@@ -1 +1 @@
add_subdirectory(triton/ir) add_subdirectory(triton/Dialect)

View File

@@ -0,0 +1 @@
add_subdirectory(Triton)

View File

@@ -1,7 +1,6 @@
#ifndef TRITON_IR_DIALECT_H_ #ifndef TRITON_IR_DIALECT_H_
#define TRITON_IR_DIALECT_H_ #define TRITON_IR_DIALECT_H_
#include "triton/ir/Traits.h"
#include "mlir/IR/BuiltinOps.h" #include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Dialect.h" #include "mlir/IR/Dialect.h"
@@ -9,11 +8,11 @@
#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/SCF.h"
#include "triton/ir/Dialect.h.inc" #include "triton/Dialect/Triton/Traits.h"
#include "triton/Dialect/Triton/Dialect.h.inc"
#include "triton/ir/OpsEnums.h.inc" #include "triton/Dialect/Triton/OpsEnums.h.inc"
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "triton/ir/Ops.h.inc" #include "triton/Dialect/Triton/Ops.h.inc"
#endif // TRITON_IR_DIALECT_H_ #endif // TRITON_IR_DIALECT_H_

View File

@@ -5,6 +5,6 @@
#include "mlir/IR/Types.h" #include "mlir/IR/Types.h"
#define GET_TYPEDEF_CLASSES #define GET_TYPEDEF_CLASSES
#include "triton/ir/Types.h.inc" #include "triton/Dialect/Triton/Types.h.inc"
#endif // TRITON_IR_TYPES_H_ #endif // TRITON_IR_TYPES_H_

View File

@@ -19,7 +19,8 @@ namespace triton
namespace nvrtc namespace nvrtc
{ {
#define TRITON_CREATE_NVRTC_EXCEPTION(name, msg) class name: public std::exception { public: const char * what() const throw(){ return "NVRTC: Error- " msg; } } #define TRITON_CREATE_NVRTC_EXCEPTION(name, msg) \
class name: public std::exception { public: const char * what() const throw() override { return "NVRTC: Error- " msg; } }
TRITON_CREATE_NVRTC_EXCEPTION(out_of_memory ,"out of memory"); TRITON_CREATE_NVRTC_EXCEPTION(out_of_memory ,"out of memory");
TRITON_CREATE_NVRTC_EXCEPTION(program_creation_failure ,"program creation failure"); TRITON_CREATE_NVRTC_EXCEPTION(program_creation_failure ,"program creation failure");
@@ -38,7 +39,8 @@ namespace triton
{ {
class base: public std::exception{}; class base: public std::exception{};
#define TRITON_CREATE_CUDA_EXCEPTION(name, msg) class name: public base { public:const char * what() const throw(){ return "CUDA: Error- " msg; } } #define TRITON_CREATE_CUDA_EXCEPTION(name, msg) \
class name: public base { public:const char * what() const throw() override { return "CUDA: Error- " msg; } }
TRITON_CREATE_CUDA_EXCEPTION(invalid_value ,"invalid value"); TRITON_CREATE_CUDA_EXCEPTION(invalid_value ,"invalid value");
@@ -106,7 +108,8 @@ namespace triton
{ {
class base: public std::exception{}; class base: public std::exception{};
#define TRITON_CREATE_CUBLAS_EXCEPTION(name, msg) class name: public base { public: const char * what() const throw(){ return "CUBLAS: Error- " msg; } } #define TRITON_CREATE_CUBLAS_EXCEPTION(name, msg) \
class name: public base { public: const char * what() const throw() override { return "CUBLAS: Error- " msg; } }
TRITON_CREATE_CUBLAS_EXCEPTION(not_initialized ,"not initialized"); TRITON_CREATE_CUBLAS_EXCEPTION(not_initialized ,"not initialized");
TRITON_CREATE_CUBLAS_EXCEPTION(alloc_failed ,"alloc failed"); TRITON_CREATE_CUBLAS_EXCEPTION(alloc_failed ,"alloc failed");
@@ -124,7 +127,8 @@ namespace triton
namespace cudnn namespace cudnn
{ {
#define TRITON_CREATE_CUDNN_EXCEPTION(name, msg) class name: public std::exception { public: const char * what() const throw(){ return "CUDNN: Error- " msg; } } #define TRITON_CREATE_CUDNN_EXCEPTION(name, msg) \
class name: public std::exception { public: const char * what() const throw() override { return "CUDNN: Error- " msg; } }
TRITON_CREATE_CUDNN_EXCEPTION(not_initialized ,"not initialized"); TRITON_CREATE_CUDNN_EXCEPTION(not_initialized ,"not initialized");
TRITON_CREATE_CUDNN_EXCEPTION(alloc_failed ,"allocation failed"); TRITON_CREATE_CUDNN_EXCEPTION(alloc_failed ,"allocation failed");
@@ -148,7 +152,8 @@ namespace triton
{ {
class base: public std::exception{}; class base: public std::exception{};
#define TRITON_CREATE_HIP_EXCEPTION(name, msg) class name: public base { public:const char * what() const throw(){ return "HIP: Error- " msg; } } #define TRITON_CREATE_HIP_EXCEPTION(name, msg) \
class name: public base { public:const char * what() const throw() override { return "HIP: Error- " msg; } }
TRITON_CREATE_HIP_EXCEPTION(invalid_value ,"invalid value"); TRITON_CREATE_HIP_EXCEPTION(invalid_value ,"invalid value");

View File

@@ -1,4 +1,3 @@
# add_subdirectory(codegen) # add_subdirectory(codegen)
add_subdirectory(driver) add_subdirectory(driver)
add_subdirectory(ir) add_subdirectory(Dialect)
# add_subdirectory(transforms)

View File

@@ -0,0 +1 @@
add_subdirectory(Triton)

View File

@@ -1,5 +1,5 @@
#include "triton/ir/Dialect.h" #include "triton/Dialect/Triton/Dialect.h"
#include "triton/ir/Types.h" #include "triton/Dialect/Triton/Types.h"
#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/TypeSwitch.h" #include "llvm/ADT/TypeSwitch.h"
@@ -8,7 +8,7 @@
#include "mlir/IR/DialectImplementation.h" #include "mlir/IR/DialectImplementation.h"
#include "triton/ir/Dialect.cpp.inc" #include "triton/Dialect/Triton/Dialect.cpp.inc"
using namespace mlir; using namespace mlir;
using namespace mlir::triton; using namespace mlir::triton;
@@ -18,7 +18,7 @@ void TritonDialect::initialize() {
addOperations< addOperations<
#define GET_OP_LIST #define GET_OP_LIST
#include "triton/ir/Ops.cpp.inc" #include "triton/Dialect/Triton/Ops.cpp.inc"
>(); >();
// We can also add interface here. // We can also add interface here.

View File

@@ -1,5 +1,5 @@
#include "triton/ir/Dialect.h" #include "triton/Dialect/Triton/Dialect.h"
#include "triton/ir/Types.h" #include "triton/Dialect/Triton/Types.h"
#include "mlir/IR/Builders.h" #include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/BuiltinAttributes.h"
@@ -38,10 +38,10 @@ static Type getPointerTypeFromTensor(Type type) {
} }
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "triton/ir/Ops.cpp.inc" #include "triton/Dialect/Triton/Ops.cpp.inc"
// enum attribute definitions // enum attribute definitions
#include "triton/ir/OpsEnums.cpp.inc" #include "triton/Dialect/Triton/OpsEnums.cpp.inc"
namespace mlir { namespace mlir {
namespace triton { namespace triton {

View File

@@ -1,5 +1,5 @@
#include "triton/ir/Dialect.h" #include "triton/Dialect/Triton/Dialect.h"
#include "triton/ir/Types.h" #include "triton/Dialect/Triton/Types.h"
#include "mlir/IR/DialectImplementation.h" // required by `Types.cpp.inc` #include "mlir/IR/DialectImplementation.h" // required by `Types.cpp.inc`
#include "llvm/ADT/TypeSwitch.h" // required by `Types.cpp.inc` #include "llvm/ADT/TypeSwitch.h" // required by `Types.cpp.inc`
@@ -7,7 +7,7 @@ using namespace mlir;
using namespace mlir::triton; using namespace mlir::triton;
#define GET_TYPEDEF_CLASSES #define GET_TYPEDEF_CLASSES
#include "triton/ir/Types.cpp.inc" #include "triton/Dialect/Triton/Types.cpp.inc"
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Triton Dialect // Triton Dialect
@@ -15,7 +15,7 @@ using namespace mlir::triton;
void TritonDialect::registerTypes() { void TritonDialect::registerTypes() {
addTypes< addTypes<
#define GET_TYPEDEF_LIST #define GET_TYPEDEF_LIST
#include "triton/ir/Types.cpp.inc" #include "triton/Dialect/Triton/Types.cpp.inc"
>(); >();
} }

View File

@@ -12,8 +12,8 @@
#include "mlir/Transforms/Passes.h" #include "mlir/Transforms/Passes.h"
#include "triton/ir/Dialect.h" #include "triton/Dialect/Triton/Dialect.h"
#include "triton/ir/Types.h" #include "triton/Dialect/Triton/Types.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/LegacyPassManager.h"