Skip to content
Closed
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
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_subdirectory(triton)
add_subdirectory(triton)
27 changes: 27 additions & 0 deletions include/flagtree/Common/UnifiedHardwareBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef UNIFIED_HARDWARE_BASE_H
#define UNIFIED_HARDWARE_BASE_H

#include <optional>

namespace mlir {
namespace flagtree {
//this is the unified hardware abstraction for hardware
//to determined if these abstraction is specified, using std::optional is needed
//using in passes: if(uh_flagtree->xxx()){...}

class UnifiedHardware{

public:
virtual ~UnifiedHardware() = default;

//DMA
virtual std::optional<int> getAllocSpaceForDMATag() const {
return std::nullopt;
}

};

} // namespace flagtree
} // namespace mlir

#endif // UNIFIED_HARDWARE_BASE_H
1 change: 1 addition & 0 deletions include/triton/Dialect/Triton/IR/TritonAttrDefs.td
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
include "mlir/IR/EnumAttr.td"
include "mlir/IR/AttrTypeBase.td"


// Attributes for LoadOp and StoreOp
def TT_CacheModifierAttr : I32EnumAttr<
"CacheModifier", "",
Expand Down
17 changes: 17 additions & 0 deletions third_party/aipu/backend/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
from mlir.passmanager import PassManager
from mlir.ir import Context, Module

from triton._C.libtriton.aipu import UnifiedHardwareAIPU

from dataclasses import dataclass
import functools
import hashlib
from typing import Any, Dict, Tuple
from types import ModuleType



def min_dot_size(target: GPUTarget):
return lambda lhsType, rhsType: (1, 1, 1)

Expand Down Expand Up @@ -80,6 +83,7 @@ def load_dialects(self, ctx):

@staticmethod
def make_ttir(mod, metadata, opt):

pm = ir.pass_manager(mod.context)
pm.enable_debug()
passes.common.add_inliner(pm)
Expand All @@ -96,6 +100,19 @@ def make_ttir(mod, metadata, opt):

@staticmethod
def make_linalg(mod, metadata, opt):

import ctypes
uh_aipu = UnifiedHardwareAIPU()
obj_ptr = id(uh_aipu)
uh_aipu_ptr = ctypes.cast(obj_ptr, ctypes.c_void_p)


from mlir.ir import IntegerAttr, IntegerType
ctx = Context()
ptr_type = IntegerType.get_unsigned(64, ctx)
ptr_attr = IntegerAttr.get(ptr_type, uh_aipu_ptr.value)
# mod.set_attr("uh_aipu_ptr", ptr_attr) #报错

pm = ir.pass_manager(mod.context)
pm.enable_debug()
# add pass here
Expand Down
8 changes: 8 additions & 0 deletions third_party/aipu/triton_aipu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "triton-shared/Conversion/TritonToLinalg/TritonToLinalg.h"
#include "triton-shared/Conversion/TritonToLinalgExperimental/TritonToLinalgExperimental.h"

#include "unified_hardware_aipu.h"

#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
Expand Down Expand Up @@ -69,6 +71,7 @@ void init_triton_aipu(py::module &&m) {
init_triton_aipu_common(m.def_submodule("common"));
auto passes = m.def_submodule("passes");
init_triton_aipu_passes_convert(passes.def_submodule("convert"));

// load dialects
m.def("load_dialects", [](mlir::MLIRContext &context) {
using namespace mlir;
Expand All @@ -88,4 +91,9 @@ void init_triton_aipu(py::module &&m) {
context.loadAllAvailableDialects();
});
// register passes here

//flagtree
py::class_<mlir::aipu::UnifiedHardwareAIPU>(m, "UnifiedHardwareAIPU")
.def(py::init<>());

}
22 changes: 22 additions & 0 deletions third_party/aipu/unified_hardware_aipu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef UNIFIED_HARDWARE_AIPU_H
#define UNIFIED_HARDWARE_AIPU_H

#include <optional>

#include "flagtree/Common/UnifiedHardwareBase.h"

namespace mlir {
namespace aipu {

class UnifiedHardwareAIPU final : public mlir::flagtree::UnifiedHardware {

//DMA
std::optional<int> getAllocSpaceForDMATag() const override{
return std::optional<int>(11);
}
};

} // namespace aipu
} // namespace mlir

#endif // UNIFIED_HARDWARE_AIPU_H
Loading