void genParams(std::stringstream &kerStream, int id, bool is_linear)
 {
     auto node_ptr = m_buffer_node.get();
     dynamic_cast<BufferNode<T> *>(node_ptr)->genParams(kerStream, id, is_linear);
     for (int i = 0; i < 4; i++) {
         kerStream << "int shift" << id << "_" << i << ",\n";
     }
 }
 void setArgs(std::vector<void *> &args, bool is_linear)
 {
     auto node_ptr = m_buffer_node.get();
     dynamic_cast<BufferNode<T> *>(node_ptr)->setArgs(args, is_linear);
     for (int i = 0; i < 4; i++) {
         const int &d = m_shifts[i];
         args.push_back((void *)&d);
     }
 }
Esempio n. 3
0
    Array<T> createNodeArray(const dim4 &dims, Node_ptr node)
    {
        Array<T> out =  Array<T>(dims, node);

        unsigned length =0, buf_count = 0, bytes = 0;

        Node *n = node.get();
        n->getInfo(length, buf_count, bytes);
        n->resetFlags();

        if (length > MAX_JIT_LEN ||
            buf_count >= MAX_BUFFERS ||
            bytes >= MAX_BYTES) {
            out.eval();
        }

        return out;
    }
Esempio n. 4
0
    Array<T> createNodeArray(const dim4 &dims, Node_ptr node)
    {
        verifyDoubleSupport<T>();

        Array<T> out =  Array<T>(dims, node);

        unsigned length =0, buf_count = 0, bytes = 0;

        Node *n = node.get();
        n->getInfo(length, buf_count, bytes);
        n->resetFlags();

        if (length > getMaxJitSize() ||
            buf_count >= getMaxBuffers() ||
            bytes >= getMaxBytes()) {
            out.eval();
        }

        return out;
    }
Esempio n. 5
0
    Array<T> createNodeArray(const dim4 &dims, Node_ptr node)
    {
        Array<T> out =  Array<T>(dims, node);

        if (evalFlag()) {

            if (node->getHeight() >= (int)getMaxJitSize()) {
                out.eval();
            } else {
                size_t alloc_bytes, alloc_buffers;
                size_t lock_bytes, lock_buffers;

                deviceMemoryInfo(&alloc_bytes, &alloc_buffers,
                                 &lock_bytes, &lock_buffers);

                // Check if approaching the memory limit
                if (lock_bytes > getMaxBytes() ||
                    lock_buffers > getMaxBuffers()) {

                    unsigned length =0, buf_count = 0, bytes = 0;
                    Node *n = node.get();
                    JIT::Node_map_t nodes_map;
                    std::vector<JIT::Node *> full_nodes;
                    std::vector<JIT::Node_ids> full_ids;
                    n->getNodesMap(nodes_map, full_nodes, full_ids);

                    for(auto &jit_node : full_nodes) {
                        jit_node->getInfo(length, buf_count, bytes);
                    }

                    if (2 * bytes > lock_bytes) {
                        out.eval();
                    }
                }
            }
        }

        return out;
    }
Esempio n. 6
0
// this finds consequetive sequences of instructions.
void Node::CreateList(Instruction_list& instructions, Node_list& nodes)/*{{{*/
{
	Instruction_list::iterator cur = instructions.begin();

	if (instructions.end() == cur)
		return;

	Instruction_list::iterator begin = cur++;

	while (cur != instructions.end())
	{
		Node_ptr node;
		Instruction_ptr instruction = *cur;

//		message("%p\n", instruction->Address());

		switch (instruction->Type())
		{
			case Instruction::CONDITIONAL_JUMP:
				cur++;
				node = ConditionalJumpNode::CreateFrom(instruction, 
						instructions.end() == cur ? INVALID_ADDR : (**cur).Address(),
						begin, cur);
				begin = cur;
				break;

			case Instruction::JUMP:
				cur++;
				node = JumpNode::CreateFrom(instruction, begin, cur);
				begin = cur;
				break;

			case Instruction::LABEL:
			case Instruction::CASE:
				if (begin != cur)
				{
					node.reset( new FallThroughNode(instruction->Address(), begin, cur) );
					begin = cur; 
				}
				cur++;	// yes, increase after node creation, not before 
				break;

			case Instruction::RETURN:
				cur++;
				node.reset( new ReturnNode(begin, cur) );
				begin = cur;
				break;
/*
 * TODO: currently call's are in the instruction list as:
 *     AssignmentInstruction(CallExpression())
			case Instruction::CALL:
                cur++;
                node.reset( new CallNode(instruction->Address(), instruction->.., begin, cur) );
                begin = cur;
                break;
*/
/*
			case Instruction::SWITCH:
                cur++;
                node.reset( new N_WayNode(GetSwitchExpression(), begin, cur) );
                begin = cur;
                break;
*/
			default:
				cur++;
				break;
		}

		if (node.get())
		{
			nodes.push_back(node);
		}
	}

	ConnectSuccessors(nodes);
}/*}}}*/
Esempio n. 7
0
 UnaryNode(Node_ptr child) :
     TNode<To>(0, child->getHeight() + 1, {{child}}),
     m_child(reinterpret_cast<TNode<Ti> *>(child.get()))
 {
 }
 void setData(Param<T> param, std::shared_ptr<T> data, const unsigned bytes, bool is_linear)
 {
     auto node_ptr = m_buffer_node.get();
     dynamic_cast<BufferNode<T> *>(node_ptr)->setData(param, data, bytes, is_linear);
 }
 void getInfo(unsigned &len, unsigned &buf_count, unsigned &bytes)
 {
     auto node_ptr = m_buffer_node.get();
     dynamic_cast<BufferNode<T> *>(node_ptr)->getInfo(len, buf_count, bytes);
 }
Esempio n. 10
0
 void operator() (Node_ptr item)
 {
     os << *item.get();
 }