Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Add oneAPI DPC++ ESIMD extention as a new backend for T2S on GPU #21

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 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 .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Installation
downloads
install

.vscode
# T2S generated tmp
*.out
tmp.txt
Expand Down
2 changes: 2 additions & 0 deletions Halide/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ SOURCE_FILES = \
CanonicalizeGPUVars.cpp \
Closure.cpp \
CodeGen_ARM.cpp \
CodeGen_DPC_Dev.cpp \
CodeGen_C.cpp \
CodeGen_D3D12Compute_Dev.cpp \
CodeGen_GPU_Dev.cpp \
Expand Down Expand Up @@ -647,6 +648,7 @@ HEADER_FILES = \
CanonicalizeGPUVars.h \
Closure.h \
CodeGen_ARM.h \
CodeGen_DPC_Dev.h \
CodeGen_C.h \
CodeGen_D3D12Compute_Dev.h \
CodeGen_GPU_Dev.h \
Expand Down
1 change: 1 addition & 0 deletions Halide/performance
1 change: 1 addition & 0 deletions Halide/preprocessor
37 changes: 34 additions & 3 deletions Halide/src/CodeGen_CM_Dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,10 @@ void CodeGen_CM_Dev::CodeGen_CM_C::print_media_block_rw(Type t, vector<Expr> arg
for (int j = 0; j < cols; j += max_cols_at_once) {
int cols_at_once = j + max_cols_at_once <= cols ? max_cols_at_once : cols-j;

// Replace the buffer name with the one specified in stensors
string name = is_write ? args[7].as<StringImm>()->value : print_expr(args[0]);
stream << get_indent() << (is_write ? "write(" : "read(");
stream << print_name(print_expr(args[0])) << ", ";
stream << print_name(name) << ", ";
stream << print_expr(args[1] * bytes) << ", ";
stream << print_expr(args[2] + i) << ", ";
auto ramp = args[4].as<Ramp>();
Expand Down Expand Up @@ -683,6 +685,28 @@ void CodeGen_CM_Dev::add_kernel(Stmt s,
src_stream.str(str);
}

class FindRefName : public IRVisitor
{
const string &buf_name;
public:
using IRVisitor::visit;
string ref_name;

void visit(const Call *op) override {
if (op->is_intrinsic(Call::cm_store_2d)) {
internal_assert(op->args[0].as<Variable>());
auto &name = op->args[0].as<Variable>()->name;
if (name == buf_name && op->args.size() == 8) {
internal_assert(op->args[7].as<StringImm>());
ref_name = op->args[7].as<StringImm>()->value;
}
}
}

FindRefName(const string &_b)
: buf_name(_b) {}
};

void CodeGen_CM_Dev::CodeGen_CM_C::add_kernel(Stmt s,
const string &name,
const vector<DeviceArgument> &args) {
Expand All @@ -692,7 +716,14 @@ void CodeGen_CM_Dev::CodeGen_CM_C::add_kernel(Stmt s,
stream << "extern \"C\" _GENX_MAIN_ void " << name << "(\n";
for (size_t i = 0; i < args.size(); i++) {
if (args[i].is_buffer) {
stream << "SurfaceIndex " << print_name(args[i].name)
string name = args[i].name;
// Trick: replace the buffer name with the one specified in stensor
FindRefName frn(name);
s.accept(&frn);
if (!frn.ref_name.empty()) {
name = frn.ref_name;
}
stream << "SurfaceIndex " << print_name(name)
<< " [[type(\"image2d_t " << print_type(args[i].type) << "\")]]";
Allocation alloc;
alloc.type = args[i].type;
Expand Down Expand Up @@ -760,4 +791,4 @@ vector<char> CodeGen_CM_Dev::compile_to_src() {
}

} // namespace Internal
} // namespace Halide
} // namespace Halide
Loading