Skip to content

Commit

Permalink
Fixed automatic affinity discovery (but still depends on OS files). A…
Browse files Browse the repository at this point in the history
…dded script to count violations
  • Loading branch information
TizianoDeMatteis committed Dec 30, 2015
1 parent 3be0d09 commit d899ee0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
49 changes: 49 additions & 0 deletions scripts/count_violations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

#---------------------------------------------------------------------
#
# Copyright (C) 2015- by Tiziano De Matteis (dematteis <at> di.unipi.it)
#
# This file is part of elastic-hft.
#
# elastic-hft is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ---------------------------------------------------------------------
# Count the number of violations taking in input a directory containing the stats files
# e.g. generated with conf_interval_real or conf_interval_synthetic scripts

if [ -z "$1" ]; then
echo "Specify the directory containing the stat files as first command line argument"
exit 1
fi

if [ -z "$2" ]; then
echo "Specify the latency threshold (in usecs) as second command line argument"
exit 1
fi

if [ ! -d "$1" ]; then
echo "The directory $1 does not exists!"
exit 1
fi


for stat_file in $1/stat*dat
do
tail -n +2 $stat_file | head -n -2 | cut -f 3 | awk -v thr=$2 'BEGIN {count=0} {if($1>thr){count++}} END{print count;}' >> tmp_violations
done


cat tmp_violations | awk 'BEGIN{sum=0; count=0;} {sum+=$1; count++;} END {print "Average #violations: "sum/count;}'
rm tmp_violations;
15 changes: 10 additions & 5 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ std::vector<int>* getCoreIDs()
num_virt_cores+= cpu->getVirtualCores().size();
}
std::vector<int> *core_ids=new std::vector<int>();

std::vector<VirtualCore*> virtualCores = topology->getVirtualCores();
std::vector<PhysicalCore*> physicalCores= topology->getPhysicalCores();

//now take the id of one virtual core per physical core;
//assuming that physical core are number starting from zero
int curr_phys_core=0;
bool constantTSC=true;
for(size_t i = 0; i < virtualCores.size(); i++)
for(size_t i=0;i<physicalCores.size();i++)
{
PhysicalCore* pc=(physicalCores.at(i));
core_ids->push_back(pc->getVirtualCore()->getVirtualCoreId());
if(!pc->getVirtualCore()->areTicksConstant())
constantTSC=false;
}
/* for(size_t i = 0; i < virtualCores.size(); i++)
{
VirtualCore* vc = virtualCores.at(i);
if(vc->getPhysicalCoreId()==curr_phys_core)
Expand All @@ -116,7 +121,7 @@ std::vector<int>* getCoreIDs()
}
if(!vc->areTicksConstant())
constantTSC=false;
}
}*/
if(!constantTSC)
std::cout<< "ATTENTION: the machine has not constant TSC. The program may not work since relies on this to get accurate timings" <<std::endl;
return core_ids;
Expand Down

0 comments on commit d899ee0

Please sign in to comment.