Beispiel #1
0
        public override void doThrottling()
        {
            //All nodes in the low intensity can alway freely inject.
            int [] low_grps = low_intensity_cluster.allNodes();
            foreach (int grp in low_grps)
            {
                for (int thd = 0; thd < wkld.getGroupSize(grp); thd++)
                {
                    int node = wkld.mapThd(grp, thd);
                    m_nodeStates[node] = NodeState.Low;
                    setThrottleRate(node, false);
                }
            }

            //Throttle all the high other nodes
            int [] high_grps = cluster_pool.allNodes();
            foreach (int grp in high_grps)
            {
                for (int thd = 0; thd < wkld.getGroupSize(grp); thd++)
                {
                    int node = wkld.mapThd(grp, thd);
                    setThrottleRate(node, true);
                    m_nodeStates[node] = NodeState.HighOther;
                }
            }

            //Unthrottle all the nodes in the free-injecting cluster
            int [] grps = cluster_pool.nodesInNextCluster();
            foreach (int grp in grps)
            {
                for (int thd = 0; thd < wkld.getGroupSize(grp); thd++)
                {
                    int node = wkld.mapThd(grp, thd);
                    setThrottleRate(node, false);
                    m_nodeStates[node] = NodeState.HighGolden;
                    Simulator.stats.throttle_time_bysrc[node].Add();
                }
            }

            /* Throttle nodes in always throttled mode. */
            int [] throttled_grps = throttled_cluster.allNodes();

            foreach (int grp in throttled_grps)
            {
                for (int thd = 0; thd < wkld.getGroupSize(grp); thd++)
                {
                    int node = wkld.mapThd(grp, thd);
                    setThrottleRate(node, true);
                    m_nodeStates[node] = NodeState.AlwaysThrottled;
                    Simulator.stats.always_throttle_time_bysrc[node].Add();
                }
            }
        }
        public override void doThrottling()
        {
            //All nodes in the low intensity can alway freely inject.
            int [] low_nodes = low_intensity_cluster.allNodes();

            if (low_nodes.Length > 0)
            {
#if DEBUG_CLUSTER2
                Console.WriteLine("\n:: cycle {0} ::", Simulator.CurrentRound);
                Console.Write("\nLow nodes *NOT* throttled: ");
#endif
                foreach (int node in low_nodes)
                {
#if DEBUG_CLUSTER2
                    writeNode(node);
#endif
                    setThrottleRate(node, false);
                    m_nodeStates[node] = NodeState.Low;
                }
            }

            //Throttle all the high other nodes
            int [] high_nodes = cluster_pool.allNodes();
#if DEBUG_CLUSTER2
            Console.Write("\nAll high other nodes: ");
#endif
            foreach (int node in high_nodes)
            {
#if DEBUG_CLUSTER2
                writeNode(node);
#endif
                setThrottleRate(node, true);
                m_nodeStates[node] = NodeState.HighOther;
            }

            //Unthrottle all the nodes in the free-injecting cluster
            int [] nodes = cluster_pool.nodesInNextCluster();
#if DEBUG_CLUSTER2
            Console.Write("\nUnthrottling cluster nodes: ");
#endif
            if (nodes.Length > 0)
            {
                foreach (int node in nodes)
                {
                    setThrottleRate(node, false);
                    m_nodeStates[node] = NodeState.HighGolden;
                    Simulator.stats.throttle_time_bysrc[node].Add();
#if DEBUG_CLUSTER2
                    writeNode(node);
#endif
                }
            }

            /* Throttle nodes in always throttled mode. */
            int [] throttled_nodes = throttled_cluster.allNodes();

            if (throttled_nodes.Length > 0)
            {
#if DEBUG_CLUSTER2
                Console.Write("\nAlways Throttled nodes: ");
#endif
                foreach (int node in throttled_nodes)
                {
                    setThrottleRate(node, true);
                    //TODO: need another state for throttled throttled_nodes
                    m_nodeStates[node] = NodeState.AlwaysThrottled;
                    Simulator.stats.always_throttle_time_bysrc[node].Add();
#if DEBUG_CLUSTER2
                    writeNode(node);
#endif
                }
            }

#if DEBUG_CLUSTER2
            Console.Write("\n*NOT* Throttled nodes: ");
            for (int i = 0; i < Config.N; i++)
            {
                if (!m_isThrottled[i])
                {
                    writeNode(i);
                }
            }
            Console.Write("\n");
#endif
        }
        public override void doThrottling()
        {
            //All nodes in the low intensity can alway freely inject.
            int [] low_nodes = low_intensity_cluster.allNodes();
            if (low_nodes.Length > 0 && isTestPhase == true)
            {
                low_intensity_cluster.printCluster();
                throw new Exception("ERROR: Low nodes exist during sensitivity test phase.");
            }
            if (low_nodes.Length > 0)
            {
#if DEBUG_CLUSTER2
                Console.WriteLine("\n:: cycle {0} ::", Simulator.CurrentRound);
                Console.Write("\nLow nodes *NOT* throttled: ");
#endif
                foreach (int node in low_nodes)
                {
#if DEBUG_CLUSTER2
                    writeNode(node);
#endif
                    setThrottleRate(node, false);
                    m_nodeStates[node] = NodeState.Low;
                }
            }

            //Throttle all the high other nodes
            int [] high_nodes = cluster_pool.allNodes();
#if DEBUG_CLUSTER2
            Console.Write("\nAll high other nodes: ");
#endif
            foreach (int node in high_nodes)
            {
#if DEBUG_CLUSTER2
                writeNode(node);
#endif
                setThrottleRate(node, true);
                m_nodeStates[node] = NodeState.HighOther;
            }

            //Unthrottle all the nodes in the free-injecting cluster
            int [] nodes = cluster_pool.nodesInNextCluster();
#if DEBUG_CLUSTER2
            Console.Write("\nUnthrottling cluster nodes: ");
#endif
            if (nodes.Length > 0)
            {
                //Clear the vector for last free nodes
                Array.Clear(last_free_nodes, 0, last_free_nodes.Length);
                foreach (int node in nodes)
                {
                    ins_free[node]        = Simulator.stats.insns_persrc[node].Count;
                    last_free_nodes[node] = 1;

                    setThrottleRate(node, false);
                    m_nodeStates[node] = NodeState.HighGolden;
                    Simulator.stats.throttle_time_bysrc[node].Add();
#if DEBUG_CLUSTER2
                    writeNode(node);
#endif
                }
            }

            /* Throttle nodes in always throttled mode. */
            int [] throttled_nodes = throttled_cluster.allNodes();
            if (throttled_nodes.Length > 0 && isTestPhase == true)
            {
                throttled_cluster.printCluster();
                throw new Exception("ERROR: Throttled nodes exist during sensitivity test phase.");
            }
            if (throttled_nodes.Length > 0)
            {
#if DEBUG_CLUSTER2
                Console.Write("\nAlways Throttled nodes: ");
#endif
                foreach (int node in throttled_nodes)
                {
                    setThrottleRate(node, true);
                    //TODO: need another state for throttled throttled_nodes
                    m_nodeStates[node] = NodeState.AlwaysThrottled;
                    Simulator.stats.always_throttle_time_bysrc[node].Add();
#if DEBUG_CLUSTER2
                    writeNode(node);
#endif
                }
            }

#if DEBUG_CLUSTER2
            Console.Write("\n*NOT* Throttled nodes: ");
            for (int i = 0; i < Config.N; i++)
            {
                if (!m_isThrottled[i])
                {
                    writeNode(i);
                }
            }
            Console.Write("\n");
#endif
        }
Beispiel #4
0
        /**
         * @brief Add a new node to the cluster.
         *
         * If the new node doesn't exceed the total mpki of the most recent added cluster,
         * the node is inserted to that cluster. Otherwise, it's added to a new cluster.
         **/
        public override void addNewNode(int id, double mpki)
        {
            nodes_pool.Add(id);
            Cluster cur_cluster;

            if (q.Count == 0)
            {
                q.Add(new Cluster());
                cur_cluster = q[0];
                cur_cluster.addNode(id, mpki);
                return;
            }
            else
            {
                List <int> availCluster    = new List <int>();
                bool       needNewCluster  = true;
                double     maxDist         = 0;
                Cluster    selectedCluster = q[0];
                for (int i = 0; i < q.Count; i++)
                {
                    cur_cluster = q[i];
                    double sum_MPKI = cur_cluster.totalClusterMPKI() + mpki;
#if DEBUG_DIST
                    Console.WriteLine("sum_MPKI = {0}, mpki_threshold = {1}", sum_MPKI, _mpki_threshold);
#endif
                    if (sum_MPKI <= _mpki_threshold)
                    {
                        //cur_cluster.addNode(id,mpki);
                        availCluster.Add(i);
                        needNewCluster = false;
                        //return;
                    }
                }
                for (int i = 0; i < availCluster.Count; i++)
                {
                    double avgDist = 0.0;
                    cur_cluster = q[i];
                    int [] nodes = cur_cluster.allNodes();
                    for (int j = 0; j < nodes.Length; j++)
                    {
                        avgDist += computeDist(nodes[j], id);
                    }
                    avgDist = avgDist / nodes.Length;
                    if (avgDist > maxDist)
                    {
                        selectedCluster = cur_cluster;
                        maxDist         = avgDist;
                    }
                }
                if (needNewCluster)
                {
#if DEBUG_DIST
                    Console.WriteLine("Adding a new cluster");
#endif
                    q.Add(new Cluster());
                    //count is incremented
                    cur_cluster = q[q.Count - 1];
                    cur_cluster.addNode(id, mpki);
                    return;
                }
                else
                {
#if DEBUG_DIST
                    int [] allNodes = selectedCluster.allNodes();
                    Console.Write("Adding {0} to cluster with nodes: ", id);
                    for (int i = 0; i < allNodes.Length; i++)
                    {
                        Console.Write("{0} ", allNodes[i]);
                    }
                    Console.WriteLine("");
#endif
                    selectedCluster.addNode(id, mpki);
                }
            }
            return;
        }