Esempio n. 1
0
 void genOffsets(std::stringstream &kerStream, bool is_linear)
 {
     if (m_gen_offset) return;
     if (!(m_lhs->isGenOffset())) m_lhs->genOffsets(kerStream, is_linear);
     if (!(m_rhs->isGenOffset())) m_rhs->genOffsets(kerStream, is_linear);
     m_gen_offset = true;
 }
Esempio n. 2
0
/* Live register analysis {{{ */
void Node::LiveRegisterAnalysis(Node_list& nodes)
{
	bool changed;

	do
	{
//		message(".");
		changed = false;

		for (Node_list::reverse_iterator item = nodes.rbegin();
				item != nodes.rend();
				item++)
		{
			Node_ptr node = *item;
			
			BoolArray prev_live_in = node->mLiveIn;
			BoolArray prev_live_out = node->mLiveOut;
			
			for (int i = 0; i < node->SuccessorCount(); i++)
			{
				if (node->Successor(i).get())
					node->mLiveOut |= node->Successor(i)->mLiveIn;
			}

			node->mLiveIn = node->Uses() | (node->mLiveOut & ~node->Definitions());

			if ((prev_live_in != node->mLiveIn) || (prev_live_out != node->mLiveOut))
				changed = true;
		}
	
	} while (changed);
}/*}}}*/
Esempio n. 3
0
        void genFuncs(std::stringstream &kerStream, str_map_t &declStrs)
        {
            if (m_gen_func) return;

            if (!(m_lhs->isGenFunc())) m_lhs->genFuncs(kerStream, declStrs);
            if (!(m_rhs->isGenFunc())) m_rhs->genFuncs(kerStream, declStrs);

            std::stringstream declStream;
            declStream << "declare " << m_type_str << " " << m_op_str
                       << "(" << m_lhs->getTypeStr() << " , " << m_rhs->getTypeStr() << ")\n";

            str_map_iter loc = declStrs.find(declStream.str());
            if (loc == declStrs.end()) {
                declStrs[declStream.str()] = true;
            }

            kerStream << "%val" << m_id << " = call "
                      << m_type_str << " "
                      << m_op_str << "("
                      << m_lhs->getTypeStr() << " "
                      << "%val" << m_lhs->getId() << ", "
                      << m_rhs->getTypeStr() << " "
                      << "%val" << m_rhs->getId() << ")\n";

            m_gen_func = true;
        }
Esempio n. 4
0
 void genParams(std::stringstream &kerStream)
 {
     if (m_gen_param) return;
     if (!(m_lhs->isGenParam())) m_lhs->genParams(kerStream);
     if (!(m_rhs->isGenParam())) m_rhs->genParams(kerStream);
     m_gen_param = true;
 }
Esempio n. 5
0
 bool isLinear(dim_t dims[4])
 {
     if (!m_set_is_linear) {
         m_linear = m_lhs->isLinear(dims) && m_rhs->isLinear(dims);
         m_set_is_linear = true;
     }
     return m_linear;
 }
Esempio n. 6
0
 void resetFlags()
 {
     if (m_set_id) {
         resetCommonFlags();
         m_lhs->resetFlags();
         m_rhs->resetFlags();
     }
 }
Esempio n. 7
0
 void genParams(std::stringstream &kerStream,
                std::stringstream &annStream, bool is_linear)
 {
     if (m_gen_param) return;
     if (!(m_lhs->isGenParam())) m_lhs->genParams(kerStream, annStream, is_linear);
     if (!(m_rhs->isGenParam())) m_rhs->genParams(kerStream, annStream, is_linear);
     m_gen_param = true;
 }
Esempio n. 8
0
        void setArgs(std::vector<void *> &args, bool is_linear)
        {
            if (m_set_arg) return;

            m_lhs->setArgs(args, is_linear);
            m_rhs->setArgs(args, is_linear);

            m_set_arg = true;
        }
Esempio n. 9
0
 void resetFlags()
 {
     m_set_id = false;
     m_gen_func = false;
     m_gen_param = false;
     m_gen_offset = false;
     m_lhs->resetFlags();
     m_rhs->resetFlags();
 }
Esempio n. 10
0
        int setArgs(cl::Kernel &ker, int id)
        {
            if (m_set_arg) return id;
            m_set_arg = true;

            id = m_lhs->setArgs(ker, id);
            id = m_rhs->setArgs(ker, id);
            return id;
        }
Esempio n. 11
0
        int setArgs(cl::Kernel &ker, int id, bool is_linear)
        {
            if (m_set_arg) return id;
            m_set_arg = true;

            id = m_lhs->setArgs(ker, id, is_linear);
            id = m_rhs->setArgs(ker, id, is_linear);
            return id;
        }
Esempio n. 12
0
 void genKerName(std::stringstream &kerStream, bool genInputs)
 {
     if (!genInputs) {
         // Make the hex representation of enum part of the Kernel name
         kerStream << std::setw(2) << std::setfill('0') << std::hex << m_op << std::dec;
     }
     m_lhs->genKerName(kerStream, genInputs);
     m_rhs->genKerName(kerStream, genInputs);
 }
Esempio n. 13
0
        void setArgs(std::vector<void *> &args)
        {
            if (m_set_arg) return;

            m_lhs->setArgs(args);
            m_rhs->setArgs(args);

            m_set_arg = true;
        }
Esempio n. 14
0
        void genKerName(std::stringstream &kerStream)
        {
            m_child->genKerName(kerStream);

            // Make the hex representation of enum part of the Kernel name
            kerStream << "_" << std::setw(2) << std::setfill('0') << std::hex << m_op;
            kerStream << std::setw(2) << std::setfill('0') << std::hex << m_child->getId();
            kerStream << std::setw(2) << std::setfill('0') << std::hex << m_id << std::dec;
            m_gen_name = true;
        }
Esempio n. 15
0
 BinaryNode(const char *out_type_str, const char *name_str,
            const char *op_str,
            Node_ptr lhs, Node_ptr rhs, int op)
     : Node(out_type_str, name_str, std::max(lhs->getHeight(), rhs->getHeight()) + 1),
       m_op_str(op_str),
       m_lhs(lhs),
       m_rhs(rhs),
       m_op(op)
 {
 }
Esempio n. 16
0
        void getInfo(unsigned &len, unsigned &buf_count, unsigned &bytes)
        {
            if (m_is_eval) return;

            m_lhs->getInfo(len, buf_count, bytes);
            m_rhs->getInfo(len, buf_count, bytes);
            len++;

            m_is_eval = true;
            return;
        }
Esempio n. 17
0
        int setId(int id)
        {
            if (m_set_id) return id;

            id = m_lhs->setId(id);
            id = m_rhs->setId(id);

            m_id = id;
            m_set_id = true;

            return m_id + 1;
        }
Esempio n. 18
0
        void genFuncs(std::stringstream &kerStream)
        {
            if (m_gen_func) return;

            if (!(m_child->isGenFunc())) m_child->genFuncs(kerStream);

            kerStream << m_type_str << " val" << m_id << " = "
                      << m_op_str << "(val" << m_child->getId() << ");"
                      << "\n";

            m_gen_func = true;
        }
Esempio n. 19
0
        void genKerName(std::stringstream &kerStream)
        {
            m_lhs->genKerName(kerStream);
            m_rhs->genKerName(kerStream);

            if (m_gen_name) return;
            // Make the dec representation of enum part of the Kernel name
            kerStream << "_" << std::setw(3) << std::setfill('0') << std::dec << m_op;
            kerStream << std::setw(3) << std::setfill('0') << std::dec << m_lhs->getId();
            kerStream << std::setw(3) << std::setfill('0') << std::dec << m_rhs->getId();
            kerStream << std::setw(3) << std::setfill('0') << std::dec << m_id << std::dec;
            m_gen_name = true;
        }
Esempio n. 20
0
 void *calc(int idx)
 {
     if (calcCurrent(idx)) {
         m_val = m_op.eval(*(Ti *)m_child->calc(idx));
     }
     return (void *)&m_val;
 }
Esempio n. 21
0
 void *calc(int x, int y, int z, int w)
 {
     if (calcCurrent(x, y, z, w)) {
         m_val = m_op.eval(*(Ti *)m_child->calc(x, y, z, w));
     }
     return (void *)(&m_val);
 }
Esempio n. 22
0
void ReflectiveScriptClass::setProperty(
        QScriptValue& object, 
        const QScriptString & name, 
        uint id, 
        const QScriptValue& value)
{
    // std::cout << __FUNCTION__ << " " << 
    //     name.toString().toStdString() << std::endl;

    Node_ptr node = qscriptvalue_cast< Node_ptr >(object.data());

    if (node)
    {
        // Ensure it is initialized
        node->check_for_initialized();

        ::gsim::core::descriptor_type type = 
            node->descriptor->get_type();

        if (type == ::gsim::core::TYPE_STRUCT)
        {
            // because I am sure it is initialized
            if (id < node->children.size())
            {
                fromScriptValue(value, node->children[id]);
            }
        }
        else if (node->descriptor->is_repeated())
        {
            if (id < node->children.size())
            {
                fromScriptValue(value, node->children[id]);
            }
            else if (node->descriptor->is_variable_length() &&
                    QString(name) == "length")
            {
                // length property
                unsigned int length = value.toUInt32();

                node->descriptor->set_length(node->holder, length);

                // re-initialized in next access
                node->reset();
            }
        }
    }
}
Esempio n. 23
0
 bool isLinear(const dim_t *dims)
 {
     if (!m_set_is_linear) {
         m_linear = m_child->isLinear(dims);
         m_set_is_linear = true;
     }
     return m_linear;
 }
Esempio n. 24
0
 UnaryNode(const char *out_type_str, const char *name_str,
           const char *op_str,
           Node_ptr child, int op)
     : Node(out_type_str, name_str, child->getHeight() + 1, {{child}}),
       m_op_str(op_str),
       m_op(op)
 {
 }
Esempio n. 25
0
 void resetFlags()
 {
     m_set_id = false;
     m_gen_func = false;
     m_gen_param = false;
     m_gen_offset = false;
     m_child->resetFlags();
 }
Esempio n. 26
0
 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";
     }
 }
Esempio n. 27
0
 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. 28
0
        void getInfo(unsigned &len, unsigned &buf_count, unsigned &bytes)
        {
            if (m_set_id) return;

            m_child->getInfo(len, buf_count, bytes);
            len++;

            m_set_id = true;
            return;
        }
Esempio n. 29
0
        int setId(int id)
        {
            if (m_set_id) return id;

            id = m_child->setId(id);

            m_id = id;
            m_set_id = true;

            return m_id + 1;
        }
Esempio n. 30
0
	void operator() (Node_ptr node)
	{
		for (int i = 0; i < node->SuccessorCount(); i++)
		{
			Node_map::iterator item = mMap.find( node->SuccessorAddress(i) );
			if (mMap.end() != item)
			{
				bool success = node->ConnectSuccessor(i, item->second);
				if (!success)
				{
					message("Failed to connect successor\n");
				}
			}
			else
			{
				message("%p Unable to find successor block with address %p\n",
						node->Address(),
						node->SuccessorAddress(i) );
			}
		}
	}