Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Code of Conduct file #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
80 changes: 80 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

This Code of Conduct also applies outside the project spaces when there is a
reasonable belief that an individual's behavior may have a negative impact on
the project or its community.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at <[email protected]>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ void populatePrintOpToLLVMPattern(LLVMTypeConverter &typeConverter,
const TargetInfoBase &targetInfo,
PatternBenefit benefit);

void populateRegReallocOpToLLVMPatterns(LLVMTypeConverter &typeConverter,
RewritePatternSet &patterns,
PatternBenefit benefit);

} // namespace triton
} // namespace mlir

Expand Down
42 changes: 42 additions & 0 deletions include/triton/Conversion/TritonGPUToLLVM/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "triton/Dialect/TritonGPU/IR/Dialect.h"
#include "triton/Dialect/TritonGPU/IR/LinearLayoutConversions.h"
#include "triton/Dialect/TritonNvidiaGPU/IR/Dialect.h"
#include "triton/Dialect/TritonNvidiaGPU/Transforms/Utility.h"
#include "triton/Tools/LinearLayout.h"
#include "triton/Tools/StrUtil.h"
#include "triton/Tools/Sys/GetEnv.hpp"
Expand Down Expand Up @@ -144,6 +145,20 @@ using namespace mlir::triton;
namespace mlir {
namespace triton {

static inline void insertBarrier(PatternRewriter &rewriter, Operation *op) {
auto barrierOp = rewriter.create<mlir::gpu::BarrierOp>(op->getLoc());
auto asyncTaskIds = getAsyncTaskIds(op);
if (asyncTaskIds.size() == 1) {
int asyncTaskId = asyncTaskIds[0];
int barId = asyncTaskId + nameBarrierIdBegin;
assert(barId < nameBarrierIdEnd);
// TODO: Change hard code style of numThreads.
const int numThreads = 128;
barrierOp->setAttr("bar_id", rewriter.getI64IntegerAttr(barId));
barrierOp->setAttr("num_threads", rewriter.getI64IntegerAttr(numThreads));
}
}

// Delinearize supposing order is [0, 1, .. , n]
template <typename T>
llvm::SmallVector<T> getMultiDimIndexImpl(T linearIndex,
Expand Down Expand Up @@ -371,6 +386,20 @@ inline Value getStackPointer(RewriterBase &rewriter,
return funcOp.getArgument(funcOp.getNumArguments() - 1);
}

static Operation *getWarpGroupId(Operation *op) {
auto funcOp = op->getParentOfType<FunctionOpInterface>();
Operation *getWarpId = nullptr;
funcOp.walk([&](Operation *op) -> void {
if (isa<mlir::triton::nvidia_gpu::GetCanonicalWarpIdOp>(op)) {
assert(getWarpId == nullptr);
getWarpId = op;
}
});
assert(getWarpId);
getWarpId->dump();
return getWarpId;
}

inline Value getSharedMemoryBase(Location loc, RewriterBase &rewriter,
Operation *op) {
auto ptrTy = LLVM::LLVMPointerType::get(rewriter.getContext(), 3);
Expand All @@ -381,6 +410,19 @@ inline Value getSharedMemoryBase(Location loc, RewriterBase &rewriter,
.getValue()
.getZExtValue();
Value offVal = i32_val(offset);
if (op->hasAttr("allocation.copy")) {
auto copy = cast<IntegerAttr>(op->getAttr("allocation.copy")).getValue().getZExtValue();
if (copy != 1) {
Operation *getWarpId = getWarpGroupId(op);
Value warpsPerWG = i32_val(4);
Value wgId = udiv(getWarpId->getResult(0), warpsPerWG);
// (wgId - 1) * allocation.size + offset
auto singleSize = cast<IntegerAttr>(op->getAttr("allocation.size")).getValue().getZExtValue();
Value sub1 = sub(wgId, i32_val(1));
Value temp = mul(sub1, i32_val(singleSize));
offVal = add(temp, offVal);
}
}
Value base = gep(ptrTy, i8_ty, LLVM::getStackPointer(rewriter, func), offVal);
return base;
}
Expand Down
105 changes: 105 additions & 0 deletions include/triton/Dialect/TritonGPU/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,109 @@ def TritonGPUOptimizeAccumulatorInit: Pass<"tritongpu-optimize-accumulator-init"
"mlir::triton::TritonDialect"];
}

def TritonGPUTaskIdPropagate : Pass<"triton-gpu-taskid-propagate", "mlir::ModuleOp"> {
let summary = "Propagate async_task_id annotations based on dependencies";

let description = [{
This pass propagates the `async_task_id` annotation to the dependencies
of any op that has it set. This has the functional effect of partitioning
the graph into multiple async tasks, based on the initial annotation.
}];

let dependentDialects = [
"mlir::triton::gpu::TritonGPUDialect",
"mlir::triton::nvidia_gpu::TritonNvidiaGPUDialect"
];

let options = [
Option<"numConsumerGroups", "num-consumer-groups",
"int32_t", /*default*/"0",
"number of consumer warp groups for warp specialization">
];
}

def TritonGPUWSCodePartition: Pass<"tritongpu-warp-spec-code-partition", "mlir::ModuleOp"> {
let summary = "TritonGPU warp specialization code partition";

let description = "This pass generates warp specialized code baed on task id attributes.";

let dependentDialects = ["mlir::triton::gpu::TritonGPUDialect",
"mlir::triton::TritonDialect",
"mlir::triton::nvidia_gpu::TritonNvidiaGPUDialect"];
let options = [
Option<"numBuffers", "num-buffers",
"int32_t", /*default*/"0",
"number of buffering for producer-consumer">,
Option<"numConsumerGroups", "num-consumer-groups",
"int32_t", /*default*/"0",
"number of consumer warp groups for warp specialization">,
Option<"regDecProducer", "producer-reg-dec",
"int32_t", /*default*/"40",
"register decrement for producer warp group">,
Option<"regIncConsumer", "consumer-reg-inc",
"int32_t", /*default*/"232",
"register indrement for consumer warp group">
];
}

def TritonGPUWSDataPartition : Pass<"tritongpu-warp-spec-data-partition", "mlir::ModuleOp"> {
let summary = "Warp specialization data partition";

let description = "This pass partitions operations into multiple suboperations which operate on smaller data shapes";

let dependentDialects = ["mlir::triton::gpu::TritonGPUDialect",
"mlir::triton::nvidia_gpu::TritonNvidiaGPUDialect"];
let options = [
Option<"numConsumerGroups", "num-consumer-groups",
"int32_t", /*default*/"0",
"number of consumer warp groups for warp specialization">
];
}

def TritonGPUWSLowering : Pass<"tritongpu-warp-spec-lowering", "mlir::ModuleOp"> {
let summary = "Warp specialization lowering";

let description = "This pass lowers warp specializtion related operations.";

let dependentDialects = ["mlir::triton::gpu::TritonGPUDialect",
"mlir::triton::nvidia_gpu::TritonNvidiaGPUDialect"];
let options = [
Option<"numConsumerGroups", "num-consumer-groups",
"int32_t", /*default*/"0",
"number of consumer warp groups for warp specialization">
];
}

def TritonGPUPingPongSync: Pass<"tritongpu-ping-pong-sync", "mlir::ModuleOp"> {
let summary = "TritonGPU experiemental ping pong schedule";

let description = "This pass generates warp specialized code baed on warp group id attributes.";

let dependentDialects = ["mlir::triton::gpu::TritonGPUDialect",
"mlir::triton::TritonDialect"];
let options = [
Option<"numConsumerGroups", "num-consumer-groups",
"int32_t", /*default*/"0",
"number of consumer warp groups for warp specialization">,
Option<"partitionStyle", "partition-style",
"int32_t", /*default*/"0",
"partition style for multiple consumer warp groups">
];
}

// #ifdef __FACEBOOK__
def TritonGPULoopScheduling: Pass<"tritongpu-loop-scheduling", "mlir::ModuleOp"> {
let summary = "Generate loop scheduling for SWP";

let description = "This pass sets up stages and clustering for software pipelining.";

let dependentDialects = ["mlir::triton::gpu::TritonGPUDialect",
"mlir::triton::TritonDialect"];
let options = [
Option<"numStages", "num-stages",
"int32_t", /*default*/"3",
"number of pipeline stages">
];
}
// #endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ void addOps(scf::ForOp forOp, int stage,
/// mutable.
void replaceUsesAndPropagateType(OpBuilder &builder, Operation *oldUse,
Value val);

// Begin __FACEBOOK__ CompPipe
/// Create a map from load ops to their indirection level and the
/// final use of the load op (another load op, or a dot op).
/// Indirection level is "0" for the load op directly used by the dot op,
/// "1" for the load op used by the load op used by the dot op, and so on.
llvm::SmallVector<std::tuple<Operation *, int, Operation *>>
loadOpsToIndirectionLevelAndUse(scf::ForOp forOp);
// End __FACEBOOK__ CompPipe
} // namespace triton
} // namespace mlir

Expand Down
6 changes: 4 additions & 2 deletions include/triton/Dialect/TritonGPU/Transforms/Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ class CoarseSchedule {
return true;
}

void insertDepsOfOp(Operation *op, int stage, CoarseSchedule::Cluster cluster,
bool includeArg);
void
insertDepsOfOp(Operation *op, int stage, CoarseSchedule::Cluster cluster,
bool includeArg,
DenseMap<Operation *, Operation *> *additionalDep = nullptr);

void erase(Operation *op) { opToStageAndCluster.erase(op); }

Expand Down
Loading