forked from intel/graph-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Depend-intel#333] Convert a subset of GPU dialect ops to the GPU Ope…
…nCL runtime calls
- Loading branch information
1 parent
ce6d1d3
commit 7593767
Showing
9 changed files
with
703 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//===-- GpuOclRuntime.h - GPU OpenCL runtime --------------------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef GC_GPUOCLRUNTIME_H | ||
#define GC_GPUOCLRUNTIME_H | ||
|
||
namespace mlir::gc::gpu { | ||
constexpr char GPU_OCL_MALLOC[] = "gcGpuOclMalloc"; | ||
constexpr char GPU_OCL_DEALLOC[] = "gcGpuOclDealloc"; | ||
constexpr char GPU_OCL_MEMCPY[] = "gcGpuOclMemcpy"; | ||
constexpr char GPU_OCL_KERNEL_CREATE[] = "gcGpuOclKernelCreate"; | ||
constexpr char GPU_OCL_KERNEL_DESTROY[] = "gcGpuOclKernelDestroy"; | ||
constexpr char GPU_OCL_KERNEL_LAUNCH[] = "gcGpuOclKernelLaunch"; | ||
constexpr char GPU_OCL_MOD_DESTRUCTOR[] = "gcGpuOclModuleDestructor"; | ||
} // namespace mlir::gc::gpu | ||
|
||
#ifndef GC_GPU_OCL_CONST_ONLY | ||
|
||
// TBD | ||
|
||
#else | ||
#undef GC_GPU_OCL_CONST_ONLY | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//===-- AddContextArg.cpp - Add context argument ----------------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#include "mlir/Conversion/Passes.h" | ||
#include "mlir/Dialect/Func/IR/FuncOps.h" | ||
|
||
namespace mlir::gc { | ||
#define GEN_PASS_DECL_ADDCONTEXTARG | ||
#define GEN_PASS_DEF_ADDCONTEXTARG | ||
#include "gc/Transforms/Passes.h.inc" | ||
} // namespace mlir::gc | ||
|
||
using namespace mlir; | ||
|
||
namespace { | ||
struct AddContextArg final : gc::impl::AddContextArgBase<AddContextArg> { | ||
void runOnOperation() override { | ||
auto func = getOperation(); | ||
auto funcType = func.getFunctionType(); | ||
auto argTypes = llvm::to_vector<8>(funcType.getInputs()); | ||
auto resultTypes = llvm::to_vector<1>(funcType.getResults()); | ||
auto ctx = func->getContext(); | ||
auto newArgType = MemRefType::get({}, IntegerType::get(ctx, 8)); | ||
argTypes.emplace_back(newArgType); | ||
auto newFuncType = FunctionType::get(ctx, argTypes, resultTypes); | ||
func.setType(newFuncType); | ||
|
||
if (func.getBody().hasOneBlock()) { | ||
func.getBody().front().addArgument(newArgType, func.getLoc()); | ||
} | ||
|
||
// Find all function calls and append the last argument of the current | ||
// function to the call. | ||
func.walk([&](func::CallOp call) { | ||
auto args = llvm::to_vector<8>(call.getOperands()); | ||
args.emplace_back(func.getArgument(func.getNumArguments() - 1)); | ||
call->setOperands(args); | ||
}); | ||
} | ||
}; | ||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
gc_add_mlir_library(GcGpuPasses | ||
AddContextArg.cpp | ||
GpuToGpuOcl.cpp | ||
LinalgToXeGPU.cpp | ||
Pipeline.cpp | ||
|
||
|
Oops, something went wrong.