Skip to content
Snippets Groups Projects
Commit a9296ae7 authored by Prakalp Srivastava's avatar Prakalp Srivastava
Browse files

Modified file to provide mapping provided by kernel object to get arguments from

parent instead of getInValAt() function
parent e7c3ae27
No related branches found
No related tags found
No related merge requests found
......@@ -54,9 +54,10 @@ public:
// calls
class Kernel {
public:
Kernel(Function* _KF, std::vector<unsigned>* _inArgMap = NULL,
unsigned _gridDim = 0, std::vector<Value*>
_globalWGSize = std::vector<Value*>(), unsigned _blockDim = 0,
Kernel(Function* _KF, std::vector<unsigned> _inArgMap =
std::vector<unsigned>(), unsigned _gridDim = 0, std::vector<Value*>
_globalWGSize = std::vector<Value*>(),
unsigned _blockDim = 0,
std::vector<Value*> _localWGSize = std::vector<Value*>())
: KernelFunction(_KF), inArgMap(_inArgMap),
gridDim(_gridDim), globalWGSize(_globalWGSize),
......@@ -69,11 +70,15 @@ public:
}
Function* KernelFunction;
std::vector<unsigned>* inArgMap;
std::vector<unsigned> inArgMap;
unsigned gridDim;
unsigned blockDim;
std::vector<Value*> globalWGSize;
std::vector<Value*> localWGSize;
std::vector<unsigned> getInArgMap() {
return inArgMap;
}
};
// Helper function declarations
......@@ -469,7 +474,11 @@ void CodeGenTraversal::insertRuntimeCalls(DFInternalNode* N, const Twine& FileNa
std::vector<OutputPtr> OutputPointers;
for(unsigned i=0; i<CF->getFunctionType()->getNumParams(); i++) {
Value* inputVal = getInValueAt(C, i, F_X86, RI);
// The kernel object gives us the mapping of arguments from kernel launch
// node function (F_X86) to kernel (kernel->KF)
Value* inputVal = getArgumentAt(F_X86, kernel->getInArgMap()[i]);
DEBUG(errs() << "\tArgument "<< i<< " = " << *inputVal << "\n");
// input value has been obtained.
// Check if input is a scalar value or a pointer operand
// For scalar values such as int, float, etc. the size is simply the size of
......@@ -484,10 +493,10 @@ void CodeGenTraversal::insertRuntimeCalls(DFInternalNode* N, const Twine& FileNa
Argument* A = getArgumentAt(CF, i);
if(isOutput == True) {
errs() << *A << " is an OUTPUT argument\n";
DEBUG(errs() << *A << " is an OUTPUT argument\n");
}
if(isInput == True) {
errs() << *A << " is an INPUT argument\n";
DEBUG(errs() << *A << " is an INPUT argument\n");
}
......@@ -495,7 +504,7 @@ void CodeGenTraversal::insertRuntimeCalls(DFInternalNode* N, const Twine& FileNa
Type::getInt8PtrTy(M.getContext()),
inputVal->getName()+".i8ptr",
RI);
Value* inputSize = getInValueAt(C, i+1, F_X86, RI);
Value* inputSize = getArgumentAt(F_X86, kernel->getInArgMap()[i+1]);
assert(inputSize->getType() == Type::getInt64Ty(M.getContext())
&& "Pointer type input must always be followed by size (integer type)");
Value* setInputArgs[] = {GraphID,
......@@ -551,9 +560,9 @@ void CodeGenTraversal::insertRuntimeCalls(DFInternalNode* N, const Twine& FileNa
};
d_Output = CallInst::Create(llvm_visc_ptx_argument_ptr,
ArrayRef<Value*>(setOutputArgs, 6),
"d_output."+CF->getName(),
RI);
ArrayRef<Value*>(setOutputArgs, 6),
"d_output."+CF->getName(),
RI);
}
// Enqueue kernel
......@@ -601,9 +610,10 @@ void CodeGenTraversal::insertRuntimeCalls(DFInternalNode* N, const Twine& FileNa
// Read all the pointer arguments which had side effects i.e., had out
// attribute
for(auto output: OutputPointers) {
errs() << "Read: " << *output.d_ptr << "\n";
errs() << "\t To: " << *output.h_ptr << "\n";
errs() << "\t #bytes: " << *output.bytes << "\n";
DEBUG(errs() << "Read: " << *output.d_ptr << "\n");
DEBUG(errs() << "\tTo: " << *output.h_ptr << "\n");
DEBUG(errs() << "\t#bytes: " << *output.bytes << "\n");
Value* GetOutputArgs[] = {GraphID, output.h_ptr, output.d_ptr, output.bytes};
CallInst* CI = CallInst::Create(llvm_visc_ptx_getOutput,
ArrayRef<Value*>(GetOutputArgs, 4),
......@@ -688,14 +698,13 @@ void CodeGenTraversal::codeGen(DFInternalNode* N) {
DEBUG(errs() << "Found intermediate node. Getting size parameters.\n");
// Keep track of the arguments order.
std::vector<unsigned>* map1 = N->getInArgMap();
std::vector<unsigned>* map2 = kernel->getInArgMap();
std::vector<unsigned> map1 = N->getInArgMap();
std::vector<unsigned> map2 = kernel->getInArgMap();
// The limit is the size of map2, because this is the number of kernel arguments
for (unsigned i = 0; i < map2.size(); i++) {
map2[i] = map1[map2[i]];
}
free(map1);
}
......
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