Skip to content
Snippets Groups Projects
Commit 17ac2769 authored by kotsifa2's avatar kotsifa2
Browse files

Edit generated runtime calls to tensor runtime, according to required

signatures.
parent f8685646
No related branches found
No related tags found
No related merge requests found
...@@ -56,9 +56,9 @@ private: ...@@ -56,9 +56,9 @@ private:
InPlaceDFGAnalysis::InPlaceDFGParameter *IPP; InPlaceDFGAnalysis::InPlaceDFGParameter *IPP;
// VISC Runtime API and Tensor runtime API // VISC Runtime API and Tensor runtime API
Constant* llvm_visc_initTensorRt; // FIXME: sync names Constant* llvm_hpvm_initTensorRt; // FIXME: sync names
Constant* llvm_visc_cleanupTensorRt; // FIXME: add function Constant* llvm_hpvm_cleanupTensorRt; // FIXME: add function
Constant* llvm_visc_requestTensor; // FIXME: add function Constant* hpvm_request_tensor; // FIXME: add function
// Functions // Functions
...@@ -105,9 +105,9 @@ void CGT_CUDNN::initRuntimeAPI() { ...@@ -105,9 +105,9 @@ void CGT_CUDNN::initRuntimeAPI() {
// - initialization // - initialization
// - cleanup // - cleanup
// - request a tensor // - request a tensor
DECLARE(llvm_visc_initTensorRt); DECLARE(llvm_hpvm_initTensorRt);
DECLARE(llvm_visc_cleanupTensorRt); DECLARE(llvm_hpvm_cleanupTensorRt);
DECLARE(llvm_visc_requestTensor); DECLARE(hpvm_request_tensor);
// Find visc.init and visc.cleanup calls, and add placeholder methods // Find visc.init and visc.cleanup calls, and add placeholder methods
// for initialization and cleanup of the hpvm tensor runtime // for initialization and cleanup of the hpvm tensor runtime
...@@ -115,12 +115,12 @@ void CGT_CUDNN::initRuntimeAPI() { ...@@ -115,12 +115,12 @@ void CGT_CUDNN::initRuntimeAPI() {
Function* VI = M.getFunction("llvm.visc.init"); Function* VI = M.getFunction("llvm.visc.init");
assert(VI->getNumUses() == 1 && "__visc__init should only be used once\n"); assert(VI->getNumUses() == 1 && "__visc__init should only be used once\n");
InitCall = cast<Instruction>(*VI->user_begin()); InitCall = cast<Instruction>(*VI->user_begin());
CallInst::Create(llvm_visc_initTensorRt, ArrayRef<Value*>(), "", InitCall); CallInst::Create(llvm_hpvm_initTensorRt, ArrayRef<Value*>(), "", InitCall);
Function* VC = M.getFunction("llvm.visc.cleanup"); Function* VC = M.getFunction("llvm.visc.cleanup");
assert(VC->getNumUses() == 1 && "__visc__clear should only be used once\n"); assert(VC->getNumUses() == 1 && "__visc__clear should only be used once\n");
CleanupCall = cast<Instruction>(*VC->user_begin()); CleanupCall = cast<Instruction>(*VC->user_begin());
CallInst::Create(llvm_visc_cleanupTensorRt, ArrayRef<Value*>(), "", CleanupCall); CallInst::Create(llvm_hpvm_cleanupTensorRt, ArrayRef<Value*>(), "", CleanupCall);
} }
...@@ -178,15 +178,17 @@ void CGT_CUDNN::codeGen(DFLeafNode* N) { ...@@ -178,15 +178,17 @@ void CGT_CUDNN::codeGen(DFLeafNode* N) {
// This is the first instruction of the function, insert them before this // This is the first instruction of the function, insert them before this
Instruction* FI = &*(F_cudnn->getEntryBlock().begin()); Instruction* FI = &*(F_cudnn->getEntryBlock().begin());
// In this backend, the target device is GPU. // In this backend, the target device is GPU, represented by i32 1.
// Create an LLVM Value that represents the visc::GPU_TARGET FIXME ConstantInt *TargetDeviceID =
ConstantInt::get(Type::getInt32Ty(M.getContext()), -1);
for (Function::arg_iterator ai = F_cudnn->arg_begin(), for (Function::arg_iterator ai = F_cudnn->arg_begin(),
ae = F_cudnn->arg_end(); ai != ae; ++ai) { ae = F_cudnn->arg_end(); ai != ae; ++ai) {
Argument* Arg = &*ai; Argument* Arg = &*ai;
if (Arg->getType()->isPointerTy()) { if (Arg->getType()->isPointerTy()) {
CallInst::Create(llvm_visc_requestTensor, Value *Args[] = {Arg, TargetDeviceID};
ArrayRef<Value*>(Arg), // FIXME: add second argument CallInst::Create(hpvm_request_tensor,
ArrayRef<Value*>(Args, 2),
"", FI); "", FI);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment