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

Changed the order of code generation to postorder (leaves first, parent after children).

Added a (simple, to be reconsidered) way of finding a kernel.
parent 53a18742
No related branches found
No related tags found
No related merge requests found
......@@ -66,14 +66,16 @@ namespace {
CodeGenTraversal(Module &_M, BuildDFG &_DFG) : M(_M), DFG(_DFG) { }
virtual void visit(DFInternalNode* N) {
DEBUG(errs() << "Generating Code for Node (I) - " << N->getFuncPointer()->getName() << "\n");
codeGen(N);
DEBUG(errs() << "DONE" << "\n");
for(DFGraph::children_iterator i = N->getChildGraph()->begin(),
e = N->getChildGraph()->end(); i != e; ++i) {
DFNode* child = *i;
child->applyDFNodeVisitor(*this);
}
DEBUG(errs() << "Generating Code for Node (I) - " << N->getFuncPointer()->getName() << "\n");
codeGen(N);
DEBUG(errs() << "DONE" << "\n");
}
virtual void visit(DFLeafNode* N) {
......@@ -210,11 +212,12 @@ namespace {
// The following is to find which function to call
Function * OpenCLFunction;
int parentLevel = ParentDFNode->getLevel();
int parentReplFactor = ParentDFNode->getNumOfDim();
if (!parentLevel) {
// We only have one level in the hierarchy, but still need to
// specify a global id
assert((dim != 2) && "Invalid dimension argument");
if (!parentLevel || !parentReplFactor) {
// We only have one level in the hierarchy or the parent node is not
// replicated. This indicates that the parent node is the kernel
// launch, so we need to specify a global id
FunctionType* FT =
FunctionType::get(Type::getInt32Ty(getGlobalContext()),
......@@ -284,10 +287,12 @@ namespace {
// The following is to find which function to call
Function * OpenCLFunction;
int parentLevel = ParentDFNode->getLevel();
int parentReplFactor = ParentDFNode->getNumOfDim();
if (!parentLevel) {
// We only have one level in the hierarchy, thus the node
// instances are global_size (gridDim x blockDim)
if (!parentLevel || !parentReplFactor) {
// We only have one level in the hierarchy or the parent node is not
// replicated. This indicates that the parent node is the kernel
// launch, so the instances are global_size (gridDim x blockDim)
FunctionType* FT =
FunctionType::get(Type::getInt32Ty(getGlobalContext()),
std::vector<Type*>(1, Type::getInt32Ty(getGlobalContext())),
......
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